📄 i386.c
字号:
/* The "default" register map used in 64bit mode. *//* APPLE LOCAL begin mainline 2006-02-17 4356747 stack realign */int const dbx64_register_map[FIRST_PSEUDO_REGISTER+1] ={ 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 */ 16 /* return column */};/* APPLE LOCAL end mainline 2006-02-17 4356747 stack realign *//* 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)*//* APPLE LOCAL begin mainline 2006-02-17 4356747 stack realign */int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER+1] ={ 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 */ -1, -1, -1, -1, -1, -1, -1, -1, /* extended integer registers */ -1, -1, -1, -1, -1, -1, -1, -1, /* extended SSE registers */ 8 /* return column */};/* APPLE LOCAL end mainline 2006-02-17 4356747 stack realign *//* Test and compare insns in i386.md store the information needed to generate branch and scc insns here. */rtx ix86_compare_op0 = NULL_RTX;rtx ix86_compare_op1 = NULL_RTX;#define MAX_386_STACK_LOCALS 3/* Size of the register save area. */#define X86_64_VARARGS_SIZE (REGPARM_MAX * UNITS_PER_WORD + SSE_REGPARM_MAX * 16)/* Define the structure for the machine field in struct function. */struct stack_local_entry GTY(()){ unsigned short mode; unsigned short n; rtx rtl; struct stack_local_entry *next;};/* Structure describing stack frame layout. Stack grows downward: [arguments] <- ARG_POINTER saved pc saved frame pointer if frame_pointer_needed <- HARD_FRAME_POINTER [saved regs] [padding1] \ ) [va_arg registers] ( > to_allocate <- FRAME_POINTER [frame] ( ) [padding2] / */struct ix86_frame{ int nregs; int padding1; int va_arg_size; HOST_WIDE_INT frame; int padding2; int outgoing_arguments_size; int red_zone_size; HOST_WIDE_INT to_allocate; /* The offsets relative to ARG_POINTER. */ HOST_WIDE_INT frame_pointer_offset; HOST_WIDE_INT hard_frame_pointer_offset; HOST_WIDE_INT stack_pointer_offset; /* When save_regs_using_mov is set, emit prologue using move instead of push instructions. */ bool save_regs_using_mov;};/* Used to enable/disable debugging features. */const char *ix86_debug_arg_string, *ix86_debug_addr_string;/* Code model option as passed by user. */const char *ix86_cmodel_string;/* Parsed value. */enum cmodel ix86_cmodel;/* Asm dialect. */const char *ix86_asm_string;enum asm_dialect ix86_asm_dialect = ASM_ATT;/* TLS dialext. */const char *ix86_tls_dialect_string;enum tls_dialect ix86_tls_dialect = TLS_DIALECT_GNU;/* Which unit we are generating floating point math for. */enum fpmath_unit ix86_fpmath;/* Which cpu are we scheduling for. */enum processor_type ix86_tune;/* Which instruction set architecture to use. */enum processor_type ix86_arch;/* Strings to hold which cpu and instruction set architecture to use. */const char *ix86_tune_string; /* for -mtune=<xxx> */const char *ix86_arch_string; /* for -march=<xxx> */const char *ix86_fpmath_string; /* for -mfpmath=<xxx> *//* # of registers to use to pass arguments. */const char *ix86_regparm_string;/* true if sse prefetch instruction is not NOOP. */int x86_prefetch_sse;/* ix86_regparm_string as a number */int ix86_regparm;/* Alignment to use for loops and jumps: *//* Power of two alignment for loops. */const char *ix86_align_loops_string;/* Power of two alignment for non-loop jumps. */const char *ix86_align_jumps_string;/* Power of two alignment for stack boundary in bytes. */const char *ix86_preferred_stack_boundary_string;/* APPLE LOCAL begin 4356747 stack realign *//* -mstackrealign option *//* extern *//* Note #1 to merger: This decl will move to "i386.opt" in the next FSF merge, and then we'll need an 'extern' here. */const char *ix86_force_align_arg_pointer;static const char ix86_force_align_arg_pointer_string[] = "force_align_arg_pointer";/* Note #2 to merger: The -mstackrealign stuff was submitted to FSF trunkon 10feb2006: http://gcc.gnu.org/ml/gcc-patches/2006-02/msg00854.htmlApple needed this enhancement promptly (before the FSF acted on that patch), soA) I copied in a previous, necessary trunk patch: http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00931.html This patch is marked "mainline 2006-02-17 4356747 stack realign".B) I added my own patch (URL above), marked "4356747 stack realign".C) I had to modify my patch to work without the "i386.opt" file (I was too lazyto merge this non-trivial change into Apple's Curry branch).HTH. *//* APPLE LOCAL end 4356747 stack realign *//* Preferred alignment for stack boundary in bits. */unsigned int ix86_preferred_stack_boundary;/* Values 1-5: see jump.c */int ix86_branch_cost;const char *ix86_branch_cost_string;/* Power of two alignment for functions. */const char *ix86_align_funcs_string;/* Prefix built by ASM_GENERATE_INTERNAL_LABEL. */char internal_label_prefix[16];int internal_label_prefix_len;static void output_pic_addr_const (FILE *, rtx, int);static void put_condition_code (enum rtx_code, enum machine_mode, int, int, FILE *);static const char *get_some_local_dynamic_name (void);static int get_some_local_dynamic_name_1 (rtx *, void *);static rtx ix86_expand_int_compare (enum rtx_code, rtx, rtx);static enum rtx_code ix86_prepare_fp_compare_args (enum rtx_code, rtx *, rtx *);static bool ix86_fixed_condition_code_regs (unsigned int *, unsigned int *);static enum machine_mode ix86_cc_modes_compatible (enum machine_mode, enum machine_mode);static rtx get_thread_pointer (int);static rtx legitimize_tls_address (rtx, enum tls_model, int);static void get_pc_thunk_name (char [32], unsigned int);static rtx gen_push (rtx);static int ix86_flags_dependant (rtx, rtx, enum attr_type);static int ix86_agi_dependant (rtx, rtx, enum attr_type);static struct machine_function * ix86_init_machine_status (void);static int ix86_split_to_parts (rtx, rtx *, enum machine_mode);static int ix86_nsaved_regs (void);static void ix86_emit_save_regs (void);static void ix86_emit_save_regs_using_mov (rtx, HOST_WIDE_INT);static void ix86_emit_restore_regs_using_mov (rtx, HOST_WIDE_INT, int);static void ix86_output_function_epilogue (FILE *, HOST_WIDE_INT);static HOST_WIDE_INT ix86_GOT_alias_set (void);static void ix86_adjust_counter (rtx, HOST_WIDE_INT);static rtx ix86_expand_aligntest (rtx, int);static void ix86_expand_strlensi_unroll_1 (rtx, rtx, rtx);static int ix86_issue_rate (void);static int ix86_adjust_cost (rtx, rtx, rtx, int);static int ia32_multipass_dfa_lookahead (void);static void ix86_init_mmx_sse_builtins (void);static rtx x86_this_parameter (tree);static void x86_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);static bool x86_can_output_mi_thunk (tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);static void x86_file_start (void);static void ix86_reorg (void);static bool ix86_expand_carry_flag_compare (enum rtx_code, rtx, rtx, rtx*);static tree ix86_build_builtin_va_list (void);static void ix86_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int);static tree ix86_gimplify_va_arg (tree, tree, tree *, tree *);static bool ix86_vector_mode_supported_p (enum machine_mode);static int ix86_address_cost (rtx);static bool ix86_cannot_force_const_mem (rtx);static rtx ix86_delegitimize_address (rtx);struct builtin_description;static rtx ix86_expand_sse_comi (const struct builtin_description *, tree, rtx);static rtx ix86_expand_sse_compare (const struct builtin_description *, tree, rtx);static rtx ix86_expand_unop1_builtin (enum insn_code, tree, rtx);static rtx ix86_expand_unop_builtin (enum insn_code, tree, rtx, int);static rtx ix86_expand_binop_builtin (enum insn_code, tree, rtx);static rtx ix86_expand_store_builtin (enum insn_code, tree);static rtx safe_vector_operand (rtx, enum machine_mode);static rtx ix86_expand_fp_compare (enum rtx_code, rtx, rtx, rtx, rtx *, rtx *);static int ix86_fp_comparison_arithmetics_cost (enum rtx_code code);static int ix86_fp_comparison_fcomi_cost (enum rtx_code code);static int ix86_fp_comparison_sahf_cost (enum rtx_code code);static int ix86_fp_comparison_cost (enum rtx_code code);static unsigned int ix86_select_alt_pic_regnum (void);static int ix86_save_reg (unsigned int, int);static void ix86_compute_frame_layout (struct ix86_frame *);static int ix86_comp_type_attributes (tree, tree);static int ix86_function_regparm (tree, tree);const struct attribute_spec ix86_attribute_table[];static bool ix86_function_ok_for_sibcall (tree, tree);/* APPLE LOCAL begin mainline 2005-09-20 4205103 */static tree ix86_handle_cconv_attribute (tree *, tree, tree, int, bool *);static int ix86_value_regno (enum machine_mode, tree, tree);/* APPLE LOCAL end mainline 2005-09-20 4205103 */static bool contains_128bit_aligned_vector_p (tree);static rtx ix86_struct_value_rtx (tree, int);static bool ix86_ms_bitfield_layout_p (tree);static tree ix86_handle_struct_attribute (tree *, tree, tree, int, bool *);static int extended_reg_mentioned_1 (rtx *, void *);/* APPLE LOCAL begin why is this local? */#if TARGET_MACHOstatic bool ix86_binds_local_p (tree);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -