OSDN Git Service

gcc/
[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   /* Start of data section.  */
95   int data_section_start;
96   
97   /* Name of device library.  */
98   const char *const library_name; 
99 };
100
101 /* Preprocessor macros to define depending on MCU type.  */
102 extern const char *avr_extra_arch_macro;
103 extern const struct base_arch_s *avr_current_arch;
104 extern const struct mcu_type_s *avr_current_device;
105 extern const struct mcu_type_s avr_mcu_types[];
106 extern const struct base_arch_s avr_arch_types[];
107
108 #define TARGET_CPU_CPP_BUILTINS()       avr_cpu_cpp_builtins (pfile)
109
110 #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)
111 extern GTY(()) section *progmem_section;
112 #endif
113
114 #define AVR_HAVE_JMP_CALL (avr_current_arch->have_jmp_call && !TARGET_SHORT_CALLS)
115 #define AVR_HAVE_MUL (avr_current_arch->have_mul)
116 #define AVR_HAVE_MOVW (avr_current_arch->have_movw_lpmx)
117 #define AVR_HAVE_LPMX (avr_current_arch->have_movw_lpmx)
118 #define AVR_HAVE_RAMPZ (avr_current_arch->have_elpm)
119 #define AVR_HAVE_EIJMP_EICALL (avr_current_arch->have_eijmp_eicall)
120 #define AVR_HAVE_8BIT_SP (avr_current_device->short_sp || TARGET_TINY_STACK)
121
122 #define AVR_2_BYTE_PC (!AVR_HAVE_EIJMP_EICALL)
123 #define AVR_3_BYTE_PC (AVR_HAVE_EIJMP_EICALL)
124
125 #define BITS_BIG_ENDIAN 0
126 #define BYTES_BIG_ENDIAN 0
127 #define WORDS_BIG_ENDIAN 0
128
129 #ifdef IN_LIBGCC2
130 /* This is to get correct SI and DI modes in libgcc2.c (32 and 64 bits).  */
131 #define UNITS_PER_WORD 4
132 #else
133 /* Width of a word, in units (bytes).  */
134 #define UNITS_PER_WORD 1
135 #endif
136
137 #define POINTER_SIZE 16
138
139
140 /* Maximum sized of reasonable data type
141    DImode or Dfmode ...  */
142 #define MAX_FIXED_MODE_SIZE 32
143
144 #define PARM_BOUNDARY 8
145
146 #define FUNCTION_BOUNDARY 8
147
148 #define EMPTY_FIELD_BOUNDARY 8
149
150 /* No data type wants to be aligned rounder than this.  */
151 #define BIGGEST_ALIGNMENT 8
152
153 #define MAX_OFILE_ALIGNMENT (32768 * 8)
154
155 #define TARGET_VTABLE_ENTRY_ALIGN 8
156
157 #define STRICT_ALIGNMENT 0
158
159 #define INT_TYPE_SIZE (TARGET_INT8 ? 8 : 16)
160 #define SHORT_TYPE_SIZE (INT_TYPE_SIZE == 8 ? INT_TYPE_SIZE : 16)
161 #define LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 16 : 32)
162 #define LONG_LONG_TYPE_SIZE (INT_TYPE_SIZE == 8 ? 32 : 64)
163 #define FLOAT_TYPE_SIZE 32
164 #define DOUBLE_TYPE_SIZE 32
165 #define LONG_DOUBLE_TYPE_SIZE 32
166
167 #define DEFAULT_SIGNED_CHAR 1
168
169 #define SIZE_TYPE (INT_TYPE_SIZE == 8 ? "long unsigned int" : "unsigned int")
170 #define PTRDIFF_TYPE (INT_TYPE_SIZE == 8 ? "long int" :"int")
171
172 #define WCHAR_TYPE_SIZE 16
173
174 #define FIRST_PSEUDO_REGISTER 36
175
176 #define FIXED_REGISTERS {\
177   1,1,/* r0 r1 */\
178   0,0,/* r2 r3 */\
179   0,0,/* r4 r5 */\
180   0,0,/* r6 r7 */\
181   0,0,/* r8 r9 */\
182   0,0,/* r10 r11 */\
183   0,0,/* r12 r13 */\
184   0,0,/* r14 r15 */\
185   0,0,/* r16 r17 */\
186   0,0,/* r18 r19 */\
187   0,0,/* r20 r21 */\
188   0,0,/* r22 r23 */\
189   0,0,/* r24 r25 */\
190   0,0,/* r26 r27 */\
191   0,0,/* r28 r29 */\
192   0,0,/* r30 r31 */\
193   1,1,/*  STACK */\
194   1,1 /* arg pointer */  }
195
196 #define CALL_USED_REGISTERS {                   \
197   1,1,/* r0 r1 */                               \
198     0,0,/* r2 r3 */                             \
199     0,0,/* r4 r5 */                             \
200     0,0,/* r6 r7 */                             \
201     0,0,/* r8 r9 */                             \
202     0,0,/* r10 r11 */                           \
203     0,0,/* r12 r13 */                           \
204     0,0,/* r14 r15 */                           \
205     0,0,/* r16 r17 */                           \
206     1,1,/* r18 r19 */                           \
207     1,1,/* r20 r21 */                           \
208     1,1,/* r22 r23 */                           \
209     1,1,/* r24 r25 */                           \
210     1,1,/* r26 r27 */                           \
211     0,0,/* r28 r29 */                           \
212     1,1,/* r30 r31 */                           \
213     1,1,/*  STACK */                            \
214     1,1 /* arg pointer */  }
215
216 #define REG_ALLOC_ORDER {                       \
217     24,25,                                      \
218     18,19,                                      \
219     20,21,                                      \
220     22,23,                                      \
221     30,31,                                      \
222     26,27,                                      \
223     28,29,                                      \
224     17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,    \
225     0,1,                                        \
226     32,33,34,35                                 \
227     }
228
229 #define ADJUST_REG_ALLOC_ORDER order_regs_for_local_alloc ()
230
231
232 #define HARD_REGNO_NREGS(REGNO, MODE) ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
233
234 #define HARD_REGNO_MODE_OK(REGNO, MODE) avr_hard_regno_mode_ok(REGNO, MODE)
235
236 #define MODES_TIEABLE_P(MODE1, MODE2) 1
237
238 enum reg_class {
239   NO_REGS,
240   R0_REG,                       /* r0 */
241   POINTER_X_REGS,               /* r26 - r27 */
242   POINTER_Y_REGS,               /* r28 - r29 */
243   POINTER_Z_REGS,               /* r30 - r31 */
244   STACK_REG,                    /* STACK */
245   BASE_POINTER_REGS,            /* r28 - r31 */
246   POINTER_REGS,                 /* r26 - r31 */
247   ADDW_REGS,                    /* r24 - r31 */
248   SIMPLE_LD_REGS,               /* r16 - r23 */
249   LD_REGS,                      /* r16 - r31 */
250   NO_LD_REGS,                   /* r0 - r15 */
251   GENERAL_REGS,                 /* r0 - r31 */
252   ALL_REGS, LIM_REG_CLASSES
253 };
254
255
256 #define N_REG_CLASSES (int)LIM_REG_CLASSES
257
258 #define REG_CLASS_NAMES {                                       \
259                  "NO_REGS",                                     \
260                    "R0_REG",    /* r0 */                        \
261                    "POINTER_X_REGS", /* r26 - r27 */            \
262                    "POINTER_Y_REGS", /* r28 - r29 */            \
263                    "POINTER_Z_REGS", /* r30 - r31 */            \
264                    "STACK_REG", /* STACK */                     \
265                    "BASE_POINTER_REGS", /* r28 - r31 */         \
266                    "POINTER_REGS", /* r26 - r31 */              \
267                    "ADDW_REGS", /* r24 - r31 */                 \
268                    "SIMPLE_LD_REGS", /* r16 - r23 */            \
269                    "LD_REGS",   /* r16 - r31 */                 \
270                    "NO_LD_REGS", /* r0 - r15 */                 \
271                    "GENERAL_REGS", /* r0 - r31 */               \
272                    "ALL_REGS" }
273
274 #define REG_CLASS_CONTENTS {                                            \
275   {0x00000000,0x00000000},      /* NO_REGS */                           \
276   {0x00000001,0x00000000},      /* R0_REG */                            \
277   {3 << REG_X,0x00000000},      /* POINTER_X_REGS, r26 - r27 */         \
278   {3 << REG_Y,0x00000000},      /* POINTER_Y_REGS, r28 - r29 */         \
279   {3 << REG_Z,0x00000000},      /* POINTER_Z_REGS, r30 - r31 */         \
280   {0x00000000,0x00000003},      /* STACK_REG, STACK */                  \
281   {(3 << REG_Y) | (3 << REG_Z),                                         \
282      0x00000000},               /* BASE_POINTER_REGS, r28 - r31 */      \
283   {(3 << REG_X) | (3 << REG_Y) | (3 << REG_Z),                          \
284      0x00000000},               /* POINTER_REGS, r26 - r31 */           \
285   {(3 << REG_X) | (3 << REG_Y) | (3 << REG_Z) | (3 << REG_W),           \
286      0x00000000},               /* ADDW_REGS, r24 - r31 */              \
287   {0x00ff0000,0x00000000},      /* SIMPLE_LD_REGS r16 - r23 */          \
288   {(3 << REG_X)|(3 << REG_Y)|(3 << REG_Z)|(3 << REG_W)|(0xff << 16),    \
289      0x00000000},       /* LD_REGS, r16 - r31 */                        \
290   {0x0000ffff,0x00000000},      /* NO_LD_REGS  r0 - r15 */              \
291   {0xffffffff,0x00000000},      /* GENERAL_REGS, r0 - r31 */            \
292   {0xffffffff,0x00000003}       /* ALL_REGS */                          \
293 }
294
295 #define REGNO_REG_CLASS(R) avr_regno_reg_class(R)
296
297 #define BASE_REG_CLASS (reload_completed ? BASE_POINTER_REGS : POINTER_REGS)
298
299 #define INDEX_REG_CLASS NO_REGS
300
301 #define REGNO_OK_FOR_BASE_P(r) (((r) < FIRST_PSEUDO_REGISTER            \
302                                  && ((r) == REG_X                       \
303                                      || (r) == REG_Y                    \
304                                      || (r) == REG_Z                    \
305                                      || (r) == ARG_POINTER_REGNUM))     \
306                                 || (reg_renumber                        \
307                                     && (reg_renumber[r] == REG_X        \
308                                         || reg_renumber[r] == REG_Y     \
309                                         || reg_renumber[r] == REG_Z     \
310                                         || (reg_renumber[r]             \
311                                             == ARG_POINTER_REGNUM))))
312
313 #define REGNO_OK_FOR_INDEX_P(NUM) 0
314
315 #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
316
317 #define CLASS_MAX_NREGS(CLASS, MODE)   class_max_nregs (CLASS, MODE)
318
319 #define STACK_PUSH_CODE POST_DEC
320
321 #define STACK_GROWS_DOWNWARD
322
323 #define STARTING_FRAME_OFFSET 1
324
325 #define STACK_POINTER_OFFSET 1
326
327 #define FIRST_PARM_OFFSET(FUNDECL) 0
328
329 #define STACK_BOUNDARY 8
330
331 #define STACK_POINTER_REGNUM 32
332
333 #define FRAME_POINTER_REGNUM REG_Y
334
335 #define ARG_POINTER_REGNUM 34
336
337 #define STATIC_CHAIN_REGNUM 2
338
339 #define ELIMINABLE_REGS {                                       \
340       {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},               \
341         {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}            \
342        ,{FRAME_POINTER_REGNUM+1,STACK_POINTER_REGNUM+1}}
343
344 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
345   OFFSET = avr_initial_elimination_offset (FROM, TO)
346
347 #define RETURN_ADDR_RTX(count, tem) avr_return_addr_rtx (count, tem)
348
349 /* Don't use Push rounding. expr.c: emit_single_push_insn is broken 
350    for POST_DEC targets (PR27386).  */
351 /*#define PUSH_ROUNDING(NPUSHED) (NPUSHED)*/
352
353 typedef struct avr_args {
354   int nregs;                    /* # registers available for passing */
355   int regno;                    /* next available register number */
356 } CUMULATIVE_ARGS;
357
358 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
359   init_cumulative_args (&(CUM), FNTYPE, LIBNAME, FNDECL)
360
361 #define FUNCTION_ARG_REGNO_P(r) function_arg_regno_p(r)
362
363 extern int avr_reg_order[];
364
365 #define DEFAULT_PCC_STRUCT_RETURN 0
366
367 #define EPILOGUE_USES(REGNO) avr_epilogue_uses(REGNO)
368
369 #define HAVE_POST_INCREMENT 1
370 #define HAVE_PRE_DECREMENT 1
371
372 #define MAX_REGS_PER_ADDRESS 1
373
374 #define REG_OK_FOR_BASE_NOSTRICT_P(X) \
375   (REGNO (X) >= FIRST_PSEUDO_REGISTER || REG_OK_FOR_BASE_STRICT_P(X))
376
377 #define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
378
379 /* LEGITIMIZE_RELOAD_ADDRESS will allow register R26/27 to be used, where it
380    is no worse than normal base pointers R28/29 and R30/31. For example:
381    If base offset is greater than 63 bytes or for R++ or --R addressing.  */
382    
383 #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)    \
384 do {                                                                        \
385   if (1&&(GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC))     \
386     {                                                                       \
387       push_reload (XEXP (X,0), XEXP (X,0), &XEXP (X,0), &XEXP (X,0),        \
388                    POINTER_REGS, GET_MODE (X),GET_MODE (X) , 0, 0,          \
389                    OPNUM, RELOAD_OTHER);                                    \
390       goto WIN;                                                             \
391     }                                                                       \
392   if (GET_CODE (X) == PLUS                                                  \
393       && REG_P (XEXP (X, 0))                                                \
394       && (reg_equiv_constant (REGNO (XEXP (X, 0))) == 0)                    \
395       && GET_CODE (XEXP (X, 1)) == CONST_INT                                \
396       && INTVAL (XEXP (X, 1)) >= 1)                                         \
397     {                                                                       \
398       int fit = INTVAL (XEXP (X, 1)) <= (64 - GET_MODE_SIZE (MODE));        \
399       if (fit)                                                              \
400         {                                                                   \
401           if (reg_equiv_address (REGNO (XEXP (X, 0))) != 0)                 \
402             {                                                               \
403               int regno = REGNO (XEXP (X, 0));                              \
404               rtx mem = make_memloc (X, regno);                             \
405               push_reload (XEXP (mem,0), NULL, &XEXP (mem,0), NULL,         \
406                            POINTER_REGS, Pmode, VOIDmode, 0, 0,             \
407                            1, ADDR_TYPE (TYPE));                            \
408               push_reload (mem, NULL_RTX, &XEXP (X, 0), NULL,               \
409                            BASE_POINTER_REGS, GET_MODE (X), VOIDmode, 0, 0, \
410                            OPNUM, TYPE);                                    \
411               goto WIN;                                                     \
412             }                                                               \
413         }                                                                   \
414       else if (! (frame_pointer_needed && XEXP (X,0) == frame_pointer_rtx)) \
415         {                                                                   \
416           push_reload (X, NULL_RTX, &X, NULL,                               \
417                        POINTER_REGS, GET_MODE (X), VOIDmode, 0, 0,          \
418                        OPNUM, TYPE);                                        \
419           goto WIN;                                                         \
420         }                                                                   \
421     }                                                                       \
422 } while(0)
423
424 #define BRANCH_COST(speed_p, predictable_p) 0
425
426 #define SLOW_BYTE_ACCESS 0
427
428 #define NO_FUNCTION_CSE
429
430 #define TEXT_SECTION_ASM_OP "\t.text"
431
432 #define DATA_SECTION_ASM_OP "\t.data"
433
434 #define BSS_SECTION_ASM_OP "\t.section .bss"
435
436 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
437    There are no shared libraries on this target, and these sections are
438    placed in the read-only program memory, so they are not writable.  */
439
440 #undef CTORS_SECTION_ASM_OP
441 #define CTORS_SECTION_ASM_OP "\t.section .ctors,\"a\",@progbits"
442
443 #undef DTORS_SECTION_ASM_OP
444 #define DTORS_SECTION_ASM_OP "\t.section .dtors,\"a\",@progbits"
445
446 #define TARGET_ASM_CONSTRUCTOR avr_asm_out_ctor
447
448 #define TARGET_ASM_DESTRUCTOR avr_asm_out_dtor
449
450 #define SUPPORTS_INIT_PRIORITY 0
451
452 #define JUMP_TABLES_IN_TEXT_SECTION 0
453
454 #define ASM_COMMENT_START " ; "
455
456 #define ASM_APP_ON "/* #APP */\n"
457
458 #define ASM_APP_OFF "/* #NOAPP */\n"
459
460 /* Switch into a generic section.  */
461 #define TARGET_ASM_NAMED_SECTION avr_asm_named_section
462
463 #define ASM_OUTPUT_ASCII(FILE, P, SIZE)  gas_output_ascii (FILE,P,SIZE)
464
465 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '\n' || ((C) == '$'))
466
467 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGN) \
468   avr_asm_output_aligned_decl_common (STREAM, DECL, NAME, SIZE, ALIGN, false)
469
470 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
471   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
472
473 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGN)  \
474   avr_asm_output_aligned_decl_common (STREAM, DECL, NAME, SIZE, ALIGN, true)
475
476 #undef TYPE_ASM_OP
477 #undef SIZE_ASM_OP
478 #undef WEAK_ASM_OP
479 #define TYPE_ASM_OP     "\t.type\t"
480 #define SIZE_ASM_OP     "\t.size\t"
481 #define WEAK_ASM_OP     "\t.weak\t"
482 /* Define the strings used for the special svr4 .type and .size directives.
483    These strings generally do not vary from one system running svr4 to
484    another, but if a given system (e.g. m88k running svr) needs to use
485    different pseudo-op names for these, they may be overridden in the
486    file which includes this one.  */
487
488
489 #undef TYPE_OPERAND_FMT
490 #define TYPE_OPERAND_FMT        "@%s"
491 /* The following macro defines the format used to output the second
492    operand of the .type assembler directive.  Different svr4 assemblers
493    expect various different forms for this operand.  The one given here
494    is just a default.  You may need to override it in your machine-
495    specific tm.h file (depending upon the particulars of your assembler).  */
496
497 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)             \
498 avr_asm_declare_function_name ((FILE), (NAME), (DECL))
499
500 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
501   do {                                                                  \
502     if (!flag_inhibit_size_directive)                                   \
503       ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);                           \
504   } while (0)
505
506 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
507 do {                                                                    \
508   ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");                     \
509   size_directive_output = 0;                                            \
510   if (!flag_inhibit_size_directive && DECL_SIZE (DECL))                 \
511     {                                                                   \
512       size_directive_output = 1;                                        \
513       ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME,                            \
514                                  int_size_in_bytes (TREE_TYPE (DECL))); \
515     }                                                                   \
516   ASM_OUTPUT_LABEL(FILE, NAME);                                         \
517 } while (0)
518
519 #undef ASM_FINISH_DECLARE_OBJECT
520 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
521 do {                                                                     \
522      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);             \
523      HOST_WIDE_INT size;                                                 \
524      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)                \
525          && ! AT_END && TOP_LEVEL                                        \
526          && DECL_INITIAL (DECL) == error_mark_node                       \
527          && !size_directive_output)                                      \
528        {                                                                 \
529          size_directive_output = 1;                                      \
530          size = int_size_in_bytes (TREE_TYPE (DECL));                    \
531          ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);                   \
532        }                                                                 \
533    } while (0)
534
535
536 #define ESCAPES \
537 "\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
538 \0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
539 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
540 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
541 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
542 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
543 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
544 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
545 /* A table of bytes codes used by the ASM_OUTPUT_ASCII and
546    ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
547    corresponds to a particular byte value [0..255].  For any
548    given byte value, if the value in the corresponding table
549    position is zero, the given character can be output directly.
550    If the table value is 1, the byte must be output as a \ooo
551    octal escape.  If the tables value is anything else, then the
552    byte value should be output as a \ followed by the value
553    in the table.  Note that we can use standard UN*X escape
554    sequences for many control characters, but we don't use
555    \a to represent BEL because some svr4 assemblers (e.g. on
556    the i386) don't know about that.  Also, we don't use \v
557    since some versions of gas, such as 2.2 did not accept it.  */
558
559 #define STRING_LIMIT    ((unsigned) 64)
560 #define STRING_ASM_OP   "\t.string\t"
561 /* Some svr4 assemblers have a limit on the number of characters which
562    can appear in the operand of a .string directive.  If your assembler
563    has such a limitation, you should define STRING_LIMIT to reflect that
564    limit.  Note that at least some svr4 assemblers have a limit on the
565    actual number of bytes in the double-quoted string, and that they
566    count each character in an escape sequence as one byte.  Thus, an
567    escape sequence like \377 would count as four bytes.
568
569    If your target assembler doesn't support the .string directive, you
570    should define this to zero.  */
571
572 /* Globalizing directive for a label.  */
573 #define GLOBAL_ASM_OP ".global\t"
574
575 #define SET_ASM_OP      "\t.set\t"
576
577 #define ASM_WEAKEN_LABEL(FILE, NAME)    \
578   do                                    \
579     {                                   \
580       fputs ("\t.weak\t", (FILE));      \
581       assemble_name ((FILE), (NAME));   \
582       fputc ('\n', (FILE));             \
583     }                                   \
584   while (0)
585
586 #define SUPPORTS_WEAK 1
587
588 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM)        \
589 sprintf (STRING, "*.%s%lu", PREFIX, (unsigned long)(NUM))
590
591 #define HAS_INIT_SECTION 1
592
593 #define REGISTER_NAMES {                                \
594   "r0","r1","r2","r3","r4","r5","r6","r7",              \
595     "r8","r9","r10","r11","r12","r13","r14","r15",      \
596     "r16","r17","r18","r19","r20","r21","r22","r23",    \
597     "r24","r25","r26","r27","r28","r29","r30","r31",    \
598     "__SP_L__","__SP_H__","argL","argH"}
599
600 #define FINAL_PRESCAN_INSN(insn, operand, nop) final_prescan_insn (insn, operand,nop)
601
602 #define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
603
604 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '~' || (CODE) == '!')
605
606 #define PRINT_OPERAND_ADDRESS(STREAM, X) print_operand_address(STREAM, X)
607
608 #define USER_LABEL_PREFIX ""
609
610 #define ASSEMBLER_DIALECT AVR_HAVE_MOVW
611
612 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO)      \
613 {                                               \
614   gcc_assert (REGNO < 32);                      \
615   fprintf (STREAM, "\tpush\tr%d", REGNO);       \
616 }
617
618 #define ASM_OUTPUT_REG_POP(STREAM, REGNO)       \
619 {                                               \
620   gcc_assert (REGNO < 32);                      \
621   fprintf (STREAM, "\tpop\tr%d", REGNO);        \
622 }
623
624 #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE)          \
625   avr_output_addr_vec_elt(STREAM, VALUE)
626
627 #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \
628   (switch_to_section (progmem_section), \
629    (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM))
630
631 #define ASM_OUTPUT_SKIP(STREAM, N)              \
632 fprintf (STREAM, "\t.skip %lu,0\n", (unsigned long)(N))
633
634 #define ASM_OUTPUT_ALIGN(STREAM, POWER)                 \
635   do {                                                  \
636       if ((POWER) > 1)                                  \
637           fprintf (STREAM, "\t.p2align\t%d\n", POWER);  \
638   } while (0)
639
640 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
641   default_elf_asm_output_external (FILE, DECL, NAME)
642
643 #define CASE_VECTOR_MODE HImode
644
645 #undef WORD_REGISTER_OPERATIONS
646
647 #define MOVE_MAX 4
648
649 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
650
651 #define Pmode HImode
652
653 #define FUNCTION_MODE HImode
654
655 #define DOLLARS_IN_IDENTIFIERS 0
656
657 #define NO_DOLLAR_IN_LABEL 1
658
659 #define TRAMPOLINE_SIZE 4
660
661 /* Store in cc_status the expressions
662    that the condition codes will describe
663    after execution of an instruction whose pattern is EXP.
664    Do not alter them if the instruction would not alter the cc's.  */
665
666 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
667
668 /* The add insns don't set overflow in a usable way.  */
669 #define CC_OVERFLOW_UNUSABLE 01000
670 /* The mov,and,or,xor insns don't set carry.  That's ok though as the
671    Z bit is all we need when doing unsigned comparisons on the result of
672    these insns (since they're always with 0).  However, conditions.h has
673    CC_NO_OVERFLOW defined for this purpose.  Rename it to something more
674    understandable.  */
675 #define CC_NO_CARRY CC_NO_OVERFLOW
676
677
678 /* Output assembler code to FILE to increment profiler label # LABELNO
679    for profiling a function entry.  */
680
681 #define FUNCTION_PROFILER(FILE, LABELNO)  \
682   fprintf (FILE, "/* profiler %d */", (LABELNO))
683
684 #define ADJUST_INSN_LENGTH(INSN, LENGTH) (LENGTH =\
685                                           adjust_insn_length (INSN, LENGTH))
686
687 extern const char *avr_device_to_arch (int argc, const char **argv);
688 extern const char *avr_device_to_data_start (int argc, const char **argv);
689 extern const char *avr_device_to_startfiles (int argc, const char **argv);
690 extern const char *avr_device_to_devicelib (int argc, const char **argv);
691
692 #define EXTRA_SPEC_FUNCTIONS \
693   { "device_to_arch", avr_device_to_arch }, \
694   { "device_to_data_start", avr_device_to_data_start }, \
695   { "device_to_startfile", avr_device_to_startfiles }, \
696   { "device_to_devicelib", avr_device_to_devicelib },
697
698 #define CPP_SPEC ""
699
700 #define CC1_SPEC ""
701
702 #define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
703     %{!fenforce-eh-specs:-fno-enforce-eh-specs} \
704     %{!fexceptions:-fno-exceptions}"
705 /* A C string constant that tells the GCC driver program options to
706    pass to `cc1plus'.  */
707
708 #define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;mmcu=avr31:-mmcu=avr3;mmcu=avr51:-mmcu=avr5;\
709 mmcu=*:-mmcu=%*}"
710
711 #define LINK_SPEC "\
712 %{mrelax:--relax\
713          %{mpmem-wrap-around:%{mmcu=at90usb8*:--pmem-wrap-around=8k}\
714                              %{mmcu=atmega16*:--pmem-wrap-around=16k}\
715                              %{mmcu=atmega32*|\
716                                mmcu=at90can32*:--pmem-wrap-around=32k}\
717                              %{mmcu=atmega64*|\
718                                mmcu=at90can64*|\
719                                mmcu=at90usb64*:--pmem-wrap-around=64k}}}\
720 %:device_to_arch(%{mmcu=*:%*})\
721 %:device_to_data_start(%{mmcu=*:%*})"
722
723 #define LIB_SPEC \
724   "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
725
726 #define LIBSTDCXX "gcc"
727 /* No libstdc++ for now.  Empty string doesn't work.  */
728
729 #define LIBGCC_SPEC \
730   "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lgcc }}}}}"
731
732 #define STARTFILE_SPEC "%:device_to_startfile(%{mmcu=*:%*})"
733
734 #define ENDFILE_SPEC ""
735
736 /* This is the default without any -mmcu=* option (AT90S*).  */
737 #define MULTILIB_DEFAULTS { "mmcu=avr2" }
738
739 #define TEST_HARD_REG_CLASS(CLASS, REGNO) \
740   TEST_HARD_REG_BIT (reg_class_contents[ (int) (CLASS)], REGNO)
741
742 /* Note that the other files fail to use these
743    in some of the places where they should.  */
744
745 #if defined(__STDC__) || defined(ALMOST_STDC)
746 #define AS2(a,b,c) #a " " #b "," #c
747 #define AS2C(b,c) " " #b "," #c
748 #define AS3(a,b,c,d) #a " " #b "," #c "," #d
749 #define AS1(a,b) #a " " #b
750 #else
751 #define AS1(a,b) "a     b"
752 #define AS2(a,b,c) "a   b,c"
753 #define AS2C(b,c) " b,c"
754 #define AS3(a,b,c,d) "a b,c,d"
755 #endif
756 #define OUT_AS1(a,b) output_asm_insn (AS1(a,b), operands)
757 #define OUT_AS2(a,b,c) output_asm_insn (AS2(a,b,c), operands)
758 #define CR_TAB "\n\t"
759
760 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
761
762 #define DWARF2_DEBUGGING_INFO 1
763
764 #define DWARF2_ADDR_SIZE 4
765
766 #define OBJECT_FORMAT_ELF
767
768 #define INCOMING_RETURN_ADDR_RTX   avr_incoming_return_addr_rtx ()
769 #define INCOMING_FRAME_SP_OFFSET   (AVR_3_BYTE_PC ? 3 : 2)
770
771 /* The caller's stack pointer value immediately before the call
772    is one byte below the first argument.  */
773 #define ARG_POINTER_CFA_OFFSET(FNDECL)  -1
774
775 #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
776   avr_hard_regno_rename_ok (OLD_REG, NEW_REG)
777
778 /* A C structure for machine-specific, per-function data.
779    This is added to the cfun structure.  */
780 struct GTY(()) machine_function
781 {
782   /* 'true' - if current function is a naked function.  */
783   int is_naked;
784
785   /* 'true' - if current function is an interrupt function 
786      as specified by the "interrupt" attribute.  */
787   int is_interrupt;
788
789   /* 'true' - if current function is a signal function 
790      as specified by the "signal" attribute.  */
791   int is_signal;
792   
793   /* 'true' - if current function is a 'task' function 
794      as specified by the "OS_task" attribute.  */
795   int is_OS_task;
796
797   /* 'true' - if current function is a 'main' function 
798      as specified by the "OS_main" attribute.  */
799   int is_OS_main;
800   
801   /* Current function stack size.  */
802   int stack_usage;
803
804   /* 'true' if a callee might be tail called */
805   int sibcall_fails;
806 };