Skip to content

Commit

Permalink
Darwin, Arm64 : Initial stab at darwinpcs variadic functions.
Browse files Browse the repository at this point in the history
These use the simpler char * version - but it remains to be seen if
we need a non-standard rendition to cater for any amusing platform
differences.
  • Loading branch information
iains committed Feb 12, 2022
1 parent 0bc8ac2 commit f9c6558
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions gcc/config/aarch64/aarch64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6941,7 +6941,20 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
size is rounded up to 8 bytes, so will account for enough slots to
accommodate the entire argument - potentially, with some padding
at the end. When the current position is 0 - any allocation needs
a stack slot. CHECKME: do we need to align 16byte entities? */
a stack slot. CHECKME: do we need to align 16byte entities?

but we don't do this for unnamed parms in variadic functions, they
each get their own slot. */
if (!arg.named)
{
pcum->aapcs_stack_words = size / UNITS_PER_WORD;
pcum->darwinpcs_sub_word_offset = 0;
pcum->darwinpcs_sub_word_pos = 0;
/* We skip the re-alignment for 16byte things, since we currently
assume that the darwinpcs doesn't force such alignment. */
return;
}

if (pcum->darwinpcs_sub_word_pos == 0)
pcum->aapcs_stack_words = size / UNITS_PER_WORD;

Expand Down Expand Up @@ -18777,14 +18790,24 @@ static GTY(()) tree va_list_type;
void *__vr_top;
int __gr_offs;
int __vr_offs;
}; */
};

darwinpcs uses 'char *' for the va_list (in common with other platform
ports). */

static tree
aarch64_build_builtin_va_list (void)
{
tree va_list_name;
tree f_stack, f_grtop, f_vrtop, f_groff, f_vroff;

/* darwinpcs uses a simple char * for this. */
if (TARGET_MACHO)
{
va_list_type = build_pointer_type (char_type_node);
return va_list_type;
}

/* Create the type. */
va_list_type = lang_hooks.types.make_type (RECORD_TYPE);
/* Give it the required name. */
Expand Down Expand Up @@ -18856,6 +18879,13 @@ aarch64_expand_builtin_va_start (tree valist, rtx nextarg ATTRIBUTE_UNUSED)
int vr_save_area_size = cfun->va_list_fpr_size;
int vr_offset;

/* darwinpcs uses the default, char * va_list impl. */
if (TARGET_MACHO)
{
std_expand_builtin_va_start (valist, nextarg);
return;
}

cum = &crtl->args.info;
if (cfun->va_list_gpr_size)
gr_save_area_size = MIN ((NUM_ARG_REGS - cum->aapcs_ncrn) * UNITS_PER_WORD,
Expand Down Expand Up @@ -18946,6 +18976,9 @@ aarch64_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
HOST_WIDE_INT size, rsize, adjust, align;
tree t, u, cond1, cond2;

if (TARGET_MACHO)
return std_gimplify_va_arg_expr (valist, type, pre_p, post_p);

indirect_p = pass_va_arg_by_reference (type);
if (indirect_p)
type = build_pointer_type (type);
Expand Down Expand Up @@ -19202,6 +19235,9 @@ aarch64_setup_incoming_varargs (cumulative_args_t cum_v,
int gr_saved = cfun->va_list_gpr_size;
int vr_saved = cfun->va_list_fpr_size;

if (TARGET_MACHO)
return;

/* The caller has advanced CUM up to, but not beyond, the last named
argument. Advance a local copy of CUM past the last "real" named
argument, to find out how many registers are left over. */
Expand Down

0 comments on commit f9c6558

Please sign in to comment.