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