OSDN Git Service

* doc/extend.texi: Document new xstormy16 attribute.
[pf3gnuchains/gcc-fork.git] / gcc / config / stormy16 / stormy16.h
1 /* Xstormy16 cpu description.
2    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3    Free Software Foundation, Inc.
4    Contributed by Red Hat, Inc.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 \f
24 /* Driver configuration */
25
26 /* Defined in svr4.h.  */
27 #undef ASM_SPEC
28 #define ASM_SPEC ""
29
30 /* For xstormy16:
31    - If -msim is specified, everything is built and linked as for the sim.
32    - If -T is specified, that linker script is used, and it should provide
33      appropriate libraries.
34    - If neither is specified, everything is built as for the sim, but no
35      I/O support is assumed.
36
37 */
38 #undef LIB_SPEC
39 #define LIB_SPEC "-( -lc %{msim:-lsim}%{!msim:%{!T*:-lnosys}} -)"
40
41 /* Defined in svr4.h.  */
42 #undef STARTFILE_SPEC
43 #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
44
45 /* Defined in svr4.h.  */
46 #undef ENDFILE_SPEC
47 #define ENDFILE_SPEC "crtend.o%s crtn.o%s"
48
49 /* Defined in svr4.h for host compilers.  */
50 /* #define MD_EXEC_PREFIX "" */
51
52 /* Defined in svr4.h for host compilers.  */
53 /* #define MD_STARTFILE_PREFIX "" */
54
55 \f
56 /* Run-time target specifications */
57
58 #define TARGET_CPU_CPP_BUILTINS() do {  \
59   builtin_define_std ("xstormy16");     \
60   builtin_assert ("machine=xstormy16"); \
61 } while (0)
62
63 /* This declaration should be present.  */
64 extern int target_flags;
65
66 #define TARGET_SWITCHES                                 \
67   {{ "sim", 0, "Provide libraries for the simulator" }, \
68    { "", 0, "" }}
69
70 #define TARGET_VERSION fprintf (stderr, " (xstormy16 cpu core)");
71
72 #define CAN_DEBUG_WITHOUT_FP
73
74 \f
75 /* Storage Layout */
76
77 #define BITS_BIG_ENDIAN 1
78
79 #define BYTES_BIG_ENDIAN 0
80
81 #define WORDS_BIG_ENDIAN 0
82
83 #define UNITS_PER_WORD 2
84
85 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)                               \
86 do {                                                                    \
87   if (GET_MODE_CLASS (MODE) == MODE_INT                                 \
88       && GET_MODE_SIZE (MODE) < 2)                                      \
89     (MODE) = HImode;                                                    \
90 } while (0)
91
92 #define PARM_BOUNDARY 16
93
94 #define STACK_BOUNDARY 16
95
96 #define FUNCTION_BOUNDARY 16
97
98 #define BIGGEST_ALIGNMENT 16
99
100 /* Defined in svr4.h.  */
101 /* #define MAX_OFILE_ALIGNMENT */
102
103 #define DATA_ALIGNMENT(TYPE, ALIGN)             \
104   (TREE_CODE (TYPE) == ARRAY_TYPE               \
105    && TYPE_MODE (TREE_TYPE (TYPE)) == QImode    \
106    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
107
108 #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
109   (TREE_CODE (EXP) == STRING_CST        \
110    && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
111
112 #define STRICT_ALIGNMENT 1
113
114 /* Defined in svr4.h.  */
115 #define PCC_BITFIELD_TYPE_MATTERS 1
116 \f
117 /* Layout of Source Language Data Types */
118
119 #define INT_TYPE_SIZE 16
120
121 #define SHORT_TYPE_SIZE 16
122
123 #define LONG_TYPE_SIZE 32
124
125 #define LONG_LONG_TYPE_SIZE 64
126
127 #define FLOAT_TYPE_SIZE 32
128
129 #define DOUBLE_TYPE_SIZE 64
130
131 #define LONG_DOUBLE_TYPE_SIZE 64
132
133 #define DEFAULT_SIGNED_CHAR 0
134
135 /* Defined in svr4.h.  */
136 #define SIZE_TYPE "unsigned int"
137
138 /* Defined in svr4.h.  */
139 #define PTRDIFF_TYPE "int"
140
141 /* Defined in svr4.h, to "long int".  */
142 /* #define WCHAR_TYPE "long int" */
143
144 /* Defined in svr4.h.  */
145 #undef WCHAR_TYPE_SIZE
146 #define WCHAR_TYPE_SIZE 32
147
148 /* Define this macro if the type of Objective-C selectors should be `int'.
149
150    If this macro is not defined, then selectors should have the type `struct
151    objc_selector *'.  */
152 /* #define OBJC_INT_SELECTORS */
153
154 \f
155 /* Register Basics */
156
157 #define FIRST_PSEUDO_REGISTER 19
158
159 #define FIXED_REGISTERS \
160   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1 }
161
162 #define CALL_USED_REGISTERS \
163   { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1 }
164
165 \f
166 /* Order of allocation of registers */
167
168 #define REG_ALLOC_ORDER { 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 10, 11, 12, 13, 14, 15, 16 }
169
170 \f
171 /* How Values Fit in Registers */
172
173 #define HARD_REGNO_NREGS(REGNO, MODE)                           \
174   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
175
176 #define HARD_REGNO_MODE_OK(REGNO, MODE) ((REGNO) != 16 || (MODE) == BImode)
177
178 /* A C expression that is nonzero if it is desirable to choose register
179    allocation so as to avoid move instructions between a value of mode MODE1
180    and a value of mode MODE2.
181
182    If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R, MODE2)' are
183    ever different for any R, then `MODES_TIEABLE_P (MODE1, MODE2)' must be
184    zero.  */
185 #define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) != BImode && (MODE2) != BImode)
186
187 \f
188 /* Register Classes */
189
190 enum reg_class
191 {
192   NO_REGS,
193   R0_REGS,
194   R1_REGS,
195   TWO_REGS,
196   R2_REGS,
197   EIGHT_REGS,
198   R8_REGS,
199   ICALL_REGS,
200   GENERAL_REGS,
201   CARRY_REGS,
202   ALL_REGS,
203   LIM_REG_CLASSES
204 };
205
206 #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
207
208 #define REG_CLASS_NAMES                         \
209 {                                               \
210   "NO_REGS",                                    \
211   "R0_REGS",                                    \
212   "R1_REGS",                                    \
213   "TWO_REGS",                                   \
214   "R2_REGS",                                    \
215   "EIGHT_REGS",                                 \
216   "R8_REGS",                                    \
217   "ICALL_REGS",                                 \
218   "GENERAL_REGS",                               \
219   "CARRY_REGS",                                 \
220   "ALL_REGS"                                    \
221 }
222
223 #define REG_CLASS_CONTENTS                      \
224 {                                               \
225   { 0x00000 },                                  \
226   { 0x00001 },                                  \
227   { 0x00002 },                                  \
228   { 0x00003 },                                  \
229   { 0x00004 },                                  \
230   { 0x000FF },                                  \
231   { 0x00100 },                                  \
232   { 0x00300 },                                  \
233   { 0x6FFFF },                                  \
234   { 0x10000 },                                  \
235   { (1 << FIRST_PSEUDO_REGISTER) - 1 }          \
236 }
237
238 #define REGNO_REG_CLASS(REGNO)                  \
239   ((REGNO) == 0   ? R0_REGS                     \
240    : (REGNO) == 1 ? R1_REGS                     \
241    : (REGNO) == 2 ? R2_REGS                     \
242    : (REGNO) < 8  ? EIGHT_REGS                  \
243    : (REGNO) == 8 ? R8_REGS                     \
244    : (REGNO) == 16 ? CARRY_REGS                 \
245    : (REGNO) <= 18 ? GENERAL_REGS               \
246    : ALL_REGS)
247
248 #define BASE_REG_CLASS GENERAL_REGS
249
250 #define INDEX_REG_CLASS GENERAL_REGS
251
252 /*   The following letters are unavailable, due to being used as
253    constraints:
254         '0'..'9'
255         '<', '>'
256         'E', 'F', 'G', 'H'
257         'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'
258         'Q', 'R', 'S', 'T', 'U'
259         'V', 'X'
260         'g', 'i', 'm', 'n', 'o', 'p', 'r', 's' */
261
262 #define REG_CLASS_FROM_LETTER(CHAR)             \
263  (  (CHAR) == 'a' ? R0_REGS                     \
264   : (CHAR) == 'b' ? R1_REGS                     \
265   : (CHAR) == 'c' ? R2_REGS                     \
266   : (CHAR) == 'd' ? R8_REGS                     \
267   : (CHAR) == 'e' ? EIGHT_REGS                  \
268   : (CHAR) == 't' ? TWO_REGS                    \
269   : (CHAR) == 'y' ? CARRY_REGS                  \
270   : (CHAR) == 'z' ? ICALL_REGS                  \
271   : NO_REGS)
272
273 #define REGNO_OK_FOR_BASE_P(NUM) 1
274
275 #define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM)
276
277 /* This declaration must be present.  */
278 #define PREFERRED_RELOAD_CLASS(X, CLASS) \
279   xstormy16_preferred_reload_class (X, CLASS)
280
281 #define PREFERRED_OUTPUT_RELOAD_CLASS(X, CLASS) \
282   xstormy16_preferred_reload_class (X, CLASS)
283
284 /* This chip has the interesting property that only the first eight
285    registers can be moved to/from memory.  */
286 #define SECONDARY_RELOAD_CLASS(CLASS, MODE, X)                  \
287   xstormy16_secondary_reload_class (CLASS, MODE, X)
288
289 /* Normally the compiler avoids choosing registers that have been explicitly
290    mentioned in the rtl as spill registers (these registers are normally those
291    used to pass parameters and return values).  However, some machines have so
292    few registers of certain classes that there would not be enough registers to
293    use as spill registers if this were done.
294
295    Define `SMALL_REGISTER_CLASSES' to be an expression with a nonzero value on
296    these machines.  When this macro has a nonzero value, the compiler allows
297    registers explicitly used in the rtl to be used as spill registers but
298    avoids extending the lifetime of these registers.
299
300    It is always safe to define this macro with a nonzero value, but if you
301    unnecessarily define it, you will reduce the amount of optimizations that
302    can be performed in some cases.  If you do not define this macro with a
303    nonzero value when it is required, the compiler will run out of spill
304    registers and print a fatal error message.  For most machines, you should
305    not define this macro at all.  */
306 /* #define SMALL_REGISTER_CLASSES */
307
308 /* This declaration is required.  */
309 #define CLASS_MAX_NREGS(CLASS, MODE) \
310   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
311
312 /* If defined, a C expression for a class that contains registers which the
313    compiler must always access in a mode that is the same size as the mode in
314    which it loaded the register.
315
316    For the example, loading 32-bit integer or floating-point objects into
317    floating-point registers on the Alpha extends them to 64-bits.  Therefore
318    loading a 64-bit object and then storing it as a 32-bit object does not
319    store the low-order 32-bits, as would be the case for a normal register.
320    Therefore, `alpha.h' defines this macro as `FLOAT_REGS'.  */
321 /* #define CLASS_CANNOT_CHANGE_SIZE */
322
323 #define CONST_OK_FOR_LETTER_P(VALUE, C)                 \
324   (  (C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 3          \
325    : (C) == 'J' ? exact_log2 (VALUE) != -1              \
326    : (C) == 'K' ? exact_log2 (~(VALUE)) != -1           \
327    : (C) == 'L' ? (VALUE) >= 0 && (VALUE) <= 255        \
328    : (C) == 'M' ? (VALUE) >= -255 && (VALUE) <= 0       \
329    : (C) == 'N' ? (VALUE) >= -3 && (VALUE) <= 0         \
330    : (C) == 'O' ? (VALUE) >= 1 && (VALUE) <= 4          \
331    : (C) == 'P' ? (VALUE) >= -4 && (VALUE) <= -1        \
332    : 0 )
333
334 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) 0
335
336 #define EXTRA_CONSTRAINT(VALUE, C) \
337   xstormy16_extra_constraint_p (VALUE, C)
338
339 \f
340 /* Basic Stack Layout */
341
342 /* We want to use post-increment instructions to push things on the stack,
343    because we don't have any pre-increment ones.  */
344 #define STACK_PUSH_CODE POST_INC
345
346 /* #define FRAME_GROWS_DOWNWARD */
347
348 #define ARGS_GROW_DOWNWARD 1
349
350 #define STARTING_FRAME_OFFSET 0
351
352 #define FIRST_PARM_OFFSET(FUNDECL) 0
353
354 #define RETURN_ADDR_RTX(COUNT, FRAMEADDR)       \
355   ((COUNT) == 0                                 \
356    ? gen_rtx_MEM (Pmode, arg_pointer_rtx)       \
357    : NULL_RTX)
358
359 #define INCOMING_RETURN_ADDR_RTX  \
360    gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (-4)))
361
362 #define INCOMING_FRAME_SP_OFFSET (xstormy16_interrupt_function_p () ? 6 : 4)
363
364 \f
365 /* Register That Address the Stack Frame.  */
366
367 #define STACK_POINTER_REGNUM 15
368
369 #define FRAME_POINTER_REGNUM 17
370
371 #define HARD_FRAME_POINTER_REGNUM 13
372
373 #define ARG_POINTER_REGNUM 18
374
375 #define STATIC_CHAIN_REGNUM 1
376
377 \f
378 /* Eliminating the Frame Pointer and the Arg Pointer */
379
380 #define FRAME_POINTER_REQUIRED 0
381
382 #define ELIMINABLE_REGS                                 \
383 {                                                       \
384   {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM},         \
385   {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},    \
386   {ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM},         \
387   {ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM},    \
388 }
389
390 #define CAN_ELIMINATE(FROM, TO)                                         \
391  ((FROM) == ARG_POINTER_REGNUM && (TO) == STACK_POINTER_REGNUM          \
392   ? ! frame_pointer_needed                                              \
393   : 1)
394
395 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
396   (OFFSET) = xstormy16_initial_elimination_offset (FROM, TO)
397
398 \f
399 /* Passing Function Arguments on the Stack */
400
401 #define PUSH_ROUNDING(BYTES) (((BYTES) + 1) & ~1)
402
403 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
404
405 \f
406 /* Function Arguments in Registers */
407
408 #define NUM_ARGUMENT_REGISTERS 6
409 #define FIRST_ARGUMENT_REGISTER 2
410
411 #define XSTORMY16_WORD_SIZE(TYPE, MODE)                         \
412   ((((TYPE) ? int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE))  \
413     + 1)                                                        \
414    / 2)
415
416 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
417         xstormy16_function_arg (CUM, MODE, TYPE, NAMED)
418
419 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0
420
421 /* For this platform, the value of CUMULATIVE_ARGS is the number of words
422    of arguments that have been passed in registers so far.  */
423 #define CUMULATIVE_ARGS int
424
425 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
426   (CUM) = 0
427
428 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)                    \
429   ((CUM) = xstormy16_function_arg_advance (CUM, MODE, TYPE, NAMED))
430
431 #define FUNCTION_ARG_REGNO_P(REGNO)                                     \
432   ((REGNO) >= FIRST_ARGUMENT_REGISTER                                   \
433    && (REGNO) < FIRST_ARGUMENT_REGISTER + NUM_ARGUMENT_REGISTERS)
434
435 \f
436 /* How Scalar Function Values are Returned */
437
438 /* The number of the hard register that is used to return a scalar value from a
439    function call.  */
440 #define RETURN_VALUE_REGNUM     FIRST_ARGUMENT_REGISTER
441      
442 #define FUNCTION_VALUE(VALTYPE, FUNC) \
443   xstormy16_function_value (VALTYPE, FUNC)
444
445 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, RETURN_VALUE_REGNUM)
446
447 #define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == RETURN_VALUE_REGNUM)
448
449 \f
450 /* Function Entry and Exit */
451
452 #define EPILOGUE_USES(REGNO) \
453   xstormy16_epilogue_uses (REGNO)
454
455 \f
456 /* Generating Code for Profiling.  */
457
458 /* This declaration must be present, but it can be an abort if profiling is
459    not implemented.  */
460      
461 #define FUNCTION_PROFILER(FILE, LABELNO) xstormy16_function_profiler ()
462
463 \f
464 /* If the target has particular reasons why a function cannot be inlined,
465    it may define the TARGET_CANNOT_INLINE_P.  This macro takes one argument,
466    the DECL describing the function.  The function should NULL if the function
467    *can* be inlined.  Otherwise it should return a pointer to a string containing
468    a message describing why the function could not be inlined.  The message will
469    displayed if the '-Winline' command line switch has been given.  If the message
470    contains a '%s' sequence, this will be replaced by the name of the function.  */
471 /* #define TARGET_CANNOT_INLINE_P(FN_DECL) xstormy16_cannot_inline_p (FN_DECL) */
472 \f
473 /* Implementing the Varargs Macros.  */
474
475 /* Implement the stdarg/varargs va_start macro.  STDARG_P is nonzero if this
476    is stdarg.h instead of varargs.h.  VALIST is the tree of the va_list
477    variable to initialize.  NEXTARG is the machine independent notion of the
478    'next' argument after the variable arguments.  If not defined, a standard
479    implementation will be defined that works for arguments passed on the stack.  */
480 #define EXPAND_BUILTIN_VA_START(VALIST, NEXTARG) \
481   xstormy16_expand_builtin_va_start (VALIST, NEXTARG)
482 \f
483 /* Trampolines for Nested Functions.  */
484
485 #define TRAMPOLINE_SIZE 8
486
487 #define TRAMPOLINE_ALIGNMENT 16
488
489 #define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \
490   xstormy16_initialize_trampoline (ADDR, FNADDR, STATIC_CHAIN)
491
492 \f
493 /* Define this macro to override the type used by the library routines to pick
494    up arguments of type `float'.  (By default, they use a union of `float' and
495    `int'.)
496
497    The obvious choice would be `float'--but that won't work with traditional C
498    compilers that expect all arguments declared as `float' to arrive as
499    `double'.  To avoid this conversion, the library routines ask for the value
500    as some other type and then treat it as a `float'.  */
501 /* #define FLOAT_ARG_TYPE */
502
503 /* Define this macro to override the way library routines redesignate a `float'
504    argument as a `float' instead of the type it was passed as.  The default is
505    an expression which takes the `float' field of the union.  */
506 /* #define FLOATIFY(PASSED_VALUE) */
507
508 /* Define this macro to override the type used by the library routines to
509    return values that ought to have type `float'.  (By default, they use
510    `int'.)
511
512    The obvious choice would be `float'--but that won't work with traditional C
513    compilers gratuitously convert values declared as `float' into `double'.  */
514 /* #define FLOAT_VALUE_TYPE */
515
516 /* Define this macro to override the way the value of a `float'-returning
517    library routine should be packaged in order to return it.  These functions
518    are actually declared to return type `FLOAT_VALUE_TYPE' (normally `int').
519
520    These values can't be returned as type `float' because traditional C
521    compilers would gratuitously convert the value to a `double'.
522
523    A local variable named `intify' is always available when the macro `INTIFY'
524    is used.  It is a union of a `float' field named `f' and a field named `i'
525    whose type is `FLOAT_VALUE_TYPE' or `int'.
526
527    If you don't define this macro, the default definition works by copying the
528    value through that union.  */
529 /* #define INTIFY(FLOAT_VALUE) */
530
531 /* Define this macro as the name of the data type corresponding to `SImode' in
532    the system's own C compiler.
533
534    You need not define this macro if that type is `long int', as it usually is.  */
535 /* #define nongcc_SI_type */
536
537 /* Define this macro as the name of the data type corresponding to the
538    word_mode in the system's own C compiler.
539
540    You need not define this macro if that type is `long int', as it usually is.  */
541 /* #define nongcc_word_type */
542
543 /* Define these macros to supply explicit C statements to carry out various
544    arithmetic operations on types `float' and `double' in the library routines
545    in `libgcc1.c'.  See that file for a full list of these macros and their
546    arguments.
547
548    On most machines, you don't need to define any of these macros, because the
549    C compiler that comes with the system takes care of doing them.  */
550 /* #define perform_...  */
551
552 \f
553 /* Addressing Modes */
554
555 #define HAVE_POST_INCREMENT 1
556
557 #define HAVE_PRE_DECREMENT 1
558
559 #define CONSTANT_ADDRESS_P(X) CONSTANT_P (X)
560
561 #define MAX_REGS_PER_ADDRESS 1
562
563 #ifdef REG_OK_STRICT
564 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)        \
565 do {                                                    \
566   if (xstormy16_legitimate_address_p (MODE, X, 1))      \
567     goto LABEL;                                         \
568 } while (0)
569 #else
570 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL)        \
571 do {                                                    \
572   if (xstormy16_legitimate_address_p (MODE, X, 0))      \
573     goto LABEL;                                         \
574 } while (0)
575 #endif
576
577 #ifdef REG_OK_STRICT
578 #define REG_OK_FOR_BASE_P(X)                                               \
579   (REGNO_OK_FOR_BASE_P (REGNO (X)) && (REGNO (X) < FIRST_PSEUDO_REGISTER))
580 #else
581 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
582 #endif
583
584 #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
585
586 /* On this chip, this is true if the address is valid with an offset
587    of 0 but not of 6, because in that case it cannot be used as an
588    address for DImode or DFmode, or if the address is a post-increment
589    or pre-decrement address.
590 */
591 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)                        \
592   if (xstormy16_mode_dependent_address_p (ADDR))                                \
593     goto LABEL
594
595 #define LEGITIMATE_CONSTANT_P(X) 1
596
597 \f
598 /* Describing Relative Costs of Operations */
599
600 #define REGISTER_MOVE_COST(MODE, FROM, TO) 2
601
602 #define MEMORY_MOVE_COST(M,C,I) (5 + memory_move_secondary_cost (M, C, I))
603
604 #define BRANCH_COST 5
605
606 #define SLOW_BYTE_ACCESS 0
607
608 #define NO_FUNCTION_CSE
609
610 \f
611 /* Dividing the output into sections.  */
612
613 #define TEXT_SECTION_ASM_OP ".text"
614
615 #define DATA_SECTION_ASM_OP ".data"
616
617 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
618
619 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
620    There are no shared libraries on this target so these sections need
621    not be writable.
622
623    Defined in elfos.h.  */
624
625 #undef CTORS_SECTION_ASM_OP
626 #undef DTORS_SECTION_ASM_OP
627 #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"a\""
628 #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"a\""
629 #define EXTRA_SECTIONS in_bss100
630
631 /* We define the function body in a separate macro so that if we ever
632    add another section, we can just add an entry to
633    EXTRA_SECTION_FUNCTIONS without making it difficult to read.  It is
634    not used anywhere else.  */
635 #define XSTORMY16_SECTION_FUNCTION(name, in, string, bits)                        \
636   void                                                                            \
637   name ()                                                                         \
638   {                                                                               \
639     if (in_section != in)                                                         \
640       {                                                                           \
641         fprintf (asm_out_file, "\t.section %s,\"aw\",@%sbits\n", string, bits);   \
642         in_section = in;                                                          \
643       }                                                                           \
644   }
645
646 #undef  EXTRA_SECTION_FUNCTIONS
647 #define EXTRA_SECTION_FUNCTIONS         \
648   XSTORMY16_SECTION_FUNCTION (bss100_section, in_bss100, ".bss_below100", "no")
649
650 #define JUMP_TABLES_IN_TEXT_SECTION 1
651
652 \f
653 /* The Overall Framework of an Assembler File.  */
654
655 #define ASM_COMMENT_START ";"
656
657 #define ASM_APP_ON "#APP\n"
658
659 #define ASM_APP_OFF "#NO_APP\n"
660 \f
661 /* Output of Data.  */
662
663 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '|')
664
665 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
666   xstormy16_asm_output_aligned_common(STREAM, DECL, NAME, SIZE, ALIGNMENT, 1)
667 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
668   xstormy16_asm_output_aligned_common(STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
669
670 \f
671 /* Output and Generation of Labels.  */
672
673 #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL)                           \
674   do {                                                                  \
675     const char *rn = XSTR (SYMBOL, 0);                                  \
676     if (rn[0] == '@' && rn[2] == '.')                                   \
677       rn += 3;                                                          \
678     if (SYMBOL_REF_FUNCTION_P (SYMBOL))                                 \
679       ASM_OUTPUT_LABEL_REF ((STREAM), rn);                              \
680     else                                                                \
681       assemble_name (STREAM, rn);                                       \
682   } while (0)
683
684 #define ASM_OUTPUT_LABEL_REF(STREAM, NAME)      \
685 do  {                                           \
686   fputs ("@fptr(", STREAM);                     \
687   assemble_name (STREAM, NAME);                 \
688   fputc (')', STREAM);                          \
689 } while (0)
690
691 #define ASM_OUTPUT_LABELREF(STREAM, NAME)       \
692   asm_fprintf ((STREAM), "%U%s", xstormy16_strip_name_encoding (NAME));
693
694 /* Globalizing directive for a label.  */
695 #define GLOBAL_ASM_OP "\t.globl "
696
697 \f
698 /* Macros Controlling Initialization Routines.  */
699
700 /* When you are using special sections for
701    initialization and termination functions, this macro also controls how
702    `crtstuff.c' and `libgcc2.c' arrange to run the initialization functions.
703
704    Defined in svr4.h.  */
705 /* #define INIT_SECTION_ASM_OP */
706
707 /* Define this macro as a C statement to output on the stream STREAM the
708    assembler code to arrange to call the function named NAME at initialization
709    time.
710
711    Assume that NAME is the name of a C function generated automatically by the
712    compiler.  This function takes no arguments.  Use the function
713    `assemble_name' to output the name NAME; this performs any system-specific
714    syntactic transformations such as adding an underscore.
715
716    If you don't define this macro, nothing special is output to arrange to call
717    the function.  This is correct when the function will be called in some
718    other manner--for example, by means of the `collect2' program, which looks
719    through the symbol table to find these functions by their names.
720
721    Defined in svr4.h.  */
722 /* #define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) */
723
724 /* This is like `ASM_OUTPUT_CONSTRUCTOR' but used for termination functions
725    rather than initialization functions.
726
727    Defined in svr4.h.  */
728 /* #define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) */
729
730 /* Define this macro if the system uses ELF format object files.
731
732    Defined in svr4.h.  */
733 /* #define OBJECT_FORMAT_ELF */
734
735 \f
736 /* Output of Assembler Instructions.  */
737
738 #define REGISTER_NAMES                                                  \
739 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",    \
740   "r11", "r12", "r13", "psw", "sp", "carry", "fp", "ap" }
741
742 #define ADDITIONAL_REGISTER_NAMES               \
743   { { "r14", 14 },                              \
744     { "r15", 15 } }
745
746 #define PRINT_OPERAND(STREAM, X, CODE) xstormy16_print_operand (STREAM, X, CODE)
747
748 #define PRINT_OPERAND_ADDRESS(STREAM, X) xstormy16_print_operand_address (STREAM, X)
749
750 /* USER_LABEL_PREFIX is defined in svr4.h.  */
751 #define REGISTER_PREFIX ""
752 #define LOCAL_LABEL_PREFIX "."
753 #define USER_LABEL_PREFIX ""
754 #define IMMEDIATE_PREFIX "#"
755
756 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \
757   fprintf (STREAM, "\tpush %d\n", REGNO)
758
759 #define ASM_OUTPUT_REG_POP(STREAM, REGNO) \
760   fprintf (STREAM, "\tpop %d\n", REGNO)
761
762 \f
763 /* Output of dispatch tables.  */
764
765 /* This port does not use the ASM_OUTPUT_ADDR_VEC_ELT macro, because
766    this could cause label alignment to appear between the 'br' and the table,
767    which would be bad.  Instead, it controls the output of the table
768    itself.  */
769 #define ASM_OUTPUT_ADDR_VEC(LABEL, BODY) \
770   xstormy16_output_addr_vec (file, LABEL, BODY)
771
772 /* Alignment for ADDR_VECs is the same as for code.  */
773 #define ADDR_VEC_ALIGN(ADDR_VEC) 1
774
775 \f
776 /* Assembler Commands for Exception Regions.  */
777
778 #define DWARF2_UNWIND_INFO 0
779
780 /* Don't use __builtin_setjmp for unwinding, since it's tricky to get
781    at the high 16 bits of an address.  */
782 #define DONT_USE_BUILTIN_SETJMP
783 #define JMP_BUF_SIZE  8
784 \f
785 /* Assembler Commands for Alignment.  */
786
787 #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
788   fprintf ((STREAM), "\t.p2align %d\n", (POWER))
789
790 \f
791 /* Macros Affecting all Debug Formats.  */
792
793 /* Defined in svr4.h.  */
794 #undef PREFERRED_DEBUGGING_TYPE
795 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
796
797 \f
798 /* Macros for SDB and Dwarf Output.  */
799
800 /* Define this macro if addresses in Dwarf 2 debugging info should not
801    be the same size as pointers on the target architecture.  The
802    macro's value should be the size, in bytes, to use for addresses in
803    the debugging info.
804
805    Some architectures use word addresses to refer to code locations,
806    but Dwarf 2 info always uses byte addresses.  On such machines,
807    Dwarf 2 addresses need to be larger than the architecture's
808    pointers.  */
809 #define DWARF2_ADDR_SIZE 4
810
811 \f
812 /* Miscellaneous Parameters.  */
813
814 #define PREDICATE_CODES                                 \
815   {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT }},    \
816   {"equality_operator", {EQ, NE }},                     \
817   {"inequality_operator", {GE, GT, LE, LT, GEU, GTU, LEU, LTU }}, \
818   {"xstormy16_ineqsi_operator", {LT, GE, LTU, GEU }}, \
819   {"xstormy16_below100_operand", {MEM }}, \
820   {"xstormy16_below100_or_register", {MEM, REG }}, \
821   {"xstormy16_splittable_below100_or_register", {MEM, REG }}, \
822   {"xstormy16_onebit_clr_operand", {CONST_INT }}, \
823   {"xstormy16_onebit_set_operand", {CONST_INT }}, \
824   {"nonimmediate_nonstack_operand", {REG, MEM}},
825
826 #define CASE_VECTOR_MODE SImode
827
828 #define WORD_REGISTER_OPERATIONS
829
830 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
831
832 #define MOVE_MAX 2
833
834 #define SHIFT_COUNT_TRUNCATED 1
835
836 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
837
838 #define Pmode HImode
839
840 #define FUNCTION_MODE HImode
841
842 #define NO_IMPLICIT_EXTERN_C
843
844 /* Defined in svr4.h.  */
845 #define HANDLE_SYSV_PRAGMA 1
846
847 /* Define this if the target system supports the function `atexit' from the
848    ANSI C standard.  If this is not defined, and `INIT_SECTION_ASM_OP' is not
849    defined, a default `exit' function will be provided to support C++.
850
851    Defined by svr4.h */
852 /* #define HAVE_ATEXIT */
853
854 /* A C statement which is executed by the Haifa scheduler after it has scheduled
855    an insn from the ready list.  FILE is either a null pointer, or a stdio stream
856    to write any debug output to.  VERBOSE is the verbose level provided by
857    -fsched-verbose-<n>.  INSN is the instruction that was scheduled.  MORE is the
858    number of instructions that can be issued in the current cycle.  This macro
859    is responsible for updating the value of MORE (typically by (MORE)--).  */
860 /* #define MD_SCHED_VARIABLE_ISSUE (FILE, VERBOSE, INSN, MORE) */
861
862 \f
863 /* Define the information needed to generate branch and scc insns.  This is
864    stored from the compare operation.  Note that we can't use "rtx" here
865    since it hasn't been defined!  */
866
867 extern struct rtx_def *xstormy16_compare_op0, *xstormy16_compare_op1;
868
869 /* End of xstormy16.h */