📄 xtensa.h
字号:
/* Definitions of Tensilica's Xtensa target machine for GNU compiler. Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Bob Wilson (bwilson@tensilica.com) at Tensilica.This file is part of GCC.GCC is free software; you can redistribute it and/or modify it underthe terms of the GNU General Public License as published by the FreeSoftware Foundation; either version 2, or (at your option) any laterversion.GCC is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licensefor more details.You should have received a copy of the GNU General Public Licensealong with GCC; see the file COPYING. If not, write to the FreeSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA02111-1307, USA. *//* Get Xtensa configuration settings */#include "xtensa-config.h"/* Standard GCC variables that we reference. */extern int current_function_calls_alloca;extern int target_flags;extern int optimize;/* External variables defined in xtensa.c. *//* comparison type */enum cmp_type { CMP_SI, /* four byte integers */ CMP_DI, /* eight byte integers */ CMP_SF, /* single precision floats */ CMP_DF, /* double precision floats */ CMP_MAX /* max comparison type */};extern struct rtx_def * branch_cmp[2]; /* operands for compare */extern enum cmp_type branch_type; /* what type of branch to use */extern unsigned xtensa_current_frame_size;/* Masks for the -m switches */#define MASK_NO_FUSED_MADD 0x00000001 /* avoid f-p mul/add */#define MASK_CONST16 0x00000002 /* use CONST16 instruction *//* Macros used in the machine description to select various Xtensa configuration options. */#define TARGET_BIG_ENDIAN XCHAL_HAVE_BE#define TARGET_DENSITY XCHAL_HAVE_DENSITY#define TARGET_MAC16 XCHAL_HAVE_MAC16#define TARGET_MUL16 XCHAL_HAVE_MUL16#define TARGET_MUL32 XCHAL_HAVE_MUL32#define TARGET_DIV32 XCHAL_HAVE_DIV32#define TARGET_NSA XCHAL_HAVE_NSA#define TARGET_MINMAX XCHAL_HAVE_MINMAX#define TARGET_SEXT XCHAL_HAVE_SEXT#define TARGET_BOOLEANS XCHAL_HAVE_BOOLEANS#define TARGET_HARD_FLOAT XCHAL_HAVE_FP#define TARGET_HARD_FLOAT_DIV XCHAL_HAVE_FP_DIV#define TARGET_HARD_FLOAT_RECIP XCHAL_HAVE_FP_RECIP#define TARGET_HARD_FLOAT_SQRT XCHAL_HAVE_FP_SQRT#define TARGET_HARD_FLOAT_RSQRT XCHAL_HAVE_FP_RSQRT#define TARGET_ABS XCHAL_HAVE_ABS#define TARGET_ADDX XCHAL_HAVE_ADDX/* Macros controlled by command-line options. */#define TARGET_NO_FUSED_MADD (target_flags & MASK_NO_FUSED_MADD)#define TARGET_CONST16 (target_flags & MASK_CONST16)#define TARGET_DEFAULT ( \ (XCHAL_HAVE_L32R ? 0 : MASK_CONST16))#define TARGET_SWITCHES \{ \ {"const16", MASK_CONST16, \ N_("Use CONST16 instruction to load constants")}, \ {"no-const16", -MASK_CONST16, \ N_("Use PC-relative L32R instruction to load constants")}, \ {"no-fused-madd", MASK_NO_FUSED_MADD, \ N_("Disable fused multiply/add and multiply/subtract FP instructions")}, \ {"fused-madd", -MASK_NO_FUSED_MADD, \ N_("Enable fused multiply/add and multiply/subtract FP instructions")}, \ {"text-section-literals", 0, \ N_("Intersperse literal pools with code in the text section")}, \ {"no-text-section-literals", 0, \ N_("Put literal pools in a separate literal section")}, \ {"target-align", 0, \ N_("Automatically align branch targets to reduce branch penalties")}, \ {"no-target-align", 0, \ N_("Do not automatically align branch targets")}, \ {"longcalls", 0, \ N_("Use indirect CALLXn instructions for large programs")}, \ {"no-longcalls", 0, \ N_("Use direct CALLn instructions for fast calls")}, \ {"", TARGET_DEFAULT, 0} \}#define OVERRIDE_OPTIONS override_options ()/* Target CPU builtins. */#define TARGET_CPU_CPP_BUILTINS() \ do { \ builtin_assert ("cpu=xtensa"); \ builtin_assert ("machine=xtensa"); \ builtin_define ("__xtensa__"); \ builtin_define ("__XTENSA__"); \ builtin_define ("__XTENSA_WINDOWED_ABI__"); \ builtin_define (TARGET_BIG_ENDIAN ? "__XTENSA_EB__" : "__XTENSA_EL__"); \ if (!TARGET_HARD_FLOAT) \ builtin_define ("__XTENSA_SOFT_FLOAT__"); \ if (flag_pic) \ { \ builtin_define ("__PIC__"); \ builtin_define ("__pic__"); \ } \ } while (0)#define CPP_SPEC " %(subtarget_cpp_spec) "#ifndef SUBTARGET_CPP_SPEC#define SUBTARGET_CPP_SPEC ""#endif#define EXTRA_SPECS \ { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC },#ifdef __XTENSA_EB__#define LIBGCC2_WORDS_BIG_ENDIAN 1#else#define LIBGCC2_WORDS_BIG_ENDIAN 0#endif/* Show we can debug even without a frame pointer. */#define CAN_DEBUG_WITHOUT_FP/* Target machine storage layout *//* Define this if most significant bit is lowest numbered in instructions that operate on numbered bit-fields. */#define BITS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)/* Define this if most significant byte of a word is the lowest numbered. */#define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)/* Define this if most significant word of a multiword number is the lowest. */#define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN != 0)#define MAX_BITS_PER_WORD 32/* Width of a word, in units (bytes). */#define UNITS_PER_WORD 4#define MIN_UNITS_PER_WORD 4/* Width of a floating point register. */#define UNITS_PER_FPREG 4/* Size in bits of various types on the target machine. */#define INT_TYPE_SIZE 32#define SHORT_TYPE_SIZE 16#define LONG_TYPE_SIZE 32#define LONG_LONG_TYPE_SIZE 64#define FLOAT_TYPE_SIZE 32#define DOUBLE_TYPE_SIZE 64#define LONG_DOUBLE_TYPE_SIZE 64/* Allocation boundary (in *bits*) for storing pointers in memory. */#define POINTER_BOUNDARY 32/* Allocation boundary (in *bits*) for storing arguments in argument list. */#define PARM_BOUNDARY 32/* Allocation boundary (in *bits*) for the code of a function. */#define FUNCTION_BOUNDARY 32/* Alignment of field after 'int : 0' in a structure. */#define EMPTY_FIELD_BOUNDARY 32/* Every structure's size must be a multiple of this. */#define STRUCTURE_SIZE_BOUNDARY 8/* There is no point aligning anything to a rounder boundary than this. */#define BIGGEST_ALIGNMENT 128/* Set this nonzero if move instructions will actually fail to work when given unaligned data. */#define STRICT_ALIGNMENT 1/* Promote integer modes smaller than a word to SImode. Set UNSIGNEDP for QImode, because there is no 8-bit load from memory with sign extension. Otherwise, leave UNSIGNEDP alone, since Xtensa has 16-bit loads both with and without sign extension. */#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \ do { \ if (GET_MODE_CLASS (MODE) == MODE_INT \ && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ { \ if ((MODE) == QImode) \ (UNSIGNEDP) = 1; \ (MODE) = SImode; \ } \ } while (0)/* Imitate the way many other C compilers handle alignment of bitfields and the structures that contain them. */#define PCC_BITFIELD_TYPE_MATTERS 1/* Disable the use of word-sized or smaller complex modes for structures, and for function arguments in particular, where they cause problems with register a7. The xtensa_copy_incoming_a7 function assumes that there is a single reference to an argument in a7, but with small complex modes the real and imaginary components may be extracted separately, leading to two uses of the register, only one of which would be replaced. */#define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) \ ((MODE) == CQImode || (MODE) == CHImode)/* Align string constants and constructors to at least a word boundary. The typical use of this macro is to increase alignment for string constants to be word aligned so that 'strcpy' calls that copy constants can be done inline. */#define CONSTANT_ALIGNMENT(EXP, ALIGN) \ ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \ && (ALIGN) < BITS_PER_WORD \ ? BITS_PER_WORD \ : (ALIGN))/* Align arrays, unions and records to at least a word boundary. One use of this macro is to increase alignment of medium-size data to make it all fit in fewer cache lines. Another is to cause character arrays to be word-aligned so that 'strcpy' calls that copy constants to character arrays can be done inline. */#undef DATA_ALIGNMENT#define DATA_ALIGNMENT(TYPE, ALIGN) \ ((((ALIGN) < BITS_PER_WORD) \ && (TREE_CODE (TYPE) == ARRAY_TYPE \ || TREE_CODE (TYPE) == UNION_TYPE \ || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN))/* Operations between registers always perform the operation on the full register even if a narrower mode is specified. */#define WORD_REGISTER_OPERATIONS/* Xtensa loads are zero-extended by default. */#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND/* 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. The fake frame pointer and argument pointer will never appear in the generated code, since they will always be eliminated and replaced by either the stack pointer or the hard frame pointer. 0 - 15 AR[0] - AR[15] 16 FRAME_POINTER (fake = initial sp) 17 ARG_POINTER (fake = initial sp + framesize) 18 BR[0] for floating-point CC 19 - 34 FR[0] - FR[15] 35 MAC16 accumulator */#define FIRST_PSEUDO_REGISTER 36/* Return the stabs register number to use for REGNO. */#define DBX_REGISTER_NUMBER(REGNO) xtensa_dbx_register_number (REGNO)/* 1 for registers that have pervasive standard uses and are not available for the register allocator. */#define FIXED_REGISTERS \{ \ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 1, 1, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, \}/* 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, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, \ 1, 1, 1, \ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ 1, \}/* For non-leaf procedures on Xtensa processors, the allocation order is as specified below by REG_ALLOC_ORDER. For leaf procedures, we want to use the lowest numbered registers first to minimize register window overflows. However, local-alloc is not smart enough to consider conflicts with incoming arguments. If an incoming argument in a2 is live throughout the function and local-alloc decides to use a2, then the incoming argument must either be spilled or copied to another register. To get around this, we define ORDER_REGS_FOR_LOCAL_ALLOC to redefine reg_alloc_order for leaf functions such that lowest numbered registers are used first with the exception that the incoming argument registers are not used until after other register choices have been exhausted. */#define REG_ALLOC_ORDER \{ 8, 9, 10, 11, 12, 13, 14, 15, 7, 6, 5, 4, 3, 2, \ 18, \ 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, \ 0, 1, 16, 17, \ 35, \}#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()/* For Xtensa, the only point of this is to prevent GCC from otherwise giving preference to call-used registers. To minimize window overflows for the AR registers, we want to give preference to the lower-numbered AR registers. For other register files, which are not windowed, we still prefer call-used registers, if there are any. */extern const char xtensa_leaf_regs[FIRST_PSEUDO_REGISTER];#define LEAF_REGISTERS xtensa_leaf_regs/* For Xtensa, no remapping is necessary, but this macro must be defined if LEAF_REGISTERS is defined. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -