Commit d702f362 by Georg-Johann Lay Committed by Georg-Johann Lay

re PR target/50887 ([avr] Support ACCUMULATE_OUTGOING_ARGS)

	PR target/50887
	* config/avr/avr.opt (-maccumulate-args): New option.
	* config/avr/avr.h (STARTING_FRAME_OFFSET): Redefine to
	avr_starting_frame_offset.
	(ACCUMULATE_OUTGOING_ARGS): Define to avr_accumulate_outgoing_args.
	* config/avr/avr.md (UNSPECV_WRITE_SP_IRQ_ON): Remove.
	(UNSPECV_WRITE_SP_IRQ_OFF): Remove.
	(UNSPECV_WRITE_SP): New constant.
	(*addhi3_sp_R): Rewrite to...
	(*addhi3_sp): ...this new insn.
	(movhi_sp_r_irq_off, movhi_sp_r_irq_on): Combine to...
	(movhi_sp_r): ...this new insn.
	* config/avr/avr-protos.h (avr_accumulate_outgoing_args): New.
	(avr_starting_frame_offset): New.
	* config/avr/avr.c (avr_accumulate_outgoing_args): New function.
	(avr_starting_frame_offset): New function.
	(avr_outgoing_args_size): New static function.
	(avr_initial_elimination_offset): Use it.
	(avr_simple_epilogue): Use it.
	(avr_asm_function_end_prologue): Use it.
	(expand_epilogue): Use it.
	(expand_prologue): Use it.  Break out code to...
	(avr_prologue_setup_frame): ...this new static function.
	(avr_can_eliminate): Allow eliminating to frame pointer if there
	is one.
	(avr_frame_pointer_required_p): Use frame pointer if target has a
	nonlocal label.
	* config/avr/constraints.md (R): Remove.
	(Csp): New constraint.
	* config/avr/predicates.md (avr_sp_immediate_operand): Use it.

From-SVN: r180654
parent f439d6ba
2011-10-29 Georg-Johann Lay <avr@gjlay.de>
PR target/50887
* config/avr/avr.opt (-maccumulate-args): New option.
* config/avr/avr.h (STARTING_FRAME_OFFSET): Redefine to
avr_starting_frame_offset.
(ACCUMULATE_OUTGOING_ARGS): Define to avr_accumulate_outgoing_args.
* config/avr/avr.md (UNSPECV_WRITE_SP_IRQ_ON): Remove.
(UNSPECV_WRITE_SP_IRQ_OFF): Remove.
(UNSPECV_WRITE_SP): New constant.
(*addhi3_sp_R): Rewrite to...
(*addhi3_sp): ...this new insn.
(movhi_sp_r_irq_off, movhi_sp_r_irq_on): Combine to...
(movhi_sp_r): ...this new insn.
* config/avr/avr-protos.h (avr_accumulate_outgoing_args): New.
(avr_starting_frame_offset): New.
* config/avr/avr.c (avr_accumulate_outgoing_args): New function.
(avr_starting_frame_offset): New function.
(avr_outgoing_args_size): New static function.
(avr_initial_elimination_offset): Use it.
(avr_simple_epilogue): Use it.
(avr_asm_function_end_prologue): Use it.
(expand_epilogue): Use it.
(expand_prologue): Use it. Break out code to...
(avr_prologue_setup_frame): ...this new static function.
(avr_can_eliminate): Allow eliminating to frame pointer if there
is one.
(avr_frame_pointer_required_p): Use frame pointer if target has a
nonlocal label.
* config/avr/constraints.md (R): Remove.
(Csp): New constraint.
* config/avr/predicates.md (avr_sp_immediate_operand): Use it.
2011-10-29 Andi Kleen <ak@linux.intel.com> 2011-10-29 Andi Kleen <ak@linux.intel.com>
* gcc-ar.c (target_machine): Add. * gcc-ar.c (target_machine): Add.
...@@ -32,6 +32,7 @@ extern int avr_initial_elimination_offset (int from, int to); ...@@ -32,6 +32,7 @@ extern int avr_initial_elimination_offset (int from, int to);
extern int avr_simple_epilogue (void); extern int avr_simple_epilogue (void);
extern int avr_hard_regno_rename_ok (unsigned int, unsigned int); extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
extern rtx avr_return_addr_rtx (int count, rtx tem); extern rtx avr_return_addr_rtx (int count, rtx tem);
extern bool avr_accumulate_outgoing_args (void);
#ifdef TREE_CODE #ifdef TREE_CODE
extern void avr_asm_output_aligned_decl_common (FILE*, const_tree, const char*, unsigned HOST_WIDE_INT, unsigned int, bool); extern void avr_asm_output_aligned_decl_common (FILE*, const_tree, const char*, unsigned HOST_WIDE_INT, unsigned int, bool);
...@@ -77,6 +78,7 @@ extern bool avr_rotate_bytes (rtx operands[]); ...@@ -77,6 +78,7 @@ extern bool avr_rotate_bytes (rtx operands[]);
extern void expand_prologue (void); extern void expand_prologue (void);
extern void expand_epilogue (bool); extern void expand_epilogue (bool);
extern int avr_epilogue_uses (int regno); extern int avr_epilogue_uses (int regno);
extern int avr_starting_frame_offset (void);
extern void avr_output_bld (rtx operands[], int bit_nr); extern void avr_output_bld (rtx operands[], int bit_nr);
extern void avr_output_addr_vec_elt (FILE *stream, int value); extern void avr_output_addr_vec_elt (FILE *stream, int value);
......
...@@ -324,7 +324,7 @@ enum reg_class { ...@@ -324,7 +324,7 @@ enum reg_class {
#define STACK_GROWS_DOWNWARD #define STACK_GROWS_DOWNWARD
#define STARTING_FRAME_OFFSET 1 #define STARTING_FRAME_OFFSET avr_starting_frame_offset()
#define STACK_POINTER_OFFSET 1 #define STACK_POINTER_OFFSET 1
...@@ -635,3 +635,5 @@ struct GTY(()) machine_function ...@@ -635,3 +635,5 @@ struct GTY(()) machine_function
/* AVR does not round pushes, but the existance of this macro is /* AVR does not round pushes, but the existance of this macro is
required in order for pushes to be generated. */ required in order for pushes to be generated. */
#define PUSH_ROUNDING(X) (X) #define PUSH_ROUNDING(X) (X)
#define ACCUMULATE_OUTGOING_ARGS avr_accumulate_outgoing_args()
...@@ -62,8 +62,7 @@ ...@@ -62,8 +62,7 @@
(define_c_enum "unspecv" (define_c_enum "unspecv"
[UNSPECV_PROLOGUE_SAVES [UNSPECV_PROLOGUE_SAVES
UNSPECV_EPILOGUE_RESTORES UNSPECV_EPILOGUE_RESTORES
UNSPECV_WRITE_SP_IRQ_ON UNSPECV_WRITE_SP
UNSPECV_WRITE_SP_IRQ_OFF
UNSPECV_GOTO_RECEIVER UNSPECV_GOTO_RECEIVER
UNSPECV_ENABLE_IRQS UNSPECV_ENABLE_IRQS
UNSPECV_NOP UNSPECV_NOP
...@@ -380,26 +379,24 @@ ...@@ -380,26 +379,24 @@
} }
}") }")
(define_insn "movhi_sp_r_irq_off"
[(set (match_operand:HI 0 "stack_register_operand" "=q")
(unspec_volatile:HI [(match_operand:HI 1 "register_operand" "r")]
UNSPECV_WRITE_SP_IRQ_OFF))]
""
"out __SP_H__, %B1
out __SP_L__, %A1"
[(set_attr "length" "2")
(set_attr "cc" "none")])
(define_insn "movhi_sp_r_irq_on" ;; Move register $1 to the Stack Pointer register SP.
[(set (match_operand:HI 0 "stack_register_operand" "=q") ;; This insn is emit during function prologue/epilogue generation.
(unspec_volatile:HI [(match_operand:HI 1 "register_operand" "r")] ;; $2 = 0: We know that IRQs are off
UNSPECV_WRITE_SP_IRQ_ON))] ;; $2 = 1: We know that IRQs are on
;; Remaining cases when the state of the I-Flag is unknown are
;; handled by generic movhi insn.
(define_insn "movhi_sp_r"
[(set (match_operand:HI 0 "stack_register_operand" "=q,q")
(unspec_volatile:HI [(match_operand:HI 1 "register_operand" "r,r")
(match_operand:HI 2 "const_int_operand" "L,P")]
UNSPECV_WRITE_SP))]
"" ""
"cli "@
out __SP_H__, %B1 out __SP_H__,%B1\;out __SP_L__,%A1
sei cli\;out __SP_H__,%B1\;sei\;out __SP_L__,%A1"
out __SP_L__, %A1" [(set_attr "length" "2,4")
[(set_attr "length" "4")
(set_attr "cc" "none")]) (set_attr "cc" "none")])
(define_peephole2 (define_peephole2
...@@ -800,15 +797,15 @@ ...@@ -800,15 +797,15 @@
[(set_attr "length" "2") [(set_attr "length" "2")
(set_attr "cc" "set_n")]) (set_attr "cc" "set_n")])
(define_insn "*addhi3_sp_R" (define_insn "*addhi3_sp"
[(set (match_operand:HI 1 "stack_register_operand" "=q") [(set (match_operand:HI 1 "stack_register_operand" "=q")
(plus:HI (match_operand:HI 2 "stack_register_operand" "q") (plus:HI (match_operand:HI 2 "stack_register_operand" "q")
(match_operand:HI 0 "avr_sp_immediate_operand" "R")))] (match_operand:HI 0 "avr_sp_immediate_operand" "Csp")))]
"" ""
{ {
return avr_out_addto_sp (operands, NULL); return avr_out_addto_sp (operands, NULL);
} }
[(set_attr "length" "5") [(set_attr "length" "6")
(set_attr "adjust_len" "addto_sp")]) (set_attr "adjust_len" "addto_sp")])
(define_insn "*addhi3" (define_insn "*addhi3"
......
...@@ -62,6 +62,10 @@ mpmem-wrap-around ...@@ -62,6 +62,10 @@ mpmem-wrap-around
Target Report Target Report
Make the linker relaxation machine assume that a program counter wrap-around occurs. Make the linker relaxation machine assume that a program counter wrap-around occurs.
maccumulate-args
Target Report Mask(ACCUMULATE_OUTGOING_ARGS)
Accumulate outgoing function arguments and acquire/release the needed stack space for outpoing function arguments in function prologue/epilogue. Without this option, outgoing arguments are pushed before calling a function and popped afterwards. This option can lead to reduced code size for functions that call many functions that get their arguments on the stack like, for example printf.
mstrict-X mstrict-X
Target Report Var(avr_strict_X) Init(0) Target Report Var(avr_strict_X) Init(0)
When accessing RAM, use X as imposed by the hardware, i.e. just use pre-decrement, post-increment and indirect addressing with the X register. Without this option, the compiler may assume that there is an addressing mode X+const similar to Y+const and Z+const and emit instructions to emulate such an addressing mode for X. When accessing RAM, use X as imposed by the hardware, i.e. just use pre-decrement, post-increment and indirect addressing with the X register. Without this option, the compiler may assume that there is an addressing mode X+const similar to Y+const and Z+const and emit instructions to emulate such an addressing mode for X.
...@@ -98,11 +98,6 @@ ...@@ -98,11 +98,6 @@
(and (match_code "const_double") (and (match_code "const_double")
(match_test "op == CONST0_RTX (SFmode)"))) (match_test "op == CONST0_RTX (SFmode)")))
(define_constraint "R"
"Integer constant in the range -6 @dots{} 5."
(and (match_code "const_int")
(match_test "ival >= -6 && ival <= 5")))
(define_memory_constraint "Q" (define_memory_constraint "Q"
"A memory address based on Y or Z pointer with displacement." "A memory address based on Y or Z pointer with displacement."
(and (match_code "mem") (and (match_code "mem")
...@@ -162,3 +157,8 @@ ...@@ -162,3 +157,8 @@
"Constant 4-byte integer that allows XOR without clobber register." "Constant 4-byte integer that allows XOR without clobber register."
(and (match_code "const_int") (and (match_code "const_int")
(match_test "avr_popcount_each_byte (op, 4, (1<<0) | (1<<8))"))) (match_test "avr_popcount_each_byte (op, 4, (1<<0) | (1<<8))")))
(define_constraint "Csp"
"Integer constant in the range -6 @dots{} 6."
(and (match_code "const_int")
(match_test "IN_RANGE (ival, -6, 6)")))
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
;; ;;
(define_predicate "avr_sp_immediate_operand" (define_predicate "avr_sp_immediate_operand"
(and (match_code "const_int") (and (match_code "const_int")
(match_test "INTVAL (op) >= -6 && INTVAL (op) <= 5"))) (match_test "satisfies_constraint_Csp (op)")))
;; True for EQ & NE ;; True for EQ & NE
(define_predicate "eqne_operator" (define_predicate "eqne_operator"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment