Skip to content

Commit cfc4e90

Browse files
committed
Some fixes and workaround for aarch64
1 parent f20bd72 commit cfc4e90

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

gcc/config/aarch64/aarch64-builtins.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,8 @@ aarch64_init_simd_builtin_types (void)
12091209

12101210
if (aarch64_simd_types[i].itype == NULL)
12111211
{
1212+
// FIXME: problem happens when we execute this a second time.
1213+
// Currently fixed by not initializing builtins more than once in dummy-frontend.cc.
12121214
tree type = build_vector_type (eltype, GET_MODE_NUNITS (mode));
12131215
type = build_distinct_type_copy (type);
12141216
SET_TYPE_STRUCTURAL_EQUALITY (type);

gcc/config/aarch64/aarch64.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15628,11 +15628,19 @@ aarch64_insn_cost (rtx_insn *insn, bool speed)
1562815628
static void
1562915629
aarch64_init_builtins ()
1563015630
{
15631+
// TODO: find a better fix than this to avoid the failure:
15632+
// SET_TYPE_VECTOR_SUBPARTS, in tree.h:4258
15633+
static bool builtins_initialized = false;
15634+
if (builtins_initialized)
15635+
return;
15636+
1563115637
aarch64_general_init_builtins ();
1563215638
aarch64_sve::init_builtins ();
1563315639
#ifdef SUBTARGET_INIT_BUILTINS
1563415640
SUBTARGET_INIT_BUILTINS;
1563515641
#endif
15642+
15643+
builtins_initialized = true;
1563615644
}
1563715645

1563815646
/* Implement TARGET_FOLD_BUILTIN. */

gcc/jit/dummy-frontend.cc

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,16 @@ jit_langhook_init (void)
10741074
eventually be controllable by a command line option. */
10751075
mpfr_set_default_prec (256);
10761076

1077+
// FIXME: This code doesn't work as it erases the `target_builtins` map
1078+
// without checking if it's already filled before. A better check would be
1079+
// `if target_builtins.len() == 0` (or whatever this `hash_map` type method
1080+
// name is).
1081+
//static bool builtins_initialized = false;
1082+
//if (!builtins_initialized)
1083+
//{
10771084
targetm.init_builtins ();
1085+
//builtins_initialized = true;
1086+
//}
10781087

10791088
return true;
10801089
}
@@ -1285,6 +1294,39 @@ recording::type* tree_type_to_jit_type (tree type)
12851294
recording::type* element_type = tree_type_to_jit_type (inner_type);
12861295
return element_type->get_pointer();
12871296
}
1297+
else if (type == unsigned_intTI_type_node)
1298+
{
1299+
// TODO: check if this is the correct type.
1300+
return new recording::memento_of_get_type (&target_builtins_ctxt, GCC_JIT_TYPE_UINT128_T);
1301+
}
1302+
else if (INTEGRAL_TYPE_P (type))
1303+
{
1304+
// TODO: check if this is the correct type.
1305+
unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
1306+
return target_builtins_ctxt.get_int_type (size, TYPE_UNSIGNED (type));
1307+
}
1308+
else if (SCALAR_FLOAT_TYPE_P (type))
1309+
{
1310+
// TODO: check if this is the correct type.
1311+
unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
1312+
enum gcc_jit_types type;
1313+
switch (size) {
1314+
case 2:
1315+
type = GCC_JIT_TYPE_FLOAT16;
1316+
break;
1317+
case 4:
1318+
type = GCC_JIT_TYPE_FLOAT32;
1319+
break;
1320+
case 8:
1321+
type = GCC_JIT_TYPE_FLOAT64;
1322+
break;
1323+
default:
1324+
fprintf (stderr, "Unexpected float size: %d\n", size);
1325+
abort ();
1326+
break;
1327+
}
1328+
return new recording::memento_of_get_type (&target_builtins_ctxt, type);
1329+
}
12881330
else
12891331
{
12901332
// Attempt to find an unqualified type when the current type has qualifiers.
@@ -1374,7 +1416,8 @@ jit_langhook_global_bindings_p (void)
13741416
static tree
13751417
jit_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
13761418
{
1377-
gcc_unreachable ();
1419+
/* Do nothing to avoid crashing on some targets. */
1420+
return NULL_TREE;
13781421
}
13791422

13801423
static tree

0 commit comments

Comments
 (0)