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