This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, sparc]: Use ROUND_UP and ROUND_DOWN macros


Two functional changes I'd like to point out:

 /* ALIGN FRAMES on double word boundaries */
-#define SPARC_STACK_ALIGN(LOC) \
-  (TARGET_ARCH64 ? (((LOC)+15) & ~15) : (((LOC)+7) & ~7))
+#define SPARC_STACK_ALIGN(LOC) ROUND_UP ((LOC), UNITS_PER_WORD * 2)

The one above uses UNITS_PER_WORD in stack alignment calculation

       /* Always preserve double-word alignment.  */
-      offset = (offset + 8) & -8;
+      offset = ROUND_UP (offset, 8);

The one above looks like off-by-one bug, but this needs a confirmation.

2015-10-12  Uros Bizjak  <ubizjak@gmail.com>

    * config/sparc/sparc.h (SPARC_STACK_ALIGN): Implement using
    ROUND_UP macro and UNITS_PER_WORD * 2.
    * config/sparc/sparc.c (sparc_compute_frame_size):
    Use ROUND_UP and ROUND_DOWN macros where applicable.
    (function_arg_record_value, function_arg_record_value_1)
    (function_arg_record_value_1): Ditto.
    (emit_save_or_restore_regs): Use ROUND_UP to preserve offset
    alignment to double-word.
    (sparc_gimplify_va_arg): Use ROUND_UP ro calculate rsize.
    (sparc_emit_probe_stack_range): Use ROUND_DOWN to calculate
    rounded_size.

Tested by building a crosscompiler to sparc-linux-gnu. Due to the two
above changes, can someone please bootstrap and regression test this
patch properly on sparc targets?

OK for mainline if bootstrap+regtest show no problems?

Uros.

Attachment: s.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]