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