OSDN Git Service

* c-pragma.c (maybe_apply_renaming_pragma): Fix typo.
[pf3gnuchains/gcc-fork.git] / gcc / config / v850 / v850.h
1 /* Definitions of target machine for GNU compiler. NEC V850 series
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3    Free Software Foundation, Inc.
4    Contributed by Jeff Law (law@cygnus.com).
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 #ifndef GCC_V850_H
24 #define GCC_V850_H
25
26 /* These are defiend in svr4.h but we want to override them.  */
27 #undef ASM_FINAL_SPEC
28 #undef LIB_SPEC
29 #undef ENDFILE_SPEC
30 #undef LINK_SPEC
31 #undef STARTFILE_SPEC
32 #undef ASM_SPEC
33
34 #define TARGET_CPU_generic      1
35 #define TARGET_CPU_v850e        2
36
37 #ifndef TARGET_CPU_DEFAULT
38 #define TARGET_CPU_DEFAULT      TARGET_CPU_generic
39 #endif
40
41 #define MASK_DEFAULT            MASK_V850
42 #define SUBTARGET_ASM_SPEC      "%{!mv*:-mv850}"
43 #define SUBTARGET_CPP_SPEC      "%{!mv*:-D__v850__}"
44 #define TARGET_VERSION          fprintf (stderr, " (NEC V850)");
45
46 /* Choose which processor will be the default.
47    We must pass a -mv850xx option to the assembler if no explicit -mv* option
48    is given, because the assembler's processor default may not be correct.  */
49 #if TARGET_CPU_DEFAULT == TARGET_CPU_v850e
50 #undef  MASK_DEFAULT
51 #define MASK_DEFAULT            MASK_V850E
52 #undef  SUBTARGET_ASM_SPEC
53 #define SUBTARGET_ASM_SPEC      "%{!mv*:-mv850e}"
54 #undef  SUBTARGET_CPP_SPEC
55 #define SUBTARGET_CPP_SPEC      "%{!mv*:-D__v850e__}"
56 #undef  TARGET_VERSION
57 #define TARGET_VERSION          fprintf (stderr, " (NEC V850E)");
58 #endif
59
60 #define ASM_SPEC "%{mv*:-mv%*}"
61 #define CPP_SPEC                "%{mv850e:-D__v850e__} %{mv850:-D__v850__} %(subtarget_cpp_spec)"
62
63 #define EXTRA_SPECS \
64  { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \
65  { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC } 
66
67 /* Names to predefine in the preprocessor for this target machine.  */
68 #define TARGET_CPU_CPP_BUILTINS() do {          \
69   builtin_define( "__v851__" );                 \
70   builtin_define( "__v850" );                   \
71   builtin_assert( "machine=v850" );             \
72   builtin_assert( "cpu=v850" );                 \
73 } while(0)
74
75 /* Run-time compilation parameters selecting different hardware subsets.  */
76
77 extern int target_flags;
78
79 /* Target flags bits, see below for an explanation of the bits.  */
80 #define MASK_GHS                0x00000001
81 #define MASK_LONG_CALLS         0x00000002
82 #define MASK_EP                 0x00000004
83 #define MASK_PROLOG_FUNCTION    0x00000008
84 #define MASK_DEBUG              0x40000000
85
86 #define MASK_CPU                0x00000030
87 #define MASK_V850               0x00000010
88 #define MASK_V850E              0x00000020
89 #define MASK_SMALL_SLD          0x00000040
90
91 #define MASK_BIG_SWITCH         0x00000100
92 #define MASK_NO_APP_REGS        0x00000200
93 #define MASK_DISABLE_CALLT      0x00000400
94 #define MASK_STRICT_ALIGN       0x00000800
95
96 #define MASK_US_BIT_SET         0x00001000
97 #define MASK_US_MASK_SET        0x00002000
98
99 /* Macros used in the machine description to test the flags.  */
100
101 /* The GHS calling convention support doesn't really work,
102    mostly due to a lack of documentation.  Outstanding issues:
103
104      * How do varargs & stdarg really work.  How to they handle
105      passing structures (if at all).
106
107      * Doubles are normally 4 byte aligned, except in argument
108      lists where they are 8 byte aligned.  Is the alignment
109      in the argument list based on the first parameter,
110      first stack parameter, etc etc.
111
112      * Passing/returning of large structures probably isn't the same
113      as GHS.  We don't have enough documentation on their conventions
114      to be compatible.
115
116      * Tests of SETUP_INCOMING_VARARGS need to be made runtime checks
117      since it depends on TARGET_GHS.  */
118 #define TARGET_GHS (target_flags & MASK_GHS)
119  
120 /* Don't do PC-relative calls, instead load the address of the target
121    function into a register and perform a register indirect call.  */
122 #define TARGET_LONG_CALLS (target_flags & MASK_LONG_CALLS)
123
124 /* Whether to optimize space by using ep (r30) for pointers with small offsets
125    in basic blocks.  */
126 #define TARGET_EP (target_flags & MASK_EP)
127
128 /* Whether to call out-of-line functions to save registers or not.  */
129 #define TARGET_PROLOG_FUNCTION (target_flags & MASK_PROLOG_FUNCTION)
130
131 #define TARGET_V850             ((target_flags & MASK_CPU) == MASK_V850)
132
133 /* Whether to emit 2 byte per entry or 4 byte per entry switch tables.  */
134 #define TARGET_BIG_SWITCH (target_flags & MASK_BIG_SWITCH)
135
136 /* General debug flag.  */
137 #define TARGET_DEBUG            (target_flags & MASK_DEBUG)
138 #define TARGET_V850E            ((target_flags & MASK_V850E) == MASK_V850E)
139
140 #define TARGET_US_BIT_SET       (target_flags & MASK_US_BIT_SET)
141
142 /* Whether to assume that the SLD.B and SLD.H instructions only have small
143    displacement fields, thus allowing the generated code to run on any of
144    the V850 range of processors.  */
145 #define TARGET_SMALL_SLD        (target_flags & MASK_SMALL_SLD)
146
147 /* True if callt will not be used for function prolog & epilog.  */
148 #define TARGET_DISABLE_CALLT    (target_flags & MASK_DISABLE_CALLT)
149
150 /* False if r2 and r5 can be used by the compiler.  True if r2
151    and r5 are to be fixed registers (for compatibility with GHS).  */
152 #define TARGET_NO_APP_REGS      (target_flags & MASK_NO_APP_REGS)
153
154 #define TARGET_STRICT_ALIGN     (target_flags & MASK_STRICT_ALIGN)
155
156 /* Macro to define tables used to set the flags.
157    This is a list in braces of pairs in braces,
158    each pair being { "NAME", VALUE }
159    where VALUE is the bits to set or minus the bits to clear.
160    An empty string NAME is used to identify the default VALUE.  */
161
162 #define TARGET_SWITCHES                                                 \
163   {{ "ghs",                      MASK_GHS, N_("Support Green Hills ABI") }, \
164    { "no-ghs",                  -MASK_GHS, "" },                        \
165    { "long-calls",               MASK_LONG_CALLS,                       \
166                                 N_("Prohibit PC relative function calls") },\
167    { "no-long-calls",           -MASK_LONG_CALLS, "" },                 \
168    { "ep",                       MASK_EP,                               \
169                                 N_("Reuse r30 on a per function basis") }, \
170    { "no-ep",                   -MASK_EP, "" },                         \
171    { "prolog-function",          MASK_PROLOG_FUNCTION,                  \
172                                 N_("Use stubs for function prologues") }, \
173    { "no-prolog-function",      -MASK_PROLOG_FUNCTION, "" },            \
174    { "space",                    MASK_EP | MASK_PROLOG_FUNCTION,        \
175                                 N_("Same as: -mep -mprolog-function") }, \
176    { "debug",                    MASK_DEBUG, N_("Enable backend debugging") }, \
177    { "v850",                     MASK_V850,                             \
178                                 N_("Compile for the v850 processor") }, \
179    { "v850",                     -(MASK_V850 ^ MASK_CPU), "" },         \
180    { "v850e",                    MASK_V850E, N_("Compile for v850e processor") }, \
181    { "v850e",                   -(MASK_V850E ^ MASK_CPU), "" }, /* Make sure that the other bits are cleared.  */ \
182    { "small-sld",                MASK_SMALL_SLD, N_("Enable the use of the short load instructions") }, \
183    { "no-small-sld",            -MASK_SMALL_SLD, "" },                  \
184    { "disable-callt",            MASK_DISABLE_CALLT,                    \
185                                 N_("Do not use the callt instruction") },   \
186    { "no-disable-callt",        -MASK_DISABLE_CALLT, "" },              \
187    { "US-bit-set",               (MASK_US_BIT_SET | MASK_US_MASK_SET), "" },    \
188    { "no-US-bit-set",           -MASK_US_BIT_SET, "" },                 \
189    { "no-US-bit-set",            MASK_US_MASK_SET, "" },                \
190    { "app-regs",                -MASK_NO_APP_REGS, ""  },               \
191    { "no-app-regs",              MASK_NO_APP_REGS,                      \
192                                 N_("Do not use registers r2 and r5") }, \
193    { "strict-align",             MASK_STRICT_ALIGN,                     \
194                                 N_("Enforce strict alignment") },       \
195    { "no-strict-align",         -MASK_STRICT_ALIGN, "" },               \
196    { "big-switch",               MASK_BIG_SWITCH,                       \
197                                 N_("Use 4 byte entries in switch tables") },\
198    { "",                         MASK_DEFAULT, ""}}
199
200 /* Information about the various small memory areas.  */
201 struct small_memory_info {
202   const char *name;
203   const char *value;
204   long max;
205   long physical_max;
206 };
207
208 enum small_memory_type {
209   /* tiny data area, using EP as base register */
210   SMALL_MEMORY_TDA = 0,
211   /* small data area using dp as base register */
212   SMALL_MEMORY_SDA,
213   /* zero data area using r0 as base register */
214   SMALL_MEMORY_ZDA,
215   SMALL_MEMORY_max
216 };
217
218 extern struct small_memory_info small_memory[(int)SMALL_MEMORY_max];
219
220 #define TARGET_OPTIONS                                                  \
221 {                                                                       \
222   { "tda=",     &small_memory[ (int)SMALL_MEMORY_TDA ].value,           \
223       N_("Set the max size of data eligible for the TDA area"), 0},     \
224   { "tda-",     &small_memory[ (int)SMALL_MEMORY_TDA ].value, "", 0},   \
225   { "sda=",     &small_memory[ (int)SMALL_MEMORY_SDA ].value,           \
226       N_("Set the max size of data eligible for the SDA area"), 0},     \
227   { "sda-",     &small_memory[ (int)SMALL_MEMORY_SDA ].value, "", 0},   \
228   { "zda=",     &small_memory[ (int)SMALL_MEMORY_ZDA ].value,           \
229       N_("Set the max size of data eligible for the ZDA area"), 0},     \
230   { "zda-",     &small_memory[ (int)SMALL_MEMORY_ZDA ].value, "", 0},   \
231 }
232
233 /* Sometimes certain combinations of command options do not make
234    sense on a particular target machine.  You can define a macro
235    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
236    defined, is executed once just after all the command options have
237    been parsed.
238
239    Don't use this macro to turn on various extra optimizations for
240    `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
241 #define OVERRIDE_OPTIONS override_options ()
242
243
244 /* Show we can debug even without a frame pointer.  */
245 #define CAN_DEBUG_WITHOUT_FP
246
247 /* Some machines may desire to change what optimizations are
248    performed for various optimization levels.   This macro, if
249    defined, is executed once just after the optimization level is
250    determined and before the remainder of the command options have
251    been parsed.  Values set in this macro are used as the default
252    values for the other command line options.
253
254    LEVEL is the optimization level specified; 2 if `-O2' is
255    specified, 1 if `-O' is specified, and 0 if neither is specified.
256
257    SIZE is nonzero if `-Os' is specified, 0 otherwise.  
258
259    You should not use this macro to change options that are not
260    machine-specific.  These should uniformly selected by the same
261    optimization level on all supported machines.  Use this macro to
262    enable machine-specific optimizations.
263
264    *Do not examine `write_symbols' in this macro!* The debugging
265    options are not supposed to alter the generated code. */
266
267 #define OPTIMIZATION_OPTIONS(LEVEL,SIZE)                                \
268 {                                                                       \
269   target_flags |= MASK_STRICT_ALIGN;                                    \
270   if (LEVEL)                                                            \
271     target_flags |= (MASK_EP | MASK_PROLOG_FUNCTION);                   \
272 }
273
274 \f
275 /* Target machine storage layout */
276
277 /* Define this if most significant bit is lowest numbered
278    in instructions that operate on numbered bit-fields.
279    This is not true on the NEC V850.  */
280 #define BITS_BIG_ENDIAN 0
281
282 /* Define this if most significant byte of a word is the lowest numbered.  */
283 /* This is not true on the NEC V850.  */
284 #define BYTES_BIG_ENDIAN 0
285
286 /* Define this if most significant word of a multiword number is lowest
287    numbered.
288    This is not true on the NEC V850.  */
289 #define WORDS_BIG_ENDIAN 0
290
291 /* Width of a word, in units (bytes).  */
292 #define UNITS_PER_WORD          4
293
294 /* Define this macro if it is advisable to hold scalars in registers
295    in a wider mode than that declared by the program.  In such cases,
296    the value is constrained to be within the bounds of the declared
297    type, but kept valid in the wider mode.  The signedness of the
298    extension may differ from that of the type.
299
300    Some simple experiments have shown that leaving UNSIGNEDP alone
301    generates the best overall code.  */
302
303 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE)  \
304   if (GET_MODE_CLASS (MODE) == MODE_INT \
305       && GET_MODE_SIZE (MODE) < 4)      \
306     { (MODE) = SImode; }
307
308 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
309 #define PARM_BOUNDARY           32
310
311 /* The stack goes in 32 bit lumps.  */
312 #define STACK_BOUNDARY          32
313
314 /* Allocation boundary (in *bits*) for the code of a function.
315    16 is the minimum boundary; 32 would give better performance.  */
316 #define FUNCTION_BOUNDARY 16
317
318 /* No data type wants to be aligned rounder than this.  */
319 #define BIGGEST_ALIGNMENT       32
320
321 /* Alignment of field after `int : 0' in a structure.  */
322 #define EMPTY_FIELD_BOUNDARY 32
323
324 /* No structure field wants to be aligned rounder than this.  */
325 #define BIGGEST_FIELD_ALIGNMENT 32
326
327 /* Define this if move instructions will actually fail to work
328    when given unaligned data.  */
329 #define STRICT_ALIGNMENT  TARGET_STRICT_ALIGN
330
331 /* Define this as 1 if `char' should by default be signed; else as 0.
332
333    On the NEC V850, loads do sign extension, so make this default. */
334 #define DEFAULT_SIGNED_CHAR 1
335 \f
336 /* Standard register usage.  */
337
338 /* Number of actual hardware registers.
339    The hardware registers are assigned numbers for the compiler
340    from 0 to just below FIRST_PSEUDO_REGISTER.
341
342    All registers that the compiler knows about must be given numbers,
343    even those that are not normally considered general registers.  */
344
345 #define FIRST_PSEUDO_REGISTER 34
346
347 /* 1 for registers that have pervasive standard uses
348    and are not available for the register allocator.  */
349
350 #define FIXED_REGISTERS \
351   { 1, 1, 0, 1, 1, 0, 0, 0, \
352     0, 0, 0, 0, 0, 0, 0, 0, \
353     0, 0, 0, 0, 0, 0, 0, 0, \
354     0, 0, 0, 0, 0, 0, 1, 0, \
355     1, 1}
356
357 /* 1 for registers not available across function calls.
358    These must include the FIXED_REGISTERS and also any
359    registers that can be used without being saved.
360    The latter must include the registers where values are returned
361    and the register where structure-value addresses are passed.
362    Aside from that, you can include as many other registers as you
363    like.  */
364
365 #define CALL_USED_REGISTERS \
366   { 1, 1, 0, 1, 1, 1, 1, 1, \
367     1, 1, 1, 1, 1, 1, 1, 1, \
368     1, 1, 1, 1, 0, 0, 0, 0, \
369     0, 0, 0, 0, 0, 0, 1, 1, \
370     1, 1}
371
372 /* List the order in which to allocate registers.  Each register must be
373    listed once, even those in FIXED_REGISTERS.
374
375    On the 850, we make the return registers first, then all of the volatile
376    registers, then the saved registers in reverse order to better save the
377    registers with an out of line function, and finally the fixed
378    registers.  */
379
380 #define REG_ALLOC_ORDER                                                 \
381 {                                                                       \
382   10, 11,                               /* return registers */          \
383   12, 13, 14, 15, 16, 17, 18, 19,       /* scratch registers */         \
384    6,  7,  8,  9, 31,                   /* argument registers */        \
385   29, 28, 27, 26, 25, 24, 23, 22,       /* saved registers */           \
386   21, 20,  2,                                                           \
387    0,  1,  3,  4,  5, 30, 32, 33        /* fixed registers */           \
388 }
389
390 /* If TARGET_NO_APP_REGS is not defined then add r2 and r5 to
391    the pool of fixed registers. See PR 14505. */
392 #define CONDITIONAL_REGISTER_USAGE  \
393 {                                                       \
394   if (TARGET_NO_APP_REGS)                               \
395     {                                                   \
396      fixed_regs[2] = 1;  call_used_regs[2] = 1;         \
397      fixed_regs[5] = 1;  call_used_regs[5] = 1;         \
398     }                                                   \
399 }
400
401 /* Return number of consecutive hard regs needed starting at reg REGNO
402    to hold something of mode MODE.
403
404    This is ordinarily the length in words of a value of mode MODE
405    but can be less for certain modes in special long registers.  */
406
407 #define HARD_REGNO_NREGS(REGNO, MODE)   \
408   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
409
410 /* Value is 1 if hard register REGNO can hold a value of machine-mode
411    MODE.  */
412
413 #define HARD_REGNO_MODE_OK(REGNO, MODE) \
414  ((((REGNO) & 1) == 0) || (GET_MODE_SIZE (MODE) <= 4))
415
416 /* Value is 1 if it is a good idea to tie two pseudo registers
417    when one has mode MODE1 and one has mode MODE2.
418    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
419    for any hard reg, then this must be 0 for correct output.  */
420 #define MODES_TIEABLE_P(MODE1, MODE2) \
421   (MODE1 == MODE2 || (GET_MODE_SIZE (MODE1) <= 4 && GET_MODE_SIZE (MODE2) <= 4))
422
423 \f
424 /* Define the classes of registers for register constraints in the
425    machine description.  Also define ranges of constants.
426
427    One of the classes must always be named ALL_REGS and include all hard regs.
428    If there is more than one class, another class must be named NO_REGS
429    and contain no registers.
430
431    The name GENERAL_REGS must be the name of a class (or an alias for
432    another name such as ALL_REGS).  This is the class of registers
433    that is allowed by "g" or "r" in a register constraint.
434    Also, registers outside this class are allocated only when
435    instructions express preferences for them.
436
437    The classes must be numbered in nondecreasing order; that is,
438    a larger-numbered class must never be contained completely
439    in a smaller-numbered class.
440
441    For any two classes, it is very desirable that there be another
442    class that represents their union.  */
443    
444 enum reg_class
445 {
446   NO_REGS, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
447 };
448
449 #define N_REG_CLASSES (int) LIM_REG_CLASSES
450
451 /* Give names of register classes as strings for dump file.   */
452
453 #define REG_CLASS_NAMES \
454 { "NO_REGS", "GENERAL_REGS", "ALL_REGS", "LIM_REGS" }
455
456 /* Define which registers fit in which classes.
457    This is an initializer for a vector of HARD_REG_SET
458    of length N_REG_CLASSES.  */
459
460 #define REG_CLASS_CONTENTS              \
461 {                                       \
462   { 0x00000000 }, /* NO_REGS      */    \
463   { 0xffffffff }, /* GENERAL_REGS */    \
464   { 0xffffffff }, /* ALL_REGS   */      \
465 }
466
467 /* The same information, inverted:
468    Return the class number of the smallest class containing
469    reg number REGNO.  This could be a conditional expression
470    or could index an array.  */
471
472 #define REGNO_REG_CLASS(REGNO)  GENERAL_REGS
473
474 /* The class value for index registers, and the one for base regs.  */
475
476 #define INDEX_REG_CLASS NO_REGS
477 #define BASE_REG_CLASS  GENERAL_REGS
478
479 /* Get reg_class from a letter such as appears in the machine description.  */
480
481 #define REG_CLASS_FROM_LETTER(C) (NO_REGS)
482
483 /* Macros to check register numbers against specific register classes.  */
484
485 /* These assume that REGNO is a hard or pseudo reg number.
486    They give nonzero only if REGNO is a hard reg of the suitable class
487    or a pseudo reg currently allocated to a suitable hard reg.
488    Since they use reg_renumber, they are safe only once reg_renumber
489    has been allocated, which happens in local-alloc.c.  */
490  
491 #define REGNO_OK_FOR_BASE_P(regno) \
492   ((regno) < FIRST_PSEUDO_REGISTER || reg_renumber[regno] >= 0)
493
494 #define REGNO_OK_FOR_INDEX_P(regno) 0
495
496 /* Given an rtx X being reloaded into a reg required to be
497    in class CLASS, return the class of reg to actually use.
498    In general this is just CLASS; but on some machines
499    in some cases it is preferable to use a more restrictive class.  */
500
501 #define PREFERRED_RELOAD_CLASS(X,CLASS)  (CLASS)
502
503 /* Return the maximum number of consecutive registers
504    needed to represent mode MODE in a register of class CLASS.  */
505
506 #define CLASS_MAX_NREGS(CLASS, MODE)    \
507   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
508
509 /* The letters I, J, K, L, M, N, O, P in a register constraint string
510    can be used to stand for particular ranges of immediate operands.
511    This macro defines what the ranges are.
512    C is the letter, and VALUE is a constant value.
513    Return 1 if VALUE is in the range specified by C.  */
514
515 #define INT_7_BITS(VALUE) ((unsigned) (VALUE) + 0x40 < 0x80)
516 #define INT_8_BITS(VALUE) ((unsigned) (VALUE) + 0x80 < 0x100)
517 /* zero */
518 #define CONST_OK_FOR_I(VALUE) ((VALUE) == 0)
519 /* 5 bit signed immediate */
520 #define CONST_OK_FOR_J(VALUE) ((unsigned) (VALUE) + 0x10 < 0x20)
521 /* 16 bit signed immediate */
522 #define CONST_OK_FOR_K(VALUE) ((unsigned) (VALUE) + 0x8000 < 0x10000)
523 /* valid constant for movhi instruction.  */
524 #define CONST_OK_FOR_L(VALUE) \
525   (((unsigned) ((int) (VALUE) >> 16) + 0x8000 < 0x10000) \
526    && CONST_OK_FOR_I ((VALUE & 0xffff)))
527 /* 16 bit unsigned immediate */
528 #define CONST_OK_FOR_M(VALUE) ((unsigned)(VALUE) < 0x10000)
529 /* 5 bit unsigned immediate in shift instructions */
530 #define CONST_OK_FOR_N(VALUE) ((unsigned) (VALUE) <= 31)
531 /* 9 bit signed immediate for word multiply instruction.  */
532 #define CONST_OK_FOR_O(VALUE) ((unsigned) (VALUE) + 0x100 < 0x200)
533
534 #define CONST_OK_FOR_P(VALUE) 0
535
536 #define CONST_OK_FOR_LETTER_P(VALUE, C)  \
537   ((C) == 'I' ? CONST_OK_FOR_I (VALUE) : \
538    (C) == 'J' ? CONST_OK_FOR_J (VALUE) : \
539    (C) == 'K' ? CONST_OK_FOR_K (VALUE) : \
540    (C) == 'L' ? CONST_OK_FOR_L (VALUE) : \
541    (C) == 'M' ? CONST_OK_FOR_M (VALUE) : \
542    (C) == 'N' ? CONST_OK_FOR_N (VALUE) : \
543    (C) == 'O' ? CONST_OK_FOR_O (VALUE) : \
544    (C) == 'P' ? CONST_OK_FOR_P (VALUE) : \
545    0)
546
547 /* Similar, but for floating constants, and defining letters G and H.
548    Here VALUE is the CONST_DOUBLE rtx itself. 
549      
550   `G' is a zero of some form.  */
551
552 #define CONST_DOUBLE_OK_FOR_G(VALUE)                                    \
553   ((GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_FLOAT                     \
554     && (VALUE) == CONST0_RTX (GET_MODE (VALUE)))                        \
555    || (GET_MODE_CLASS (GET_MODE (VALUE)) == MODE_INT                    \
556        && CONST_DOUBLE_LOW (VALUE) == 0                                 \
557        && CONST_DOUBLE_HIGH (VALUE) == 0))
558
559 #define CONST_DOUBLE_OK_FOR_H(VALUE) 0
560
561 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)                          \
562   ((C) == 'G'   ? CONST_DOUBLE_OK_FOR_G (VALUE)                         \
563    : (C) == 'H' ? CONST_DOUBLE_OK_FOR_H (VALUE)                         \
564    : 0)
565
566 \f
567 /* Stack layout; function entry, exit and calling.  */
568
569 /* Define this if pushing a word on the stack
570    makes the stack pointer a smaller address.  */
571
572 #define STACK_GROWS_DOWNWARD
573
574 /* Define this if the nominal address of the stack frame
575    is at the high-address end of the local variables;
576    that is, each additional local variable allocated
577    goes at a more negative offset in the frame.  */
578
579 #define FRAME_GROWS_DOWNWARD
580
581 /* Offset within stack frame to start allocating local variables at.
582    If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
583    first local allocated.  Otherwise, it is the offset to the BEGINNING
584    of the first local allocated.  */
585
586 #define STARTING_FRAME_OFFSET 0
587
588 /* Offset of first parameter from the argument pointer register value.  */
589 /* Is equal to the size of the saved fp + pc, even if an fp isn't
590    saved since the value is used before we know.  */
591
592 #define FIRST_PARM_OFFSET(FNDECL) 0
593
594 /* Specify the registers used for certain standard purposes.
595    The values of these macros are register numbers.  */
596
597 /* Register to use for pushing function arguments.  */
598 #define STACK_POINTER_REGNUM 3
599
600 /* Base register for access to local variables of the function.  */
601 #define FRAME_POINTER_REGNUM 32
602
603 /* Register containing return address from latest function call.  */
604 #define LINK_POINTER_REGNUM 31
605      
606 /* On some machines the offset between the frame pointer and starting
607    offset of the automatic variables is not known until after register
608    allocation has been done (for example, because the saved registers
609    are between these two locations).  On those machines, define
610    `FRAME_POINTER_REGNUM' the number of a special, fixed register to
611    be used internally until the offset is known, and define
612    `HARD_FRAME_POINTER_REGNUM' to be actual the hard register number
613    used for the frame pointer.
614
615    You should define this macro only in the very rare circumstances
616    when it is not possible to calculate the offset between the frame
617    pointer and the automatic variables until after register
618    allocation has been completed.  When this macro is defined, you
619    must also indicate in your definition of `ELIMINABLE_REGS' how to
620    eliminate `FRAME_POINTER_REGNUM' into either
621    `HARD_FRAME_POINTER_REGNUM' or `STACK_POINTER_REGNUM'.
622
623    Do not define this macro if it would be the same as
624    `FRAME_POINTER_REGNUM'. */
625 #undef  HARD_FRAME_POINTER_REGNUM 
626 #define HARD_FRAME_POINTER_REGNUM 29
627
628 /* Base register for access to arguments of the function.  */
629 #define ARG_POINTER_REGNUM 33
630
631 /* Register in which static-chain is passed to a function.  */
632 #define STATIC_CHAIN_REGNUM 20
633
634 /* Value should be nonzero if functions must have frame pointers.
635    Zero means the frame pointer need not be set up (and parms
636    may be accessed via the stack pointer) in functions that seem suitable.
637    This is computed in `reload', in reload1.c.  */
638 #define FRAME_POINTER_REQUIRED 0
639
640 /* If defined, this macro specifies a table of register pairs used to
641    eliminate unneeded registers that point into the stack frame.  If
642    it is not defined, the only elimination attempted by the compiler
643    is to replace references to the frame pointer with references to
644    the stack pointer.
645
646    The definition of this macro is a list of structure
647    initializations, each of which specifies an original and
648    replacement register.
649
650    On some machines, the position of the argument pointer is not
651    known until the compilation is completed.  In such a case, a
652    separate hard register must be used for the argument pointer.
653    This register can be eliminated by replacing it with either the
654    frame pointer or the argument pointer, depending on whether or not
655    the frame pointer has been eliminated.
656
657    In this case, you might specify:
658         #define ELIMINABLE_REGS  \
659         {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
660          {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
661          {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
662
663    Note that the elimination of the argument pointer with the stack
664    pointer is specified first since that is the preferred elimination. */
665
666 #define ELIMINABLE_REGS                                                 \
667 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },                        \
668  { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM },                   \
669  { ARG_POINTER_REGNUM,   STACK_POINTER_REGNUM },                        \
670  { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM }}                   \
671
672 /* A C expression that returns nonzero if the compiler is allowed to
673    try to replace register number FROM-REG with register number
674    TO-REG.  This macro need only be defined if `ELIMINABLE_REGS' is
675    defined, and will usually be the constant 1, since most of the
676    cases preventing register elimination are things that the compiler
677    already knows about. */
678
679 #define CAN_ELIMINATE(FROM, TO) \
680  ((TO) == STACK_POINTER_REGNUM ? ! frame_pointer_needed : 1)
681
682 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It
683    specifies the initial difference between the specified pair of
684    registers.  This macro must be defined if `ELIMINABLE_REGS' is
685    defined. */
686
687 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET)                    \
688 {                                                                       \
689   if ((FROM) == FRAME_POINTER_REGNUM)                                   \
690     (OFFSET) = get_frame_size () + current_function_outgoing_args_size; \
691   else if ((FROM) == ARG_POINTER_REGNUM)                                \
692    (OFFSET) = compute_frame_size (get_frame_size (), (long *)0);        \
693   else                                                                  \
694     abort ();                                                           \
695 }
696
697 /* A guess for the V850.  */
698 #define PROMOTE_PROTOTYPES 1
699
700 /* Keep the stack pointer constant throughout the function.  */
701 #define ACCUMULATE_OUTGOING_ARGS 1
702
703 /* Value is the number of bytes of arguments automatically
704    popped when returning from a subroutine call.
705    FUNDECL is the declaration node of the function (as a tree),
706    FUNTYPE is the data type of the function (as a tree),
707    or for a library call it is an identifier node for the subroutine name.
708    SIZE is the number of bytes of arguments passed on the stack.  */
709
710 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
711
712 #define RETURN_ADDR_RTX(COUNT, FP) v850_return_addr (COUNT)
713 \f
714 /* Define a data type for recording info about an argument list
715    during the scan of that argument list.  This data type should
716    hold all necessary information about the function itself
717    and about the args processed so far, enough to enable macros
718    such as FUNCTION_ARG to determine where the next arg should go.  */
719
720 #define CUMULATIVE_ARGS struct cum_arg
721 struct cum_arg { int nbytes; int anonymous_args; };
722
723 /* Define where to put the arguments to a function.
724    Value is zero to push the argument on the stack,
725    or a hard register in which to store the argument.
726
727    MODE is the argument's machine mode.
728    TYPE is the data type of the argument (as a tree).
729     This is null for libcalls where that information may
730     not be available.
731    CUM is a variable of type CUMULATIVE_ARGS which gives info about
732     the preceding args and about the function being called.
733    NAMED is nonzero if this argument is a named parameter
734     (otherwise it is an extra parameter matching an ellipsis).  */
735
736 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
737   function_arg (&CUM, MODE, TYPE, NAMED)
738
739 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
740   function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
741
742 /* Initialize a variable CUM of type CUMULATIVE_ARGS
743    for a call to a function whose data type is FNTYPE.
744    For a library call, FNTYPE is 0.  */
745
746 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT)       \
747  ((CUM).nbytes = 0, (CUM).anonymous_args = 0)
748
749 /* Update the data in CUM to advance over an argument
750    of mode MODE and data type TYPE.
751    (TYPE is null for libcalls where that information may not be available.)  */
752
753 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)    \
754  ((CUM).nbytes += ((MODE) != BLKmode                    \
755   ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD       \
756   : (int_size_in_bytes (TYPE) + UNITS_PER_WORD - 1) & -UNITS_PER_WORD))
757
758 /* When a parameter is passed in a register, stack space is still
759    allocated for it.  */
760 #define REG_PARM_STACK_SPACE(DECL) (!TARGET_GHS ? 16 : 0)
761
762 /* Define this if the above stack space is to be considered part of the
763    space allocated by the caller.  */
764 #define OUTGOING_REG_PARM_STACK_SPACE
765
766 /* Do any setup necessary for varargs/stdargs functions.  */
767 #define SETUP_INCOMING_VARARGS(CUM, MODE, TYPE, PAS, SECOND) \
768   (CUM).anonymous_args = (!TARGET_GHS ? 1 : 0);
769
770 /* Implement `va_arg'.  */
771 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
772   v850_va_arg (valist, type)
773
774 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED)          \
775   ((TYPE) && int_size_in_bytes (TYPE) > 8)
776  
777 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \
778   ((TYPE) && int_size_in_bytes (TYPE) > 8)
779
780 /* 1 if N is a possible register number for function argument passing.  */
781
782 #define FUNCTION_ARG_REGNO_P(N) (N >= 6 && N <= 9)
783
784 /* Define how to find the value returned by a function.
785    VALTYPE is the data type of the value (as a tree).
786    If the precise function being called is known, FUNC is its FUNCTION_DECL;
787    otherwise, FUNC is 0.   */
788    
789 #define FUNCTION_VALUE(VALTYPE, FUNC) \
790   gen_rtx_REG (TYPE_MODE (VALTYPE), 10)
791
792 /* Define how to find the value returned by a library function
793    assuming the value has mode MODE.  */
794
795 #define LIBCALL_VALUE(MODE) \
796   gen_rtx_REG (MODE, 10)
797
798 /* 1 if N is a possible register number for a function value.  */
799
800 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 10)
801
802 /* Return values > 8 bytes in length in memory.  */
803 #define DEFAULT_PCC_STRUCT_RETURN 0
804 #define RETURN_IN_MEMORY(TYPE)  \
805   (int_size_in_bytes (TYPE) > 8 || TYPE_MODE (TYPE) == BLKmode)
806
807 /* Register in which address to store a structure value
808    is passed to a function.  On the V850 it's passed as
809    the first parameter.  */
810
811 #define STRUCT_VALUE 0
812
813 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
814    the stack pointer does not matter.  The value is tested only in
815    functions that have frame pointers.
816    No definition is equivalent to always zero.  */
817
818 #define EXIT_IGNORE_STACK 1
819
820 /* Define this macro as a C expression that is nonzero for registers
821    used by the epilogue or the `return' pattern.  */
822
823 #define EPILOGUE_USES(REGNO) \
824   (reload_completed && (REGNO) == LINK_POINTER_REGNUM)
825
826 /* Output assembler code to FILE to increment profiler label # LABELNO
827    for profiling a function entry.  */
828
829 #define FUNCTION_PROFILER(FILE, LABELNO) ;
830
831 #define TRAMPOLINE_TEMPLATE(FILE)                       \
832   do {                                                  \
833     fprintf (FILE, "\tjarl .+4,r12\n");                 \
834     fprintf (FILE, "\tld.w 12[r12],r20\n");             \
835     fprintf (FILE, "\tld.w 16[r12],r12\n");             \
836     fprintf (FILE, "\tjmp [r12]\n");                    \
837     fprintf (FILE, "\tnop\n");                          \
838     fprintf (FILE, "\t.long 0\n");                      \
839     fprintf (FILE, "\t.long 0\n");                      \
840   } while (0)
841
842 /* Length in units of the trampoline for entering a nested function.  */
843
844 #define TRAMPOLINE_SIZE 24
845
846 /* Emit RTL insns to initialize the variable parts of a trampoline.
847    FNADDR is an RTX for the address of the function's pure code.
848    CXT is an RTX for the static chain value for the function.  */
849
850 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
851 {                                                                       \
852   emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 16)),    \
853                  (CXT));                                                \
854   emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 20)),    \
855                  (FNADDR));                                             \
856 }
857
858 /* Addressing modes, and classification of registers for them.  */
859
860 \f
861 /* 1 if X is an rtx for a constant that is a valid address.  */
862
863 /* ??? This seems too exclusive.  May get better code by accepting more
864    possibilities here, in particular, should accept ZDA_NAME SYMBOL_REFs.  */
865
866 #define CONSTANT_ADDRESS_P(X)   \
867   (GET_CODE (X) == CONST_INT                            \
868    && CONST_OK_FOR_K (INTVAL (X)))
869
870 /* Maximum number of registers that can appear in a valid memory address.  */
871
872 #define MAX_REGS_PER_ADDRESS 1
873
874 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
875    and check its validity for a certain class.
876    We have two alternate definitions for each of them.
877    The usual definition accepts all pseudo regs; the other rejects
878    them unless they have been allocated suitable hard regs.
879    The symbol REG_OK_STRICT causes the latter definition to be used.
880
881    Most source files want to accept pseudo regs in the hope that
882    they will get allocated to the class that the insn wants them to be in.
883    Source files for reload pass need to be strict.
884    After reload, it makes no difference, since pseudo regs have
885    been eliminated by then.  */
886
887 #ifndef REG_OK_STRICT
888
889 /* Nonzero if X is a hard reg that can be used as an index
890    or if it is a pseudo reg.  */
891 #define REG_OK_FOR_INDEX_P(X) 0
892 /* Nonzero if X is a hard reg that can be used as a base reg
893    or if it is a pseudo reg.  */
894 #define REG_OK_FOR_BASE_P(X) 1
895 #define REG_OK_FOR_INDEX_P_STRICT(X) 0
896 #define REG_OK_FOR_BASE_P_STRICT(X) REGNO_OK_FOR_BASE_P (REGNO (X))
897 #define STRICT 0
898
899 #else
900
901 /* Nonzero if X is a hard reg that can be used as an index.  */
902 #define REG_OK_FOR_INDEX_P(X) 0
903 /* Nonzero if X is a hard reg that can be used as a base reg.  */
904 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
905 #define STRICT 1
906
907 #endif
908
909 /* A C expression that defines the optional machine-dependent
910    constraint letters that can be used to segregate specific types of
911    operands, usually memory references, for the target machine.
912    Normally this macro will not be defined.  If it is required for a
913    particular target machine, it should return 1 if VALUE corresponds
914    to the operand type represented by the constraint letter C.  If C
915    is not defined as an extra constraint, the value returned should
916    be 0 regardless of VALUE.
917
918    For example, on the ROMP, load instructions cannot have their
919    output in r0 if the memory reference contains a symbolic address.
920    Constraint letter `Q' is defined as representing a memory address
921    that does *not* contain a symbolic address.  An alternative is
922    specified with a `Q' constraint on the input and `r' on the
923    output.  The next alternative specifies `m' on the input and a
924    register class that does not include r0 on the output.  */
925
926 #define EXTRA_CONSTRAINT(OP, C)                                         \
927  ((C) == 'Q'   ? ep_memory_operand (OP, GET_MODE (OP), 0)               \
928   : (C) == 'R' ? special_symbolref_operand (OP, VOIDmode)               \
929   : (C) == 'S' ? (GET_CODE (OP) == SYMBOL_REF                           \
930                   && !SYMBOL_REF_ZDA_P (OP))                            \
931   : (C) == 'T' ? ep_memory_operand(OP,GET_MODE(OP),TRUE)                \
932   : (C) == 'U' ? ((GET_CODE (OP) == SYMBOL_REF                          \
933                    && SYMBOL_REF_ZDA_P (OP))                            \
934                   || (GET_CODE (OP) == CONST                            \
935                       && GET_CODE (XEXP (OP, 0)) == PLUS                \
936                       && GET_CODE (XEXP (XEXP (OP, 0), 0)) == SYMBOL_REF \
937                       && SYMBOL_REF_ZDA_P (XEXP (XEXP (OP, 0), 0))))    \
938   : 0)
939 \f
940 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
941    that is a valid memory address for an instruction.
942    The MODE argument is the machine mode for the MEM expression
943    that wants to use this address.
944
945    The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS,
946    except for CONSTANT_ADDRESS_P which is actually
947    machine-independent.  */
948
949 /* Accept either REG or SUBREG where a register is valid.  */
950   
951 #define RTX_OK_FOR_BASE_P(X)                                            \
952   ((REG_P (X) && REG_OK_FOR_BASE_P (X))                                 \
953    || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X))                 \
954        && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
955
956 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR)                         \
957 do {                                                                    \
958   if (RTX_OK_FOR_BASE_P (X)) goto ADDR;                                 \
959   if (CONSTANT_ADDRESS_P (X)                                            \
960       && (MODE == QImode || INTVAL (X) % 2 == 0)                        \
961       && (GET_MODE_SIZE (MODE) <= 4 || INTVAL (X) % 4 == 0))            \
962     goto ADDR;                                                          \
963   if (GET_CODE (X) == LO_SUM                                            \
964       && GET_CODE (XEXP (X, 0)) == REG                                  \
965       && REG_OK_FOR_BASE_P (XEXP (X, 0))                                \
966       && CONSTANT_P (XEXP (X, 1))                                       \
967       && (GET_CODE (XEXP (X, 1)) != CONST_INT                           \
968           || ((MODE == QImode || INTVAL (XEXP (X, 1)) % 2 == 0)         \
969               && CONST_OK_FOR_K (INTVAL (XEXP (X, 1)))))                \
970       && GET_MODE_SIZE (MODE) <= GET_MODE_SIZE (word_mode))             \
971     goto ADDR;                                                          \
972   if (special_symbolref_operand (X, MODE)                               \
973       && (GET_MODE_SIZE (MODE) <= GET_MODE_SIZE (word_mode)))           \
974      goto ADDR;                                                         \
975   if (GET_CODE (X) == PLUS                                              \
976       && CONSTANT_ADDRESS_P (XEXP (X, 1))                               \
977       && (MODE == QImode || INTVAL (XEXP (X, 1)) % 2 == 0)              \
978       && RTX_OK_FOR_BASE_P (XEXP (X, 0))) goto ADDR;                    \
979 } while (0)
980
981 \f
982 /* Try machine-dependent ways of modifying an illegitimate address
983    to be legitimate.  If we find one, return the new, valid address.
984    This macro is used in only one place: `memory_address' in explow.c.
985
986    OLDX is the address as it was before break_out_memory_refs was called.
987    In some cases it is useful to look at this to decide what needs to be done.
988
989    MODE and WIN are passed so that this macro can use
990    GO_IF_LEGITIMATE_ADDRESS.
991
992    It is always safe for this macro to do nothing.  It exists to recognize
993    opportunities to optimize the output.   */
994
995 #define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN)  {}
996
997 /* Go to LABEL if ADDR (a legitimate address expression)
998    has an effect that depends on the machine mode it is used for.  */
999
1000 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)  {}
1001
1002 /* Nonzero if the constant value X is a legitimate general operand.
1003    It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.  */
1004
1005 #define LEGITIMATE_CONSTANT_P(X)                                        \
1006   (GET_CODE (X) == CONST_DOUBLE                                         \
1007    || !(GET_CODE (X) == CONST                                           \
1008         && GET_CODE (XEXP (X, 0)) == PLUS                               \
1009         && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF               \
1010         && GET_CODE (XEXP (XEXP (X, 0), 1)) == CONST_INT                \
1011         && ! CONST_OK_FOR_K (INTVAL (XEXP (XEXP (X, 0), 1)))))
1012
1013 /* In rare cases, correct code generation requires extra machine
1014    dependent processing between the second jump optimization pass and
1015    delayed branch scheduling.  On those machines, define this macro
1016    as a C statement to act on the code starting at INSN.  */
1017
1018 #define MACHINE_DEPENDENT_REORG(INSN) v850_reorg (INSN)
1019
1020 \f
1021 /* Tell final.c how to eliminate redundant test instructions.  */
1022
1023 /* Here we define machine-dependent flags and fields in cc_status
1024    (see `conditions.h').  No extra ones are needed for the VAX.  */
1025
1026 /* Store in cc_status the expressions
1027    that the condition codes will describe
1028    after execution of an instruction whose pattern is EXP.
1029    Do not alter them if the instruction would not alter the cc's.  */
1030
1031 #define CC_OVERFLOW_UNUSABLE 0x200
1032 #define CC_NO_CARRY CC_NO_OVERFLOW
1033 #define NOTICE_UPDATE_CC(EXP, INSN) notice_update_cc(EXP, INSN)
1034
1035 /* Nonzero if access to memory by bytes or half words is no faster
1036    than accessing full words.  */
1037 #define SLOW_BYTE_ACCESS 1
1038
1039 /* According expr.c, a value of around 6 should minimize code size, and
1040    for the V850 series, that's our primary concern.  */
1041 #define MOVE_RATIO 6
1042
1043 /* Indirect calls are expensive, never turn a direct call
1044    into an indirect call.  */
1045 #define NO_FUNCTION_CSE
1046
1047 /* The four different data regions on the v850.  */
1048 typedef enum 
1049 {
1050   DATA_AREA_NORMAL,
1051   DATA_AREA_SDA,
1052   DATA_AREA_TDA,
1053   DATA_AREA_ZDA
1054 } v850_data_area;
1055
1056 /* A list of names for sections other than the standard two, which are
1057    `in_text' and `in_data'.  You need not define this macro on a
1058    system with no other sections (that GCC needs to use).  */
1059 #undef  EXTRA_SECTIONS
1060 #define EXTRA_SECTIONS in_tdata, in_sdata, in_zdata, \
1061  in_rozdata, in_rosdata, in_sbss, in_zbss, in_zcommon, in_scommon
1062
1063 /* One or more functions to be defined in `varasm.c'.  These
1064    functions should do jobs analogous to those of `text_section' and
1065    `data_section', for your additional sections.  Do not define this
1066    macro if you do not define `EXTRA_SECTIONS'. */
1067 #undef  EXTRA_SECTION_FUNCTIONS
1068
1069 /* This could be done a lot more cleanly using ANSI C ... */
1070 #define EXTRA_SECTION_FUNCTIONS                                         \
1071 void                                                                    \
1072 sdata_section ()                                                        \
1073 {                                                                       \
1074   if (in_section != in_sdata)                                           \
1075     {                                                                   \
1076       fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP);             \
1077       in_section = in_sdata;                                            \
1078     }                                                                   \
1079 }                                                                       \
1080                                                                         \
1081 void                                                                    \
1082 rosdata_section ()                                                      \
1083 {                                                                       \
1084   if (in_section != in_rosdata)                                         \
1085     {                                                                   \
1086       fprintf (asm_out_file, "%s\n", ROSDATA_SECTION_ASM_OP);           \
1087       in_section = in_sdata;                                            \
1088     }                                                                   \
1089 }                                                                       \
1090                                                                         \
1091 void                                                                    \
1092 sbss_section ()                                                         \
1093 {                                                                       \
1094   if (in_section != in_sbss)                                            \
1095     {                                                                   \
1096       fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP);              \
1097       in_section = in_sbss;                                             \
1098     }                                                                   \
1099 }                                                                       \
1100                                                                         \
1101 void                                                                    \
1102 tdata_section ()                                                        \
1103 {                                                                       \
1104   if (in_section != in_tdata)                                           \
1105     {                                                                   \
1106       fprintf (asm_out_file, "%s\n", TDATA_SECTION_ASM_OP);             \
1107       in_section = in_tdata;                                            \
1108     }                                                                   \
1109 }                                                                       \
1110                                                                         \
1111 void                                                                    \
1112 zdata_section ()                                                        \
1113 {                                                                       \
1114   if (in_section != in_zdata)                                           \
1115     {                                                                   \
1116       fprintf (asm_out_file, "%s\n", ZDATA_SECTION_ASM_OP);             \
1117       in_section = in_zdata;                                            \
1118     }                                                                   \
1119 }                                                                       \
1120                                                                         \
1121 void                                                                    \
1122 rozdata_section ()                                                      \
1123 {                                                                       \
1124   if (in_section != in_rozdata)                                         \
1125     {                                                                   \
1126       fprintf (asm_out_file, "%s\n", ROZDATA_SECTION_ASM_OP);           \
1127       in_section = in_rozdata;                                          \
1128     }                                                                   \
1129 }                                                                       \
1130                                                                         \
1131 void                                                                    \
1132 zbss_section ()                                                         \
1133 {                                                                       \
1134   if (in_section != in_zbss)                                            \
1135     {                                                                   \
1136       fprintf (asm_out_file, "%s\n", ZBSS_SECTION_ASM_OP);              \
1137       in_section = in_zbss;                                             \
1138     }                                                                   \
1139 }
1140
1141 #define TEXT_SECTION_ASM_OP  "\t.section .text"
1142 #define DATA_SECTION_ASM_OP  "\t.section .data"
1143 #define BSS_SECTION_ASM_OP   "\t.section .bss"
1144 #define SDATA_SECTION_ASM_OP "\t.section .sdata,\"aw\""
1145 #define SBSS_SECTION_ASM_OP  "\t.section .sbss,\"aw\""
1146 #define ZDATA_SECTION_ASM_OP "\t.section .zdata,\"aw\""
1147 #define ZBSS_SECTION_ASM_OP  "\t.section .zbss,\"aw\""
1148 #define TDATA_SECTION_ASM_OP "\t.section .tdata,\"aw\""
1149 #define ROSDATA_SECTION_ASM_OP "\t.section .rosdata,\"a\""
1150 #define ROZDATA_SECTION_ASM_OP "\t.section .rozdata,\"a\""
1151
1152 #define SCOMMON_ASM_OP         "\t.scomm\t"
1153 #define ZCOMMON_ASM_OP         "\t.zcomm\t"
1154 #define TCOMMON_ASM_OP         "\t.tcomm\t"
1155
1156 /* Output at beginning/end of assembler file.  */
1157 #undef ASM_FILE_START
1158 #define ASM_FILE_START(FILE) asm_file_start(FILE)
1159
1160 #define ASM_COMMENT_START "#"
1161
1162 /* Output to assembler file text saying following lines
1163    may contain character constants, extra white space, comments, etc.  */
1164
1165 #define ASM_APP_ON "#APP\n"
1166
1167 /* Output to assembler file text saying following lines
1168    no longer contain unusual constructs.  */
1169
1170 #define ASM_APP_OFF "#NO_APP\n"
1171
1172 #undef  USER_LABEL_PREFIX
1173 #define USER_LABEL_PREFIX "_"
1174
1175 #define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL)  \
1176   if (! v850_output_addr_const_extra (FILE, X)) \
1177      goto FAIL
1178
1179 /* This says how to output the assembler to define a global
1180    uninitialized but not common symbol.  */
1181
1182 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
1183   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
1184
1185 #undef  ASM_OUTPUT_ALIGNED_BSS 
1186 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
1187   v850_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
1188
1189 /* This says how to output the assembler to define a global
1190    uninitialized, common symbol. */
1191 #undef  ASM_OUTPUT_ALIGNED_COMMON
1192 #undef  ASM_OUTPUT_COMMON
1193 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
1194      v850_output_common (FILE, DECL, NAME, SIZE, ALIGN)
1195
1196 /* This says how to output the assembler to define a local
1197    uninitialized symbol. */
1198 #undef  ASM_OUTPUT_ALIGNED_LOCAL
1199 #undef  ASM_OUTPUT_LOCAL
1200 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
1201      v850_output_local (FILE, DECL, NAME, SIZE, ALIGN)
1202      
1203 /* Globalizing directive for a label.  */
1204 #define GLOBAL_ASM_OP "\t.global "
1205
1206 #define ASM_PN_FORMAT "%s___%lu"
1207
1208 /* This is how we tell the assembler that two symbols have the same value.  */
1209
1210 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
1211   do { assemble_name(FILE, NAME1);       \
1212        fputs(" = ", FILE);               \
1213        assemble_name(FILE, NAME2);       \
1214        fputc('\n', FILE); } while (0)
1215
1216
1217 /* How to refer to registers in assembler output.
1218    This sequence is indexed by compiler's hard-register-number (see above).  */
1219
1220 #define REGISTER_NAMES                                                  \
1221 {  "r0",  "r1",  "r2",  "sp",  "gp",  "r5",  "r6" , "r7",               \
1222    "r8",  "r9", "r10", "r11", "r12", "r13", "r14", "r15",               \
1223   "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",               \
1224   "r24", "r25", "r26", "r27", "r28", "r29",  "ep", "r31",               \
1225   ".fp", ".ap"}
1226
1227 #define ADDITIONAL_REGISTER_NAMES                                       \
1228 { { "zero",     0 },                                                    \
1229   { "hp",       2 },                                                    \
1230   { "r3",       3 },                                                    \
1231   { "r4",       4 },                                                    \
1232   { "tp",       5 },                                                    \
1233   { "fp",       29 },                                                   \
1234   { "r30",      30 },                                                   \
1235   { "lp",       31} }
1236
1237 /* Print an instruction operand X on file FILE.
1238    look in v850.c for details */
1239
1240 #define PRINT_OPERAND(FILE, X, CODE)  print_operand (FILE, X, CODE)
1241
1242 #define PRINT_OPERAND_PUNCT_VALID_P(CODE) \
1243   ((CODE) == '.')
1244
1245 /* Print a memory operand whose address is X, on file FILE.
1246    This uses a function in output-vax.c.  */
1247
1248 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
1249
1250 #define ASM_OUTPUT_REG_PUSH(FILE,REGNO)
1251 #define ASM_OUTPUT_REG_POP(FILE,REGNO)
1252
1253 /* This is how to output an element of a case-vector that is absolute.  */
1254
1255 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
1256   fprintf (FILE, "\t%s .L%d\n",                                 \
1257            (TARGET_BIG_SWITCH ? ".long" : ".short"), VALUE)
1258
1259 /* This is how to output an element of a case-vector that is relative.  */
1260
1261 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL)                \
1262   fprintf (FILE, "\t%s %s.L%d-.L%d%s\n",                                \
1263            (TARGET_BIG_SWITCH ? ".long" : ".short"),                    \
1264            (! TARGET_BIG_SWITCH && TARGET_V850E ? "(" : ""),            \
1265            VALUE, REL,                                                  \
1266            (! TARGET_BIG_SWITCH && TARGET_V850E ? ")>>1" : ""))
1267
1268 #define ASM_OUTPUT_ALIGN(FILE, LOG)     \
1269   if ((LOG) != 0)                       \
1270     fprintf (FILE, "\t.align %d\n", (LOG))
1271
1272 /* We don't have to worry about dbx compatibility for the v850.  */
1273 #define DEFAULT_GDB_EXTENSIONS 1
1274
1275 /* Use stabs debugging info by default.  */
1276 #undef PREFERRED_DEBUGGING_TYPE
1277 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
1278
1279 /* Specify the machine mode that this machine uses
1280    for the index in the tablejump instruction.  */
1281 #define CASE_VECTOR_MODE (TARGET_BIG_SWITCH ? SImode : HImode)
1282
1283 /* Define this if the case instruction drops through after the table
1284    when the index is out of range.  Don't define it if the case insn
1285    jumps to the default label instead.  */
1286 /* #define CASE_DROPS_THROUGH */
1287
1288 /* Define as C expression which evaluates to nonzero if the tablejump
1289    instruction expects the table to contain offsets from the address of the
1290    table.
1291    Do not define this if the table should contain absolute addresses. */
1292 #define CASE_VECTOR_PC_RELATIVE 1
1293
1294 /* The switch instruction requires that the jump table immediately follow
1295    it. */
1296 #define JUMP_TABLES_IN_TEXT_SECTION 1
1297
1298 /* svr4.h defines this assuming that 4 byte alignment is required.  */
1299 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
1300 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
1301   ASM_OUTPUT_ALIGN ((FILE), (TARGET_BIG_SWITCH ? 2 : 1));
1302
1303 #define WORD_REGISTER_OPERATIONS
1304
1305 /* Byte and short loads sign extend the value to a word.  */
1306 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
1307
1308 /* This flag, if defined, says the same insns that convert to a signed fixnum
1309    also convert validly to an unsigned one.  */
1310 #define FIXUNS_TRUNC_LIKE_FIX_TRUNC
1311
1312 /* Max number of bytes we can move from memory to memory
1313    in one reasonably fast instruction.  */
1314 #define MOVE_MAX        4
1315
1316 /* Define if shifts truncate the shift count
1317    which implies one can omit a sign-extension or zero-extension
1318    of a shift count.  */
1319 #define SHIFT_COUNT_TRUNCATED 1
1320
1321 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
1322    is done just by pretending it is already truncated.  */
1323 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
1324
1325 #define STORE_FLAG_VALUE 1
1326
1327 #define MULDI3_LIBCALL  "__muldi3"
1328 #define UCMPDI2_LIBCALL "__ucmpdi2"
1329 #define CMPDI2_LIBCALL  "__cmpdi2"
1330 #define NEGDI2_LIBCALL  "__negdi2"
1331
1332 #define INIT_TARGET_OPTABS                              \
1333   do                                                    \
1334     {                                                   \
1335       cmp_optab->handlers[(int) DImode].libfunc         \
1336         = init_one_libfunc (CMPDI2_LIBCALL);            \
1337       ucmp_optab->handlers[(int) DImode].libfunc        \
1338         = init_one_libfunc (UCMPDI2_LIBCALL);           \
1339       neg_optab->handlers[(int) DImode].libfunc         \
1340         = init_one_libfunc (NEGDI2_LIBCALL);            \
1341     }                                                   \
1342   while (0)
1343
1344 /* Specify the machine mode that pointers have.
1345    After generation of rtl, the compiler makes no further distinction
1346    between pointers and any other objects of this machine mode.  */
1347 #define Pmode SImode
1348
1349 /* A function address in a call instruction
1350    is a byte address (for indexing purposes)
1351    so give the MEM rtx a byte's mode.  */
1352 #define FUNCTION_MODE QImode
1353
1354 /* Tell compiler we want to support GHS pragmas */
1355 #define REGISTER_TARGET_PRAGMAS() do {                          \
1356   c_register_pragma ("ghs", "interrupt", ghs_pragma_interrupt); \
1357   c_register_pragma ("ghs", "section",   ghs_pragma_section);   \
1358   c_register_pragma ("ghs", "starttda",  ghs_pragma_starttda);  \
1359   c_register_pragma ("ghs", "startsda",  ghs_pragma_startsda);  \
1360   c_register_pragma ("ghs", "startzda",  ghs_pragma_startzda);  \
1361   c_register_pragma ("ghs", "endtda",    ghs_pragma_endtda);    \
1362   c_register_pragma ("ghs", "endsda",    ghs_pragma_endsda);    \
1363   c_register_pragma ("ghs", "endzda",    ghs_pragma_endzda);    \
1364 } while (0)
1365
1366 /* enum GHS_SECTION_KIND is an enumeration of the kinds of sections that
1367    can appear in the "ghs section" pragma.  These names are used to index
1368    into the GHS_default_section_names[] and GHS_current_section_names[]
1369    that are defined in v850.c, and so the ordering of each must remain
1370    consistant. 
1371
1372    These arrays give the default and current names for each kind of 
1373    section defined by the GHS pragmas.  The current names can be changed
1374    by the "ghs section" pragma.  If the current names are null, use 
1375    the default names.  Note that the two arrays have different types.
1376
1377    For the *normal* section kinds (like .data, .text, etc.) we do not
1378    want to explicitly force the name of these sections, but would rather
1379    let the linker (or at least the back end) choose the name of the 
1380    section, UNLESS the user has force a specific name for these section
1381    kinds.  To accomplish this set the name in ghs_default_section_names
1382    to null.  */
1383
1384 enum GHS_section_kind
1385
1386   GHS_SECTION_KIND_DEFAULT,
1387
1388   GHS_SECTION_KIND_TEXT,
1389   GHS_SECTION_KIND_DATA, 
1390   GHS_SECTION_KIND_RODATA,
1391   GHS_SECTION_KIND_BSS,
1392   GHS_SECTION_KIND_SDATA,
1393   GHS_SECTION_KIND_ROSDATA,
1394   GHS_SECTION_KIND_TDATA,
1395   GHS_SECTION_KIND_ZDATA,
1396   GHS_SECTION_KIND_ROZDATA,
1397
1398   COUNT_OF_GHS_SECTION_KINDS  /* must be last */
1399 };
1400
1401 /* The following code is for handling pragmas supported by the
1402    v850 compiler produced by Green Hills Software.  This is at
1403    the specific request of a customer.  */
1404
1405 typedef struct data_area_stack_element
1406 {
1407   struct data_area_stack_element * prev;
1408   v850_data_area                   data_area; /* Current default data area.  */
1409 } data_area_stack_element;
1410
1411 /* Track the current data area set by the
1412    data area pragma (which can be nested).  */
1413 extern data_area_stack_element * data_area_stack;
1414
1415 /* Names of the various data areas used on the v850.  */
1416 extern union tree_node * GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
1417 extern union tree_node * GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
1418
1419 /* The assembler op to start the file.  */
1420
1421 #define FILE_ASM_OP "\t.file\n"
1422
1423 /* Enable the register move pass to improve code.  */
1424 #define ENABLE_REGMOVE_PASS
1425
1426
1427 /* Implement ZDA, TDA, and SDA */
1428
1429 #define EP_REGNUM 30    /* ep register number */
1430
1431 #define SYMBOL_FLAG_ZDA         (SYMBOL_FLAG_MACH_DEP << 0)
1432 #define SYMBOL_FLAG_TDA         (SYMBOL_FLAG_MACH_DEP << 1)
1433 #define SYMBOL_FLAG_SDA         (SYMBOL_FLAG_MACH_DEP << 2)
1434 #define SYMBOL_REF_ZDA_P(X)     ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_ZDA) != 0)
1435 #define SYMBOL_REF_TDA_P(X)     ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_TDA) != 0)
1436 #define SYMBOL_REF_SDA_P(X)     ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_SDA) != 0)
1437
1438 /* Define this if you have defined special-purpose predicates in the
1439    file `MACHINE.c'.  This macro is called within an initializer of an
1440    array of structures.  The first field in the structure is the name
1441    of a predicate and the second field is an array of rtl codes.  For
1442    each predicate, list all rtl codes that can be in expressions
1443    matched by the predicate.  The list should have a trailing comma.  */
1444
1445 #define PREDICATE_CODES                                                 \
1446 { "reg_or_0_operand",           { REG, SUBREG, CONST_INT, CONST_DOUBLE }}, \
1447 { "reg_or_int5_operand",        { REG, SUBREG, CONST_INT }},            \
1448 { "reg_or_int9_operand",        { REG, SUBREG, CONST_INT }},            \
1449 { "reg_or_const_operand",       { REG, CONST_INT }},                    \
1450 { "call_address_operand",       { REG, SYMBOL_REF }},                   \
1451 { "movsi_source_operand",       { LABEL_REF, SYMBOL_REF, CONST_INT,     \
1452                                   CONST_DOUBLE, CONST, HIGH, MEM,       \
1453                                   REG, SUBREG }},                       \
1454 { "special_symbolref_operand",  { SYMBOL_REF }},                        \
1455 { "power_of_two_operand",       { CONST_INT }},                         \
1456 { "pattern_is_ok_for_prologue", { PARALLEL }},                          \
1457 { "pattern_is_ok_for_epilogue", { PARALLEL }},                          \
1458 { "register_is_ok_for_epilogue",{ REG }},                               \
1459 { "pattern_is_ok_for_dispose",  { PARALLEL }},                          \
1460 { "pattern_is_ok_for_prepare",  { PARALLEL }},                          \
1461 { "register_is_ok_for_dispose", { REG }},                               \
1462 { "not_power_of_two_operand",   { CONST_INT }},
1463   
1464 #endif /* ! GCC_V850_H */