@@ -1035,6 +1035,8 @@ jit_end_diagnostic (diagnostic_context *context,
10351035 gcc::jit::active_playback_ctxt->add_diagnostic (context, *diagnostic);
10361036}
10371037
1038+ static bool builtins_initialized = false ;
1039+
10381040/* Language hooks. */
10391041
10401042static bool
@@ -1073,7 +1075,12 @@ jit_langhook_init (void)
10731075 eventually be controllable by a command line option. */
10741076 mpfr_set_default_prec (256 );
10751077
1076- targetm.init_builtins ();
1078+ // TODO: check if this is a good fix.
1079+ if (!builtins_initialized)
1080+ {
1081+ targetm.init_builtins ();
1082+ builtins_initialized = true ;
1083+ }
10771084
10781085 return true ;
10791086}
@@ -1291,6 +1298,39 @@ recording::type* tree_type_to_jit_type (tree type)
12911298 recording::type* element_type = tree_type_to_jit_type (inner_type);
12921299 return element_type->get_pointer ();
12931300 }
1301+ else if (type == unsigned_intTI_type_node)
1302+ {
1303+ // TODO: check if this is the correct type.
1304+ return new recording::memento_of_get_type (&target_builtins_ctxt, GCC_JIT_TYPE_UINT128_T);
1305+ }
1306+ else if (INTEGRAL_TYPE_P (type))
1307+ {
1308+ // TODO: check if this is the correct type.
1309+ unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
1310+ return target_builtins_ctxt.get_int_type (size, TYPE_UNSIGNED (type));
1311+ }
1312+ else if (SCALAR_FLOAT_TYPE_P (type))
1313+ {
1314+ // TODO: check if this is the correct type.
1315+ unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
1316+ enum gcc_jit_types type;
1317+ switch (size) {
1318+ case 2 :
1319+ type = GCC_JIT_TYPE_FLOAT16;
1320+ break ;
1321+ case 4 :
1322+ type = GCC_JIT_TYPE_FLOAT32;
1323+ break ;
1324+ case 8 :
1325+ type = GCC_JIT_TYPE_FLOAT64;
1326+ break ;
1327+ default :
1328+ fprintf (stderr, " Unexpected float size: %d\n " , size);
1329+ abort ();
1330+ break ;
1331+ }
1332+ return new recording::memento_of_get_type (&target_builtins_ctxt, type);
1333+ }
12941334 else
12951335 {
12961336 // Attempt to find an unqualified type when the current type has qualifiers.
@@ -1380,7 +1420,8 @@ jit_langhook_global_bindings_p (void)
13801420static tree
13811421jit_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
13821422{
1383- gcc_unreachable ();
1423+ /* Do nothing to avoid crashing on some targets. */
1424+ return NULL_TREE;
13841425}
13851426
13861427static tree
0 commit comments