@@ -1035,6 +1035,8 @@ jit_end_diagnostic (diagnostic_context *context,
1035
1035
gcc::jit::active_playback_ctxt->add_diagnostic (context, *diagnostic);
1036
1036
}
1037
1037
1038
+ static bool builtins_initialized = false ;
1039
+
1038
1040
/* Language hooks. */
1039
1041
1040
1042
static bool
@@ -1073,7 +1075,12 @@ jit_langhook_init (void)
1073
1075
eventually be controllable by a command line option. */
1074
1076
mpfr_set_default_prec (256 );
1075
1077
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
+ }
1077
1084
1078
1085
return true ;
1079
1086
}
@@ -1291,6 +1298,39 @@ recording::type* tree_type_to_jit_type (tree type)
1291
1298
recording::type* element_type = tree_type_to_jit_type (inner_type);
1292
1299
return element_type->get_pointer ();
1293
1300
}
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
+ }
1294
1334
else
1295
1335
{
1296
1336
// Attempt to find an unqualified type when the current type has qualifiers.
@@ -1380,7 +1420,8 @@ jit_langhook_global_bindings_p (void)
1380
1420
static tree
1381
1421
jit_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
1382
1422
{
1383
- gcc_unreachable ();
1423
+ /* Do nothing to avoid crashing on some targets. */
1424
+ return NULL_TREE;
1384
1425
}
1385
1426
1386
1427
static tree
0 commit comments