Back to index

cell-binutils  2.17cvs20070401
tc-i386.h
Go to the documentation of this file.
00001 /* tc-i386.h -- Header file for tc-i386.c
00002    Copyright 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
00003    2001, 2002, 2003, 2004, 2005, 2006, 2007
00004    Free Software Foundation, Inc.
00005 
00006    This file is part of GAS, the GNU Assembler.
00007 
00008    GAS is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2, or (at your option)
00011    any later version.
00012 
00013    GAS is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with GAS; see the file COPYING.  If not, write to the Free
00020    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00021    02110-1301, USA.  */
00022 
00023 #ifndef TC_I386
00024 #define TC_I386 1
00025 
00026 #include "opcodes/i386-opc.h"
00027 
00028 struct fix;
00029 
00030 #define TARGET_BYTES_BIG_ENDIAN    0
00031 
00032 #define TARGET_ARCH         bfd_arch_i386
00033 #define TARGET_MACH         (i386_mach ())
00034 extern unsigned long i386_mach (void);
00035 
00036 #ifdef TE_FreeBSD
00037 #define AOUT_TARGET_FORMAT  "a.out-i386-freebsd"
00038 #endif
00039 #ifdef TE_NetBSD
00040 #define AOUT_TARGET_FORMAT  "a.out-i386-netbsd"
00041 #endif
00042 #ifdef TE_386BSD
00043 #define AOUT_TARGET_FORMAT  "a.out-i386-bsd"
00044 #endif
00045 #ifdef TE_LINUX
00046 #define AOUT_TARGET_FORMAT  "a.out-i386-linux"
00047 #endif
00048 #ifdef TE_Mach
00049 #define AOUT_TARGET_FORMAT  "a.out-mach3"
00050 #endif
00051 #ifdef TE_DYNIX
00052 #define AOUT_TARGET_FORMAT  "a.out-i386-dynix"
00053 #endif
00054 #ifndef AOUT_TARGET_FORMAT
00055 #define AOUT_TARGET_FORMAT  "a.out-i386"
00056 #endif
00057 
00058 #ifdef TE_FreeBSD
00059 #define ELF_TARGET_FORMAT   "elf32-i386-freebsd"
00060 #define ELF_TARGET_FORMAT64 "elf64-x86-64-freebsd"
00061 #elif defined (TE_VXWORKS)
00062 #define ELF_TARGET_FORMAT   "elf32-i386-vxworks"
00063 #endif
00064 
00065 #ifndef ELF_TARGET_FORMAT
00066 #define ELF_TARGET_FORMAT   "elf32-i386"
00067 #endif
00068 
00069 #ifndef ELF_TARGET_FORMAT64
00070 #define ELF_TARGET_FORMAT64 "elf64-x86-64"
00071 #endif
00072 
00073 #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
00074      || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF))
00075 extern const char *i386_target_format (void);
00076 #define TARGET_FORMAT i386_target_format ()
00077 #else
00078 #ifdef OBJ_ELF
00079 #define TARGET_FORMAT              ELF_TARGET_FORMAT
00080 #endif
00081 #ifdef OBJ_AOUT
00082 #define TARGET_FORMAT              AOUT_TARGET_FORMAT
00083 #endif
00084 #endif
00085 
00086 #if (defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF))
00087 #define md_end i386_elf_emit_arch_note
00088 extern void i386_elf_emit_arch_note (void);
00089 #endif
00090 
00091 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
00092 
00093 #define LOCAL_LABELS_FB 1
00094 
00095 extern const char extra_symbol_chars[];
00096 #define tc_symbol_chars extra_symbol_chars
00097 
00098 extern const char *i386_comment_chars;
00099 #define tc_comment_chars i386_comment_chars
00100 
00101 /* Prefixes will be emitted in the order defined below.
00102    WAIT_PREFIX must be the first prefix since FWAIT is really is an
00103    instruction, and so must come before any prefixes.
00104    The preferred prefix order is SEG_PREFIX, ADDR_PREFIX, DATA_PREFIX,
00105    LOCKREP_PREFIX.  */
00106 #define WAIT_PREFIX  0
00107 #define SEG_PREFIX   1
00108 #define ADDR_PREFIX  2
00109 #define DATA_PREFIX  3
00110 #define LOCKREP_PREFIX      4
00111 #define REX_PREFIX   5       /* must come last.  */
00112 #define MAX_PREFIXES 6      /* max prefixes per opcode */
00113 
00114 /* we define the syntax here (modulo base,index,scale syntax) */
00115 #define REGISTER_PREFIX '%'
00116 #define IMMEDIATE_PREFIX '$'
00117 #define ABSOLUTE_PREFIX '*'
00118 
00119 /* these are the instruction mnemonic suffixes.  */
00120 #define WORD_MNEM_SUFFIX  'w'
00121 #define BYTE_MNEM_SUFFIX  'b'
00122 #define SHORT_MNEM_SUFFIX 's'
00123 #define LONG_MNEM_SUFFIX  'l'
00124 #define QWORD_MNEM_SUFFIX  'q'
00125 /* Intel Syntax */
00126 #define LONG_DOUBLE_MNEM_SUFFIX 'x'
00127 
00128 #define END_OF_INSN '\0'
00129 
00130 /*
00131   'templates' is for grouping together 'template' structures for opcodes
00132   of the same name.  This is only used for storing the insns in the grand
00133   ole hash table of insns.
00134   The templates themselves start at START and range up to (but not including)
00135   END.
00136   */
00137 typedef struct
00138 {
00139   const template *start;
00140   const template *end;
00141 }
00142 templates;
00143 
00144 /* 386 operand encoding bytes:  see 386 book for details of this.  */
00145 typedef struct
00146 {
00147   unsigned int regmem;      /* codes register or memory operand */
00148   unsigned int reg;  /* codes register operand (or extended opcode) */
00149   unsigned int mode; /* how to interpret regmem & reg */
00150 }
00151 modrm_byte;
00152 
00153 /* x86-64 extension prefix.  */
00154 typedef int rex_byte;
00155 
00156 /* 386 opcode byte to code indirect addressing.  */
00157 typedef struct
00158 {
00159   unsigned base;
00160   unsigned index;
00161   unsigned scale;
00162 }
00163 sib_byte;
00164 
00165 enum processor_type
00166 {
00167   PROCESSOR_UNKNOWN,
00168   PROCESSOR_I486,
00169   PROCESSOR_PENTIUM,
00170   PROCESSOR_PENTIUMPRO,
00171   PROCESSOR_PENTIUM4,
00172   PROCESSOR_NOCONA,
00173   PROCESSOR_CORE,
00174   PROCESSOR_CORE2,
00175   PROCESSOR_K6,
00176   PROCESSOR_ATHLON,
00177   PROCESSOR_K8,
00178   PROCESSOR_GENERIC32,
00179   PROCESSOR_GENERIC64,
00180   PROCESSOR_AMDFAM10
00181 };
00182 
00183 /* x86 arch names, types and features */
00184 typedef struct
00185 {
00186   const char *name;         /* arch name */
00187   enum processor_type type; /* arch type */
00188   unsigned int flags;              /* cpu feature flags */
00189 }
00190 arch_entry;
00191 
00192 /* The name of the global offset table generated by the compiler. Allow
00193    this to be overridden if need be.  */
00194 #ifndef GLOBAL_OFFSET_TABLE_NAME
00195 #define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
00196 #endif
00197 
00198 #if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) && !defined (LEX_AT)
00199 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) x86_cons (EXP, NBYTES)
00200 extern void x86_cons (expressionS *, int);
00201 #endif
00202 
00203 #define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP) x86_cons_fix_new(FRAG, OFF, LEN, EXP)
00204 extern void x86_cons_fix_new
00205   (fragS *, unsigned int, unsigned int, expressionS *);
00206 
00207 #define DIFF_EXPR_OK    /* foo-. gets turned into PC relative relocs */
00208 
00209 #define NO_RELOC BFD_RELOC_NONE
00210 
00211 void i386_validate_fix (struct fix *);
00212 #define TC_VALIDATE_FIX(FIX,SEGTYPE,SKIP) i386_validate_fix(FIX)
00213 
00214 #define tc_fix_adjustable(X)  tc_i386_fix_adjustable(X)
00215 extern int tc_i386_fix_adjustable (struct fix *);
00216 
00217 /* Values passed to md_apply_fix don't include the symbol value.  */
00218 #define MD_APPLY_SYM_VALUE(FIX) 0
00219 
00220 /* ELF wants external syms kept, as does PE COFF.  */
00221 #if defined (TE_PE) && defined (STRICT_PE_FORMAT)
00222 #define EXTERN_FORCE_RELOC                       \
00223   (OUTPUT_FLAVOR == bfd_target_elf_flavour              \
00224    || OUTPUT_FLAVOR == bfd_target_coff_flavour)
00225 #else
00226 #define EXTERN_FORCE_RELOC                       \
00227   (OUTPUT_FLAVOR == bfd_target_elf_flavour)
00228 #endif
00229 
00230 /* This expression evaluates to true if the relocation is for a local
00231    object for which we still want to do the relocation at runtime.
00232    False if we are willing to perform this relocation while building
00233    the .o file.  GOTOFF does not need to be checked here because it is
00234    not pcrel.  I am not sure if some of the others are ever used with
00235    pcrel, but it is easier to be safe than sorry.  */
00236 
00237 #define TC_FORCE_RELOCATION_LOCAL(FIX)                  \
00238   (!(FIX)->fx_pcrel                              \
00239    || (FIX)->fx_r_type == BFD_RELOC_386_PLT32           \
00240    || (FIX)->fx_r_type == BFD_RELOC_386_GOT32           \
00241    || (FIX)->fx_r_type == BFD_RELOC_386_GOTPC           \
00242    || TC_FORCE_RELOCATION (FIX))
00243 
00244 extern int i386_parse_name (char *, expressionS *, char *);
00245 #define md_parse_name(s, e, m, c) i386_parse_name (s, e, c)
00246 
00247 extern const struct relax_type md_relax_table[];
00248 #define TC_GENERIC_RELAX_TABLE md_relax_table
00249 
00250 extern int optimize_align_code;
00251 
00252 #define md_do_align(n, fill, len, max, around)                        \
00253 if ((n)                                                               \
00254     && !need_pass_2                                            \
00255     && optimize_align_code                                     \
00256     && (!(fill)                                                       \
00257        || ((char)*(fill) == (char)0x90 && (len) == 1))                \
00258     && subseg_text_p (now_seg))                                       \
00259   {                                                            \
00260     frag_align_code ((n), (max));                              \
00261     goto around;                                               \
00262   }
00263 
00264 #define MAX_MEM_FOR_RS_ALIGN_CODE  15
00265 
00266 extern void i386_align_code (fragS *, int);
00267 
00268 #define HANDLE_ALIGN(fragP)                                    \
00269 if (fragP->fr_type == rs_align_code)                                  \
00270   i386_align_code (fragP, (fragP->fr_next->fr_address                 \
00271                         - fragP->fr_address                           \
00272                         - fragP->fr_fix));
00273 
00274 void i386_print_statistics (FILE *);
00275 #define tc_print_statistics i386_print_statistics
00276 
00277 #define md_number_to_chars number_to_chars_littleendian
00278 
00279 #ifdef SCO_ELF
00280 #define tc_init_after_args() sco_id ()
00281 extern void sco_id (void);
00282 #endif
00283 
00284 #define WORKING_DOT_WORD 1
00285 
00286 /* We want .cfi_* pseudo-ops for generating unwind info.  */
00287 #define TARGET_USE_CFIPOP 1
00288 
00289 extern unsigned int x86_dwarf2_return_column;
00290 #define DWARF2_DEFAULT_RETURN_COLUMN x86_dwarf2_return_column
00291 
00292 extern int x86_cie_data_alignment;
00293 #define DWARF2_CIE_DATA_ALIGNMENT x86_cie_data_alignment
00294 
00295 #define tc_regname_to_dw2regnum tc_x86_regname_to_dw2regnum
00296 extern int tc_x86_regname_to_dw2regnum (char *);
00297 
00298 #define tc_cfi_frame_initial_instructions tc_x86_frame_initial_instructions
00299 extern void tc_x86_frame_initial_instructions (void);
00300 
00301 #define md_elf_section_type(str,len) i386_elf_section_type (str, len)
00302 extern int i386_elf_section_type (const char *, size_t);
00303 
00304 /* Support for SHF_X86_64_LARGE */
00305 extern int x86_64_section_word (char *, size_t);
00306 extern int x86_64_section_letter (int, char **);
00307 #define md_elf_section_letter(LETTER, PTR_MSG)   x86_64_section_letter (LETTER, PTR_MSG)
00308 #define md_elf_section_word(STR, LEN)            x86_64_section_word (STR, LEN)
00309 
00310 #ifdef TE_PE
00311 
00312 #define O_secrel O_md1
00313 
00314 #define TC_DWARF2_EMIT_OFFSET  tc_pe_dwarf2_emit_offset
00315 void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
00316 
00317 #endif /* TE_PE */
00318 
00319 #endif /* TC_I386 */