1 /* brig-lang.c -- brig (HSAIL) input gcc interface.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
4 for General Processor Tech.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
25 #include "coretypes.h"
28 #include "tree-iterator.h"
29 #include "print-tree.h"
30 #include "stringpool.h"
31 #include "basic-block.h"
32 #include "gimple-expr.h"
35 #include "stor-layout.h"
41 #include "diagnostic.h"
42 #include "langhooks.h"
43 #include "langhooks-def.h"
46 #include "brigfrontend/brig-to-generic.h"
48 #include "fold-const.h"
49 #include "common/common-target.h"
52 #include "brig-builtins.h"
54 /* This file is based on Go frontent'd go-lang.c and gogo-tree.cc. */
58 int gccbrig_verbose
= 0;
60 /* Language-dependent contents of a type. */
62 struct GTY (()) lang_type
67 /* Language-dependent contents of a decl. */
69 struct GTY ((variable_size
)) lang_decl
74 /* Language-dependent contents of an identifier. This must include a
77 struct GTY (()) lang_identifier
79 struct tree_identifier common
;
82 /* The resulting tree type. */
84 union GTY ((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
85 chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), "
86 "TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN "
87 "(&%h.generic)) : NULL"))) lang_tree_node
89 union tree_node
GTY ((tag ("0"), desc ("tree_node_structure (&%h)"))) generic
;
90 struct lang_identifier
GTY ((tag ("1"))) identifier
;
93 /* We don't use language_function. */
95 struct GTY (()) language_function
101 /* The option mask. */
104 brig_langhook_option_lang_mask (void)
109 /* Initialize the options structure. */
112 brig_langhook_init_options_struct (struct gcc_options
*opts
)
114 /* Signed overflow is precisely defined. */
115 opts
->x_flag_wrapv
= 1;
117 /* If we set this to one, the whole program optimizations internalize
118 all global variables, making them invisible to the dyn loader (and
119 thus the HSA runtime implementation). */
120 opts
->x_flag_whole_program
= 0;
122 /* The builtin math functions should not set errno. */
123 opts
->x_flag_errno_math
= 0;
124 opts
->frontend_set_flag_errno_math
= false;
126 opts
->x_flag_exceptions
= 0;
127 opts
->x_flag_non_call_exceptions
= 0;
129 opts
->x_flag_finite_math_only
= 0;
130 opts
->x_flag_signed_zeros
= 1;
133 /* Handle Brig specific options. Return 0 if we didn't do anything. */
136 brig_langhook_handle_option
137 (size_t scode
, const char *arg ATTRIBUTE_UNUSED
,
138 int value ATTRIBUTE_UNUSED
, int kind ATTRIBUTE_UNUSED
,
139 location_t loc ATTRIBUTE_UNUSED
,
140 const struct cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
142 enum opt_code code
= (enum opt_code
) scode
;
154 /* Run after parsing options. */
157 brig_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED
)
159 if (flag_excess_precision_cmdline
== EXCESS_PRECISION_DEFAULT
)
160 flag_excess_precision_cmdline
= EXCESS_PRECISION_STANDARD
;
162 /* gccbrig casts pointers around like crazy, TBAA produces
163 broken code if not force disabling it. */
164 flag_strict_aliasing
= 0;
166 /* Returning false means that the backend should be used. */
171 get_file_size (FILE *file
)
174 fseek (file
, 0, SEEK_END
);
175 size
= (size_t) ftell (file
);
176 fseek (file
, 0, SEEK_SET
);
181 brig_langhook_parse_file (void)
183 brig_to_generic brig_to_gen
;
185 for (unsigned int i
= 0; i
< num_in_fnames
; ++i
)
189 f
= fopen (in_fnames
[i
], "r");
190 size_t fsize
= get_file_size (f
);
191 char *brig_blob
= new char[fsize
];
192 if (fread (brig_blob
, 1, fsize
, f
) != fsize
)
194 error ("could not read the BRIG file");
197 brig_to_gen
.parse (brig_blob
);
201 brig_to_gen
.write_globals ();
205 brig_langhook_type_for_size (unsigned int bits
,
208 /* Copied from go-lang.c */
212 if (bits
== INT_TYPE_SIZE
)
213 type
= unsigned_type_node
;
214 else if (bits
== CHAR_TYPE_SIZE
)
215 type
= unsigned_char_type_node
;
216 else if (bits
== SHORT_TYPE_SIZE
)
217 type
= short_unsigned_type_node
;
218 else if (bits
== LONG_TYPE_SIZE
)
219 type
= long_unsigned_type_node
;
220 else if (bits
== LONG_LONG_TYPE_SIZE
)
221 type
= long_long_unsigned_type_node
;
223 type
= make_unsigned_type(bits
);
227 if (bits
== INT_TYPE_SIZE
)
228 type
= integer_type_node
;
229 else if (bits
== CHAR_TYPE_SIZE
)
230 type
= signed_char_type_node
;
231 else if (bits
== SHORT_TYPE_SIZE
)
232 type
= short_integer_type_node
;
233 else if (bits
== LONG_TYPE_SIZE
)
234 type
= long_integer_type_node
;
235 else if (bits
== LONG_LONG_TYPE_SIZE
)
236 type
= long_long_integer_type_node
;
238 type
= make_signed_type(bits
);
244 brig_langhook_type_for_mode (machine_mode mode
, int unsignedp
)
246 if (mode
== TYPE_MODE (void_type_node
))
247 return void_type_node
;
249 if (VECTOR_MODE_P (mode
))
253 inner
= brig_langhook_type_for_mode (GET_MODE_INNER (mode
), unsignedp
);
254 if (inner
!= NULL_TREE
)
255 return build_vector_type_for_mode (inner
, mode
);
260 enum mode_class mc
= GET_MODE_CLASS (mode
);
261 if (mc
== MODE_FLOAT
)
263 switch (GET_MODE_BITSIZE (mode
))
266 return float_type_node
;
268 return double_type_node
;
270 /* We have to check for long double in order to support
271 i386 excess precision. */
272 if (mode
== TYPE_MODE (long_double_type_node
))
273 return long_double_type_node
;
279 else if (mc
== MODE_INT
)
280 return brig_langhook_type_for_size(GET_MODE_BITSIZE(mode
), unsignedp
);
283 /* E.g., build_common_builtin_nodes () asks for modes/builtins
284 we do not generate or need. Just ignore them silently for now.
292 brig_langhook_builtin_function (tree decl
)
297 static GTY(()) tree registered_builtin_types
;
300 brig_langhook_register_builtin_type (tree type
, const char *name
)
304 if (!TYPE_NAME (type
))
306 decl
= build_decl (UNKNOWN_LOCATION
, TYPE_DECL
,
307 get_identifier (name
), type
);
308 DECL_ARTIFICIAL (decl
) = 1;
309 TYPE_NAME (type
) = decl
;
312 registered_builtin_types
= tree_cons (0, type
, registered_builtin_types
);
316 /* Return true if we are in the global binding level. */
319 brig_langhook_global_bindings_p (void)
321 return current_function_decl
== NULL_TREE
;
324 /* Push a declaration into the current binding level. From Go: We can't
325 usefully implement this since we don't want to convert from tree
326 back to one of our internal data structures. I think the only way
327 this is used is to record a decl which is to be returned by
328 getdecls, and we could implement it for that purpose if
332 brig_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED
)
337 /* This hook is used to get the current list of declarations as trees.
338 From Go: We don't support that; instead we use the write_globals hook.
339 This can't simply crash because it is called by -gstabs. */
342 brig_langhook_getdecls (void)
348 brig_langhook_gimplify_expr (tree
*expr_p
, gimple_seq
*pre_p ATTRIBUTE_UNUSED
,
349 gimple_seq
*post_p ATTRIBUTE_UNUSED
)
352 /* Strip off the static chain info that appears to function
353 calls for some strange reason even though we don't add
354 nested functions. Maybe something wrong with the function
355 declaration contexts? */
356 if (TREE_CODE (*expr_p
) == CALL_EXPR
357 && CALL_EXPR_STATIC_CHAIN (*expr_p
) != NULL_TREE
)
358 CALL_EXPR_STATIC_CHAIN (*expr_p
) = NULL_TREE
;
363 brig_langhook_eh_personality (void)
368 /* Functions called directly by the generic backend.
369 Adapted from go-lang.c. */
372 convert (tree type
, tree expr
)
374 if (type
== error_mark_node
|| expr
== error_mark_node
375 || TREE_TYPE (expr
) == error_mark_node
)
376 return error_mark_node
;
378 if (type
== TREE_TYPE (expr
))
381 if (TYPE_MAIN_VARIANT (type
) == TYPE_MAIN_VARIANT (TREE_TYPE (expr
)))
382 return fold_convert (type
, expr
);
384 switch (TREE_CODE (type
))
388 return fold_convert (type
, expr
);
390 return fold (convert_to_integer (type
, expr
));
392 return fold (convert_to_real (type
, expr
));
394 return fold (convert_to_vector (type
, expr
));
396 return build1 (VIEW_CONVERT_EXPR
, type
, convert (size_type_node
, expr
));
404 static GTY (()) tree brig_gc_root
;
406 /* Preserve trees that we create from the garbage collector. */
409 brig_preserve_from_gc (tree t
)
411 brig_gc_root
= tree_cons (NULL_TREE
, t
, brig_gc_root
);
414 /* Convert an identifier for use in an error message. */
417 brig_localize_identifier (const char *ident
)
419 return identifier_to_locale (ident
);
422 /* Built-in initialization code cribbed from lto-lang.c which cribbed it
426 static GTY(()) tree built_in_attributes
[(int) ATTR_LAST
];
429 static GTY(()) tree builtin_types
[(int) BT_LAST
+ 1];
431 static GTY(()) tree string_type_node
;
432 static GTY(()) tree const_string_type_node
;
433 static GTY(()) tree wint_type_node
;
434 static GTY(()) tree intmax_type_node
;
435 static GTY(()) tree uintmax_type_node
;
436 static GTY(()) tree signed_size_type_node
;
438 /* Flags needed to process builtins.def. */
444 def_fn_type (builtin_type def
, builtin_type ret
, bool var
, int n
, ...)
447 tree
*args
= XALLOCAVEC (tree
, n
);
453 for (i
= 0; i
< n
; ++i
)
455 builtin_type a
= (builtin_type
) va_arg (list
, int);
456 t
= builtin_types
[a
];
457 if (t
== error_mark_node
)
463 t
= builtin_types
[ret
];
466 if (t
== error_mark_node
)
469 t
= build_varargs_function_type_array (t
, n
, args
);
471 t
= build_function_type_array (t
, n
, args
);
473 builtin_types
[def
] = t
;
476 /* Used to help initialize the builtin-types.def table. When a type of
477 the correct size doesn't exist, use error_mark_node instead of NULL.
478 The later results in segfaults even when a decl using the type doesn't
482 builtin_type_for_size (int size
, bool unsignedp
)
484 tree type
= brig_langhook_type_for_size (size
, unsignedp
);
485 return type
? type
: error_mark_node
;
488 /* Support for DEF_BUILTIN. */
491 def_builtin_1 (enum built_in_function fncode
, const char *name
,
492 enum built_in_class fnclass
, tree fntype
, tree libtype
,
493 bool both_p
, bool fallback_p
, bool nonansi_p
,
494 tree fnattrs
, bool implicit_p
)
499 if (fntype
== error_mark_node
)
502 libname
= name
+ strlen ("__builtin_");
503 decl
= add_builtin_function (name
, fntype
, fncode
, fnclass
,
504 (fallback_p
? libname
: NULL
),
509 && !(nonansi_p
&& flag_no_nonansi_builtin
))
510 add_builtin_function (libname
, libtype
, fncode
, fnclass
,
513 set_builtin_decl (fncode
, decl
, implicit_p
);
517 /* Initialize the attribute table for all the supported builtins. */
520 brig_init_attributes (void)
522 /* Fill in the built_in_attributes array. */
523 #define DEF_ATTR_NULL_TREE(ENUM) \
524 built_in_attributes[(int) ENUM] = NULL_TREE;
525 #define DEF_ATTR_INT(ENUM, VALUE) \
526 built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE);
527 #define DEF_ATTR_STRING(ENUM, VALUE) \
528 built_in_attributes[(int) ENUM] = build_string (strlen (VALUE), VALUE);
529 #define DEF_ATTR_IDENT(ENUM, STRING) \
530 built_in_attributes[(int) ENUM] = get_identifier (STRING);
531 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
532 built_in_attributes[(int) ENUM] \
533 = tree_cons (built_in_attributes[(int) PURPOSE], \
534 built_in_attributes[(int) VALUE], \
535 built_in_attributes[(int) CHAIN]);
536 #include "builtin-attrs.def"
537 #undef DEF_ATTR_NULL_TREE
539 #undef DEF_ATTR_STRING
540 #undef DEF_ATTR_IDENT
541 #undef DEF_ATTR_TREE_LIST
544 /* Create builtin types and functions. VA_LIST_REF_TYPE_NODE and
545 VA_LIST_ARG_TYPE_NODE are used in builtin-types.def. */
548 brig_define_builtins (tree va_list_ref_type_node ATTRIBUTE_UNUSED
,
549 tree va_list_arg_type_node ATTRIBUTE_UNUSED
)
551 #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
552 builtin_types[ENUM] = VALUE;
553 #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
554 def_fn_type (ENUM, RETURN, 0, 0);
555 #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
556 def_fn_type (ENUM, RETURN, 0, 1, ARG1);
557 #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
558 def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2);
559 #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
560 def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3);
561 #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
562 def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4);
563 #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
564 def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
565 #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
567 def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
568 #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
570 def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
571 #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
573 def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
575 #define DEF_FUNCTION_TYPE_9(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
576 ARG6, ARG7, ARG8, ARG9) \
577 def_fn_type (ENUM, RETURN, 0, 9, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
579 #define DEF_FUNCTION_TYPE_10(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
580 ARG6, ARG7, ARG8, ARG9, ARG10) \
581 def_fn_type (ENUM, RETURN, 0, 10, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
582 ARG7, ARG8, ARG9, ARG10);
583 #define DEF_FUNCTION_TYPE_11(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
584 ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) \
585 def_fn_type (ENUM, RETURN, 0, 11, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
586 ARG7, ARG8, ARG9, ARG10, ARG11);
587 #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
588 def_fn_type (ENUM, RETURN, 1, 0);
589 #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
590 def_fn_type (ENUM, RETURN, 1, 1, ARG1);
591 #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
592 def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2);
593 #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
594 def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3);
595 #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
596 def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
597 #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
598 def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
599 #define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
601 def_fn_type (ENUM, RETURN, 1, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
602 #define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
604 def_fn_type (ENUM, RETURN, 1, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
605 #define DEF_POINTER_TYPE(ENUM, TYPE) \
606 builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
608 #include "builtin-types.def"
610 #undef DEF_PRIMITIVE_TYPE
611 #undef DEF_FUNCTION_TYPE_0
612 #undef DEF_FUNCTION_TYPE_1
613 #undef DEF_FUNCTION_TYPE_2
614 #undef DEF_FUNCTION_TYPE_3
615 #undef DEF_FUNCTION_TYPE_4
616 #undef DEF_FUNCTION_TYPE_5
617 #undef DEF_FUNCTION_TYPE_6
618 #undef DEF_FUNCTION_TYPE_7
619 #undef DEF_FUNCTION_TYPE_8
620 #undef DEF_FUNCTION_TYPE_9
621 #undef DEF_FUNCTION_TYPE_10
622 #undef DEF_FUNCTION_TYPE_11
623 #undef DEF_FUNCTION_TYPE_VAR_0
624 #undef DEF_FUNCTION_TYPE_VAR_1
625 #undef DEF_FUNCTION_TYPE_VAR_2
626 #undef DEF_FUNCTION_TYPE_VAR_3
627 #undef DEF_FUNCTION_TYPE_VAR_4
628 #undef DEF_FUNCTION_TYPE_VAR_5
629 #undef DEF_FUNCTION_TYPE_VAR_6
630 #undef DEF_FUNCTION_TYPE_VAR_7
631 #undef DEF_POINTER_TYPE
632 builtin_types
[(int) BT_LAST
] = NULL_TREE
;
634 brig_init_attributes ();
636 #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,\
637 NONANSI_P, ATTRS, IMPLICIT, COND) \
639 def_builtin_1 (ENUM, NAME, CLASS, builtin_types[(int) TYPE], \
640 builtin_types[(int) LIBTYPE], BOTH_P, FALLBACK_P, \
641 NONANSI_P, built_in_attributes[(int) ATTRS], IMPLICIT);
643 #undef DEF_HSAIL_BUILTIN
644 #define DEF_HSAIL_BUILTIN(ENUM, HSAIL_OPCODE, HSAIL_TYPE, NAME, TYPE, ATTRS) \
645 DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
646 false, true, true, ATTRS, false, true)
648 /* HSAIL atomic builtins do not have separate identifying opcodes. */
650 #undef DEF_HSAIL_ATOMIC_BUILTIN
651 #define DEF_HSAIL_ATOMIC_BUILTIN(ENUM, ATOMIC_OPCODE, HSAIL_TYPE, NAME, \
653 DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
654 false, true, true, ATTRS, false, true)
656 /* HSAIL saturating arithmetics builtins. */
658 #undef DEF_HSAIL_SAT_BUILTIN
659 #define DEF_HSAIL_SAT_BUILTIN(ENUM, BRIG_OPCODE, HSAIL_TYPE, NAME, \
661 DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
662 false, true, true, ATTRS, false, true)
664 /* HSAIL builtins used internally by the frontend. */
666 #undef DEF_HSAIL_INTR_BUILTIN
667 #define DEF_HSAIL_INTR_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
668 DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
669 false, true, true, ATTRS, false, true)
671 /* HSAIL saturated conversions. */
673 #undef DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN
674 #define DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN(ENUM, HSAIL_DEST_TYPE, HSAIL_SRC_TYPE, \
676 DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
677 false, true, true, ATTRS, false, true)
679 #include "builtins.def"
682 /* Build nodes that would have be created by the C front-end; necessary
683 for including builtin-types.def and ultimately builtins.def. Borrowed
687 brig_build_c_type_nodes (void)
689 gcc_assert (void_type_node
);
691 void_list_node
= build_tree_list (NULL_TREE
, void_type_node
);
692 string_type_node
= build_pointer_type (char_type_node
);
693 const_string_type_node
694 = build_pointer_type (build_qualified_type (char_type_node
,
697 if (strcmp (SIZE_TYPE
, "unsigned int") == 0)
699 intmax_type_node
= integer_type_node
;
700 uintmax_type_node
= unsigned_type_node
;
701 signed_size_type_node
= integer_type_node
;
703 else if (strcmp (SIZE_TYPE
, "long unsigned int") == 0)
705 intmax_type_node
= long_integer_type_node
;
706 uintmax_type_node
= long_unsigned_type_node
;
707 signed_size_type_node
= long_integer_type_node
;
709 else if (strcmp (SIZE_TYPE
, "long long unsigned int") == 0)
711 intmax_type_node
= long_long_integer_type_node
;
712 uintmax_type_node
= long_long_unsigned_type_node
;
713 signed_size_type_node
= long_long_integer_type_node
;
719 signed_size_type_node
= NULL_TREE
;
720 for (i
= 0; i
< NUM_INT_N_ENTS
; i
++)
721 if (int_n_enabled_p
[i
])
724 sprintf (name
, "__int%d unsigned", int_n_data
[i
].bitsize
);
726 if (strcmp (name
, SIZE_TYPE
) == 0)
728 intmax_type_node
= int_n_trees
[i
].signed_type
;
729 uintmax_type_node
= int_n_trees
[i
].unsigned_type
;
730 signed_size_type_node
= int_n_trees
[i
].signed_type
;
733 if (signed_size_type_node
== NULL_TREE
)
737 wint_type_node
= unsigned_type_node
;
738 pid_type_node
= integer_type_node
;
743 brig_langhook_init (void)
745 build_common_tree_nodes (false);
747 /* Builtin initialization related code borrowed from lto-lang.c. */
748 void_list_node
= build_tree_list (NULL_TREE
, void_type_node
);
750 brig_build_c_type_nodes ();
752 if (TREE_CODE (va_list_type_node
) == ARRAY_TYPE
)
754 tree x
= build_pointer_type (TREE_TYPE (va_list_type_node
));
755 brig_define_builtins (x
, x
);
759 brig_define_builtins (build_reference_type (va_list_type_node
),
763 targetm
.init_builtins ();
764 build_common_builtin_nodes ();
769 #undef LANG_HOOKS_NAME
770 #undef LANG_HOOKS_INIT
771 #undef LANG_HOOKS_OPTION_LANG_MASK
772 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
773 #undef LANG_HOOKS_HANDLE_OPTION
774 #undef LANG_HOOKS_POST_OPTIONS
775 #undef LANG_HOOKS_PARSE_FILE
776 #undef LANG_HOOKS_TYPE_FOR_MODE
777 #undef LANG_HOOKS_TYPE_FOR_SIZE
778 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
779 #undef LANG_HOOKS_BUILTIN_FUNCTION
780 #undef LANG_HOOKS_GLOBAL_BINDINGS_P
781 #undef LANG_HOOKS_PUSHDECL
782 #undef LANG_HOOKS_GETDECLS
783 #undef LANG_HOOKS_WRITE_GLOBALS
784 #undef LANG_HOOKS_GIMPLIFY_EXPR
785 #undef LANG_HOOKS_EH_PERSONALITY
787 #define LANG_HOOKS_NAME "GNU Brig"
788 #define LANG_HOOKS_INIT brig_langhook_init
789 #define LANG_HOOKS_OPTION_LANG_MASK brig_langhook_option_lang_mask
790 #define LANG_HOOKS_INIT_OPTIONS_STRUCT brig_langhook_init_options_struct
791 #define LANG_HOOKS_HANDLE_OPTION brig_langhook_handle_option
792 #define LANG_HOOKS_POST_OPTIONS brig_langhook_post_options
793 #define LANG_HOOKS_PARSE_FILE brig_langhook_parse_file
794 #define LANG_HOOKS_TYPE_FOR_MODE brig_langhook_type_for_mode
795 #define LANG_HOOKS_TYPE_FOR_SIZE brig_langhook_type_for_size
796 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE brig_langhook_register_builtin_type
797 #define LANG_HOOKS_BUILTIN_FUNCTION brig_langhook_builtin_function
798 #define LANG_HOOKS_GLOBAL_BINDINGS_P brig_langhook_global_bindings_p
799 #define LANG_HOOKS_PUSHDECL brig_langhook_pushdecl
800 #define LANG_HOOKS_GETDECLS brig_langhook_getdecls
801 #define LANG_HOOKS_GIMPLIFY_EXPR brig_langhook_gimplify_expr
802 #define LANG_HOOKS_EH_PERSONALITY brig_langhook_eh_personality
804 struct lang_hooks lang_hooks
= LANG_HOOKS_INITIALIZER
;
806 #include "gt-brig-brig-lang.h"
807 #include "gtype-brig.h"