return info.stack_words > 0 ? info.reg_words * UNITS_PER_WORD : 0;
}
+/* Given MODE and TYPE of a function argument, return the alignment in
+ bits.
+ In case of typedef, alignment of its original type is
+ used. */
+
+static unsigned int
+mips_function_arg_alignment (machine_mode mode, const_tree type)
+{
+ if (!type)
+ return GET_MODE_ALIGNMENT (mode);
+
+ if (is_typedef_decl (TYPE_NAME (type)))
+ type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
+
+ return TYPE_ALIGN (type);
+}
+
/* Implement TARGET_FUNCTION_ARG_BOUNDARY. Every parameter gets at
least PARM_BOUNDARY bits of alignment, but will be given anything up
to STACK_BOUNDARY bits if the type requires it. */
mips_function_arg_boundary (machine_mode mode, const_tree type)
{
unsigned int alignment;
+ alignment = mips_function_arg_alignment (mode, type);
- alignment = type ? TYPE_ALIGN (type) : GET_MODE_ALIGNMENT (mode);
if (alignment < PARM_BOUNDARY)
alignment = PARM_BOUNDARY;
if (alignment > STACK_BOUNDARY)
--- /dev/null
+/* Check that typedef alignment does not affect passing of function
+ parameters for N64/N32 ABIs. */
+/* { dg-do compile { target { "mips*-*-*" } } } */
+/* { dg-options "-mabi=64" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+typedef struct ui8
+{
+ unsigned v[8];
+} uint8 __attribute__ ((aligned(64)));
+
+unsigned
+callee (int x, uint8 a)
+{
+ return a.v[0];
+}
+
+/* { dg-final { scan-assembler "\tsd\t\\\$5,0\\(\\\$\[0-9\]\\)" } } */
+/* { dg-final { scan-assembler "\tsd\t\\\$6,8\\(\\\$\[0-9\]\\)" } } */
+/* { dg-final { scan-assembler "\tsd\t\\\$7,16\\(\\\$\[0-9\]\\)" } } */
--- /dev/null
+/* Check that typedef alignment does not affect passing of function
+ parameters for O32 ABI. */
+/* { dg-do compile { target { "mips*-*-*" } } } */
+/* { dg-options "-mabi=32" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+typedef struct ui8
+{
+ unsigned v[8];
+} uint8 __attribute__ ((aligned(64)));
+
+unsigned
+callee (int x, uint8 a)
+{
+ return a.v[0];
+}
+
+/* { dg-final { scan-assembler "\tsw\t\\\$5,1\\d\\d\\(\\\$(sp|fp)\\)" } } */
+/* { dg-final { scan-assembler "\tsw\t\\\$6,1\\d\\d\\(\\\$(sp|fp)\\)" } } */
+/* { dg-final { scan-assembler "\tsw\t\\\$7,1\\d\\d\\(\\\$(sp|fp)\\)" } } */