OSDN Git Service

2011-09-02 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / avr / avr.h
1 /* Definitions of target machine for GNU compiler,
2    for ATMEL AVR at90s8515, ATmega103/103L, ATmega603/603L microcontrollers.
3    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 
4    2008, 2009, 2010, 2011
5    Free Software Foundation, Inc.
6    Contributed by Denis Chertykov (chertykov@gmail.com)
7
8 This file is part of GCC.
9
10 GCC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
13 any later version.
14
15 GCC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING3.  If not see
22 <http://www.gnu.org/licenses/>.  */
23
24 /* Names to predefine in the preprocessor for this target machine.  */
25
26 struct base_arch_s {
27   /* Assembler only.  */
28   int asm_only;
29
30   /* Core have 'MUL*' instructions.  */
31   int have_mul;
32
33   /* Core have 'CALL' and 'JMP' instructions.  */
34   int have_jmp_call;
35
36   /* Core have 'MOVW' and 'LPM Rx,Z' instructions.  */
37   int have_movw_lpmx;
38
39   /* Core have 'ELPM' instructions.  */
40   int have_elpm;
41
42   /* Core have 'ELPM Rx,Z' instructions.  */
43   int have_elpmx;
44
45   /* Core have 'EICALL' and 'EIJMP' instructions.  */
46   int have_eijmp_eicall;
47
48   /* Reserved for xmega architecture.  */
49   int reserved;
50
51   /* Reserved for xmega architecture.  */
52   int reserved2;
53   
54   /* Default start of data section address for architecture.  */
55   int default_data_section_start;
56
57   const char *const macro;
58   
59   /* Architecture name.  */
60   const char *const arch_name;  
61 };
62
63 /* These names are used as the index into the avr_arch_types[] table 
64    above.  */
65
66 enum avr_arch
67 {
68   ARCH_UNKNOWN,
69   ARCH_AVR1,
70   ARCH_AVR2,
71   ARCH_AVR25,
72   ARCH_AVR3,
73   ARCH_AVR31,
74   ARCH_AVR35,
75   ARCH_AVR4,
76   ARCH_AVR5,
77   ARCH_AVR51,
78   ARCH_AVR6
79 };
80
81 struct mcu_type_s {
82   /* Device name.  */
83   const char *const name;
84   
85   /* Index in avr_arch_types[].  */
86   int arch; 
87   
88   /* Must lie outside user's namespace.  NULL == no macro.  */
89   const char *const macro;
90   
91   /* Stack pointer have 8 bits width.  */
92   int short_sp;
93   
94   /* Some AVR devices have a core erratum when skipping a 2-word instruction.
95      Skip instructions are:  SBRC, SBRS, SBIC, SBIS, CPSE.
96      Problems will occur with return address is IRQ executes during the
97      skip sequence.
98
99      A support ticket from Atmel returned the following information:
100
101          Subject: (ATTicket:644469) On AVR skip-bug core Erratum
102          From: avr@atmel.com                    Date: 2011-07-27
103          (Please keep the subject when replying to this mail)
104
105          This errata exists only in AT90S8515 and ATmega103 devices.
106
107          For information please refer the following respective errata links
108             http://www.atmel.com/dyn/resources/prod_documents/doc2494.pdf
109             http://www.atmel.com/dyn/resources/prod_documents/doc1436.pdf  */
110
111   /* Core Erratum:  Must not skip 2-word instruction.  */
112   int errata_skip;
113   
114   /* Start of data section.  */
115   int data_section_start;
116   
117   /* Name of device library.  */
118   const char *const library_name; 
119 };
120
121 /* Preprocessor macros to define depending on MCU type.  */
122 extern const char *avr_extra_arch_macro;
123 extern const struct base_arch_s *avr_current_arch;
124 extern const struct mcu_type_s *avr_current_device;
125 extern const struct mcu_type_s avr_mcu_types[];
126 extern const struct base_arch_s avr_arch_types[];
127
128 #define TARGET_CPU_CPP_BUILTINS()       avr_cpu_cpp_builtins (pfile)
129
130 #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)
131 extern GTY(()) section *progmem_section;
132 #endif
133
134 #define AVR_HAVE_JMP_CALL (avr_current_arch->have_jmp_call && !TARGET_SHORT_CALLS)
135 #define AVR_HAVE_MUL (avr_current_arch->have_mul)
136 #define AVR_HAVE_MOVW (avr_current_arch->have_movw_lpmx)
137 #define AVR_HAVE_LPMX (avr_current_arch->have_movw_lpmx)
138 #define AVR_HAVE_RAMPZ (avr_current_arch->have_elpm)
139 #define AVR_HAVE_EIJMP_EICALL (avr_current_arch->have_eijmp_eicall)
140 #define AVR_HAVE_8BIT_SP (avr_current_device->short_sp || TARGET_TINY_STACK)
141
142 #define AVR_2_BYTE_PC (!AVR_HAVE_EIJMP_EICALL)
143 #define AVR_3_BYTE_PC (AVR_HAVE_EIJMP_EICALL)
144
145 #define BITS_BIG_ENDIAN 0
146 #define BYTES_BIG_ENDIAN 0
147 #define WORDS_BIG_ENDIAN 0
148
149 #ifdef IN_LIBGCC2
150 /* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits).  */
151 #define UNITS_PER_WORD 4
152 #else
153 /* Width of a word, in units (bytes).  */
154 #define UNITS_PER_WORD 1
155 #endif
156
157 #define POINTER_SIZE 16
158
159
160 /* Maximum sized of reasonable data type
161    DImode or Dfmode ...  */
162 #define MAX_FIXED_MODE_SIZE 32
163
164 #define PARM_BOUNDARY 8
165
166 #define FUNCTION_BOUNDARY 8
167
168 #define EMPTY_FIELD_BOUNDARY 8
169
170 /* No data type wants to be aligned rounder than this.  */
171 #define BIGGEST_ALIGNMENT 8
172
173 #define TARGET_VTABLE_ENTRY_ALIGN 8
174
175 #define STRICT_ALIGNMENT 0
176
177 #define INT_TYPE_SIZE (TARGET_INT8 ? 8 : 16)
178 #define SHORT_TYPE_SIZE (INT_TYPE_SIZE == 8 ? INT_TYPE_SIZE : 16)
179 #define LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 16 : 32)
180 #define LONG_LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 32 : 64)
181 #define FLOAT_TYPE_SIZE 32
182 #define DOUBLE_TYPE_SIZE 32
183 #define LONG_DOUBLE_TYPE_SIZE 32
184
185 #define DEFAULT_SIGNED_CHAR 1
186
187 #define SIZE_TYPE (INT_TYPE_SIZE == 8 ? "long unsigned int" : "unsigned int")
188 #define PTRDIFF_TYPE (INT_TYPE_SIZE == 8 ? "long int" :"int")
189
190 #define WCHAR_TYPE_SIZE 16
191
192 #define FIRST_PSEUDO_REGISTER 36
193
194 #define FIXED_REGISTERS {\
195   1,1,/* r0 r1 */\
196   0,0,/* r2 r3 */\
197   0,0,/* r4 r5 */\
198   0,0,/* r6 r7 */\
199   0,0,/* r8 r9 */\
200   0,0,/* r10 r11 */\
201   0,0,/* r12 r13 */\
202   0,0,/* r14 r15 */\
203   0,0,/* r16 r17 */\
204   0,0,/* r18 r19 */\
205   0,0,/* r20 r21 */\
206   0,0,/* r22 r23 */\
207   0,0,/* r24 r25 */\
208   0,0,/* r26 r27 */\
209   0,0,/* r28 r29 */\
210   0,0,/* r30 r31 */\
211   1,1,/*  STACK */\
212   1,1 /* arg pointer */  }
213
214 #define CALL_USED_REGISTERS {                   \
215   1,1,/* r0 r1 */                               \
216     0,0,/* r2 r3 */                             \
217     0,0,/* r4 r5 */                             \
218     0,0,/* r6 r7 */                             \
219     0,0,/* r8 r9 */                             \
220     0,0,/* r10 r11 */                           \
221     0,0,/* r12 r13 */                           \
222     0,0,/* r14 r15 */                           \
223     0,0,/* r16 r17 */                           \
224     1,1,/* r18 r19 */                           \
225     1,1,/* r20 r21 */                           \
226     1,1,/* r22 r23 */                           \
227     1,1,/* r24 r25 */                           \
228     1,1,/* r26 r27 */                           \
229     0,0,/* r28 r29 */                           \
230     1,1,/* r30 r31 */                           \
231     1,1,/*  STACK */                            \
232     1,1 /* arg pointer */  }
233
234 #define REG_ALLOC_ORDER {                       \
235     24,25,                                      \
236     18,19,                                      \
237     20,21,                                      \
238     22,23,                                      \
239     30,31,                                      \
240     26,27,                                      \
241     28,29,                                      \
242     17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,    \
243     0,1,                                        \
244     32,33,34,35                                 \
245     }
246
247 #define ADJUST_REG_ALLOC_ORDER order_regs_for_local_alloc ()
248
249
250 #define HARD_REGNO_NREGS(REGNO, MODE) ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
251
252 #define HARD_REGNO_MODE_OK(REGNO, MODE) avr_hard_regno_mode_ok(REGNO, MODE)
253
254 #define MODES_TIEABLE_P(MODE1, MODE2) 1
255
256 enum reg_class {
257   NO_REGS,
258   R0_REG,                       /* r0 */
259   POINTER_X_REGS,               /* r26 - r27 */
260   POINTER_Y_REGS,               /* r28 - r29 */
261   POINTER_Z_REGS,               /* r30 - r31 */
262   STACK_REG,                    /* STACK */
263   BASE_POINTER_REGS,            /* r28 - r31 */
264   POINTER_REGS,                 /* r26 - r31 */
265   ADDW_REGS,                    /* r24 - r31 */
266   SIMPLE_LD_REGS,               /* r16 - r23 */
267   LD_REGS,                      /* r16 - r31 */
268   NO_LD_REGS,                   /* r0 - r15 */
269   GENERAL_REGS,                 /* r0 - r31 */
270   ALL_REGS, LIM_REG_CLASSES
271 };
272
273
274 #define N_REG_CLASSES (int)LIM_REG_CLASSES
275
276 #define REG_CLASS_NAMES {                                       \
277                  "NO_REGS",                                     \
278                    "R0_REG",    /* r0 */                        \
279                    "POINTER_X_REGS", /* r26 - r27 */            \
280                    "POINTER_Y_REGS", /* r28 - r29 */            \
281                    "POINTER_Z_REGS", /* r30 - r31 */            \
282                    "STACK_REG", /* STACK */                     \
283                    "BASE_POINTER_REGS", /* r28 - r31 */         \
284                    "POINTER_REGS", /* r26 - r31 */              \
285                    "ADDW_REGS", /* r24 - r31 */                 \
286                    "SIMPLE_LD_REGS", /* r16 - r23 */            \
287                    "LD_REGS",   /* r16 - r31 */                 \
288                    "NO_LD_REGS", /* r0 - r15 */                 \
289                    "GENERAL_REGS", /* r0 - r31 */               \
290                    "ALL_REGS" }
291
292 #define REG_CLASS_CONTENTS {                                            \
293   {0x00000000,0x00000000},      /* NO_REGS */                           \
294   {0x00000001,0x00000000},      /* R0_REG */                            \
295   {3 << REG_X,0x00000000},      /* POINTER_X_REGS, r26 - r27 */         \
296   {3 << REG_Y,0x00000000},      /* POINTER_Y_REGS, r28 - r29 */         \
297   {3 << REG_Z,0x00000000},      /* POINTER_Z_REGS, r30 - r31 */         \
298   {0x00000000,0x00000003},      /* STACK_REG, STACK */                  \
299   {(3 << REG_Y) | (3 << REG_Z),                                         \
300      0x00000000},               /* BASE_POINTER_REGS, r28 - r31 */      \
301   {(3 << REG_X) | (3 << REG_Y) | (3 << REG_Z),                          \
302      0x00000000},               /* POINTER_REGS, r26 - r31 */           \
303   {(3 << REG_X) | (3 << REG_Y) | (3 << REG_Z) | (3 << REG_W),           \
304      0x00000000},               /* ADDW_REGS, r24 - r31 */              \
305   {0x00ff0000,0x00000000},      /* SIMPLE_LD_REGS r16 - r23 */          \
306   {(3 << REG_X)|(3 << REG_Y)|(3 << REG_Z)|(3 << REG_W)|(0xff << 16),    \
307      0x00000000},       /* LD_REGS, r16 - r31 */                        \
308   {0x0000ffff,0x00000000},      /* NO_LD_REGS  r0 - r15 */              \
309   {0xffffffff,0x00000000},      /* GENERAL_REGS, r0 - r31 */            \
310   {0xffffffff,0x00000003}       /* ALL_REGS */                          \
311 }
312
313 #define REGNO_REG_CLASS(R) avr_regno_reg_class(R)
314
315 #define BASE_REG_CLASS (reload_completed ? BASE_POINTER_REGS : POINTER_REGS)
316
317 #define INDEX_REG_CLASS NO_REGS
318
319 #define REGNO_OK_FOR_BASE_P(r) (((r) < FIRST_PSEUDO_REGISTER            \
320                                  && ((r) == REG_X                       \
321                                      || (r) == REG_Y                    \
322                                      || (r) == REG_Z                    \
323                                      || (r) == ARG_POINTER_REGNUM))     \
324                                 || (reg_renumber                        \
325                                     && (reg_renumber[r] == REG_X        \
326                                         || reg_renumber[r] == REG_Y     \
327                                         || reg_renumber[r] == REG_Z     \
328                                         || (reg_renumber[r]             \
329                                             == ARG_POINTER_REGNUM))))
330
331 #define REGNO_OK_FOR_INDEX_P(NUM) 0
332
333 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
334
335 #define STACK_PUSH_CODE POST_DEC
336
337 #define STACK_GROWS_DOWNWARD
338
339 #define STARTING_FRAME_OFFSET 1
340
341 #define STACK_POINTER_OFFSET 1
342
343 #define FIRST_PARM_OFFSET(FUNDECL) 0
344
345 #define STACK_BOUNDARY 8
346
347 #define STACK_POINTER_REGNUM 32
348
349 #define FRAME_POINTER_REGNUM REG_Y
350
351 #define ARG_POINTER_REGNUM 34
352
353 #define STATIC_CHAIN_REGNUM 2
354
355 #define ELIMINABLE_REGS {                                       \
356       {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},               \
357         {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}            \
358        ,{FRAME_POINTER_REGNUM+1,STACK_POINTER_REGNUM+1}}
359
360 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
361   OFFSET = avr_initial_elimination_offset (FROM, TO)
362
363 #define RETURN_ADDR_RTX(count, tem) avr_return_addr_rtx (count, tem)
364
365 /* Don't use Push rounding. expr.c: emit_single_push_insn is broken 
366    for POST_DEC targets (PR27386).  */
367 /*#define PUSH_ROUNDING(NPUSHED) (NPUSHED)*/
368
369 typedef struct avr_args {
370   int nregs;                    /* # registers available for passing */
371   int regno;                    /* next available register number */
372 } CUMULATIVE_ARGS;
373
374 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
375   init_cumulative_args (&(CUM), FNTYPE, LIBNAME, FNDECL)
376
377 #define FUNCTION_ARG_REGNO_P(r) function_arg_regno_p(r)
378
379 #define DEFAULT_PCC_STRUCT_RETURN 0
380
381 #define EPILOGUE_USES(REGNO) avr_epilogue_uses(REGNO)
382
383 #define HAVE_POST_INCREMENT 1
384 #define HAVE_PRE_DECREMENT 1
385
386 #define MAX_REGS_PER_ADDRESS 1
387
388 #define REG_OK_FOR_BASE_NOSTRICT_P(X) \
389   (REGNO (X) >= FIRST_PSEUDO_REGISTER || REG_OK_FOR_BASE_STRICT_P(X))
390
391 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
392
393 /* LEGITIMIZE_RELOAD_ADDRESS will allow register R26/27 to be used, where it
394    is no worse than normal base pointers R28/29 and R30/31. For example:
395    If base offset is greater than 63 bytes or for R++ or --R addressing.  */
396    
397 #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)    \
398 do {                                                                        \
399   if (1&&(GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC))     \
400     {                                                                       \
401       push_reload (XEXP (X,0), XEXP (X,0), &XEXP (X,0), &XEXP (X,0),        \
402                    POINTER_REGS, GET_MODE (X),GET_MODE (X) , 0, 0,          \
403                    OPNUM, RELOAD_OTHER);                                    \
404       goto WIN;                                                             \
405     }                                                                       \
406   if (GET_CODE (X) == PLUS                                                  \
407       && REG_P (XEXP (X, 0))                                                \
408       && (reg_equiv_constant (REGNO (XEXP (X, 0))) == 0)                    \
409       && GET_CODE (XEXP (X, 1)) == CONST_INT                                \
410       && INTVAL (XEXP (X, 1)) >= 1)                                         \
411     {                                                                       \
412       int fit = INTVAL (XEXP (X, 1)) <= (64 - GET_MODE_SIZE (MODE));        \
413       if (fit)                                                              \
414         {                                                                   \
415           if (reg_equiv_address (REGNO (XEXP (X, 0))) != 0)                 \
416             {                                                               \
417               int regno = REGNO (XEXP (X, 0));                              \
418               rtx mem = make_memloc (X, regno);                             \
419               push_reload (XEXP (mem,0), NULL, &XEXP (mem,0), NULL,         \
420                            POINTER_REGS, Pmode, VOIDmode, 0, 0,             \
421                            1, ADDR_TYPE (TYPE));                            \
422               push_reload (mem, NULL_RTX, &XEXP (X, 0), NULL,               \
423                            BASE_POINTER_REGS, GET_MODE (X), VOIDmode, 0, 0, \
424                            OPNUM, TYPE);                                    \
425               goto WIN;                                                     \
426             }                                                               \
427         }                                                                   \
428       else if (! (frame_pointer_needed && XEXP (X,0) == frame_pointer_rtx)) \
429         {                                                                   \
430           push_reload (X, NULL_RTX, &X, NULL,                               \
431                        POINTER_REGS, GET_MODE (X), VOIDmode, 0, 0,          \
432                        OPNUM, TYPE);                                        \
433           goto WIN;                                                         \
434         }                                                                   \
435     }                                                                       \
436 } while(0)
437
438 #define BRANCH_COST(speed_p, predictable_p) 0
439
440 #define SLOW_BYTE_ACCESS 0
441
442 #define NO_FUNCTION_CSE
443
444 #define TEXT_SECTION_ASM_OP "\t.text"
445
446 #define DATA_SECTION_ASM_OP "\t.data"
447
448 #define BSS_SECTION_ASM_OP "\t.section .bss"
449
450 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
451    There are no shared libraries on this target, and these sections are
452    placed in the read-only program memory, so they are not writable.  */
453
454 #undef CTORS_SECTION_ASM_OP
455 #define CTORS_SECTION_ASM_OP "\t.section .ctors,\"a\",@progbits"
456
457 #undef DTORS_SECTION_ASM_OP
458 #define DTORS_SECTION_ASM_OP "\t.section .dtors,\"a\",@progbits"
459
460 #define TARGET_ASM_CONSTRUCTOR avr_asm_out_ctor
461
462 #define TARGET_ASM_DESTRUCTOR avr_asm_out_dtor
463
464 #define SUPPORTS_INIT_PRIORITY 0
465
466 #define JUMP_TABLES_IN_TEXT_SECTION 0
467
468 #define ASM_COMMENT_START " ; "
469
470 #define ASM_APP_ON "/* #APP */\n"
471
472 #define ASM_APP_OFF "/* #NOAPP */\n"
473
474 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '\n' || ((C) == '$'))
475
476 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGN) \
477   avr_asm_output_aligned_decl_common (STREAM, DECL, NAME, SIZE, ALIGN, false)
478
479 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
480   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
481
482 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGN)  \
483   avr_asm_output_aligned_decl_common (STREAM, DECL, NAME, SIZE, ALIGN, true)
484
485 /* Globalizing directive for a label.  */
486 #define GLOBAL_ASM_OP ".global\t"
487
488 #define SUPPORTS_WEAK 1
489
490 #define HAS_INIT_SECTION 1
491
492 #define REGISTER_NAMES {                                \
493   "r0","r1","r2","r3","r4","r5","r6","r7",              \
494     "r8","r9","r10","r11","r12","r13","r14","r15",      \
495     "r16","r17","r18","r19","r20","r21","r22","r23",    \
496     "r24","r25","r26","r27","r28","r29","r30","r31",    \
497     "__SP_L__","__SP_H__","argL","argH"}
498
499 #define FINAL_PRESCAN_INSN(insn, operand, nop) final_prescan_insn (insn, operand,nop)
500
501 #define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
502
503 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '~' || (CODE) == '!')
504
505 #define PRINT_OPERAND_ADDRESS(STREAM, X) print_operand_address(STREAM, X)
506
507 #define ASSEMBLER_DIALECT AVR_HAVE_MOVW
508
509 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO)      \
510 {                                               \
511   gcc_assert (REGNO < 32);                      \
512   fprintf (STREAM, "\tpush\tr%d", REGNO);       \
513 }
514
515 #define ASM_OUTPUT_REG_POP(STREAM, REGNO)       \
516 {                                               \
517   gcc_assert (REGNO < 32);                      \
518   fprintf (STREAM, "\tpop\tr%d", REGNO);        \
519 }
520
521 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)          \
522   avr_output_addr_vec_elt(STREAM, VALUE)
523
524 #define ASM_OUTPUT_ALIGN(STREAM, POWER)                 \
525   do {                                                  \
526       if ((POWER) > 1)                                  \
527           fprintf (STREAM, "\t.p2align\t%d\n", POWER);  \
528   } while (0)
529
530 #define CASE_VECTOR_MODE HImode
531
532 #undef WORD_REGISTER_OPERATIONS
533
534 #define MOVE_MAX 4
535
536 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
537
538 #define Pmode HImode
539
540 #define FUNCTION_MODE HImode
541
542 #define DOLLARS_IN_IDENTIFIERS 0
543
544 #define TRAMPOLINE_SIZE 4
545
546 /* Store in cc_status the expressions
547    that the condition codes will describe
548    after execution of an instruction whose pattern is EXP.
549    Do not alter them if the instruction would not alter the cc's.  */
550
551 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
552
553 /* The add insns don't set overflow in a usable way.  */
554 #define CC_OVERFLOW_UNUSABLE 01000
555 /* The mov,and,or,xor insns don't set carry.  That's ok though as the
556    Z bit is all we need when doing unsigned comparisons on the result of
557    these insns (since they're always with 0).  However, conditions.h has
558    CC_NO_OVERFLOW defined for this purpose.  Rename it to something more
559    understandable.  */
560 #define CC_NO_CARRY CC_NO_OVERFLOW
561
562
563 /* Output assembler code to FILE to increment profiler label # LABELNO
564    for profiling a function entry.  */
565
566 #define FUNCTION_PROFILER(FILE, LABELNO)  \
567   fprintf (FILE, "/* profiler %d */", (LABELNO))
568
569 #define ADJUST_INSN_LENGTH(INSN, LENGTH) (LENGTH =\
570                                           adjust_insn_length (INSN, LENGTH))
571
572 extern const char *avr_device_to_arch (int argc, const char **argv);
573 extern const char *avr_device_to_data_start (int argc, const char **argv);
574 extern const char *avr_device_to_startfiles (int argc, const char **argv);
575 extern const char *avr_device_to_devicelib (int argc, const char **argv);
576
577 #define EXTRA_SPEC_FUNCTIONS \
578   { "device_to_arch", avr_device_to_arch }, \
579   { "device_to_data_start", avr_device_to_data_start }, \
580   { "device_to_startfile", avr_device_to_startfiles }, \
581   { "device_to_devicelib", avr_device_to_devicelib },
582
583 #define CPP_SPEC ""
584
585 #define CC1_SPEC ""
586
587 #define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
588     %{!fenforce-eh-specs:-fno-enforce-eh-specs} \
589     %{!fexceptions:-fno-exceptions}"
590 /* A C string constant that tells the GCC driver program options to
591    pass to `cc1plus'.  */
592
593 #define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;mmcu=avr31:-mmcu=avr3;mmcu=avr51:-mmcu=avr5;\
594 mmcu=*:-mmcu=%*}"
595
596 #define LINK_SPEC "\
597 %{mrelax:--relax\
598          %{mpmem-wrap-around:%{mmcu=at90usb8*:--pmem-wrap-around=8k}\
599                              %{mmcu=atmega16*:--pmem-wrap-around=16k}\
600                              %{mmcu=atmega32*|\
601                                mmcu=at90can32*:--pmem-wrap-around=32k}\
602                              %{mmcu=atmega64*|\
603                                mmcu=at90can64*|\
604                                mmcu=at90usb64*:--pmem-wrap-around=64k}}}\
605 %:device_to_arch(%{mmcu=*:%*})\
606 %:device_to_data_start(%{mmcu=*:%*})"
607
608 #define LIB_SPEC \
609   "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
610
611 #define LIBSTDCXX "gcc"
612 /* No libstdc++ for now.  Empty string doesn't work.  */
613
614 #define LIBGCC_SPEC \
615   "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lgcc }}}}}"
616
617 #define STARTFILE_SPEC "%:device_to_startfile(%{mmcu=*:%*})"
618
619 #define ENDFILE_SPEC ""
620
621 /* This is the default without any -mmcu=* option (AT90S*).  */
622 #define MULTILIB_DEFAULTS { "mmcu=avr2" }
623
624 #define TEST_HARD_REG_CLASS(CLASS, REGNO) \
625   TEST_HARD_REG_BIT (reg_class_contents[ (int) (CLASS)], REGNO)
626
627 /* Note that the other files fail to use these
628    in some of the places where they should.  */
629
630 #if defined(__STDC__) || defined(ALMOST_STDC)
631 #define AS2(a,b,c) #a " " #b "," #c
632 #define AS2C(b,c) " " #b "," #c
633 #define AS3(a,b,c,d) #a " " #b "," #c "," #d
634 #define AS1(a,b) #a " " #b
635 #else
636 #define AS1(a,b) "a     b"
637 #define AS2(a,b,c) "a   b,c"
638 #define AS2C(b,c) " b,c"
639 #define AS3(a,b,c,d) "a b,c,d"
640 #endif
641 #define OUT_AS1(a,b) output_asm_insn (AS1(a,b), operands)
642 #define OUT_AS2(a,b,c) output_asm_insn (AS2(a,b,c), operands)
643 #define CR_TAB "\n\t"
644
645 #define DWARF2_ADDR_SIZE 4
646
647 #define INCOMING_RETURN_ADDR_RTX   avr_incoming_return_addr_rtx ()
648 #define INCOMING_FRAME_SP_OFFSET   (AVR_3_BYTE_PC ? 3 : 2)
649
650 /* The caller's stack pointer value immediately before the call
651    is one byte below the first argument.  */
652 #define ARG_POINTER_CFA_OFFSET(FNDECL)  -1
653
654 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
655   avr_hard_regno_rename_ok (OLD_REG, NEW_REG)
656
657 /* A C structure for machine-specific, per-function data.
658    This is added to the cfun structure.  */
659 struct GTY(()) machine_function
660 {
661   /* 'true' - if current function is a naked function.  */
662   int is_naked;
663
664   /* 'true' - if current function is an interrupt function 
665      as specified by the "interrupt" attribute.  */
666   int is_interrupt;
667
668   /* 'true' - if current function is a signal function 
669      as specified by the "signal" attribute.  */
670   int is_signal;
671   
672   /* 'true' - if current function is a 'task' function 
673      as specified by the "OS_task" attribute.  */
674   int is_OS_task;
675
676   /* 'true' - if current function is a 'main' function 
677      as specified by the "OS_main" attribute.  */
678   int is_OS_main;
679   
680   /* Current function stack size.  */
681   int stack_usage;
682
683   /* 'true' if a callee might be tail called */
684   int sibcall_fails;
685 };
686
687 /* AVR does not round pushes, but the existance of this macro is
688    required in order for pushes to be generated.  */
689 #define PUSH_ROUNDING(X)        (X)