📄 v850.h
字号:
/* Definitions of target machine for GNU compiler. NEC V850 series Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Jeff Law (law@cygnus.com). This file is part of GNU CC. GNU CC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef GCC_V850_H#define GCC_V850_H/* These are defiend in svr4.h but we want to override them. */#undef ASM_FINAL_SPEC#undef LIB_SPEC#undef ENDFILE_SPEC#undef LINK_SPEC#undef STARTFILE_SPEC#undef ASM_SPEC#define TARGET_CPU_generic 1#define TARGET_CPU_v850e 2#ifndef TARGET_CPU_DEFAULT#define TARGET_CPU_DEFAULT TARGET_CPU_generic#endif#define MASK_DEFAULT MASK_V850#define SUBTARGET_ASM_SPEC "%{!mv*:-mv850}"#define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850__}"#define TARGET_VERSION fprintf (stderr, " (NEC V850)");/* Choose which processor will be the default. We must pass a -mv850xx option to the assembler if no explicit -mv* option is given, because the assembler's processor default may not be correct. */#if TARGET_CPU_DEFAULT == TARGET_CPU_v850e#undef MASK_DEFAULT#define MASK_DEFAULT MASK_V850E#undef SUBTARGET_ASM_SPEC#define SUBTARGET_ASM_SPEC "%{!mv*:-mv850e}"#undef SUBTARGET_CPP_SPEC#define SUBTARGET_CPP_SPEC "%{!mv*:-D__v850e__}"#undef TARGET_VERSION#define TARGET_VERSION fprintf (stderr, " (NEC V850E)");#endif#define ASM_SPEC "%{mv*:-mv%*}"#define CPP_SPEC "%{mv850e:-D__v850e__} %{mv850:-D__v850__} %(subtarget_cpp_spec)"#define EXTRA_SPECS \ { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \ { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC } /* Names to predefine in the preprocessor for this target machine. */#define CPP_PREDEFINES "-D__v851__ -D__v850"/* Run-time compilation parameters selecting different hardware subsets. */extern int target_flags;/* Target flags bits, see below for an explanation of the bits. */#define MASK_GHS 0x00000001#define MASK_LONG_CALLS 0x00000002#define MASK_EP 0x00000004#define MASK_PROLOG_FUNCTION 0x00000008#define MASK_DEBUG 0x40000000#define MASK_CPU 0x00000030#define MASK_V850 0x00000010#define MASK_V850E 0x00000020#define MASK_SMALL_SLD 0x00000040#define MASK_BIG_SWITCH 0x00000100#define MASK_NO_APP_REGS 0x00000200#define MASK_DISABLE_CALLT 0x00000400#define MASK_STRICT_ALIGN 0x00000800#define MASK_US_BIT_SET 0x00001000#define MASK_US_MASK_SET 0x00002000/* Macros used in the machine description to test the flags. *//* The GHS calling convention support doesn't really work, mostly due to a lack of documentation. Outstanding issues: * How do varargs & stdarg really work. How to they handle passing structures (if at all). * Doubles are normally 4 byte aligned, except in argument lists where they are 8 byte aligned. Is the alignment in the argument list based on the first parameter, first stack parameter, etc etc. * Passing/returning of large structures probably isn't the same as GHS. We don't have enough documentation on their conventions to be compatible. * Tests of SETUP_INCOMING_VARARGS need to be made runtime checks since it depends on TARGET_GHS. */#define TARGET_GHS (target_flags & MASK_GHS) /* Don't do PC-relative calls, instead load the address of the target function into a register and perform a register indirect call. */#define TARGET_LONG_CALLS (target_flags & MASK_LONG_CALLS)/* Whether to optimize space by using ep (r30) for pointers with small offsets in basic blocks. */#define TARGET_EP (target_flags & MASK_EP)/* Whether to call out-of-line functions to save registers or not. */#define TARGET_PROLOG_FUNCTION (target_flags & MASK_PROLOG_FUNCTION)#define TARGET_V850 ((target_flags & MASK_CPU) == MASK_V850)/* Whether to emit 2 byte per entry or 4 byte per entry switch tables. */#define TARGET_BIG_SWITCH (target_flags & MASK_BIG_SWITCH)/* General debug flag. */#define TARGET_DEBUG (target_flags & MASK_DEBUG)#define TARGET_V850E ((target_flags & MASK_V850E) == MASK_V850E)#define TARGET_US_BIT_SET (target_flags & MASK_US_BIT_SET)/* Whether to assume that the SLD.B and SLD.H instructions only have small displacement fields, thus allowing the generated code to run on any of the V850 range of processors. */#define TARGET_SMALL_SLD (target_flags & MASK_SMALL_SLD)/* True if callt will not be used for function prolog & epilog. */#define TARGET_DISABLE_CALLT (target_flags & MASK_DISABLE_CALLT)/* False if r2 and r5 can be used by the compiler. True if r2 and r5 are to be fixed registers (for compatibility with GHS). */#define TARGET_NO_APP_REGS (target_flags & MASK_NO_APP_REGS)#define TARGET_STRICT_ALIGN (target_flags & MASK_STRICT_ALIGN)/* Macro to define tables used to set the flags. This is a list in braces of pairs in braces, each pair being { "NAME", VALUE } where VALUE is the bits to set or minus the bits to clear. An empty string NAME is used to identify the default VALUE. */#define TARGET_SWITCHES \ {{ "ghs", MASK_GHS, N_("Support Green Hills ABI") }, \ { "no-ghs", -MASK_GHS, "" }, \ { "long-calls", MASK_LONG_CALLS, \ N_("Prohibit PC relative function calls") },\ { "no-long-calls", -MASK_LONG_CALLS, "" }, \ { "ep", MASK_EP, \ N_("Reuse r30 on a per function basis") }, \ { "no-ep", -MASK_EP, "" }, \ { "prolog-function", MASK_PROLOG_FUNCTION, \ N_("Use stubs for function prologues") }, \ { "no-prolog-function", -MASK_PROLOG_FUNCTION, "" }, \ { "space", MASK_EP | MASK_PROLOG_FUNCTION, \ N_("Same as: -mep -mprolog-function") }, \ { "debug", MASK_DEBUG, N_("Enable backend debugging") }, \ { "v850", MASK_V850, \ N_("Compile for the v850 processor") }, \ { "v850", -(MASK_V850 ^ MASK_CPU), "" }, \ { "v850e", MASK_V850E, N_("Compile for v850e processor") }, \ { "v850e", -(MASK_V850E ^ MASK_CPU), "" }, /* Make sure that the other bits are cleared. */ \ { "small-sld", MASK_SMALL_SLD, N_("Enable the use of the short load instructions") }, \ { "no-small-sld", -MASK_SMALL_SLD, "" }, \ { "disable-callt", MASK_DISABLE_CALLT, \ N_("Do not use the callt instruction") }, \ { "no-disable-callt", -MASK_DISABLE_CALLT, "" }, \ { "US-bit-set", (MASK_US_BIT_SET | MASK_US_MASK_SET), "" }, \ { "no-US-bit-set", -MASK_US_BIT_SET, "" }, \ { "no-US-bit-set", MASK_US_MASK_SET, "" }, \ { "app-regs", -MASK_NO_APP_REGS, "" }, \ { "no-app-regs", MASK_NO_APP_REGS, \ N_("Do not use registers r2 and r5") }, \ { "strict-align", MASK_STRICT_ALIGN, \ N_("Enforce strict alignment") }, \ { "no-strict-align", -MASK_STRICT_ALIGN, "" }, \ { "big-switch", MASK_BIG_SWITCH, \ N_("Use 4 byte entries in switch tables") },\ { "", MASK_DEFAULT, ""}}/* Information about the various small memory areas. */struct small_memory_info { const char *name; const char *value; long max; long physical_max;};enum small_memory_type { /* tiny data area, using EP as base register */ SMALL_MEMORY_TDA = 0, /* small data area using dp as base register */ SMALL_MEMORY_SDA, /* zero data area using r0 as base register */ SMALL_MEMORY_ZDA, SMALL_MEMORY_max};extern struct small_memory_info small_memory[(int)SMALL_MEMORY_max];#define TARGET_OPTIONS \{ \ { "tda=", &small_memory[ (int)SMALL_MEMORY_TDA ].value, \ N_("Set the max size of data eligible for the TDA area") }, \ { "tda-", &small_memory[ (int)SMALL_MEMORY_TDA ].value, "" }, \ { "sda=", &small_memory[ (int)SMALL_MEMORY_SDA ].value, \ N_("Set the max size of data eligible for the SDA area") }, \ { "sda-", &small_memory[ (int)SMALL_MEMORY_SDA ].value, "" }, \ { "zda=", &small_memory[ (int)SMALL_MEMORY_ZDA ].value, \ N_("Set the max size of data eligible for the ZDA area") }, \ { "zda-", &small_memory[ (int)SMALL_MEMORY_ZDA ].value, "" }, \}/* Sometimes certain combinations of command options do not make sense on a particular target machine. You can define a macro `OVERRIDE_OPTIONS' to take account of this. This macro, if defined, is executed once just after all the command options have been parsed. Don't use this macro to turn on various extra optimizations for `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */#define OVERRIDE_OPTIONS override_options ()/* Show we can debug even without a frame pointer. */#define CAN_DEBUG_WITHOUT_FP/* Some machines may desire to change what optimizations are performed for various optimization levels. This macro, if defined, is executed once just after the optimization level is determined and before the remainder of the command options have been parsed. Values set in this macro are used as the default values for the other command line options. LEVEL is the optimization level specified; 2 if `-O2' is specified, 1 if `-O' is specified, and 0 if neither is specified. SIZE is nonzero if `-Os' is specified, 0 otherwise. You should not use this macro to change options that are not machine-specific. These should uniformly selected by the same optimization level on all supported machines. Use this macro to enable machine-specific optimizations. *Do not examine `write_symbols' in this macro!* The debugging options are not supposed to alter the generated code. */#define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \{ \ target_flags |= MASK_STRICT_ALIGN; \ if (LEVEL) \ target_flags |= (MASK_EP | MASK_PROLOG_FUNCTION); \}/* Target machine storage layout *//* Define this if most significant bit is lowest numbered in instructions that operate on numbered bit-fields. This is not true on the NEC V850. */#define BITS_BIG_ENDIAN 0/* Define this if most significant byte of a word is the lowest numbered. *//* This is not true on the NEC V850. */#define BYTES_BIG_ENDIAN 0/* Define this if most significant word of a multiword number is lowest numbered. This is not true on the NEC V850. */#define WORDS_BIG_ENDIAN 0/* Width of a word, in units (bytes). */#define UNITS_PER_WORD 4/* Define this macro if it is advisable to hold scalars in registers in a wider mode than that declared by the program. In such cases, the value is constrained to be within the bounds of the declared type, but kept valid in the wider mode. The signedness of the extension may differ from that of the type. Some simple experiments have shown that leaving UNSIGNEDP alone generates the best overall code. */#define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ if (GET_MODE_CLASS (MODE) == MODE_INT \ && GET_MODE_SIZE (MODE) < 4) \ { (MODE) = SImode; }/* Allocation boundary (in *bits*) for storing arguments in argument list. */#define PARM_BOUNDARY 32/* The stack goes in 32 bit lumps. */#define STACK_BOUNDARY 32/* Allocation boundary (in *bits*) for the code of a function. 16 is the minimum boundary; 32 would give better performance. */#define FUNCTION_BOUNDARY 16/* No data type wants to be aligned rounder than this. */#define BIGGEST_ALIGNMENT 32/* Alignment of field after `int : 0' in a structure. */#define EMPTY_FIELD_BOUNDARY 32/* No structure field wants to be aligned rounder than this. */#define BIGGEST_FIELD_ALIGNMENT 32/* Define this if move instructions will actually fail to work when given unaligned data. */#define STRICT_ALIGNMENT TARGET_STRICT_ALIGN/* Define this as 1 if `char' should by default be signed; else as 0. On the NEC V850, loads do sign extension, so make this default. */#define DEFAULT_SIGNED_CHAR 1/* Standard register usage. *//* Number of actual hardware registers. The hardware registers are assigned numbers for the compiler from 0 to just below FIRST_PSEUDO_REGISTER. All registers that the compiler knows about must be given numbers, even those that are not normally considered general registers. */#define FIRST_PSEUDO_REGISTER 34/* 1 for registers that have pervasive standard uses and are not available for the register allocator. */#define FIXED_REGISTERS \ { 1, 1, 0, 1, 1, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 1, 0, \ 1, 1}/* 1 for registers not available across function calls. These must include the FIXED_REGISTERS and also any registers that can be used without being saved. The latter must include the registers where values are returned and the register where structure-value addresses are passed. Aside from that, you can include as many other registers as you like. */#define CALL_USED_REGISTERS \ { 1, 1, 0, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, 1, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 1, 1, \ 1, 1}/* List the order in which to allocate registers. Each register must be listed once, even those in FIXED_REGISTERS. On the 850, we make the return registers first, then all of the volatile registers, then the saved registers in reverse order to better save the registers with an out of line function, and finally the fixed registers. */#define REG_ALLOC_ORDER \{ \ 10, 11, /* return registers */ \ 12, 13, 14, 15, 16, 17, 18, 19, /* scratch registers */ \ 6, 7, 8, 9, 31, /* argument registers */ \ 29, 28, 27, 26, 25, 24, 23, 22, /* saved registers */ \ 21, 20, 2, \ 0, 1, 3, 4, 5, 30, 32, 33 /* fixed registers */ \}/* If TARGET_NO_APP_REGS is not defined then add r2 and r5 to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -