* [AVR] Add __AVR_HAVE_MUL__ macro
@ 2007-01-16 23:42 Anatoly Sokolov
0 siblings, 0 replies; only message in thread
From: Anatoly Sokolov @ 2007-01-16 23:42 UTC (permalink / raw)
To: gcc-patches; +Cc: aesok
[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]
Hello.
This patch add __AVR_HAVE_MUL__ new cpp macros. Specifically:
- it define __AVR_HAVE_MUL__ when the device have MUL instruction;
- it rename avr_enhanced_p variable to avr_have_mul_p;
- it rename AVR_ENHANCED macros to AVR_HAVE_MUL.
Anatoly.
2007-01-16 Anatoly Sokolov <aesok@post.ru>
* config/avr/avr.h (AVR_HAVE_LPMX): New macro.
(AVR_ENHANCED): Rename to ...
(AVR_HAVE_MUL): ... new.
(avr_enhanced_p): Rename to ...
(avr_have_mul_p): ... new.
(TARGET_CPU_CPP_BUILTINS): Use 'avr_have_mul_p' instead of
'avr_enhanced_p' for "__AVR_ENHANCED__". Define "__AVR_HAVE_MUL__".
* config/avr/avr.c (avr_enhanced_p): Rename to ...
(avr_have_mul_p): ... new.
(base_arch_s): Rename 'enhanced' to 'have_mul'.
(avr_override_options): Use 'avr_have_mul_p' and 'have_mul' instead of
'avr_enhanced_p' and 'enhanced'.
(ashlhi3_out, ashrhi3_out, lshrhi3_out, avr_rtx_costs): Use
AVR_HAVE_MUL instead of AVR_ENHANCED.
* avr.md (*tablejump_enh): Use AVR_HAVE_LPMX instead of AVR_ENHANCED.
(mulqi3, *mulqi3_enh, *mulqi3_call, mulqihi3, umulqihi3, mulhi3,
*mulhi3_enh, *mulhi3_call, mulsi3, *mulsi3_call): Use AVR_HAVE_MUL
instead of AVR_ENHANCED.
(*tablejump_enh): Use AVR_HAVE_LPMX instead of AVR_ENHANCED.
* libgcc.S: Use __AVR_HAVE_MUL__ instead of __AVR_ENHANCED__.
(__tablejump__): Use __AVR_HAVE_LPMX__ instead of __AVR_ENHANCED__.
[-- Attachment #2: have_mul.txt --]
[-- Type: text/plain, Size: 9117 bytes --]
Index: libgcc.S
===================================================================
--- libgcc.S (revision 120650)
+++ libgcc.S (working copy)
@@ -56,7 +56,7 @@
.endm
/* Note: mulqi3, mulhi3 are open-coded on the enhanced core. */
-#if !defined (__AVR_ENHANCED__)
+#if !defined (__AVR_HAVE_MUL__)
/*******************************************************
Multiplication 8 x 8
*******************************************************/
@@ -159,7 +159,7 @@
.endfunc
#endif /* defined (L_mulhi3) */
-#endif /* !defined (__AVR_ENHANCED__) */
+#endif /* !defined (__AVR_HAVE_MUL__) */
#if defined (L_mulhisi3)
.global __mulhisi3
@@ -217,7 +217,7 @@
.global __mulsi3
.func __mulsi3
__mulsi3:
-#if defined (__AVR_ENHANCED__)
+#if defined (__AVR_HAVE_MUL__)
mul r_arg1L, r_arg2L
movw r_resL, r0
mul r_arg1H, r_arg2H
@@ -281,7 +281,7 @@
mov_h r_arg1H,r_resH
mov_l r_arg1L,r_resL
ret
-#endif /* !defined (__AVR_ENHANCED__) */
+#endif /* defined (__AVR_HAVE_MUL__) */
#undef r_arg1L
#undef r_arg1H
#undef r_arg1HL
@@ -668,7 +668,7 @@
rol r31
.global __tablejump__
__tablejump__:
-#if defined (__AVR_ENHANCED__)
+#if defined (__AVR_HAVE_LPMX__)
lpm __tmp_reg__, Z+
lpm r31, Z
mov r30, __tmp_reg__
Index: avr.md
===================================================================
--- avr.md (revision 120650)
+++ avr.md (working copy)
@@ -707,7 +707,7 @@
(match_operand:QI 2 "register_operand" "")))]
""
"{
- if (!AVR_ENHANCED)
+ if (!AVR_HAVE_MUL)
{
emit_insn (gen_mulqi3_call (operands[0], operands[1], operands[2]));
DONE;
@@ -718,7 +718,7 @@
[(set (match_operand:QI 0 "register_operand" "=r")
(mult:QI (match_operand:QI 1 "register_operand" "r")
(match_operand:QI 2 "register_operand" "r")))]
- "AVR_ENHANCED"
+ "AVR_HAVE_MUL"
"mul %1,%2
mov %0,r0
clr r1"
@@ -737,7 +737,7 @@
(define_insn "*mulqi3_call"
[(set (reg:QI 24) (mult:QI (reg:QI 24) (reg:QI 22)))
(clobber (reg:QI 22))]
- "!AVR_ENHANCED"
+ "!AVR_HAVE_MUL"
"%~call __mulqi3"
[(set_attr "type" "xcall")
(set_attr "cc" "clobber")])
@@ -746,7 +746,7 @@
[(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d"))
(sign_extend:HI (match_operand:QI 2 "register_operand" "d"))))]
- "AVR_ENHANCED"
+ "AVR_HAVE_MUL"
"muls %1,%2
movw %0,r0
clr r1"
@@ -757,7 +757,7 @@
[(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
- "AVR_ENHANCED"
+ "AVR_HAVE_MUL"
"mul %1,%2
movw %0,r0
clr r1"
@@ -771,7 +771,7 @@
""
"
{
- if (!AVR_ENHANCED)
+ if (!AVR_HAVE_MUL)
{
emit_insn (gen_mulhi3_call (operands[0], operands[1], operands[2]));
DONE;
@@ -782,7 +782,7 @@
[(set (match_operand:HI 0 "register_operand" "=&r")
(mult:HI (match_operand:HI 1 "register_operand" "r")
(match_operand:HI 2 "register_operand" "r")))]
- "AVR_ENHANCED"
+ "AVR_HAVE_MUL"
"mul %A1,%A2
movw %0,r0
mul %A1,%B2
@@ -807,7 +807,7 @@
[(set (reg:HI 24) (mult:HI (reg:HI 24) (reg:HI 22)))
(clobber (reg:HI 22))
(clobber (reg:QI 21))]
- "!AVR_ENHANCED"
+ "!AVR_HAVE_MUL"
"%~call __mulhi3"
[(set_attr "type" "xcall")
(set_attr "cc" "clobber")])
@@ -821,14 +821,14 @@
(clobber (reg:HI 26))
(clobber (reg:HI 30))])
(set (match_operand:SI 0 "register_operand" "") (reg:SI 22))]
- "AVR_ENHANCED"
+ "AVR_HAVE_MUL"
"")
(define_insn "*mulsi3_call"
[(set (reg:SI 22) (mult:SI (reg:SI 22) (reg:SI 18)))
(clobber (reg:HI 26))
(clobber (reg:HI 30))]
- "AVR_ENHANCED"
+ "AVR_HAVE_MUL"
"%~call __mulsi3"
[(set_attr "type" "xcall")
(set_attr "cc" "clobber")])
@@ -2220,7 +2220,7 @@
UNSPEC_INDEX_JMP))
(use (label_ref (match_operand 1 "" "")))
(clobber (match_dup 0))]
- "AVR_MEGA && AVR_ENHANCED"
+ "AVR_MEGA && AVR_HAVE_LPMX"
"lsl r30
rol r31
lpm __tmp_reg__,Z+
Index: avr.c
===================================================================
--- avr.c (revision 120650)
+++ avr.c (working copy)
@@ -120,8 +120,8 @@
/* More than 8K of program memory: use "call" and "jmp". */
int avr_mega_p = 0;
-/* Enhanced core: use "movw", "mul", ... */
-int avr_enhanced_p = 0;
+/* Core have 'MUL*' instructions. */
+int avr_have_mul_p = 0;
/* Assembler only. */
int avr_asm_only_p = 0;
@@ -131,7 +131,7 @@
struct base_arch_s {
int asm_only;
- int enhanced;
+ int have_mul;
int mega;
int have_movw_lpmx;
const char *const macro;
@@ -324,7 +324,7 @@
base = &avr_arch_types[t->arch];
avr_asm_only_p = base->asm_only;
- avr_enhanced_p = base->enhanced;
+ avr_have_mul_p = base->have_mul;
avr_mega_p = base->mega;
avr_have_movw_lpmx_p = base->have_movw_lpmx;
avr_base_arch_macro = base->macro;
@@ -3170,7 +3170,7 @@
AS1 (lsl,%B0) CR_TAB
AS2 (andi,%B0,0xe0));
}
- if (AVR_ENHANCED && scratch)
+ if (AVR_HAVE_MUL && scratch)
{
*len = 5;
return (AS2 (ldi,%3,0x20) CR_TAB
@@ -3191,7 +3191,7 @@
AS2 (ldi,%3,0xe0) CR_TAB
AS2 (and,%B0,%3));
}
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MUL)
{
*len = 6;
return ("set" CR_TAB
@@ -3211,7 +3211,7 @@
AS1 (lsl,%B0));
case 14:
- if (AVR_ENHANCED && ldi_ok)
+ if (AVR_HAVE_MUL && ldi_ok)
{
*len = 5;
return (AS2 (ldi,%B0,0x40) CR_TAB
@@ -3220,7 +3220,7 @@
AS1 (clr,%A0) CR_TAB
AS1 (clr,__zero_reg__));
}
- if (AVR_ENHANCED && scratch)
+ if (AVR_HAVE_MUL && scratch)
{
*len = 5;
return (AS2 (ldi,%3,0x40) CR_TAB
@@ -3500,7 +3500,7 @@
AS1 (asr,%A0));
case 11:
- if (AVR_ENHANCED && ldi_ok)
+ if (AVR_HAVE_MUL && ldi_ok)
{
*len = 5;
return (AS2 (ldi,%A0,0x20) CR_TAB
@@ -3520,7 +3520,7 @@
AS1 (asr,%A0));
case 12:
- if (AVR_ENHANCED && ldi_ok)
+ if (AVR_HAVE_MUL && ldi_ok)
{
*len = 5;
return (AS2 (ldi,%A0,0x10) CR_TAB
@@ -3541,7 +3541,7 @@
AS1 (asr,%A0));
case 13:
- if (AVR_ENHANCED && ldi_ok)
+ if (AVR_HAVE_MUL && ldi_ok)
{
*len = 5;
return (AS2 (ldi,%A0,0x08) CR_TAB
@@ -3947,7 +3947,7 @@
AS1 (lsr,%A0) CR_TAB
AS2 (andi,%A0,0x07));
}
- if (AVR_ENHANCED && scratch)
+ if (AVR_HAVE_MUL && scratch)
{
*len = 5;
return (AS2 (ldi,%3,0x08) CR_TAB
@@ -3968,7 +3968,7 @@
AS2 (ldi,%3,0x07) CR_TAB
AS2 (and,%A0,%3));
}
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MUL)
{
*len = 6;
return ("set" CR_TAB
@@ -3988,7 +3988,7 @@
AS1 (lsr,%A0));
case 14:
- if (AVR_ENHANCED && ldi_ok)
+ if (AVR_HAVE_MUL && ldi_ok)
{
*len = 5;
return (AS2 (ldi,%A0,0x04) CR_TAB
@@ -3997,7 +3997,7 @@
AS1 (clr,%B0) CR_TAB
AS1 (clr,__zero_reg__));
}
- if (AVR_ENHANCED && scratch)
+ if (AVR_HAVE_MUL && scratch)
{
*len = 5;
return (AS2 (ldi,%3,0x04) CR_TAB
@@ -4983,7 +4983,7 @@
switch (mode)
{
case QImode:
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MUL)
*total = COSTS_N_INSNS (optimize_size ? 3 : 4);
else if (optimize_size)
*total = COSTS_N_INSNS (AVR_MEGA ? 2 : 1);
@@ -4991,7 +4991,7 @@
return false;
case HImode:
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MUL)
*total = COSTS_N_INSNS (optimize_size ? 7 : 10);
else if (optimize_size)
*total = COSTS_N_INSNS (AVR_MEGA ? 2 : 1);
Index: avr.h
===================================================================
--- avr.h (revision 120650)
+++ avr.h (working copy)
@@ -37,8 +37,10 @@
builtin_define ("__AVR_HAVE_LPMX__"); \
if (avr_asm_only_p) \
builtin_define ("__AVR_ASM_ONLY__"); \
- if (avr_enhanced_p) \
+ if (avr_have_mul_p) \
builtin_define ("__AVR_ENHANCED__"); \
+ if (avr_have_mul_p) \
+ builtin_define ("__AVR_HAVE_MUL__"); \
if (avr_mega_p) \
builtin_define ("__AVR_MEGA__"); \
if (TARGET_NO_INTERRUPTS) \
@@ -49,7 +51,7 @@
extern const char *avr_base_arch_macro;
extern const char *avr_extra_arch_macro;
extern int avr_mega_p;
-extern int avr_enhanced_p;
+extern int avr_have_mul_p;
extern int avr_asm_only_p;
extern int avr_have_movw_lpmx_p;
#ifndef IN_LIBGCC2
@@ -57,8 +59,9 @@
#endif
#define AVR_MEGA (avr_mega_p && !TARGET_SHORT_CALLS)
-#define AVR_ENHANCED (avr_enhanced_p)
+#define AVR_HAVE_MUL (avr_have_mul_p)
#define AVR_HAVE_MOVW (avr_have_movw_lpmx_p)
+#define AVR_HAVE_LPMX (avr_have_movw_lpmx_p)
#define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-01-16 23:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-16 23:42 [AVR] Add __AVR_HAVE_MUL__ macro Anatoly Sokolov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).