📄 i386.c
字号:
5, /* MMX or SSE register to integer */ 64, /* size of prefetch block */ 6, /* number of parallel prefetches */ 5, /* Branch cost */ 4, /* cost of FADD and FSUB insns. */ 4, /* cost of FMUL instruction. */ 24, /* cost of FDIV instruction. */ 2, /* cost of FABS instruction. */ 2, /* cost of FCHS instruction. */ 35, /* cost of FSQRT instruction. */};static conststruct processor_costs k8_cost = { 1, /* cost of an add instruction */ 2, /* cost of a lea instruction */ 1, /* variable shift costs */ 1, /* constant shift costs */ {3, 4, 3, 4, 5}, /* cost of starting a multiply */ 0, /* cost of multiply per each bit set */ {18, 26, 42, 74, 74}, /* cost of a divide/mod */ 1, /* cost of movsx */ 1, /* cost of movzx */ 8, /* "large" insn */ 9, /* MOVE_RATIO */ 4, /* cost for loading QImode using movzbl */ {3, 4, 3}, /* cost of loading integer registers in QImode, HImode and SImode. Relative to reg-reg move (2). */ {3, 4, 3}, /* cost of storing integer registers */ 4, /* cost of reg,reg fld/fst */ {4, 4, 12}, /* cost of loading fp registers in SFmode, DFmode and XFmode */ {6, 6, 8}, /* cost of loading integer registers */ 2, /* cost of moving MMX register */ {3, 3}, /* cost of loading MMX registers in SImode and DImode */ {4, 4}, /* cost of storing MMX registers in SImode and DImode */ 2, /* cost of moving SSE register */ {4, 3, 6}, /* cost of loading SSE registers in SImode, DImode and TImode */ {4, 4, 5}, /* cost of storing SSE registers in SImode, DImode and TImode */ 5, /* MMX or SSE register to integer */ 64, /* size of prefetch block */ 6, /* number of parallel prefetches */ 5, /* Branch cost */ 4, /* cost of FADD and FSUB insns. */ 4, /* cost of FMUL instruction. */ 19, /* cost of FDIV instruction. */ 2, /* cost of FABS instruction. */ 2, /* cost of FCHS instruction. */ 35, /* cost of FSQRT instruction. */};static conststruct processor_costs pentium4_cost = { 1, /* cost of an add instruction */ 3, /* cost of a lea instruction */ 4, /* variable shift costs */ 4, /* constant shift costs */ {15, 15, 15, 15, 15}, /* cost of starting a multiply */ 0, /* cost of multiply per each bit set */ {56, 56, 56, 56, 56}, /* cost of a divide/mod */ 1, /* cost of movsx */ 1, /* cost of movzx */ 16, /* "large" insn */ 6, /* MOVE_RATIO */ 2, /* cost for loading QImode using movzbl */ {4, 5, 4}, /* cost of loading integer registers in QImode, HImode and SImode. Relative to reg-reg move (2). */ {2, 3, 2}, /* cost of storing integer registers */ 2, /* cost of reg,reg fld/fst */ {2, 2, 6}, /* cost of loading fp registers in SFmode, DFmode and XFmode */ {4, 4, 6}, /* cost of loading integer registers */ 2, /* cost of moving MMX register */ {2, 2}, /* cost of loading MMX registers in SImode and DImode */ {2, 2}, /* cost of storing MMX registers in SImode and DImode */ 12, /* cost of moving SSE register */ {12, 12, 12}, /* cost of loading SSE registers in SImode, DImode and TImode */ {2, 2, 8}, /* cost of storing SSE registers in SImode, DImode and TImode */ 10, /* MMX or SSE register to integer */ 64, /* size of prefetch block */ 6, /* number of parallel prefetches */ 2, /* Branch cost */ 5, /* cost of FADD and FSUB insns. */ 7, /* cost of FMUL instruction. */ 43, /* cost of FDIV instruction. */ 2, /* cost of FABS instruction. */ 2, /* cost of FCHS instruction. */ 43, /* cost of FSQRT instruction. */};static conststruct processor_costs nocona_cost = { 1, /* cost of an add instruction */ 1, /* cost of a lea instruction */ 1, /* variable shift costs */ 1, /* constant shift costs */ {10, 10, 10, 10, 10}, /* cost of starting a multiply */ 0, /* cost of multiply per each bit set */ {66, 66, 66, 66, 66}, /* cost of a divide/mod */ 1, /* cost of movsx */ 1, /* cost of movzx */ 16, /* "large" insn */ 17, /* MOVE_RATIO */ 4, /* cost for loading QImode using movzbl */ {4, 4, 4}, /* cost of loading integer registers in QImode, HImode and SImode. Relative to reg-reg move (2). */ {4, 4, 4}, /* cost of storing integer registers */ 3, /* cost of reg,reg fld/fst */ {12, 12, 12}, /* cost of loading fp registers in SFmode, DFmode and XFmode */ {4, 4, 4}, /* cost of loading integer registers */ 6, /* cost of moving MMX register */ {12, 12}, /* cost of loading MMX registers in SImode and DImode */ {12, 12}, /* cost of storing MMX registers in SImode and DImode */ 6, /* cost of moving SSE register */ {12, 12, 12}, /* cost of loading SSE registers in SImode, DImode and TImode */ {12, 12, 12}, /* cost of storing SSE registers in SImode, DImode and TImode */ 8, /* MMX or SSE register to integer */ 128, /* size of prefetch block */ 8, /* number of parallel prefetches */ 1, /* Branch cost */ 6, /* cost of FADD and FSUB insns. */ 8, /* cost of FMUL instruction. */ 40, /* cost of FDIV instruction. */ 3, /* cost of FABS instruction. */ 3, /* cost of FCHS instruction. */ 44, /* cost of FSQRT instruction. */};const struct processor_costs *ix86_cost = &pentium_cost;/* Processor feature/optimization bitmasks. */#define m_386 (1<<PROCESSOR_I386)#define m_486 (1<<PROCESSOR_I486)#define m_PENT (1<<PROCESSOR_PENTIUM)#define m_PPRO (1<<PROCESSOR_PENTIUMPRO)#define m_K6 (1<<PROCESSOR_K6)#define m_ATHLON (1<<PROCESSOR_ATHLON)#define m_PENT4 (1<<PROCESSOR_PENTIUM4)#define m_K8 (1<<PROCESSOR_K8)#define m_ATHLON_K8 (m_K8 | m_ATHLON)#define m_NOCONA (1<<PROCESSOR_NOCONA)const int x86_use_leave = m_386 | m_K6 | m_ATHLON_K8;const int x86_push_memory = m_386 | m_K6 | m_ATHLON_K8 | m_PENT4 | m_NOCONA;const int x86_zero_extend_with_and = m_486 | m_PENT;const int x86_movx = m_ATHLON_K8 | m_PPRO | m_PENT4 | m_NOCONA /* m_386 | m_K6 */;const int x86_double_with_add = ~m_386;const int x86_use_bit_test = m_386;const int x86_unroll_strlen = m_486 | m_PENT | m_PPRO | m_ATHLON_K8 | m_K6;const int x86_cmove = m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA;const int x86_fisttp = m_NOCONA;const int x86_3dnow_a = m_ATHLON_K8;const int x86_deep_branch = m_PPRO | m_K6 | m_ATHLON_K8 | m_PENT4 | m_NOCONA;/* Branch hints were put in P4 based on simulation result. But after P4 was made, no performance benefit was observed with branch hints. It also increases the code size. As the result, icc never generates branch hints. */const int x86_branch_hints = 0;const int x86_use_sahf = m_PPRO | m_K6 | m_PENT4 | m_NOCONA;const int x86_partial_reg_stall = m_PPRO;const int x86_use_himode_fiop = m_386 | m_486 | m_K6;const int x86_use_simode_fiop = ~(m_PPRO | m_ATHLON_K8 | m_PENT);const int x86_use_mov0 = m_K6;const int x86_use_cltd = ~(m_PENT | m_K6);const int x86_read_modify_write = ~m_PENT;const int x86_read_modify = ~(m_PENT | m_PPRO);const int x86_split_long_moves = m_PPRO;const int x86_promote_QImode = m_K6 | m_PENT | m_386 | m_486 | m_ATHLON_K8;const int x86_fast_prefix = ~(m_PENT | m_486 | m_386);const int x86_single_stringop = m_386 | m_PENT4 | m_NOCONA;const int x86_qimode_math = ~(0);const int x86_promote_qi_regs = 0;const int x86_himode_math = ~(m_PPRO);const int x86_promote_hi_regs = m_PPRO;const int x86_sub_esp_4 = m_ATHLON_K8 | m_PPRO | m_PENT4 | m_NOCONA;const int x86_sub_esp_8 = m_ATHLON_K8 | m_PPRO | m_386 | m_486 | m_PENT4 | m_NOCONA;const int x86_add_esp_4 = m_ATHLON_K8 | m_K6 | m_PENT4 | m_NOCONA;const int x86_add_esp_8 = m_ATHLON_K8 | m_PPRO | m_K6 | m_386 | m_486 | m_PENT4 | m_NOCONA;const int x86_integer_DFmode_moves = ~(m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_PPRO);const int x86_partial_reg_dependency = m_ATHLON_K8 | m_PENT4 | m_NOCONA;const int x86_memory_mismatch_stall = m_ATHLON_K8 | m_PENT4 | m_NOCONA;const int x86_accumulate_outgoing_args = m_ATHLON_K8 | m_PENT4 | m_NOCONA | m_PPRO;const int x86_prologue_using_move = m_ATHLON_K8 | m_PPRO;const int x86_epilogue_using_move = m_ATHLON_K8 | m_PPRO;const int x86_decompose_lea = m_PENT4 | m_NOCONA;const int x86_shift1 = ~m_486;const int x86_arch_always_fancy_math_387 = m_PENT | m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA;const int x86_sse_partial_reg_dependency = m_PENT4 | m_NOCONA | m_PPRO;/* Set for machines where the type and dependencies are resolved on SSE register parts instead of whole registers, so we may maintain just lower part of scalar values in proper format leaving the upper part undefined. */const int x86_sse_split_regs = m_ATHLON_K8;const int x86_sse_typeless_stores = m_ATHLON_K8;const int x86_sse_load0_by_pxor = m_PPRO | m_PENT4 | m_NOCONA;const int x86_use_ffreep = m_ATHLON_K8;const int x86_rep_movl_optimal = m_386 | m_PENT | m_PPRO | m_K6;/* ??? Allowing interunit moves makes it all too easy for the compiler to put integer data in xmm registers. Which results in pretty abysmal code. */const int x86_inter_unit_moves = 0 /* ~(m_ATHLON_K8) */;const int x86_ext_80387_constants = m_K6 | m_ATHLON | m_PENT4 | m_NOCONA | m_PPRO;/* Some CPU cores are not able to predict more than 4 branch instructions in the 16 byte window. */const int x86_four_jump_limit = m_PPRO | m_ATHLON_K8 | m_PENT4 | m_NOCONA;const int x86_schedule = m_PPRO | m_ATHLON_K8 | m_K6 | m_PENT;const int x86_use_bt = m_ATHLON_K8;/* Compare and exchange was added for 80486. */const int x86_cmpxchg = ~m_386;/* Exchange and add was added for 80486. */const int x86_xadd = ~m_386;/* In case the average insn count for single function invocation is lower than this constant, emit fast (but longer) prologue and epilogue code. */#define FAST_PROLOGUE_INSN_COUNT 20/* Names for 8 (low), 8 (high), and 16-bit registers, respectively. */static const char *const qi_reg_name[] = QI_REGISTER_NAMES;static const char *const qi_high_reg_name[] = QI_HIGH_REGISTER_NAMES;static const char *const hi_reg_name[] = HI_REGISTER_NAMES;/* Array of the smallest class containing reg number REGNO, indexed by REGNO. Used by REGNO_REG_CLASS in i386.h. */enum reg_class const regclass_map[FIRST_PSEUDO_REGISTER] ={ /* ax, dx, cx, bx */ AREG, DREG, CREG, BREG, /* si, di, bp, sp */ SIREG, DIREG, NON_Q_REGS, NON_Q_REGS, /* FP registers */ FP_TOP_REG, FP_SECOND_REG, FLOAT_REGS, FLOAT_REGS, FLOAT_REGS, FLOAT_REGS, FLOAT_REGS, FLOAT_REGS, /* arg pointer */ NON_Q_REGS, /* flags, fpsr, dirflag, frame */ NO_REGS, NO_REGS, NO_REGS, NON_Q_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, MMX_REGS, MMX_REGS, MMX_REGS, MMX_REGS, MMX_REGS, MMX_REGS, MMX_REGS, MMX_REGS, NON_Q_REGS, NON_Q_REGS, NON_Q_REGS, NON_Q_REGS, NON_Q_REGS, NON_Q_REGS, NON_Q_REGS, NON_Q_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS, SSE_REGS,};/* The "default" register map used in 32bit mode. */int const dbx_register_map[FIRST_PSEUDO_REGISTER] ={ 0, 2, 1, 3, 6, 7, 4, 5, /* general regs */ 12, 13, 14, 15, 16, 17, 18, 19, /* fp regs */ -1, -1, -1, -1, -1, /* arg, flags, fpsr, dir, frame */ 21, 22, 23, 24, 25, 26, 27, 28, /* SSE */ 29, 30, 31, 32, 33, 34, 35, 36, /* MMX */ -1, -1, -1, -1, -1, -1, -1, -1, /* extended integer registers */ -1, -1, -1, -1, -1, -1, -1, -1, /* extended SSE registers */};static int const x86_64_int_parameter_registers[6] ={ 5 /*RDI*/, 4 /*RSI*/, 1 /*RDX*/, 2 /*RCX*/, FIRST_REX_INT_REG /*R8 */, FIRST_REX_INT_REG + 1 /*R9 */};static int const x86_64_int_return_registers[4] ={ 0 /*RAX*/, 1 /*RDI*/, 5 /*RDI*/, 4 /*RSI*/};/* The "default" register map used in 64bit mode. */int const dbx64_register_map[FIRST_PSEUDO_REGISTER] ={ 0, 1, 2, 3, 4, 5, 6, 7, /* general regs */ 33, 34, 35, 36, 37, 38, 39, 40, /* fp regs */ -1, -1, -1, -1, -1, /* arg, flags, fpsr, dir, frame */ 17, 18, 19, 20, 21, 22, 23, 24, /* SSE */ 41, 42, 43, 44, 45, 46, 47, 48, /* MMX */ 8,9,10,11,12,13,14,15, /* extended integer registers */ 25, 26, 27, 28, 29, 30, 31, 32, /* extended SSE registers */};/* Define the register numbers to be used in Dwarf debugging information. The SVR4 reference port C compiler uses the following register numbers in its Dwarf output code: 0 for %eax (gcc regno = 0) 1 for %ecx (gcc regno = 2) 2 for %edx (gcc regno = 1) 3 for %ebx (gcc regno = 3) 4 for %esp (gcc regno = 7) 5 for %ebp (gcc regno = 6) 6 for %esi (gcc regno = 4) 7 for %edi (gcc regno = 5) The following three DWARF register numbers are never generated by the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 believes these numbers have these meanings. 8 for %eip (no gcc equivalent) 9 for %eflags (gcc regno = 17) 10 for %trapno (no gcc equivalent) It is not at all clear how we should number the FP stack registers for the x86 architecture. If the version of SDB on x86/svr4 were a bit less brain dead with respect to floating-point then we would have a precedent to follow with respect to DWARF register numbers for x86 FP registers, but the SDB on x86/svr4 is so completely broken with respect to FP registers that it is hardly worth thinking of it as something to strive for compatibility with. The version of x86/svr4 SDB I have at the moment does (partially) seem to believe that DWARF register number 11 is associated with the x86 register %st(0), but that's about all. Higher DWARF register numbers don't seem to be associated with anything in particular, and even for DWARF regno 11, SDB only seems to under- stand that it should say that a variable lives in %st(0) (when asked via an `=' command) if we said it was in DWARF regno 11, but SDB still prints garbage when asked for the value of the variable in question (via a `/' command). (Also note that the labels SDB prints for various FP stack regs when doing an `x' command are all wrong.) Note that these problems generally don't affect the native SVR4 C compiler because it doesn't allow the use of -O with -g and because when it is *not* optimizing, it allocates a memory location for each floating-point variable, and the memory location is what gets described in the DWARF AT_location attribute for the variable in question. Regardless of the severe mental illness of the x86/svr4 SDB, we do something sensible here and we use the following DWARF register numbers. Note that these are all stack-top-relative numbers. 11 for %st(0) (gcc regno = 8) 12 for %st(1) (gcc regno = 9) 13 for %st(2) (gcc regno = 10) 14 for %st(3) (gcc regno = 11) 15 for %st(4) (gcc regno = 12) 16 for %st(5) (gcc regno = 13) 17 for %st(6) (gcc regno = 14) 18 for %st(7) (gcc regno = 15)*/int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER] ={ 0, 2, 1, 3, 6, 7, 5, 4, /* general regs */ 11, 12, 13, 14, 15, 16, 17, 18, /* fp regs */ -1, 9, -1, -1, -1, /* arg, flags, fpsr, dir, frame */ 21, 22, 23, 24, 25, 26, 27, 28, /* SSE registers */ 29, 30, 31, 32, 33, 34, 35, 36, /* MMX registers */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -