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