OSDN Git Service

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