OSDN Git Service

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