Skip to content

Commit

Permalink
Some fixes and workaround for aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Apr 24, 2024
1 parent 4c5565b commit 14b9aaf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions gcc/config/aarch64/aarch64-builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,8 @@ aarch64_init_simd_builtin_types (void)

if (aarch64_simd_types[i].itype == NULL)
{
// FIXME: problem happens when we execute this a second time.
// Currently fixed by not initializing builtins more than once in dummy-frontend.cc.
tree type = build_vector_type (eltype, GET_MODE_NUNITS (mode));
type = build_distinct_type_copy (type);
SET_TYPE_STRUCTURAL_EQUALITY (type);
Expand Down
45 changes: 43 additions & 2 deletions gcc/jit/dummy-frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,8 @@ jit_end_diagnostic (diagnostic_context *context,
gcc::jit::active_playback_ctxt->add_diagnostic (context, *diagnostic);
}

static bool builtins_initialized = false;

/* Language hooks. */

static bool
Expand Down Expand Up @@ -1073,7 +1075,12 @@ jit_langhook_init (void)
eventually be controllable by a command line option. */
mpfr_set_default_prec (256);

targetm.init_builtins ();
// TODO: check if this is a good fix.
if (!builtins_initialized)
{
targetm.init_builtins ();
builtins_initialized = true;
}

return true;
}
Expand Down Expand Up @@ -1291,6 +1298,39 @@ recording::type* tree_type_to_jit_type (tree type)
recording::type* element_type = tree_type_to_jit_type (inner_type);
return element_type->get_pointer();
}
else if (type == unsigned_intTI_type_node)
{
// TODO: check if this is the correct type.
return new recording::memento_of_get_type (&target_builtins_ctxt, GCC_JIT_TYPE_UINT128_T);
}
else if (INTEGRAL_TYPE_P (type))
{
// TODO: check if this is the correct type.
unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
return target_builtins_ctxt.get_int_type (size, TYPE_UNSIGNED (type));
}
else if (SCALAR_FLOAT_TYPE_P (type))
{
// TODO: check if this is the correct type.
unsigned int size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
enum gcc_jit_types type;
switch (size) {
case 2:
type = GCC_JIT_TYPE_FLOAT16;
break;
case 4:
type = GCC_JIT_TYPE_FLOAT32;
break;
case 8:
type = GCC_JIT_TYPE_FLOAT64;
break;
default:
fprintf (stderr, "Unexpected float size: %d\n", size);
abort ();
break;
}
return new recording::memento_of_get_type (&target_builtins_ctxt, type);
}
else
{
// Attempt to find an unqualified type when the current type has qualifiers.
Expand Down Expand Up @@ -1380,7 +1420,8 @@ jit_langhook_global_bindings_p (void)
static tree
jit_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
{
gcc_unreachable ();
/* Do nothing to avoid crashing on some targets. */
return NULL_TREE;
}

static tree
Expand Down

0 comments on commit 14b9aaf

Please sign in to comment.