+2006-06-08 Anatoly Sokolov <aesok@post.ru>
+
+ * config/avr/avr.h (avr_have_movw_lpmx_p): Declare.
+ (TARGET_CPU_CPP_BUILTINS): Add __AVR_HAVE_MOVW__ and
+ __AVR_HAVE_LPMX__.
+ (AVR_HAVE_MOVW) Define.
+ (ASSEMBLER_DIALECT): Use AVR_HAVE_MOVW.
+ (ASM_SPEC): Add avr25.
+ (LINK_SPEC): Add avr25.
+ * config/avr/avr.c (avr_have_movw_lpmx_p): Add.
+ (base_arch_s): Add new member 'have_movw_lpmx'.
+ (avr_arch_types): Init 'have_movw_lpmx'.
+ (avr_mcu_types): Add 'avr25'. Move attiny13, attiny2313, attiny24,
+ attiny44, attiny84, attiny25, attiny45, attiny85, attiny261,
+ attiny461, attiny861 and at86rf401 in 'avr25' arhitecture.
+ (avr_override_options): Init 'avr_have_movw_lpmx_p'.
+ (output_movhi, output_movsisf, ashlsi3_out, avr_rtx_costs): Use
+ AVR_HAVE_MOVW.
+ (avr_file_start): Do not output '.arh' derective.
+ * config/avr/libgcc.S (mov_l): Use __AVR_HAVE_MOVW__.
+ (__do_copy_data): Use __AVR_HAVE_LPMX__.
+ * config/avr/avr.md (mcu_enhanced): Delete.
+ (mcu_have_movw): Define.
+ (negsi2, extendhisi2, zero_extendhisi2): Use 'mcu_have_movw'.
+ (call_insn, call_value_insn): Use 'call_insn' and __AVR_HAVE_MOVW__.
+ * config/avr/t-avr(MULTILIB_OPTIONS, MULTILIB_DIRNAMES): Add avr25.
+ (MULTILIB_MATCHES): Add attiny13, attiny2313, attiny24, attiny44,
+ attiny84, attiny25, attiny45, attiny85, attiny261, attiny461,
+ attiny861 and at86rf401 devices.
+
2006-06-18 Jie Zhang <jie.zhang@analog.com>
* config/bfin/bfin.c (MAX_LOOP_LENGTH): Define to be 2042 instead
/* Assembler only. */
int avr_asm_only_p = 0;
+/* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
+int avr_have_movw_lpmx_p = 0;
+
struct base_arch_s {
int asm_only;
int enhanced;
int mega;
+ int have_movw_lpmx;
const char *const macro;
};
static const struct base_arch_s avr_arch_types[] = {
- { 1, 0, 0, NULL }, /* unknown device specified */
- { 1, 0, 0, "__AVR_ARCH__=1" },
- { 0, 0, 0, "__AVR_ARCH__=2" },
- { 0, 0, 1, "__AVR_ARCH__=3" },
- { 0, 1, 0, "__AVR_ARCH__=4" },
- { 0, 1, 1, "__AVR_ARCH__=5" }
+ { 1, 0, 0, 0, NULL }, /* unknown device specified */
+ { 1, 0, 0, 0, "__AVR_ARCH__=1" },
+ { 0, 0, 0, 0, "__AVR_ARCH__=2" },
+ { 0, 0, 1, 0, "__AVR_ARCH__=3" },
+ { 0, 1, 0, 1, "__AVR_ARCH__=4" },
+ { 0, 1, 1, 1, "__AVR_ARCH__=5" },
+ { 0, 0, 0, 1, "__AVR_ARCH__=25"}
};
struct mcu_type_s {
{ "at90c8534", 2, "__AVR_AT90C8534__" },
{ "at90s8535", 2, "__AVR_AT90S8535__" },
/* Classic + MOVW, <= 8K. */
- { "attiny13", 2, "__AVR_ATtiny13__" },
- { "attiny2313", 2, "__AVR_ATtiny2313__" },
- { "attiny24", 2, "__AVR_ATtiny24__" },
- { "attiny44", 2, "__AVR_ATtiny44__" },
- { "attiny84", 2, "__AVR_ATtiny84__" },
- { "attiny25", 2, "__AVR_ATtiny25__" },
- { "attiny45", 2, "__AVR_ATtiny45__" },
- { "attiny85", 2, "__AVR_ATtiny85__" },
- { "attiny261", 2, "__AVR_ATtiny261__" },
- { "attiny461", 2, "__AVR_ATtiny461__" },
- { "attiny861", 2, "__AVR_ATtiny861__" },
- { "at86rf401", 2, "__AVR_AT86RF401__" },
+ { "avr25", 6, NULL },
+ { "attiny13", 6, "__AVR_ATtiny13__" },
+ { "attiny2313", 6, "__AVR_ATtiny2313__" },
+ { "attiny24", 6, "__AVR_ATtiny24__" },
+ { "attiny44", 6, "__AVR_ATtiny44__" },
+ { "attiny84", 6, "__AVR_ATtiny84__" },
+ { "attiny25", 6, "__AVR_ATtiny25__" },
+ { "attiny45", 6, "__AVR_ATtiny45__" },
+ { "attiny85", 6, "__AVR_ATtiny85__" },
+ { "attiny261", 6, "__AVR_ATtiny261__" },
+ { "attiny461", 6, "__AVR_ATtiny461__" },
+ { "attiny861", 6, "__AVR_ATtiny861__" },
+ { "at86rf401", 6, "__AVR_AT86RF401__" },
/* Classic, > 8K. */
{ "avr3", 3, NULL },
{ "atmega103", 3, "__AVR_ATmega103__" },
avr_asm_only_p = base->asm_only;
avr_enhanced_p = base->enhanced;
avr_mega_p = base->mega;
+ avr_have_movw_lpmx_p = base->have_movw_lpmx;
avr_base_arch_macro = base->macro;
avr_extra_arch_macro = t->macro;
AS2 (in,%B0,__SP_H__));
}
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
{
*l = 1;
return (AS2 (movw,%0,%1));
{
if (true_regnum (dest) > true_regnum (src))
{
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
{
*l = 2;
return (AS2 (movw,%C0,%C1) CR_TAB
}
else
{
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
{
*l = 2;
return (AS2 (movw,%A0,%A1) CR_TAB
if (GET_CODE (src) == CONST_INT)
{
const char *const clr_op0 =
- AVR_ENHANCED ? (AS1 (clr,%A0) CR_TAB
+ AVR_HAVE_MOVW ? (AS1 (clr,%A0) CR_TAB
AS1 (clr,%B0) CR_TAB
AS2 (movw,%C0,%A0))
: (AS1 (clr,%A0) CR_TAB
if (src == const0_rtx) /* mov r,L */
{
- *l = AVR_ENHANCED ? 3 : 4;
+ *l = AVR_HAVE_MOVW ? 3 : 4;
return clr_op0;
}
else if (src == const1_rtx)
{
if (!real_l)
output_asm_insn (clr_op0, operands);
- *l = AVR_ENHANCED ? 4 : 5;
+ *l = AVR_HAVE_MOVW ? 4 : 5;
return AS1 (inc,%A0);
}
else if (src == constm1_rtx)
{
/* Immediate constants -1 to any register */
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
{
*l = 4;
return (AS1 (clr,%A0) CR_TAB
if (bit_nr >= 0)
{
- *l = AVR_ENHANCED ? 5 : 6;
+ *l = AVR_HAVE_MOVW ? 5 : 6;
if (!real_l)
{
output_asm_insn (clr_op0, operands);
if (INTVAL (operands[2]) < 32)
break;
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
return *len = 3, (AS1 (clr,%D0) CR_TAB
AS1 (clr,%C0) CR_TAB
AS2 (movw,%A0,%C0));
int reg0 = true_regnum (operands[0]);
int reg1 = true_regnum (operands[1]);
*len = 4;
- if (AVR_ENHANCED && (reg0 + 2 != reg1))
+ if (AVR_HAVE_MOVW && (reg0 + 2 != reg1))
{
*len = 3;
return (AS2 (movw,%C0,%A1) CR_TAB
int reg0 = true_regnum (operands[0]);
int reg1 = true_regnum (operands[1]);
*len=6;
- if (AVR_ENHANCED && (reg0 != reg1 + 2))
+ if (AVR_HAVE_MOVW && (reg0 != reg1 + 2))
{
*len = 5;
return (AS2 (movw,%A0,%C1) CR_TAB
/* fall through */
case 31:
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
return *len = 4, (AS1 (lsl,%D0) CR_TAB
AS2 (sbc,%A0,%A0) CR_TAB
AS2 (mov,%B0,%A0) CR_TAB
if (INTVAL (operands[2]) < 32)
break;
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
return *len = 3, (AS1 (clr,%D0) CR_TAB
AS1 (clr,%C0) CR_TAB
AS2 (movw,%A0,%C0));
int reg0 = true_regnum (operands[0]);
int reg1 = true_regnum (operands[1]);
*len = 4;
- if (AVR_ENHANCED && (reg0 != reg1 + 2))
+ if (AVR_HAVE_MOVW && (reg0 != reg1 + 2))
{
*len = 3;
return (AS2 (movw,%A0,%C1) CR_TAB
default_file_start ();
- fprintf (asm_out_file, "\t.arch %s\n", avr_mcu_name);
+/* fprintf (asm_out_file, "\t.arch %s\n", avr_mcu_name);*/
fputs ("__SREG__ = 0x3f\n"
"__SP_H__ = 0x3e\n"
"__SP_L__ = 0x3d\n", asm_out_file);
*total = COSTS_N_INSNS (optimize_size ? 7 : 8);
break;
case 31:
- *total = COSTS_N_INSNS (AVR_ENHANCED ? 4 : 5);
+ *total = COSTS_N_INSNS (AVR_HAVE_MOVW ? 4 : 5);
break;
default:
*total = COSTS_N_INSNS (optimize_size ? 7 : 113);
builtin_define (avr_base_arch_macro); \
if (avr_extra_arch_macro) \
builtin_define (avr_extra_arch_macro); \
+ if (avr_have_movw_lpmx_p) \
+ builtin_define ("__AVR_HAVE_MOVW__"); \
+ if (avr_have_movw_lpmx_p) \
+ builtin_define ("__AVR_HAVE_LPMX__"); \
if (avr_asm_only_p) \
builtin_define ("__AVR_ASM_ONLY__"); \
if (avr_enhanced_p) \
extern int avr_mega_p;
extern int avr_enhanced_p;
extern int avr_asm_only_p;
+extern int avr_have_movw_lpmx_p;
#ifndef IN_LIBGCC2
extern GTY(()) section *progmem_section;
#endif
#define AVR_MEGA (avr_mega_p && !TARGET_SHORT_CALLS)
#define AVR_ENHANCED (avr_enhanced_p)
+#define AVR_HAVE_MOVW (avr_have_movw_lpmx_p)
#define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
#define USER_LABEL_PREFIX ""
-#define ASSEMBLER_DIALECT AVR_ENHANCED
+#define ASSEMBLER_DIALECT AVR_HAVE_MOVW
#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
{ \
/* A C string constant that tells the GCC drvier program options to
pass to `cc1plus'. */
-#define ASM_SPEC "%{mmcu=*:-mmcu=%*}"
+#define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;\
+mmcu=*:-mmcu=%*}"
#define LINK_SPEC " %{!mmcu*:-m avr2}\
%{mmcu=at90s1200|\
%{mmcu=at90s8535:crts8535.o%s} \
%{mmcu=at86rf401:crt86401.o%s} \
%{mmcu=attiny13:crttn13.o%s} \
-%{mmcu=attiny2313:crttn2313.o%s} \
+%{mmcu=attiny2313|mmcu=avr25:crttn2313.o%s} \
%{mmcu=attiny24:crttn24.o%s} \
%{mmcu=attiny44:crttn44.o%s} \
%{mmcu=attiny84:crttn84.o%s} \
(define_attr "type" "branch,branch1,arith,xcall"
(const_string "arith"))
-(define_attr "mcu_enhanced" "yes,no"
- (const (if_then_else (symbol_ref "AVR_ENHANCED")
+(define_attr "mcu_have_movw" "yes,no"
+ (const (if_then_else (symbol_ref "AVR_HAVE_MOVW")
(const_string "yes")
(const_string "no"))))
[(set_attr_alternative "length"
[(const_int 7)
(const_int 8)
- (if_then_else (eq_attr "mcu_enhanced" "yes")
+ (if_then_else (eq_attr "mcu_have_movw" "yes")
(const_int 7)
(const_int 8))])
(set_attr "cc" "set_czn,set_n,set_czn")])
{mov %A0,%A1\;mov %B0,%B1|movw %A0,%A1}\;clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0"
[(set_attr_alternative "length"
[(const_int 4)
- (if_then_else (eq_attr "mcu_enhanced" "yes")
+ (if_then_else (eq_attr "mcu_have_movw" "yes")
(const_int 5)
(const_int 6))])
(set_attr "cc" "set_n,set_n")])
{mov %A0,%A1\;mov %B0,%B1|movw %A0,%A1}\;clr %C0\;clr %D0"
[(set_attr_alternative "length"
[(const_int 2)
- (if_then_else (eq_attr "mcu_enhanced" "yes")
+ (if_then_else (eq_attr "mcu_have_movw" "yes")
(const_int 3)
(const_int 4))])
(set_attr "cc" "set_n,set_n")])
return \"icall\";
else if (which_alternative==1)
{
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
return (AS2 (movw, r30, %0) CR_TAB
\"icall\");
else
[(set_attr "cc" "clobber,clobber,clobber,clobber")
(set_attr_alternative "length"
[(const_int 1)
- (if_then_else (eq_attr "mcu_enhanced" "yes")
+ (if_then_else (eq_attr "mcu_have_movw" "yes")
(const_int 2)
(const_int 3))
(if_then_else (eq_attr "mcu_mega" "yes")
return \"icall\";
else if (which_alternative==1)
{
- if (AVR_ENHANCED)
+ if (AVR_HAVE_MOVW)
return (AS2 (movw, r30, %1) CR_TAB
\"icall\");
else
[(set_attr "cc" "clobber,clobber,clobber,clobber")
(set_attr_alternative "length"
[(const_int 1)
- (if_then_else (eq_attr "mcu_enhanced" "yes")
+ (if_then_else (eq_attr "mcu_have_movw" "yes")
(const_int 2)
(const_int 3))
(if_then_else (eq_attr "mcu_mega" "yes")