OSDN Git Service

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