Skip to content

Commit 2482856

Browse files
authored
Merge pull request #52 from rust-lang/fix/aarch64
Some fixes and workaround for aarch64
2 parents a476be0 + 14b9aaf commit 2482856

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

gcc/config/aarch64/aarch64-builtins.cc

+2
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,8 @@ aarch64_init_simd_builtin_types (void)
11101110

11111111
if (aarch64_simd_types[i].itype == NULL)
11121112
{
1113+
// FIXME: problem happens when we execute this a second time.
1114+
// Currently fixed by not initializing builtins more than once in dummy-frontend.cc.
11131115
tree type = build_vector_type (eltype, GET_MODE_NUNITS (mode));
11141116
type = build_distinct_type_copy (type);
11151117
SET_TYPE_STRUCTURAL_EQUALITY (type);

gcc/jit/dummy-frontend.cc

+43-2
Original file line numberDiff line numberDiff line change
@@ -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

10401042
static 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)
13801420
static tree
13811421
jit_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

13861427
static tree

0 commit comments

Comments
 (0)