Skip to content

Some fixes and workaround for aarch64 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading