OSDN Git Service

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