* config/v850/v850-modes.def (CCZ, CCNZ): Add new modes.
[official-gcc.git] / gcc / config / v850 / v850.h
blob96bddc25801338e7453b6bba54c630ab91061eb6
1 /* Definitions of target machine for GNU compiler. NEC V850 series
2 Copyright (C) 1996-2018 Free Software Foundation, Inc.
3 Contributed by Jeff Law (law@cygnus.com).
5 This file is part of GCC.
7 GCC 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 3, or (at your option)
10 any later version.
12 GCC 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.
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 #ifndef GCC_V850_H
27 #define GCC_V850_H
29 extern GTY(()) rtx v850_compare_op0;
30 extern GTY(()) rtx v850_compare_op1;
32 #undef LIB_SPEC
33 #define LIB_SPEC "%{!shared:%{!symbolic:--start-group -lc -lgcc --end-group}}"
35 #undef ENDFILE_SPEC
36 #undef LINK_SPEC
37 #undef STARTFILE_SPEC
38 #undef ASM_SPEC
40 #define TARGET_CPU_generic 1
41 #define TARGET_CPU_v850e 2
42 #define TARGET_CPU_v850e1 3
43 #define TARGET_CPU_v850e2 4
44 #define TARGET_CPU_v850e2v3 5
45 #define TARGET_CPU_v850e3v5 6
47 #ifndef TARGET_CPU_DEFAULT
48 #define TARGET_CPU_DEFAULT TARGET_CPU_generic
49 #endif
51 #define MASK_DEFAULT MASK_V850
52 #define SUBTARGET_ASM_SPEC "%{!mv*:-mv850}"
53 #define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850__}"
55 /* Choose which processor will be the default.
56 We must pass a -mv850xx option to the assembler if no explicit -mv* option
57 is given, because the assembler's processor default may not be correct. */
58 #if TARGET_CPU_DEFAULT == TARGET_CPU_v850e
59 #undef MASK_DEFAULT
60 #define MASK_DEFAULT MASK_V850E
61 #undef SUBTARGET_ASM_SPEC
62 #define SUBTARGET_ASM_SPEC "%{!mv*:-mv850e}"
63 #undef SUBTARGET_CPP_SPEC
64 #define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850e__}"
65 #endif
67 #if TARGET_CPU_DEFAULT == TARGET_CPU_v850e1
68 #undef MASK_DEFAULT
69 #define MASK_DEFAULT MASK_V850E /* No practical difference. */
70 #undef SUBTARGET_ASM_SPEC
71 #define SUBTARGET_ASM_SPEC "%{!mv*:-mv850e1}"
72 #undef SUBTARGET_CPP_SPEC
73 #define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850e1__} %{mv850e1:-D__v850e1__}"
74 #endif
76 #if TARGET_CPU_DEFAULT == TARGET_CPU_v850e2
77 #undef MASK_DEFAULT
78 #define MASK_DEFAULT MASK_V850E2
79 #undef SUBTARGET_ASM_SPEC
80 #define SUBTARGET_ASM_SPEC "%{!mv*:-mv850e2}"
81 #undef SUBTARGET_CPP_SPEC
82 #define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850e2__} %{mv850e2:-D__v850e2__}"
83 #endif
85 #if TARGET_CPU_DEFAULT == TARGET_CPU_v850e2v3
86 #undef MASK_DEFAULT
87 #define MASK_DEFAULT MASK_V850E2V3
88 #undef SUBTARGET_ASM_SPEC
89 #define SUBTARGET_ASM_SPEC "%{!mv*:-mv850e2v3}"
90 #undef SUBTARGET_CPP_SPEC
91 #define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850e2v3__} %{mv850e2v3:-D__v850e2v3__}"
92 #endif
94 #if TARGET_CPU_DEFAULT == TARGET_CPU_v850e3v5
95 #undef MASK_DEFAULT
96 #define MASK_DEFAULT MASK_V850E3V5
97 #undef SUBTARGET_ASM_SPEC
98 #define SUBTARGET_ASM_SPEC "%{!mv*:-mv850e3v5}"
99 #undef SUBTARGET_CPP_SPEC
100 #define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850e3v5__} %{mv850e3v5:-D__v850e3v5__}"
101 #undef TARGET_VERSION
102 #define TARGET_VERSION fprintf (stderr, " (Renesas V850E3V5)");
103 #endif
105 #define TARGET_V850E3V5_UP ((TARGET_V850E3V5))
106 #define TARGET_V850E2V3_UP ((TARGET_V850E2V3) || TARGET_V850E3V5_UP)
107 #define TARGET_V850E2_UP ((TARGET_V850E2) || TARGET_V850E2V3_UP)
108 #define TARGET_V850E_UP ((TARGET_V850E) || TARGET_V850E2_UP)
109 #define TARGET_ALL ((TARGET_V850) || TARGET_V850E_UP)
111 #define ASM_SPEC "%{m850es:-mv850e1}%{!mv850es:%{mv*:-mv%*}} \
112 %{mrelax:-mrelax} \
113 %{m8byte-align:-m8byte-align} \
114 %{msoft-float:-msoft-float} \
115 %{mhard-float:-mhard-float} \
116 %{mgcc-abi:-mgcc-abi}"
118 #define LINK_SPEC "%{mgcc-abi:-m v850}"
120 #define CPP_SPEC "\
121 %{mv850e3v5:-D__v850e3v5__} \
122 %{mv850e2v3:-D__v850e2v3__} \
123 %{mv850e2:-D__v850e2__} \
124 %{mv850es:-D__v850e1__} \
125 %{mv850e1:-D__v850e1__} \
126 %{mv850e:-D__v850e__} \
127 %{mv850:-D__v850__} \
128 %(subtarget_cpp_spec) \
129 %{mep:-D__EP__}"
131 #define EXTRA_SPECS \
132 { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \
133 { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }
136 /* Macro to decide when FPU instructions can be used. */
137 #define TARGET_USE_FPU (TARGET_V850E2V3_UP && ! TARGET_SOFT_FLOAT)
139 #define TARGET_CPU_CPP_BUILTINS() \
140 do \
142 builtin_define( "__v851__" ); \
143 builtin_define( "__v850" ); \
144 builtin_define( "__v850__" ); \
145 builtin_assert( "machine=v850" ); \
146 builtin_assert( "cpu=v850" ); \
147 if (TARGET_EP) \
148 builtin_define ("__EP__"); \
149 if (TARGET_GCC_ABI) \
150 builtin_define ("__V850_GCC_ABI__"); \
151 else \
152 builtin_define ("__V850_RH850_ABI__"); \
153 if (! TARGET_DISABLE_CALLT) \
154 builtin_define ("__V850_CALLT__"); \
155 if (TARGET_8BYTE_ALIGN) \
156 builtin_define ("__V850_8BYTE_ALIGN__");\
157 builtin_define (TARGET_USE_FPU ? \
158 "__FPU_OK__" : "__NO_FPU__");\
160 while(0)
162 #define MASK_CPU (MASK_V850 | MASK_V850E | MASK_V850E1 | MASK_V850E2 | MASK_V850E2V3 | MASK_V850E3V5)
164 /* Target machine storage layout */
166 /* Define this if most significant bit is lowest numbered
167 in instructions that operate on numbered bit-fields.
168 This is not true on the NEC V850. */
169 #define BITS_BIG_ENDIAN 0
171 /* Define this if most significant byte of a word is the lowest numbered. */
172 /* This is not true on the NEC V850. */
173 #define BYTES_BIG_ENDIAN 0
175 /* Define this if most significant word of a multiword number is lowest
176 numbered.
177 This is not true on the NEC V850. */
178 #define WORDS_BIG_ENDIAN 0
180 /* Width of a word, in units (bytes). */
181 #define UNITS_PER_WORD 4
183 /* Define this macro if it is advisable to hold scalars in registers
184 in a wider mode than that declared by the program. In such cases,
185 the value is constrained to be within the bounds of the declared
186 type, but kept valid in the wider mode. The signedness of the
187 extension may differ from that of the type.
189 Some simple experiments have shown that leaving UNSIGNEDP alone
190 generates the best overall code. */
192 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
193 if (GET_MODE_CLASS (MODE) == MODE_INT \
194 && GET_MODE_SIZE (MODE) < 4) \
195 { (MODE) = SImode; }
197 /* Allocation boundary (in *bits*) for storing arguments in argument list. */
198 #define PARM_BOUNDARY 32
200 /* The stack goes in 32-bit lumps. */
201 #define STACK_BOUNDARY BIGGEST_ALIGNMENT
203 /* Allocation boundary (in *bits*) for the code of a function.
204 16 is the minimum boundary; 32 would give better performance. */
205 #define FUNCTION_BOUNDARY (((! TARGET_GCC_ABI) || optimize_size) ? 16 : 32)
207 /* No data type wants to be aligned rounder than this. */
208 #define BIGGEST_ALIGNMENT (TARGET_8BYTE_ALIGN ? 64 : 32)
210 /* Alignment of field after `int : 0' in a structure. */
211 #define EMPTY_FIELD_BOUNDARY 32
213 /* No structure field wants to be aligned rounder than this. */
214 #define BIGGEST_FIELD_ALIGNMENT BIGGEST_ALIGNMENT
216 /* Define this if move instructions will actually fail to work
217 when given unaligned data. */
218 #define STRICT_ALIGNMENT (!TARGET_NO_STRICT_ALIGN)
220 /* Define this as 1 if `char' should by default be signed; else as 0.
222 On the NEC V850, loads do sign extension, so make this default. */
223 #define DEFAULT_SIGNED_CHAR 1
225 #undef SIZE_TYPE
226 #define SIZE_TYPE "unsigned int"
228 #undef PTRDIFF_TYPE
229 #define PTRDIFF_TYPE "int"
231 #undef WCHAR_TYPE
232 #define WCHAR_TYPE "long int"
234 #undef WCHAR_TYPE_SIZE
235 #define WCHAR_TYPE_SIZE BITS_PER_WORD
237 /* Standard register usage. */
239 /* Number of actual hardware registers.
240 The hardware registers are assigned numbers for the compiler
241 from 0 to just below FIRST_PSEUDO_REGISTER.
243 All registers that the compiler knows about must be given numbers,
244 even those that are not normally considered general registers. */
246 #define FIRST_PSEUDO_REGISTER 36
248 /* 1 for registers that have pervasive standard uses
249 and are not available for the register allocator. */
251 #define FIXED_REGISTERS \
252 { 1, 1, 1, 1, 1, 1, 0, 0, \
253 0, 0, 0, 0, 0, 0, 0, 0, \
254 0, 0, 0, 0, 0, 0, 0, 0, \
255 0, 0, 0, 0, 0, 0, 1, 0, \
256 1, 1, \
257 1, 1}
259 /* 1 for registers not available across function calls.
260 These must include the FIXED_REGISTERS and also any
261 registers that can be used without being saved.
262 The latter must include the registers where values are returned
263 and the register where structure-value addresses are passed.
264 Aside from that, you can include as many other registers as you
265 like. */
267 #define CALL_USED_REGISTERS \
268 { 1, 1, 1, 1, 1, 1, 1, 1, \
269 1, 1, 1, 1, 1, 1, 1, 1, \
270 1, 1, 1, 1, 0, 0, 0, 0, \
271 0, 0, 0, 0, 0, 0, 1, 1, \
272 1, 1, \
273 1, 1}
275 /* List the order in which to allocate registers. Each register must be
276 listed once, even those in FIXED_REGISTERS.
278 On the 850, we make the return registers first, then all of the volatile
279 registers, then the saved registers in reverse order to better save the
280 registers with an out of line function, and finally the fixed
281 registers. */
283 #define REG_ALLOC_ORDER \
285 10, 11, /* return registers */ \
286 12, 13, 14, 15, 16, 17, 18, 19, /* scratch registers */ \
287 6, 7, 8, 9, 31, /* argument registers */ \
288 29, 28, 27, 26, 25, 24, 23, 22, /* saved registers */ \
289 21, 20, 2, \
290 0, 1, 3, 4, 5, 30, 32, 33, /* fixed registers */ \
291 34, 35 \
295 /* Define the classes of registers for register constraints in the
296 machine description. Also define ranges of constants.
298 One of the classes must always be named ALL_REGS and include all hard regs.
299 If there is more than one class, another class must be named NO_REGS
300 and contain no registers.
302 The name GENERAL_REGS must be the name of a class (or an alias for
303 another name such as ALL_REGS). This is the class of registers
304 that is allowed by "g" or "r" in a register constraint.
305 Also, registers outside this class are allocated only when
306 instructions express preferences for them.
308 The classes must be numbered in nondecreasing order; that is,
309 a larger-numbered class must never be contained completely
310 in a smaller-numbered class.
312 For any two classes, it is very desirable that there be another
313 class that represents their union. */
315 enum reg_class
317 NO_REGS, EVEN_REGS, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES
320 #define N_REG_CLASSES (int) LIM_REG_CLASSES
322 /* Give names of register classes as strings for dump file. */
324 #define REG_CLASS_NAMES \
325 { "NO_REGS", "EVEN_REGS", "GENERAL_REGS", "ALL_REGS", "LIM_REGS" }
327 /* Define which registers fit in which classes.
328 This is an initializer for a vector of HARD_REG_SET
329 of length N_REG_CLASSES. */
331 #define REG_CLASS_CONTENTS \
333 { 0x00000000,0x0 }, /* NO_REGS */ \
334 { 0x55555554,0x0 }, /* EVEN_REGS */ \
335 { 0xfffffffe,0x0 }, /* GENERAL_REGS */ \
336 { 0xffffffff,0x0 }, /* ALL_REGS */ \
339 /* The same information, inverted:
340 Return the class number of the smallest class containing
341 reg number REGNO. This could be a conditional expression
342 or could index an array. */
344 #define REGNO_REG_CLASS(REGNO) ((REGNO == CC_REGNUM || REGNO == FCC_REGNUM) ? NO_REGS : GENERAL_REGS)
346 /* The class value for index registers, and the one for base regs. */
348 #define INDEX_REG_CLASS NO_REGS
349 #define BASE_REG_CLASS GENERAL_REGS
351 /* Macros to check register numbers against specific register classes. */
353 /* These assume that REGNO is a hard or pseudo reg number.
354 They give nonzero only if REGNO is a hard reg of the suitable class
355 or a pseudo reg currently allocated to a suitable hard reg.
356 Since they use reg_renumber, they are safe only once reg_renumber
357 has been allocated, which happens in reginfo.c during register
358 allocation. */
360 #define REGNO_OK_FOR_BASE_P(regno) \
361 (((regno) < FIRST_PSEUDO_REGISTER \
362 && (regno) != CC_REGNUM \
363 && (regno) != FCC_REGNUM) \
364 || reg_renumber[regno] >= 0)
366 #define REGNO_OK_FOR_INDEX_P(regno) 0
368 /* Convenience wrappers around insn_const_int_ok_for_constraint. */
370 #define CONST_OK_FOR_I(VALUE) \
371 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_I)
372 #define CONST_OK_FOR_J(VALUE) \
373 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_J)
374 #define CONST_OK_FOR_K(VALUE) \
375 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_K)
376 #define CONST_OK_FOR_L(VALUE) \
377 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_L)
378 #define CONST_OK_FOR_M(VALUE) \
379 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_M)
380 #define CONST_OK_FOR_N(VALUE) \
381 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_N)
382 #define CONST_OK_FOR_O(VALUE) \
383 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_O)
384 #define CONST_OK_FOR_W(VALUE) \
385 insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_W)
387 /* Stack layout; function entry, exit and calling. */
389 /* Define this if pushing a word on the stack
390 makes the stack pointer a smaller address. */
392 #define STACK_GROWS_DOWNWARD 1
394 /* Define this to nonzero if the nominal address of the stack frame
395 is at the high-address end of the local variables;
396 that is, each additional local variable allocated
397 goes at a more negative offset in the frame. */
399 #define FRAME_GROWS_DOWNWARD 1
401 /* Offset of first parameter from the argument pointer register value. */
402 /* Is equal to the size of the saved fp + pc, even if an fp isn't
403 saved since the value is used before we know. */
405 #define FIRST_PARM_OFFSET(FNDECL) 0
407 /* Specify the registers used for certain standard purposes.
408 The values of these macros are register numbers. */
410 /* Register to use for pushing function arguments. */
411 #define STACK_POINTER_REGNUM SP_REGNUM
413 /* Base register for access to local variables of the function. */
414 #define FRAME_POINTER_REGNUM 34
416 /* Register containing return address from latest function call. */
417 #define LINK_POINTER_REGNUM LP_REGNUM
419 /* On some machines the offset between the frame pointer and starting
420 offset of the automatic variables is not known until after register
421 allocation has been done (for example, because the saved registers
422 are between these two locations). On those machines, define
423 `FRAME_POINTER_REGNUM' the number of a special, fixed register to
424 be used internally until the offset is known, and define
425 `HARD_FRAME_POINTER_REGNUM' to be actual the hard register number
426 used for the frame pointer.
428 You should define this macro only in the very rare circumstances
429 when it is not possible to calculate the offset between the frame
430 pointer and the automatic variables until after register
431 allocation has been completed. When this macro is defined, you
432 must also indicate in your definition of `ELIMINABLE_REGS' how to
433 eliminate `FRAME_POINTER_REGNUM' into either
434 `HARD_FRAME_POINTER_REGNUM' or `STACK_POINTER_REGNUM'.
436 Do not define this macro if it would be the same as
437 `FRAME_POINTER_REGNUM'. */
438 #undef HARD_FRAME_POINTER_REGNUM
439 #define HARD_FRAME_POINTER_REGNUM 29
441 /* Base register for access to arguments of the function. */
442 #define ARG_POINTER_REGNUM 35
444 /* Register in which static-chain is passed to a function. */
445 #define STATIC_CHAIN_REGNUM 20
447 /* If defined, this macro specifies a table of register pairs used to
448 eliminate unneeded registers that point into the stack frame. If
449 it is not defined, the only elimination attempted by the compiler
450 is to replace references to the frame pointer with references to
451 the stack pointer.
453 The definition of this macro is a list of structure
454 initializations, each of which specifies an original and
455 replacement register.
457 On some machines, the position of the argument pointer is not
458 known until the compilation is completed. In such a case, a
459 separate hard register must be used for the argument pointer.
460 This register can be eliminated by replacing it with either the
461 frame pointer or the argument pointer, depending on whether or not
462 the frame pointer has been eliminated.
464 In this case, you might specify:
465 #define ELIMINABLE_REGS \
466 {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
467 {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
468 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}
470 Note that the elimination of the argument pointer with the stack
471 pointer is specified first since that is the preferred elimination. */
473 #define ELIMINABLE_REGS \
474 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
475 { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
476 { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
477 { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }} \
479 /* This macro returns the initial difference between the specified pair
480 of registers. */
482 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
484 if ((FROM) == FRAME_POINTER_REGNUM) \
485 (OFFSET) = get_frame_size () + crtl->outgoing_args_size; \
486 else if ((FROM) == ARG_POINTER_REGNUM) \
487 (OFFSET) = compute_frame_size (get_frame_size (), (long *)0); \
488 else \
489 gcc_unreachable (); \
492 /* Keep the stack pointer constant throughout the function. */
493 #define ACCUMULATE_OUTGOING_ARGS 1
495 #define RETURN_ADDR_RTX(COUNT, FP) v850_return_addr (COUNT)
497 /* Define a data type for recording info about an argument list
498 during the scan of that argument list. This data type should
499 hold all necessary information about the function itself
500 and about the args processed so far, enough to enable macros
501 such as FUNCTION_ARG to determine where the next arg should go. */
503 #define CUMULATIVE_ARGS struct cum_arg
504 struct cum_arg { int nbytes; };
506 /* Initialize a variable CUM of type CUMULATIVE_ARGS
507 for a call to a function whose data type is FNTYPE.
508 For a library call, FNTYPE is 0. */
510 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
511 do { (CUM).nbytes = 0; } while (0)
513 /* When a parameter is passed in a register, stack space is still
514 allocated for it. */
515 #define REG_PARM_STACK_SPACE(DECL) 0
517 /* 1 if N is a possible register number for function argument passing. */
519 #define FUNCTION_ARG_REGNO_P(N) (N >= 6 && N <= 9)
521 #define DEFAULT_PCC_STRUCT_RETURN 0
523 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
524 the stack pointer does not matter. The value is tested only in
525 functions that have frame pointers.
526 No definition is equivalent to always zero. */
528 #define EXIT_IGNORE_STACK 1
530 /* Define this macro as a C expression that is nonzero for registers
531 used by the epilogue or the `return' pattern. */
533 #define EPILOGUE_USES(REGNO) \
534 (reload_completed && (REGNO) == LINK_POINTER_REGNUM)
536 /* Output assembler code to FILE to increment profiler label # LABELNO
537 for profiling a function entry. */
539 #define FUNCTION_PROFILER(FILE, LABELNO) ;
541 /* Length in units of the trampoline for entering a nested function. */
543 #define TRAMPOLINE_SIZE 24
545 /* Addressing modes, and classification of registers for them. */
548 /* 1 if X is an rtx for a constant that is a valid address. */
550 /* ??? This seems too exclusive. May get better code by accepting more
551 possibilities here, in particular, should accept ZDA_NAME SYMBOL_REFs. */
553 #define CONSTANT_ADDRESS_P(X) constraint_satisfied_p (X, CONSTRAINT_K)
555 /* Maximum number of registers that can appear in a valid memory address. */
557 #define MAX_REGS_PER_ADDRESS 1
559 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
560 return the mode to be used for the comparison.
562 For floating-point equality comparisons, CCFPEQmode should be used.
563 VOIDmode should be used in all other cases.
565 For integer comparisons against zero, reduce to CCNOmode or CCZmode if
566 possible, to allow for more combinations. */
568 #define SELECT_CC_MODE(OP, X, Y) v850_select_cc_mode (OP, X, Y)
570 #define NOTICE_UPDATE_CC(EXP, INSN)
572 /* Nonzero if access to memory by bytes or half words is no faster
573 than accessing full words. */
574 #define SLOW_BYTE_ACCESS 1
576 /* According expr.c, a value of around 6 should minimize code size, and
577 for the V850 series, that's our primary concern. */
578 #define MOVE_RATIO(speed) 6
580 /* Indirect calls are expensive, never turn a direct call
581 into an indirect call. */
582 #define NO_FUNCTION_CSE 1
584 /* The four different data regions on the v850. */
585 typedef enum
587 DATA_AREA_NORMAL,
588 DATA_AREA_SDA,
589 DATA_AREA_TDA,
590 DATA_AREA_ZDA
591 } v850_data_area;
593 #define TEXT_SECTION_ASM_OP "\t.section .text"
594 #define DATA_SECTION_ASM_OP "\t.section .data"
595 #define BSS_SECTION_ASM_OP "\t.section .bss"
596 #define SDATA_SECTION_ASM_OP "\t.section .sdata,\"aw\""
597 #define SBSS_SECTION_ASM_OP "\t.section .sbss,\"aw\""
599 #define SCOMMON_ASM_OP "\t.scomm\t"
600 #define ZCOMMON_ASM_OP "\t.zcomm\t"
601 #define TCOMMON_ASM_OP "\t.tcomm\t"
603 #define ASM_COMMENT_START "#"
605 /* Output to assembler file text saying following lines
606 may contain character constants, extra white space, comments, etc. */
608 #define ASM_APP_ON "#APP\n"
610 /* Output to assembler file text saying following lines
611 no longer contain unusual constructs. */
613 #define ASM_APP_OFF "#NO_APP\n"
615 #undef USER_LABEL_PREFIX
616 #define USER_LABEL_PREFIX "_"
618 /* This says how to output the assembler to define a global
619 uninitialized but not common symbol. */
621 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
622 asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
624 #undef ASM_OUTPUT_ALIGNED_BSS
625 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
626 v850_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
628 /* This says how to output the assembler to define a global
629 uninitialized, common symbol. */
630 #undef ASM_OUTPUT_ALIGNED_COMMON
631 #undef ASM_OUTPUT_COMMON
632 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
633 v850_output_common (FILE, DECL, NAME, SIZE, ALIGN)
635 /* This says how to output the assembler to define a local
636 uninitialized symbol. */
637 #undef ASM_OUTPUT_ALIGNED_LOCAL
638 #undef ASM_OUTPUT_LOCAL
639 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
640 v850_output_local (FILE, DECL, NAME, SIZE, ALIGN)
642 /* Globalizing directive for a label. */
643 #define GLOBAL_ASM_OP "\t.global "
645 #define ASM_PN_FORMAT "%s___%lu"
647 /* This is how we tell the assembler that two symbols have the same value. */
649 #define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
650 do { assemble_name(FILE, NAME1); \
651 fputs(" = ", FILE); \
652 assemble_name(FILE, NAME2); \
653 fputc('\n', FILE); } while (0)
656 /* How to refer to registers in assembler output.
657 This sequence is indexed by compiler's hard-register-number (see above). */
659 #define REGISTER_NAMES \
660 { "r0", "r1", "r2", "sp", "gp", "r5", "r6" , "r7", \
661 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
662 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
663 "r24", "r25", "r26", "r27", "r28", "r29", "ep", "r31", \
664 "psw", "fcc", \
665 ".fp", ".ap"}
667 /* Register numbers */
669 #define ADDITIONAL_REGISTER_NAMES \
670 { { "zero", ZERO_REGNUM }, \
671 { "hp", 2 }, \
672 { "r3", 3 }, \
673 { "r4", 4 }, \
674 { "tp", 5 }, \
675 { "fp", 29 }, \
676 { "r30", 30 }, \
677 { "lp", LP_REGNUM} }
679 /* This is how to output an element of a case-vector that is absolute. */
681 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
682 fprintf (FILE, "\t%s .L%d\n", \
683 (TARGET_BIG_SWITCH ? ".long" : ".short"), VALUE)
685 /* This is how to output an element of a case-vector that is relative. */
687 /* Disable the shift, which is for the currently disabled "switch"
688 opcode. Se casesi in v850.md. */
690 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
691 fprintf (FILE, "\t%s %s.L%d-.L%d%s\n", \
692 (TARGET_BIG_SWITCH ? ".long" : ".short"), \
693 (0 && ! TARGET_BIG_SWITCH && (TARGET_V850E_UP) ? "(" : ""), \
694 VALUE, REL, \
695 (0 && ! TARGET_BIG_SWITCH && (TARGET_V850E_UP) ? ")>>1" : ""))
697 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
698 if ((LOG) != 0) \
699 fprintf (FILE, "\t.align %d\n", (LOG))
701 /* We don't have to worry about dbx compatibility for the v850. */
702 #define DEFAULT_GDB_EXTENSIONS 1
704 /* Use dwarf2 debugging info by default. */
705 #undef PREFERRED_DEBUGGING_TYPE
706 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
708 #define DWARF2_FRAME_INFO 1
709 #define DWARF2_UNWIND_INFO 0
710 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_POINTER_REGNUM)
711 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LINK_POINTER_REGNUM)
713 #ifndef ASM_GENERATE_INTERNAL_LABEL
714 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
715 sprintf (STRING, "*.%s%u", PREFIX, (unsigned int)(NUM))
716 #endif
718 /* Specify the machine mode that this machine uses
719 for the index in the tablejump instruction. */
720 #define CASE_VECTOR_MODE (TARGET_BIG_SWITCH ? SImode : HImode)
722 /* Define as C expression which evaluates to nonzero if the tablejump
723 instruction expects the table to contain offsets from the address of the
724 table.
725 Do not define this if the table should contain absolute addresses. */
726 #define CASE_VECTOR_PC_RELATIVE 1
728 /* The switch instruction requires that the jump table immediately follow
729 it. */
730 #define JUMP_TABLES_IN_TEXT_SECTION (!TARGET_JUMP_TABLES_IN_DATA_SECTION)
732 #undef ASM_OUTPUT_BEFORE_CASE_LABEL
733 #define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE,PREFIX,NUM,TABLE) \
734 ASM_OUTPUT_ALIGN ((FILE), (TARGET_BIG_SWITCH ? 2 : 1))
736 #define WORD_REGISTER_OPERATIONS 1
738 /* Byte and short loads sign extend the value to a word. */
739 #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
741 /* Max number of bytes we can move from memory to memory
742 in one reasonably fast instruction. */
743 #define MOVE_MAX 4
745 /* Define if shifts truncate the shift count
746 which implies one can omit a sign-extension or zero-extension
747 of a shift count. */
748 #define SHIFT_COUNT_TRUNCATED 1
750 /* Specify the machine mode that pointers have.
751 After generation of rtl, the compiler makes no further distinction
752 between pointers and any other objects of this machine mode. */
753 #define Pmode SImode
755 /* A function address in a call instruction
756 is a byte address (for indexing purposes)
757 so give the MEM rtx a byte's mode. */
758 #define FUNCTION_MODE QImode
760 /* Tell compiler we want to support GHS pragmas */
761 #define REGISTER_TARGET_PRAGMAS() do { \
762 c_register_pragma ("ghs", "interrupt", ghs_pragma_interrupt); \
763 c_register_pragma ("ghs", "section", ghs_pragma_section); \
764 c_register_pragma ("ghs", "starttda", ghs_pragma_starttda); \
765 c_register_pragma ("ghs", "startsda", ghs_pragma_startsda); \
766 c_register_pragma ("ghs", "startzda", ghs_pragma_startzda); \
767 c_register_pragma ("ghs", "endtda", ghs_pragma_endtda); \
768 c_register_pragma ("ghs", "endsda", ghs_pragma_endsda); \
769 c_register_pragma ("ghs", "endzda", ghs_pragma_endzda); \
770 } while (0)
772 /* enum GHS_SECTION_KIND is an enumeration of the kinds of sections that
773 can appear in the "ghs section" pragma. These names are used to index
774 into the GHS_default_section_names[] and GHS_current_section_names[]
775 that are defined in v850.c, and so the ordering of each must remain
776 consistent.
778 These arrays give the default and current names for each kind of
779 section defined by the GHS pragmas. The current names can be changed
780 by the "ghs section" pragma. If the current names are null, use
781 the default names. Note that the two arrays have different types.
783 For the *normal* section kinds (like .data, .text, etc.) we do not
784 want to explicitly force the name of these sections, but would rather
785 let the linker (or at least the back end) choose the name of the
786 section, UNLESS the user has forced a specific name for these section
787 kinds. To accomplish this set the name in ghs_default_section_names
788 to null. */
790 enum GHS_section_kind
792 GHS_SECTION_KIND_DEFAULT,
794 GHS_SECTION_KIND_TEXT,
795 GHS_SECTION_KIND_DATA,
796 GHS_SECTION_KIND_RODATA,
797 GHS_SECTION_KIND_BSS,
798 GHS_SECTION_KIND_SDATA,
799 GHS_SECTION_KIND_ROSDATA,
800 GHS_SECTION_KIND_TDATA,
801 GHS_SECTION_KIND_ZDATA,
802 GHS_SECTION_KIND_ROZDATA,
804 COUNT_OF_GHS_SECTION_KINDS /* must be last */
807 /* The following code is for handling pragmas supported by the
808 v850 compiler produced by Green Hills Software. This is at
809 the specific request of a customer. */
811 typedef struct data_area_stack_element
813 struct data_area_stack_element * prev;
814 v850_data_area data_area; /* Current default data area. */
815 } data_area_stack_element;
817 /* Track the current data area set by the
818 data area pragma (which can be nested). */
819 extern data_area_stack_element * data_area_stack;
821 /* Names of the various data areas used on the v850. */
822 extern const char * GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
823 extern const char * GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
825 /* The assembler op to start the file. */
827 #define FILE_ASM_OP "\t.file\n"
829 /* Implement ZDA, TDA, and SDA */
831 #define EP_REGNUM 30 /* ep register number */
833 #define SYMBOL_FLAG_ZDA (SYMBOL_FLAG_MACH_DEP << 0)
834 #define SYMBOL_FLAG_TDA (SYMBOL_FLAG_MACH_DEP << 1)
835 #define SYMBOL_FLAG_SDA (SYMBOL_FLAG_MACH_DEP << 2)
836 #define SYMBOL_REF_ZDA_P(X) ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_ZDA) != 0)
837 #define SYMBOL_REF_TDA_P(X) ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_TDA) != 0)
838 #define SYMBOL_REF_SDA_P(X) ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_SDA) != 0)
840 #define TARGET_ASM_INIT_SECTIONS v850_asm_init_sections
842 /* Define this so that the cc1plus will not think that system header files
843 need an implicit 'extern "C" { ... }' assumed. This breaks testing C++
844 in a build directory where the libstdc++ header files are found via a
845 -isystem <path-to-build-dir>. */
846 #define NO_IMPLICIT_EXTERN_C
848 #define ADJUST_INSN_LENGTH(INSN, LENGTH) \
849 ((LENGTH) = v850_adjust_insn_length ((INSN), (LENGTH)))
851 #endif /* ! GCC_V850_H */