avr-protos.h (avr_output_bld): New.

* config/avr/avr-protos.h (avr_output_bld): New.
	(out_shift_with_cnt): Add t_len argument.
	* config/avr/avr.c (avr_num_arg_regs): Remove -mpack-args.
	(output_movqi, output_movhi, output_movsisf): Optimize loading
	any constant with exactly one bit set to NO_LD_REGS.
	(out_shift_with_cnt): Optimize output code for size or speed,
	depending on optimize_size.  Handle small shift counts as well
	(if not hand-optimized in ?sh??i3_out).  Shifts can be done
	with or without a scratch register, with help of __tmp_reg__
	or __zero_reg__ if necessary.  Add T_LEN argument to pass the
	length of TEMPLATE in words, return total insn length in *LEN.
	(ashlqi3_out, ashrqi3_out, lshrqi3_out): Change all calls to
	out_shift_with_cnt to work with the above change.
	(ashlhi3_out, ashlsi3_out, ashrhi3_out, ashrsi3_out, lshrhi3_out,
	lshrsi3_out): Likewise.  Optimize more known shift count cases.
	Remove cases already well optimized in out_shift_with_cnt.
	(avr_output_bld): New function.
	* config/avr/avr.h (MASK_PACK_ARGS, TARGET_PACK_ARGS): Remove.
	(TARGET_SWITCHES): Remove -mpack-args backward compatibility.
	* config/avr/avr.md (*reload_inqi, *reload_inhi, *reload_insi):
	Add reload_completed to insn condition - only for peepholes.
	(ashlqi3, ashrqi3, lshrqi3): Correct insn length for shift counts
	in a register or memory.
	(ashlhi3, ashlsi3, ashrhi3, ashrsi3, lshrhi3, lshrsi3): Likewise.
	Do not require a scratch register.
	(*ashlhi3_const, *ashlsi3_const, *ashrhi3_const, *ashrsi3_const,
	*lshrhi3_const, *lshrsi3_const): New insns and matching peepholes.
	Optimize shifts by known count using a scratch register, but only
	if one is still available after register allocation.

From-SVN: r36963
This commit is contained in:
Marek Michalkiewicz 2000-10-20 17:21:16 +02:00 committed by Denis Chertykov
parent 406b0a7cd6
commit afee2a52da
5 changed files with 797 additions and 349 deletions

View File

@ -1,3 +1,35 @@
2000-10-14 Marek Michalkiewicz <marekm@linux.org.pl>
* config/avr/avr-protos.h (avr_output_bld): New.
(out_shift_with_cnt): Add t_len argument.
* config/avr/avr.c (avr_num_arg_regs): Remove -mpack-args.
(output_movqi, output_movhi, output_movsisf): Optimize loading
any constant with exactly one bit set to NO_LD_REGS.
(out_shift_with_cnt): Optimize output code for size or speed,
depending on optimize_size. Handle small shift counts as well
(if not hand-optimized in ?sh??i3_out). Shifts can be done
with or without a scratch register, with help of __tmp_reg__
or __zero_reg__ if necessary. Add T_LEN argument to pass the
length of TEMPLATE in words, return total insn length in *LEN.
(ashlqi3_out, ashrqi3_out, lshrqi3_out): Change all calls to
out_shift_with_cnt to work with the above change.
(ashlhi3_out, ashlsi3_out, ashrhi3_out, ashrsi3_out, lshrhi3_out,
lshrsi3_out): Likewise. Optimize more known shift count cases.
Remove cases already well optimized in out_shift_with_cnt.
(avr_output_bld): New function.
* config/avr/avr.h (MASK_PACK_ARGS, TARGET_PACK_ARGS): Remove.
(TARGET_SWITCHES): Remove -mpack-args backward compatibility.
* config/avr/avr.md (*reload_inqi, *reload_inhi, *reload_insi):
Add reload_completed to insn condition - only for peepholes.
(ashlqi3, ashrqi3, lshrqi3): Correct insn length for shift counts
in a register or memory.
(ashlhi3, ashlsi3, ashrhi3, ashrsi3, lshrhi3, lshrsi3): Likewise.
Do not require a scratch register.
(*ashlhi3_const, *ashlsi3_const, *ashrhi3_const, *ashrsi3_const,
*lshrhi3_const, *lshrsi3_const): New insns and matching peepholes.
Optimize shifts by known count using a scratch register, but only
if one is still available after register allocation.
2000-10-20 J. David Anglin <dave@hiauly1.hia.nrc.ca>
* t-vax: New file. Don't build modules from libgcc1.c.

View File

@ -109,6 +109,8 @@ extern const char * lshrqi3_out PARAMS ((rtx insn, rtx operands[], int *len));
extern const char * lshrhi3_out PARAMS ((rtx insn, rtx operands[], int *len));
extern const char * lshrsi3_out PARAMS ((rtx insn, rtx operands[], int *len));
extern void avr_output_bld PARAMS ((rtx operands[], int bit_nr));
extern enum reg_class preferred_reload_class PARAMS ((rtx x,
enum reg_class class));
extern int avr_address_cost PARAMS ((rtx x));
@ -150,7 +152,8 @@ extern int avr_simplify_comparision_p PARAMS ((enum machine_mode mode,
extern RTX_CODE avr_normalize_condition PARAMS ((RTX_CODE condition));
extern int compare_eq_p PARAMS ((rtx insn));
extern void out_shift_with_cnt PARAMS ((const char *template, rtx insn,
rtx operands[], int *len));
rtx operands[], int *len,
int t_len));
extern int const_int_pow2_p PARAMS ((rtx x));
#endif /* RTX_CODE */

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,6 @@ extern int target_flags;
#define MASK_NO_INTERRUPTS 0x00020000
#define MASK_CALL_PROLOGUES 0x00040000
#define MASK_TINY_STACK 0x00080000
#define MASK_PACK_ARGS 0x00100000
#define TARGET_ORDER_1 (target_flags & MASK_ORDER_1)
#define TARGET_ORDER_2 (target_flags & MASK_ORDER_2)
@ -64,7 +63,6 @@ extern int target_flags;
#define TARGET_INSN_SIZE_DUMP (target_flags & MASK_INSN_SIZE_DUMP)
#define TARGET_CALL_PROLOGUES (target_flags & MASK_CALL_PROLOGUES)
#define TARGET_TINY_STACK (target_flags & MASK_TINY_STACK)
#define TARGET_PACK_ARGS (target_flags & MASK_PACK_ARGS)
/* Dump each assembler insn's rtl into the output file.
This is for debugging the compiler itself. */
@ -104,8 +102,6 @@ extern int target_flags;
N_("Use subroutines for function prologue/epilogue") }, \
{ "tiny-stack", MASK_TINY_STACK, \
N_("Change only the low 8 bits of the stack pointer") }, \
{ "pack-args", MASK_PACK_ARGS, \
N_("Do not align function arguments on even numbered registers") }, \
{ "rtl", MASK_RTL_DUMP, NULL }, \
{ "size", MASK_INSN_SIZE_DUMP, \
N_("Output instruction sizes to the asm file") }, \

View File

@ -182,7 +182,7 @@
[(set (match_operand:QI 0 "register_operand" "=l")
(match_operand:QI 1 "immediate_operand" "i"))
(clobber (match_operand:QI 2 "register_operand" "=&d"))]
""
"reload_completed"
"ldi %2,lo8(%1)
mov %0,%2"
[(set_attr "length" "2")
@ -231,7 +231,7 @@
[(set (match_operand:HI 0 "register_operand" "=r")
(match_operand:HI 1 "immediate_operand" "i"))
(clobber (match_operand:QI 2 "register_operand" "=&d"))]
""
"reload_completed"
"* return output_reload_inhi (insn, operands, NULL);"
[(set_attr "length" "4")
(set_attr "cc" "none")])
@ -279,7 +279,7 @@
[(set (match_operand:SI 0 "register_operand" "=r")
(match_operand:SI 1 "immediate_operand" "i"))
(clobber (match_operand:QI 2 "register_operand" "=&d"))]
""
"reload_completed"
"* return output_reload_insisf (insn, operands, NULL);"
[(set_attr "length" "8")
(set_attr "cc" "none")])
@ -889,34 +889,74 @@
;; arithmetic shift left
(define_insn "ashlqi3"
[(set (match_operand:QI 0 "register_operand" "=r,!d,r,r")
(ashift:QI (match_operand:QI 1 "register_operand" "0,0,0,0")
(match_operand:QI 2 "general_operand" "r,n,n,Qm")))]
[(set (match_operand:QI 0 "register_operand" "=r,r,r,!d,r,r")
(ashift:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,K,n,n,Qm")))]
""
"* return ashlqi3_out (insn, operands, NULL);"
[(set_attr "length" "5,4,6,7")
(set_attr "cc" "clobber,set_czn,set_czn,clobber")])
[(set_attr "length" "5,1,2,4,6,9")
(set_attr "cc" "clobber,set_czn,set_czn,set_czn,set_czn,clobber")])
(define_insn "ashlhi3"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
(ashift:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,O,K,i,Qm")))
(clobber (match_scratch:QI 3 "=X,X,X,X,&d,X"))]
(match_operand:QI 2 "general_operand" "r,P,O,K,n,Qm")))]
""
"* return ashlhi3_out (insn, operands, NULL);"
[(set_attr "length" "7,2,2,4,5,8")
[(set_attr "length" "6,2,2,4,10,10")
(set_attr "cc" "clobber,set_n,clobber,set_n,clobber,clobber")])
(define_insn "ashlsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(ashift:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,O,K,i,Qm")))
(clobber (match_scratch:QI 3 "=X,X,X,X,&d,X"))]
(match_operand:QI 2 "general_operand" "r,P,O,K,n,Qm")))]
""
"* return ashlsi3_out (insn, operands, NULL);"
[(set_attr "length" "9,4,4,8,7,10")
[(set_attr "length" "8,4,4,8,10,12")
(set_attr "cc" "clobber,set_n,clobber,set_n,clobber,clobber")])
;; Optimize if a scratch register from LD_REGS happens to be available.
(define_peephole2
[(match_scratch:QI 3 "d")
(set (match_operand:HI 0 "register_operand" "")
(ashift:HI (match_operand:HI 1 "register_operand" "")
(match_operand:QI 2 "const_int_operand" "")))]
""
[(parallel [(set (match_dup 0) (ashift:HI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
(define_insn "*ashlhi3_const"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
(ashift:HI (match_operand:HI 1 "register_operand" "0,r,0,0")
(match_operand:QI 2 "const_int_operand" "P,O,K,n")))
(clobber (match_scratch:QI 3 "=X,X,X,&d"))]
"reload_completed"
"* return ashlhi3_out (insn, operands, NULL);"
[(set_attr "length" "2,2,4,10")
(set_attr "cc" "set_n,clobber,set_n,clobber")])
(define_peephole2
[(match_scratch:QI 3 "d")
(set (match_operand:SI 0 "register_operand" "")
(ashift:SI (match_operand:SI 1 "register_operand" "")
(match_operand:QI 2 "const_int_operand" "")))]
""
[(parallel [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
(define_insn "*ashlsi3_const"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(ashift:SI (match_operand:SI 1 "register_operand" "0,r,0")
(match_operand:QI 2 "const_int_operand" "P,O,n")))
(clobber (match_scratch:QI 3 "=X,X,&d"))]
"reload_completed"
"* return ashlsi3_out (insn, operands, NULL);"
[(set_attr "length" "4,4,10")
(set_attr "cc" "set_n,clobber,clobber")])
;; >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
;; arithmetic shift right
@ -926,61 +966,141 @@
(match_operand:QI 2 "general_operand" "r,P,K,n,Qm")))]
""
"* return ashrqi3_out (insn, operands, NULL);"
[(set_attr "length" "5,1,2,5,7")
(set_attr "cc" "clobber,set_zn,set_zn,clobber,clobber")])
[(set_attr "length" "5,1,2,5,9")
(set_attr "cc" "clobber,clobber,clobber,clobber,clobber")])
(define_insn "ashrhi3"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
(ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0")
(match_operand:QI 2 "general_operand" "r,P,K,O,i,Qm")))
(clobber (match_scratch:QI 3 "=X,X,X,X,&d,X"))]
(ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,O,K,n,Qm")))]
""
"* return ashrhi3_out (insn, operands, NULL);"
[(set_attr "length" "7,2,4,4,5,8")
(set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
[(set_attr "length" "6,2,4,4,10,10")
(set_attr "cc" "clobber,clobber,set_n,clobber,clobber,clobber")])
(define_insn "ashrsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,O,K,i,Qm")))
(clobber (match_scratch:QI 3 "=X,X,X,X,&d,X"))]
(match_operand:QI 2 "general_operand" "r,P,O,K,n,Qm")))]
""
"* return ashrsi3_out (insn, operands, NULL);"
[(set_attr "length" "9,4,6,8,7,10")
(set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
[(set_attr "length" "8,4,6,8,10,12")
(set_attr "cc" "clobber,clobber,set_n,clobber,clobber,clobber")])
;; Optimize if a scratch register from LD_REGS happens to be available.
(define_peephole2
[(match_scratch:QI 3 "d")
(set (match_operand:HI 0 "register_operand" "")
(ashiftrt:HI (match_operand:HI 1 "register_operand" "")
(match_operand:QI 2 "const_int_operand" "")))]
""
[(parallel [(set (match_dup 0) (ashiftrt:HI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
(define_insn "*ashrhi3_const"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
(ashiftrt:HI (match_operand:HI 1 "register_operand" "0,r,0,0")
(match_operand:QI 2 "const_int_operand" "P,O,K,n")))
(clobber (match_scratch:QI 3 "=X,X,X,&d"))]
"reload_completed"
"* return ashrhi3_out (insn, operands, NULL);"
[(set_attr "length" "2,4,4,10")
(set_attr "cc" "clobber,set_n,clobber,clobber")])
(define_peephole2
[(match_scratch:QI 3 "d")
(set (match_operand:SI 0 "register_operand" "")
(ashiftrt:SI (match_operand:SI 1 "register_operand" "")
(match_operand:QI 2 "const_int_operand" "")))]
""
[(parallel [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
(define_insn "*ashrsi3_const"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(ashiftrt:SI (match_operand:SI 1 "register_operand" "0,r,0")
(match_operand:QI 2 "const_int_operand" "P,O,n")))
(clobber (match_scratch:QI 3 "=X,X,&d"))]
"reload_completed"
"* return ashrsi3_out (insn, operands, NULL);"
[(set_attr "length" "4,4,10")
(set_attr "cc" "clobber,set_n,clobber")])
;; >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
;; logical shift right
(define_insn "lshrqi3"
[(set (match_operand:QI 0 "register_operand" "=r,d,r,r")
(lshiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0")
(match_operand:QI 2 "general_operand" "r,n,n,Qm")))]
[(set (match_operand:QI 0 "register_operand" "=r,r,r,!d,r,r")
(lshiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,K,n,n,Qm")))]
""
"* return lshrqi3_out (insn, operands, NULL);"
[(set_attr "length" "6,4,6,7")
(set_attr "cc" "clobber,set_czn,set_czn,clobber")])
[(set_attr "length" "5,1,2,4,6,9")
(set_attr "cc" "clobber,set_czn,set_czn,set_czn,set_czn,clobber")])
(define_insn "lshrhi3"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
(lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0")
(match_operand:QI 2 "general_operand" "r,P,K,O,i,Qm")))
(clobber (match_scratch:QI 3 "=X,X,X,X,&d,X"))]
(lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,O,K,n,Qm")))]
""
"* return lshrhi3_out (insn, operands, NULL);"
[(set_attr "length" "7,2,4,2,5,8")
[(set_attr "length" "6,2,2,4,10,10")
(set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
(define_insn "lshrsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
(lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r,0,0,0")
(match_operand:QI 2 "general_operand" "r,P,O,K,i,Qm")))
(clobber (match_scratch:QI 3 "=X,X,X,X,&d,X"))]
(match_operand:QI 2 "general_operand" "r,P,O,K,n,Qm")))]
""
"* return lshrsi3_out (insn, operands, NULL);"
[(set_attr "length" "9,4,4,8,7,10")
[(set_attr "length" "8,4,4,8,10,12")
(set_attr "cc" "clobber,clobber,clobber,clobber,clobber,clobber")])
;; Optimize if a scratch register from LD_REGS happens to be available.
(define_peephole2
[(match_scratch:QI 3 "d")
(set (match_operand:HI 0 "register_operand" "")
(lshiftrt:HI (match_operand:HI 1 "register_operand" "")
(match_operand:QI 2 "const_int_operand" "")))]
""
[(parallel [(set (match_dup 0) (lshiftrt:HI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
(define_insn "*lshrhi3_const"
[(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
(lshiftrt:HI (match_operand:HI 1 "register_operand" "0,r,0,0")
(match_operand:QI 2 "const_int_operand" "P,O,K,n")))
(clobber (match_scratch:QI 3 "=X,X,X,&d"))]
"reload_completed"
"* return lshrhi3_out (insn, operands, NULL);"
[(set_attr "length" "2,2,4,10")
(set_attr "cc" "clobber,clobber,clobber,clobber")])
(define_peephole2
[(match_scratch:QI 3 "d")
(set (match_operand:SI 0 "register_operand" "")
(lshiftrt:SI (match_operand:SI 1 "register_operand" "")
(match_operand:QI 2 "const_int_operand" "")))]
""
[(parallel [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (match_dup 2)))
(clobber (match_dup 3))])]
"")
(define_insn "*lshrsi3_const"
[(set (match_operand:SI 0 "register_operand" "=r,r,r")
(lshiftrt:SI (match_operand:SI 1 "register_operand" "0,r,0")
(match_operand:QI 2 "const_int_operand" "P,O,n")))
(clobber (match_scratch:QI 3 "=X,X,&d"))]
"reload_completed"
"* return lshrsi3_out (insn, operands, NULL);"
[(set_attr "length" "4,4,10")
(set_attr "cc" "clobber,clobber,clobber")])
;; abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x)
;; abs