This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
avr port patch: movw, syntax cleanup
- To: gcc-patches at gcc dot gnu dot org
- Subject: avr port patch: movw, syntax cleanup
- From: Denis Chertykov <denisc at overta dot ru>
- Date: Wed, 13 Sep 2000 22:11:40 +0400
- Cc: marekm at linux dot org dot pl
Tue Sep 12 13:51:13 2000 Denis Chertykov <denisc@overta.ru>
* config/avr/avr.h (ASSEMBLER_DIALECT): New macro declared.
* config/avr/avr.md (*movstrqi_insn): Cleanup output template.
(*clrstrqi): Likewise.
(xorhi3,xorsi3,absqi2): Likewise.
(one_cmplhi2,one_cmplsi2): Likewise.
(addsi3): Two stupid constraint alternatives removed.
(extendhisi2): Use `movw' for enhanced avr cores.
(zero_extendhisi2): Likewise.
Index: gcc/config/avr/avr-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr-protos.h,v
retrieving revision 1.7
diff -c -3 -p -r1.7 avr-protos.h
*** avr-protos.h 2000/09/03 07:37:48 1.7
--- avr-protos.h 2000/09/13 18:00:02
*************** extern int mask_one_bit_p
*** 42,49 ****
extern void gas_output_limited_string PARAMS ((FILE *file, const char *str));
extern void gas_output_ascii PARAMS ((FILE *file, const char *str,
size_t length));
-
-
#ifdef TREE_CODE
extern void asm_output_external PARAMS ((FILE *file, tree decl,
char *name));
--- 42,47 ----
Index: gcc/config/avr/avr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.c,v
retrieving revision 1.20
diff -c -3 -p -r1.20 avr.c
*** avr.c 2000/09/03 07:37:48 1.20
--- avr.c 2000/09/13 18:00:13
*************** output_reload_insisf (insn, operands, le
*** 4666,4670 ****
}
return "";
}
-
-
--- 4666,4668 ----
Index: gcc/config/avr/avr.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.h,v
retrieving revision 1.9
diff -c -3 -p -r1.9 avr.h
*** avr.h 2000/09/03 07:37:48 1.9
--- avr.h 2000/09/13 18:00:29
*************** sprintf (STRING, "*.%s%d", PREFIX, NUM)
*** 2656,2661 ****
--- 2656,2686 ----
formats. In that case, the various `tm.h' files can define these
macros differently. */
+ #define ASSEMBLER_DIALECT AVR_ENHANCED
+ /* If your target supports multiple dialects of assembler language
+ (such as different opcodes), define this macro as a C expression
+ that gives the numeric index of the assembler language dialect to
+ use, with zero as the first variant.
+
+ If this macro is defined, you may use constructs of the form
+ `{option0|option1|option2...}' in the output templates of patterns
+ (*note Output Template::.) or in the first argument of
+ `asm_fprintf'. This construct outputs `option0', `option1' or
+ `option2', etc., if the value of `ASSEMBLER_DIALECT' is zero, one
+ or two, etc. Any special characters within these strings retain
+ their usual meaning.
+
+ If you do not define this macro, the characters `{', `|' and `}'
+ do not have any special meaning when used in templates or operands
+ to `asm_fprintf'.
+
+ Define the macros `REGISTER_PREFIX', `LOCAL_LABEL_PREFIX',
+ `USER_LABEL_PREFIX' and `IMMEDIATE_PREFIX' if you can express the
+ variations in assembler language syntax with that mechanism.
+ Define `ASSEMBLER_DIALECT' and use the `{option0|option1}' syntax
+ if the syntax variant are larger and involve such things as
+ different opcodes or operand order. */
+
#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
{ \
if (REGNO > 31) \
Index: gcc/config/avr/avr.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/avr/avr.md,v
retrieving revision 1.12
diff -c -3 -p -r1.12 avr.md
*** avr.md 2000/09/03 11:33:33 1.12
--- avr.md 2000/09/13 18:00:33
***************
*** 340,347 ****
(clobber (match_dup 0))
(clobber (match_dup 1))]
""
! "
! ld __tmp_reg__,%a1+
st %a0+,__tmp_reg__
dec %2
brne _PC_-8"
--- 340,346 ----
(clobber (match_dup 0))
(clobber (match_dup 1))]
""
! "ld __tmp_reg__,%a1+
st %a0+,__tmp_reg__
dec %2
brne _PC_-8"
***************
*** 409,416 ****
(clobber (match_dup 1))
(clobber (match_dup 0))]
""
! "
! st %a0+,__zero_reg__
dec %1
brne _PC_-6"
[(set_attr "length" "3")
--- 408,414 ----
(clobber (match_dup 1))
(clobber (match_dup 0))]
""
! "st %a0+,__zero_reg__
dec %1
brne _PC_-6"
[(set_attr "length" "3")
***************
*** 555,566 ****
[(set_attr "length" "2,1,1,2,3,3")
(set_attr "cc" "set_n,set_czn,set_czn,set_czn,set_n,set_n")])
- ;; TODO: use "movw" if available
(define_insn "addsi3"
! [(set (match_operand:SI 0 "register_operand" "=r,!w,!w,d,r,r,&*!w,&*!w")
(plus:SI
! (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r")
! (match_operand:SI 2 "nonmemory_operand" "r,I,J,i,P,N,#I,#J")))]
""
"@
add %A0,%A2\;adc %B0,%B2\;adc %C0,%C2\;adc %D0,%D2
--- 553,563 ----
[(set_attr "length" "2,1,1,2,3,3")
(set_attr "cc" "set_n,set_czn,set_czn,set_czn,set_n,set_n")])
(define_insn "addsi3"
! [(set (match_operand:SI 0 "register_operand" "=r,!w,!w,d,r,r")
(plus:SI
! (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
! (match_operand:SI 2 "nonmemory_operand" "r,I,J,i,P,N")))]
""
"@
add %A0,%A2\;adc %B0,%B2\;adc %C0,%C2\;adc %D0,%D2
***************
*** 568,578 ****
sbiw %0,%n2\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__
subi %0,lo8(-(%2))\;sbci %B0,hi8(-(%2))\;sbci %C0,hlo8(-(%2))\;sbci %D0,hhi8(-(%2))
sec\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__\;adc %C0,__zero_reg__\;adc %D0,__zero_reg__
! sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__
! mov %A0,%A1\;mov %B0,%B1\;mov %C0,%C1\;mov %D0,%D1\;adiw %0,%2\;adc %C0,__zero_reg__\;adc %D0,__zero_reg__
! mov %A0,%A1\;mov %B0,%B1\;mov %C0,%C1\;mov %D0,%D1\;sbiw %0,%n2\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__"
! [(set_attr "length" "4,3,3,4,5,5,7,7")
! (set_attr "cc" "set_n,set_n,set_czn,set_czn,set_n,set_n,set_n,set_czn")])
;-----------------------------------------------------------------------------
; sub bytes
--- 565,573 ----
sbiw %0,%n2\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__
subi %0,lo8(-(%2))\;sbci %B0,hi8(-(%2))\;sbci %C0,hlo8(-(%2))\;sbci %D0,hhi8(-(%2))
sec\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__\;adc %C0,__zero_reg__\;adc %D0,__zero_reg__
! sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__"
! [(set_attr "length" "4,3,3,4,5,5")
! (set_attr "cc" "set_n,set_n,set_czn,set_czn,set_n,set_n")])
;-----------------------------------------------------------------------------
; sub bytes
***************
*** 852,858 ****
(xor:HI (match_operand:HI 1 "register_operand" "%0")
(match_operand:HI 2 "register_operand" "r")))]
""
! "eor %0,%2\;eor %B0,%B2"
[(set_attr "length" "2")
(set_attr "cc" "set_n")])
--- 847,854 ----
(xor:HI (match_operand:HI 1 "register_operand" "%0")
(match_operand:HI 2 "register_operand" "r")))]
""
! "eor %0,%2
! eor %B0,%B2"
[(set_attr "length" "2")
(set_attr "cc" "set_n")])
***************
*** 971,977 ****
[(set (match_operand:QI 0 "register_operand" "=r")
(abs:QI (match_operand:QI 1 "register_operand" "0")))]
""
! "sbrc %0,7\;neg %0"
[(set_attr "length" "2")
(set_attr "cc" "clobber")])
--- 967,974 ----
[(set (match_operand:QI 0 "register_operand" "=r")
(abs:QI (match_operand:QI 1 "register_operand" "0")))]
""
! "sbrc %0,7
! neg %0"
[(set_attr "length" "2")
(set_attr "cc" "clobber")])
***************
*** 1043,1049 ****
[(set (match_operand:HI 0 "register_operand" "=r")
(not:HI (match_operand:HI 1 "register_operand" "0")))]
""
! "com %0\;com %B0"
[(set_attr "length" "2")
(set_attr "cc" "set_n")])
--- 1040,1047 ----
[(set (match_operand:HI 0 "register_operand" "=r")
(not:HI (match_operand:HI 1 "register_operand" "0")))]
""
! "com %0
! com %B0"
[(set_attr "length" "2")
(set_attr "cc" "set_n")])
***************
*** 1051,1057 ****
[(set (match_operand:SI 0 "register_operand" "=r")
(not:SI (match_operand:SI 1 "register_operand" "0")))]
""
! "com %0\;com %B0\;com %C0\;com %D0"
[(set_attr "length" "4")
(set_attr "cc" "set_n")])
--- 1049,1058 ----
[(set (match_operand:SI 0 "register_operand" "=r")
(not:SI (match_operand:SI 1 "register_operand" "0")))]
""
! "com %0
! com %B0
! com %C0
! com %D0"
[(set_attr "length" "4")
(set_attr "cc" "set_n")])
***************
*** 1078,1092 ****
[(set_attr "length" "5,6")
(set_attr "cc" "clobber,clobber")])
- ;; TODO: use "movw" if available
(define_insn "extendhisi2"
[(set (match_operand:SI 0 "register_operand" "=r,&r")
(sign_extend:SI (match_operand:HI 1 "register_operand" "0,*r")))]
""
"@
clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0
! mov %A0,%A1\;mov %B0,%B1\;clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0"
! [(set_attr "length" "4,6")
(set_attr "cc" "clobber,clobber")])
;; xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x
--- 1079,1100 ----
[(set_attr "length" "5,6")
(set_attr "cc" "clobber,clobber")])
(define_insn "extendhisi2"
[(set (match_operand:SI 0 "register_operand" "=r,&r")
(sign_extend:SI (match_operand:HI 1 "register_operand" "0,*r")))]
""
"@
clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0
! {mov %A0,%A1\;mov %B0,%B1|movw %A0,%A1}\;clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0"
! [(set (attr "length")
! (if_then_else
! (eq (symbol_ref "AVR_ENHANCED") (const_int 0))
! (if_then_else (eq (symbol_ref "which_alternative") (const_int 0))
! (const_int 4)
! (const_int 6))
! (if_then_else (eq (symbol_ref "which_alternative") (const_int 0))
! (const_int 4)
! (const_int 5))))
(set_attr "cc" "clobber,clobber")])
;; xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x
***************
*** 1112,1126 ****
[(set_attr "length" "3,4")
(set_attr "cc" "set_n,set_n")])
- ;; TODO: use "movw" if available
(define_insn "zero_extendhisi2"
[(set (match_operand:SI 0 "register_operand" "=r,&r")
(zero_extend:SI (match_operand:HI 1 "register_operand" "0,*r")))]
""
"@
clr %C0\;clr %D0
! mov %A0,%A1\;mov %B0,%B1\;clr %C0\;clr %D0"
! [(set_attr "length" "2,4")
(set_attr "cc" "set_n,set_n")])
;;<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>
--- 1120,1141 ----
[(set_attr "length" "3,4")
(set_attr "cc" "set_n,set_n")])
(define_insn "zero_extendhisi2"
[(set (match_operand:SI 0 "register_operand" "=r,&r")
(zero_extend:SI (match_operand:HI 1 "register_operand" "0,*r")))]
""
"@
clr %C0\;clr %D0
! {mov %A0,%A1\;mov %B0,%B1|movw %A0,%B0}\;clr %C0\;clr %D0"
! [(set (attr "length")
! (if_then_else
! (eq (symbol_ref "AVR_ENHANCED") (const_int 0))
! (if_then_else (eq (symbol_ref "which_alternative") (const_int 0))
! (const_int 2)
! (const_int 4))
! (if_then_else (eq (symbol_ref "which_alternative") (const_int 0))
! (const_int 2)
! (const_int 3))))
(set_attr "cc" "set_n,set_n")])
;;<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>