diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2018-01-03 07:18:13 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-01-03 07:18:13 +0000 |
commit | 7b4df2bf95d2254756f6509ee57a90c398baf81b (patch) | |
tree | c05cbaa50ad24f72ed0785372d754691a8e79a2b /gcc/config | |
parent | a930fe51508f431a97eaeb0f546d4b26b40dbfa1 (diff) | |
download | gcc-7b4df2bf95d2254756f6509ee57a90c398baf81b.zip gcc-7b4df2bf95d2254756f6509ee57a90c398baf81b.tar.gz gcc-7b4df2bf95d2254756f6509ee57a90c398baf81b.tar.bz2 |
poly_int: PUSH_ROUNDING
PUSH_ROUNDING is difficult to convert to a hook since there is still
a lot of conditional code based on it. It isn't clear that a direct
conversion with checks for null hooks is the right thing to do.
Rather than untangle that, this patch converts all implementations
that do something to out-of-line functions that have the same
interface as a hook would have. This should at least help towards
any future hook conversion.
2018-01-03 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* config/cr16/cr16-protos.h (cr16_push_rounding): Declare.
* config/cr16/cr16.h (PUSH_ROUNDING): Move implementation to...
* config/cr16/cr16.c (cr16_push_rounding): ...this new function.
* config/h8300/h8300-protos.h (h8300_push_rounding): Declare.
* config/h8300/h8300.h (PUSH_ROUNDING): Move implementation to...
* config/h8300/h8300.c (h8300_push_rounding): ...this new function.
* config/i386/i386-protos.h (ix86_push_rounding): Declare.
* config/i386/i386.h (PUSH_ROUNDING): Move implementation to...
* config/i386/i386.c (ix86_push_rounding): ...this new function.
* config/m32c/m32c-protos.h (m32c_push_rounding): Take and return
a poly_int64.
* config/m32c/m32c.c (m32c_push_rounding): Likewise.
* config/m68k/m68k-protos.h (m68k_push_rounding): Declare.
* config/m68k/m68k.h (PUSH_ROUNDING): Move implementation to...
* config/m68k/m68k.c (m68k_push_rounding): ...this new function.
* config/pdp11/pdp11-protos.h (pdp11_push_rounding): Declare.
* config/pdp11/pdp11.h (PUSH_ROUNDING): Move implementation to...
* config/pdp11/pdp11.c (pdp11_push_rounding): ...this new function.
* config/stormy16/stormy16-protos.h (xstormy16_push_rounding): Declare.
* config/stormy16/stormy16.h (PUSH_ROUNDING): Move implementation to...
* config/stormy16/stormy16.c (xstormy16_push_rounding): ...this new
function.
* expr.c (emit_move_resolve_push): Treat the input and result
of PUSH_ROUNDING as a poly_int64.
(emit_move_complex_push, emit_single_push_insn_1): Likewise.
(emit_push_insn): Likewise.
* lra-eliminations.c (mark_not_eliminable): Likewise.
* recog.c (push_operand): Likewise.
* reload1.c (elimination_effects): Likewise.
* rtlanal.c (nonzero_bits1): Likewise.
* calls.c (store_one_arg): Likewise. Require the padding to be
known at compile time.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r256155
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/cr16/cr16-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/cr16/cr16.c | 8 | ||||
-rw-r--r-- | gcc/config/cr16/cr16.h | 2 | ||||
-rw-r--r-- | gcc/config/h8300/h8300-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.c | 15 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.h | 13 | ||||
-rw-r--r-- | gcc/config/i386/i386-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 13 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 10 | ||||
-rw-r--r-- | gcc/config/m32c/m32c-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/m32c/m32c.c | 4 | ||||
-rw-r--r-- | gcc/config/m68k/m68k-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/m68k/m68k.c | 11 | ||||
-rw-r--r-- | gcc/config/m68k/m68k.h | 4 | ||||
-rw-r--r-- | gcc/config/pdp11/pdp11-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/pdp11/pdp11.c | 9 | ||||
-rw-r--r-- | gcc/config/pdp11/pdp11.h | 5 | ||||
-rw-r--r-- | gcc/config/stormy16/stormy16-protos.h | 1 | ||||
-rw-r--r-- | gcc/config/stormy16/stormy16.c | 8 | ||||
-rw-r--r-- | gcc/config/stormy16/stormy16.h | 2 |
20 files changed, 80 insertions, 33 deletions
diff --git a/gcc/config/cr16/cr16-protos.h b/gcc/config/cr16/cr16-protos.h index 4872c0b..8866690 100644 --- a/gcc/config/cr16/cr16-protos.h +++ b/gcc/config/cr16/cr16-protos.h @@ -94,5 +94,6 @@ extern const char *cr16_emit_logical_di (rtx *, enum rtx_code); /* Handling the "interrupt" attribute. */ extern int cr16_interrupt_function_p (void); extern bool cr16_is_data_model (enum data_model_type); +extern poly_int64 cr16_push_rounding (poly_int64); #endif /* Not GCC_CR16_PROTOS_H. */ diff --git a/gcc/config/cr16/cr16.c b/gcc/config/cr16/cr16.c index ddadab2..9ea02a9 100644 --- a/gcc/config/cr16/cr16.c +++ b/gcc/config/cr16/cr16.c @@ -2215,6 +2215,14 @@ cr16_emit_logical_di (rtx *operands, enum rtx_code code) return ""; } +/* Implement PUSH_ROUNDING. */ + +poly_int64 +cr16_push_rounding (poly_int64 bytes) +{ + return (bytes + 1) & ~1; +} + /* Initialize 'targetm' variable which contains pointers to functions and data relating to the target machine. */ diff --git a/gcc/config/cr16/cr16.h b/gcc/config/cr16/cr16.h index 5c4702c..692bbaf 100644 --- a/gcc/config/cr16/cr16.h +++ b/gcc/config/cr16/cr16.h @@ -381,7 +381,7 @@ enum reg_class #define PUSH_ARGS 1 -#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) +#define PUSH_ROUNDING(BYTES) cr16_push_rounding (BYTES) #ifndef CUMULATIVE_ARGS struct cumulative_args diff --git a/gcc/config/h8300/h8300-protos.h b/gcc/config/h8300/h8300-protos.h index d6adebb..1d4a574 100644 --- a/gcc/config/h8300/h8300-protos.h +++ b/gcc/config/h8300/h8300-protos.h @@ -112,5 +112,6 @@ extern bool h8sx_mergeable_memrefs_p (rtx, rtx); extern bool h8sx_emit_movmd (rtx, rtx, rtx, HOST_WIDE_INT); extern void h8300_swap_into_er6 (rtx); extern void h8300_swap_out_of_er6 (rtx); +extern poly_int64 h8300_push_rounding (poly_int64); #endif /* ! GCC_H8300_PROTOS_H */ diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 88c2153..432e23e 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -6044,6 +6044,21 @@ h8300_trampoline_init (rtx m_tramp, tree fndecl, rtx cxt) emit_move_insn (mem, tem); } } + +/* Implement PUSH_ROUNDING. + + On the H8/300, @-sp really pushes a byte if you ask it to - but that's + dangerous, so we claim that it always pushes a word, then we catch + the mov.b rx,@-sp and turn it into a mov.w rx,@-sp on output. + + On the H8/300H, we simplify TARGET_QUICKCALL by setting this to 4 + and doing a similar thing. */ + +poly_int64 +h8300_push_rounding (poly_int64 bytes) +{ + return ((bytes + PARM_BOUNDARY / 8 - 1) & (-PARM_BOUNDARY / 8)); +} /* Initialize the GCC target structure. */ #undef TARGET_ATTRIBUTE_TABLE diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 9ba82a7..a57e7b5 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -352,18 +352,7 @@ enum reg_class { #define FRAME_GROWS_DOWNWARD 1 -/* If we generate an insn to push BYTES bytes, - this says how many the stack pointer really advances by. - - On the H8/300, @-sp really pushes a byte if you ask it to - but that's - dangerous, so we claim that it always pushes a word, then we catch - the mov.b rx,@-sp and turn it into a mov.w rx,@-sp on output. - - On the H8/300H, we simplify TARGET_QUICKCALL by setting this to 4 - and doing a similar thing. */ - -#define PUSH_ROUNDING(BYTES) \ - (((BYTES) + PARM_BOUNDARY / 8 - 1) & -PARM_BOUNDARY / 8) +#define PUSH_ROUNDING(BYTES) h8300_push_rounding (BYTES) /* Offset of first parameter from the argument pointer register value. */ /* Is equal to the size of the saved fp + pc, even if an fp isn't diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 287b019..d1b5330 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -323,6 +323,8 @@ extern void ix86_core2i7_init_hooks (void); extern int ix86_atom_sched_reorder (FILE *, int, rtx_insn **, int *, int); +extern poly_int64 ix86_push_rounding (poly_int64); + #ifdef RTX_CODE /* Target data for multipass lookahead scheduling. Currently used for Core 2/i7 tuning. */ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index cac510d..ff058f4 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -49964,6 +49964,19 @@ ix86_excess_precision (enum excess_precision_type type) return FLT_EVAL_METHOD_UNPREDICTABLE; } +/* Implement PUSH_ROUNDING. On 386, we have pushw instruction that + decrements by exactly 2 no matter what the position was, there is no pushb. + + But as CIE data alignment factor on this arch is -4 for 32bit targets + and -8 for 64bit targets, we need to make sure all stack pointer adjustments + are in multiple of 4 for 32bit targets and 8 for 64bit targets. */ + +poly_int64 +ix86_push_rounding (poly_int64 bytes) +{ + return ROUND_UP (bytes, UNITS_PER_WORD); +} + /* Target-specific selftests. */ #if CHECKING_P diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 3b953de..8a17c0e 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1547,15 +1547,7 @@ enum reg_class goes at a more negative offset in the frame. */ #define FRAME_GROWS_DOWNWARD 1 -/* If we generate an insn to push BYTES bytes, this says how many the stack - pointer really advances by. On 386, we have pushw instruction that - decrements by exactly 2 no matter what the position was, there is no pushb. - - But as CIE data alignment factor on this arch is -4 for 32bit targets - and -8 for 64bit targets, we need to make sure all stack pointer adjustments - are in multiple of 4 for 32bit targets and 8 for 64bit targets. */ - -#define PUSH_ROUNDING(BYTES) ROUND_UP ((BYTES), UNITS_PER_WORD) +#define PUSH_ROUNDING(BYTES) ix86_push_rounding (BYTES) /* If defined, the maximum amount of space required for outgoing arguments will be computed and placed into the variable `crtl->outgoing_args_size'. diff --git a/gcc/config/m32c/m32c-protos.h b/gcc/config/m32c/m32c-protos.h index 8647a20..f68d3b3 100644 --- a/gcc/config/m32c/m32c-protos.h +++ b/gcc/config/m32c/m32c-protos.h @@ -29,7 +29,7 @@ void m32c_init_expanders (void); int m32c_initial_elimination_offset (int, int); void m32c_output_reg_pop (FILE *, int); void m32c_output_reg_push (FILE *, int); -unsigned int m32c_push_rounding (int); +poly_int64 m32c_push_rounding (poly_int64); void m32c_register_pragmas (void); void m32c_note_pragma_address (const char *, unsigned); int m32c_regno_ok_for_base_p (int); diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c index f1a465a..d8f69ee 100644 --- a/gcc/config/m32c/m32c.c +++ b/gcc/config/m32c/m32c.c @@ -1290,8 +1290,8 @@ m32c_initial_elimination_offset (int from, int to) /* Implements PUSH_ROUNDING. The R8C and M16C have byte stacks, the M32C has word stacks. */ -unsigned int -m32c_push_rounding (int n) +poly_int64 +m32c_push_rounding (poly_int64 n) { if (TARGET_R8C || TARGET_M16C) return n; diff --git a/gcc/config/m68k/m68k-protos.h b/gcc/config/m68k/m68k-protos.h index cdd6798..3c285a9 100644 --- a/gcc/config/m68k/m68k-protos.h +++ b/gcc/config/m68k/m68k-protos.h @@ -99,3 +99,4 @@ extern void init_68881_table (void); extern rtx m68k_legitimize_call_address (rtx); extern rtx m68k_legitimize_sibcall_address (rtx); extern int m68k_hard_regno_rename_ok(unsigned int, unsigned int); +extern poly_int64 m68k_push_rounding (poly_int64); diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index 10c7815..1c6484e 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -6610,4 +6610,15 @@ m68k_excess_precision (enum excess_precision_type type) return FLT_EVAL_METHOD_UNPREDICTABLE; } +/* Implement PUSH_ROUNDING. On the 680x0, sp@- in a byte insn really pushes + a word. On the ColdFire, sp@- in a byte insn pushes just a byte. */ + +poly_int64 +m68k_push_rounding (poly_int64 bytes) +{ + if (TARGET_COLDFIRE) + return bytes; + return (bytes + 1) & ~1; +} + #include "gt-m68k.h" diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index 97693cb..8eb898e6 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -468,9 +468,7 @@ extern enum reg_class regno_reg_class[]; #define STACK_GROWS_DOWNWARD 1 #define FRAME_GROWS_DOWNWARD 1 -/* On the 680x0, sp@- in a byte insn really pushes a word. - On the ColdFire, sp@- in a byte insn pushes just a byte. */ -#define PUSH_ROUNDING(BYTES) (TARGET_COLDFIRE ? BYTES : ((BYTES) + 1) & ~1) +#define PUSH_ROUNDING(BYTES) m68k_push_rounding (BYTES) #define FIRST_PARM_OFFSET(FNDECL) 8 diff --git a/gcc/config/pdp11/pdp11-protos.h b/gcc/config/pdp11/pdp11-protos.h index f6c7d1a..467b0d8 100644 --- a/gcc/config/pdp11/pdp11-protos.h +++ b/gcc/config/pdp11/pdp11-protos.h @@ -44,3 +44,4 @@ extern void pdp11_asm_output_var (FILE *, const char *, int, int, bool); extern void pdp11_expand_prologue (void); extern void pdp11_expand_epilogue (void); extern int pdp11_branch_cost (void); +extern poly_int64 pdp11_push_rounding (poly_int64); diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 06fef13..1367a07 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -1977,4 +1977,13 @@ pdp11_modes_tieable_p (machine_mode, machine_mode) return false; } +/* Implement PUSH_ROUNDING. On the pdp11, the stack is on an even + boundary. */ + +poly_int64 +pdp11_push_rounding (poly_int64 bytes) +{ + return (bytes + 1) & ~1; +} + struct gcc_target targetm = TARGET_INITIALIZER; diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index 115bb5b..5ccec18 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -257,10 +257,7 @@ enum reg_class { NO_REGS, MUL_REGS, GENERAL_REGS, LOAD_FPU_REGS, NO_LOAD_FPU_REG */ #define FRAME_GROWS_DOWNWARD 1 -/* If we generate an insn to push BYTES bytes, - this says how many the stack pointer really advances by. - On the pdp11, the stack is on an even boundary */ -#define PUSH_ROUNDING(BYTES) ((BYTES + 1) & ~1) +#define PUSH_ROUNDING(BYTES) pdp11_push_rounding (BYTES) /* current_first_parm_offset stores the # of registers pushed on the stack */ diff --git a/gcc/config/stormy16/stormy16-protos.h b/gcc/config/stormy16/stormy16-protos.h index 38be8d2..c4ce114 100644 --- a/gcc/config/stormy16/stormy16-protos.h +++ b/gcc/config/stormy16/stormy16-protos.h @@ -28,6 +28,7 @@ extern int direct_return (void); extern int xstormy16_interrupt_function_p (void); extern int xstormy16_epilogue_uses (int); extern void xstormy16_function_profiler (void); +extern poly_int64 xstormy16_push_rounding (poly_int64); #if defined (TREE_CODE) extern void xstormy16_asm_output_aligned_common (FILE *, tree, const char *, diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index a355794..002eeee 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -2635,6 +2635,14 @@ xstormy16_modes_tieable_p (machine_mode mode1, machine_mode mode2) { return mode1 != BImode && mode2 != BImode; } + +/* Implement PUSH_ROUNDING. */ + +poly_int64 +xstormy16_push_rounding (poly_int64 bytes) +{ + return (bytes + 1) & ~1; +} #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.hword\t" diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index 1d70457..dfc659c 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -255,7 +255,7 @@ enum reg_class /* Passing Function Arguments on the Stack. */ -#define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1) +#define PUSH_ROUNDING(BYTES) xstormy16_push_rounding (BYTES) /* Function Arguments in Registers. */ |