tc-i386.h revision 78838
133965Sjdp/* tc-i386.h -- Header file for tc-i386.c
278838Sobrien   Copyright 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
378838Sobrien   2001
478838Sobrien   Free Software Foundation, Inc.
533965Sjdp
633965Sjdp   This file is part of GAS, the GNU Assembler.
733965Sjdp
833965Sjdp   GAS is free software; you can redistribute it and/or modify
933965Sjdp   it under the terms of the GNU General Public License as published by
1033965Sjdp   the Free Software Foundation; either version 2, or (at your option)
1133965Sjdp   any later version.
1233965Sjdp
1333965Sjdp   GAS is distributed in the hope that it will be useful,
1433965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1533965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1633965Sjdp   GNU General Public License for more details.
1733965Sjdp
1833965Sjdp   You should have received a copy of the GNU General Public License
1933965Sjdp   along with GAS; see the file COPYING.  If not, write to the Free
2033965Sjdp   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2133965Sjdp   02111-1307, USA.  */
2233965Sjdp
2377312Sobrien
2460518Sobrien/* $FreeBSD: head/contrib/binutils/gas/config/tc-i386.h 78838 2001-06-26 17:53:08Z obrien $ */
2560518Sobrien
2677312Sobrien
2733965Sjdp#ifndef TC_I386
2833965Sjdp#define TC_I386 1
2933965Sjdp
3033965Sjdp#ifdef ANSI_PROTOTYPES
3133965Sjdpstruct fix;
3233965Sjdp#endif
3333965Sjdp
3433965Sjdp#define TARGET_BYTES_BIG_ENDIAN	0
3533965Sjdp
3633965Sjdp#ifdef TE_LYNX
3733965Sjdp#define TARGET_FORMAT		"coff-i386-lynx"
3833965Sjdp#endif
3933965Sjdp
4033965Sjdp#ifdef BFD_ASSEMBLER
4133965Sjdp/* This is used to determine relocation types in tc-i386.c.  The first
4233965Sjdp   parameter is the current relocation type, the second one is the desired
4333965Sjdp   type.  The idea is that if the original type is already some kind of PIC
4433965Sjdp   relocation, we leave it alone, otherwise we give it the desired type */
4533965Sjdp
4633965Sjdp#define tc_fix_adjustable(X)  tc_i386_fix_adjustable(X)
4733965Sjdpextern int tc_i386_fix_adjustable PARAMS ((struct fix *));
4833965Sjdp
4977312Sobrien#if (defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF) || defined (OBJ_MAYBE_COFF) || defined (OBJ_COFF)) && !defined (TE_PE)
5077312Sobrien/* This arranges for gas/write.c to not apply a relocation if
5177312Sobrien   tc_fix_adjustable() says it is not adjustable.
5277312Sobrien   The "! symbol_used_in_reloc_p" test is there specifically to cover
5377312Sobrien   the case of non-global symbols in linkonce sections.  It's the
5477312Sobrien   generally correct thing to do though;  If a reloc is going to be
5577312Sobrien   emitted against a symbol then we don't want to adjust the fixup by
5677312Sobrien   applying the reloc during assembly.  The reloc will be applied by
5777312Sobrien   the linker during final link.  */
5877312Sobrien#define TC_FIX_ADJUSTABLE(fixP) \
5977312Sobrien  (! symbol_used_in_reloc_p ((fixP)->fx_addsy) && tc_fix_adjustable (fixP))
6077312Sobrien#endif
6133965Sjdp
6233965Sjdp/* This expression evaluates to false if the relocation is for a local object
6333965Sjdp   for which we still want to do the relocation at runtime.  True if we
6433965Sjdp   are willing to perform this relocation while building the .o file.
6533965Sjdp   This is only used for pcrel relocations, so GOTOFF does not need to be
6633965Sjdp   checked here.  I am not sure if some of the others are ever used with
6777312Sobrien   pcrel, but it is easier to be safe than sorry.  */
6833965Sjdp
6960518Sobrien#define TC_RELOC_RTSYM_LOC_FIXUP(FIX)				\
7060518Sobrien  ((FIX)->fx_r_type != BFD_RELOC_386_PLT32			\
7160518Sobrien   && (FIX)->fx_r_type != BFD_RELOC_386_GOT32			\
7260518Sobrien   && (FIX)->fx_r_type != BFD_RELOC_386_GOTPC			\
7360518Sobrien   && ((FIX)->fx_addsy == NULL					\
7460518Sobrien       || (! S_IS_EXTERNAL ((FIX)->fx_addsy)			\
7560518Sobrien	   && ! S_IS_WEAK ((FIX)->fx_addsy)			\
7660518Sobrien	   && S_IS_DEFINED ((FIX)->fx_addsy)			\
7760518Sobrien	   && ! S_IS_COMMON ((FIX)->fx_addsy))))
7833965Sjdp
7933965Sjdp#define TARGET_ARCH		bfd_arch_i386
8077312Sobrien#define TARGET_MACH		(i386_mach ())
8177312Sobrienextern unsigned long i386_mach PARAMS ((void));
8233965Sjdp
8333973Sjdp#ifdef TE_FreeBSD
8460518Sobrien#define AOUT_TARGET_FORMAT	"a.out-i386-freebsd"
8533973Sjdp#endif
8633965Sjdp#ifdef TE_NetBSD
8760518Sobrien#define AOUT_TARGET_FORMAT	"a.out-i386-netbsd"
8833965Sjdp#endif
8933965Sjdp#ifdef TE_386BSD
9060518Sobrien#define AOUT_TARGET_FORMAT	"a.out-i386-bsd"
9133965Sjdp#endif
9233965Sjdp#ifdef TE_LINUX
9360518Sobrien#define AOUT_TARGET_FORMAT	"a.out-i386-linux"
9433965Sjdp#endif
9533965Sjdp#ifdef TE_Mach
9660518Sobrien#define AOUT_TARGET_FORMAT	"a.out-mach3"
9733965Sjdp#endif
9833965Sjdp#ifdef TE_DYNIX
9960518Sobrien#define AOUT_TARGET_FORMAT	"a.out-i386-dynix"
10033965Sjdp#endif
10160518Sobrien#ifndef AOUT_TARGET_FORMAT
10260518Sobrien#define AOUT_TARGET_FORMAT	"a.out-i386"
10333965Sjdp#endif
10433965Sjdp
10577312Sobrien#if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
10677312Sobrien     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF))
10760518Sobrienextern const char *i386_target_format PARAMS ((void));
10860518Sobrien#define TARGET_FORMAT i386_target_format ()
10960518Sobrien#else
11033965Sjdp#ifdef OBJ_ELF
11133965Sjdp#define TARGET_FORMAT		"elf32-i386"
11233965Sjdp#endif
11360518Sobrien#ifdef OBJ_AOUT
11460518Sobrien#define TARGET_FORMAT		AOUT_TARGET_FORMAT
11533965Sjdp#endif
11633965Sjdp#endif
11733965Sjdp
11833965Sjdp#else /* ! BFD_ASSEMBLER */
11933965Sjdp
12033965Sjdp/* COFF STUFF */
12133965Sjdp
12233965Sjdp#define COFF_MAGIC I386MAGIC
12333965Sjdp#define BFD_ARCH bfd_arch_i386
12433965Sjdp#define COFF_FLAGS F_AR32WR
12533965Sjdp#define TC_COUNT_RELOC(x) ((x)->fx_addsy || (x)->fx_r_type==7)
12633965Sjdp#define TC_COFF_FIX2RTYPE(fixP) tc_coff_fix2rtype(fixP)
12733965Sjdpextern short tc_coff_fix2rtype PARAMS ((struct fix *));
12833965Sjdp#define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag)
12933965Sjdpextern int tc_coff_sizemachdep PARAMS ((fragS *frag));
13060518Sobrien
13160518Sobrien#ifdef TE_GO32
13260518Sobrien/* DJGPP now expects some sections to be 2**4 aligned.  */
13360518Sobrien#define SUB_SEGMENT_ALIGN(SEG)						\
13460518Sobrien  ((strcmp (obj_segment_name (SEG), ".text") == 0			\
13560518Sobrien    || strcmp (obj_segment_name (SEG), ".data") == 0			\
13660518Sobrien    || strcmp (obj_segment_name (SEG), ".bss") == 0			\
13760518Sobrien    || strncmp (obj_segment_name (SEG), ".gnu.linkonce.t", 15) == 0	\
13860518Sobrien    || strncmp (obj_segment_name (SEG), ".gnu.linkonce.d", 15) == 0	\
13960518Sobrien    || strncmp (obj_segment_name (SEG), ".gnu.linkonce.r", 15) == 0)	\
14060518Sobrien   ? 4									\
14160518Sobrien   : 2)
14260518Sobrien#else
14333965Sjdp#define SUB_SEGMENT_ALIGN(SEG) 2
14460518Sobrien#endif
14560518Sobrien
14633965Sjdp#define TC_RVA_RELOC 7
14733965Sjdp/* Need this for PIC relocations */
14833965Sjdp#define NEED_FX_R_TYPE
14933965Sjdp
15033965Sjdp#ifdef TE_386BSD
15133965Sjdp/* The BSDI linker apparently rejects objects with a machine type of
15233965Sjdp   M_386 (100).  */
15333965Sjdp#define AOUT_MACHTYPE 0
15433965Sjdp#else
15533965Sjdp#define AOUT_MACHTYPE 100
15633965Sjdp#endif
15733965Sjdp
15833965Sjdp#undef REVERSE_SORT_RELOCS
15933965Sjdp
16033965Sjdp#endif /* ! BFD_ASSEMBLER */
16133965Sjdp
16278838Sobrien#ifndef LEX_AT
16378838Sobrien#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) x86_cons (EXP, NBYTES)
16478838Sobrienextern void x86_cons PARAMS ((expressionS *, int));
16578838Sobrien
16678838Sobrien#define TC_CONS_FIX_NEW(FRAG,OFF,LEN,EXP) x86_cons_fix_new(FRAG, OFF, LEN, EXP)
16778838Sobrienextern void x86_cons_fix_new
16878838Sobrien  PARAMS ((fragS *, unsigned int, unsigned int, expressionS *));
16978838Sobrien#endif
17078838Sobrien
17160518Sobrien#define TC_FORCE_RELOCATION(fixp) tc_i386_force_relocation(fixp)
17260518Sobrienextern int tc_i386_force_relocation PARAMS ((struct fix *));
17360518Sobrien
17433965Sjdp#ifdef BFD_ASSEMBLER
17533965Sjdp#define NO_RELOC BFD_RELOC_NONE
17633965Sjdp#else
17733965Sjdp#define NO_RELOC 0
17833965Sjdp#endif
17933965Sjdp#define tc_coff_symbol_emit_hook(a)	;	/* not used */
18033965Sjdp
18133965Sjdp#ifndef BFD_ASSEMBLER
18233965Sjdp#ifndef OBJ_AOUT
18333965Sjdp#ifndef TE_PE
18460518Sobrien#ifndef TE_GO32
18533965Sjdp/* Local labels starts with .L */
18633965Sjdp#define LOCAL_LABEL(name) (name[0] == '.' \
18733965Sjdp		 && (name[1] == 'L' || name[1] == 'X' || name[1] == '.'))
18833965Sjdp#endif
18933965Sjdp#endif
19033965Sjdp#endif
19160518Sobrien#endif
19233965Sjdp
19333965Sjdp#define LOCAL_LABELS_FB 1
19433965Sjdp
19533965Sjdp#define tc_aout_pre_write_hook(x)	{;}	/* not used */
19633965Sjdp#define tc_crawl_symbol_chain(a)	{;}	/* not used */
19733965Sjdp#define tc_headers_hook(a)		{;}	/* not used */
19833965Sjdp
19960518Sobrienextern const char extra_symbol_chars[];
20060518Sobrien#define tc_symbol_chars extra_symbol_chars
20160518Sobrien
20233965Sjdp#define MAX_OPERANDS 3		/* max operands per insn */
20360518Sobrien#define MAX_IMMEDIATE_OPERANDS 2/* max immediates per insn (lcall, ljmp) */
20460518Sobrien#define MAX_MEMORY_OPERANDS 2	/* max memory refs per insn (string ops) */
20533965Sjdp
20660518Sobrien/* Prefixes will be emitted in the order defined below.
20760518Sobrien   WAIT_PREFIX must be the first prefix since FWAIT is really is an
20877312Sobrien   instruction, and so must come before any prefixes.  */
20960518Sobrien#define WAIT_PREFIX	0
21060518Sobrien#define LOCKREP_PREFIX	1
21160518Sobrien#define ADDR_PREFIX	2
21260518Sobrien#define DATA_PREFIX	3
21360518Sobrien#define SEG_PREFIX	4
21477312Sobrien#define REX_PREFIX	5       /* must come last.  */
21577312Sobrien#define MAX_PREFIXES	6	/* max prefixes per opcode */
21660518Sobrien
21733965Sjdp/* we define the syntax here (modulo base,index,scale syntax) */
21833965Sjdp#define REGISTER_PREFIX '%'
21933965Sjdp#define IMMEDIATE_PREFIX '$'
22033965Sjdp#define ABSOLUTE_PREFIX '*'
22133965Sjdp
22233965Sjdp#define TWO_BYTE_OPCODE_ESCAPE 0x0f
22333965Sjdp#define NOP_OPCODE (char) 0x90
22433965Sjdp
22533965Sjdp/* register numbers */
22633965Sjdp#define EBP_REG_NUM 5
22733965Sjdp#define ESP_REG_NUM 4
22833965Sjdp
22933965Sjdp/* modrm_byte.regmem for twobyte escape */
23033965Sjdp#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
23133965Sjdp/* index_base_byte.index for no index register addressing */
23233965Sjdp#define NO_INDEX_REGISTER ESP_REG_NUM
23333965Sjdp/* index_base_byte.base for no base register addressing */
23433965Sjdp#define NO_BASE_REGISTER EBP_REG_NUM
23560518Sobrien#define NO_BASE_REGISTER_16 6
23633965Sjdp
23760518Sobrien/* these are the instruction mnemonic suffixes.  */
23860518Sobrien#define WORD_MNEM_SUFFIX  'w'
23960518Sobrien#define BYTE_MNEM_SUFFIX  'b'
24060518Sobrien#define SHORT_MNEM_SUFFIX 's'
24160518Sobrien#define LONG_MNEM_SUFFIX  'l'
24277312Sobrien#define QWORD_MNEM_SUFFIX  'q'
24360518Sobrien/* Intel Syntax */
24460518Sobrien#define LONG_DOUBLE_MNEM_SUFFIX 'x'
24533965Sjdp
24633965Sjdp/* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
24733965Sjdp#define REGMEM_FIELD_HAS_REG 0x3/* always = 0x3 */
24833965Sjdp#define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
24933965Sjdp
25033965Sjdp#define END_OF_INSN '\0'
25133965Sjdp
25260518Sobrien/* Intel Syntax */
25360518Sobrien/* Values 0-4 map onto scale factor */
25460518Sobrien#define BYTE_PTR     0
25560518Sobrien#define WORD_PTR     1
25660518Sobrien#define DWORD_PTR    2
25760518Sobrien#define QWORD_PTR    3
25860518Sobrien#define XWORD_PTR    4
25960518Sobrien#define SHORT        5
26060518Sobrien#define OFFSET_FLAT  6
26160518Sobrien#define FLAT         7
26260518Sobrien#define NONE_FOUND   8
26360518Sobrien
26433965Sjdptypedef struct
26533965Sjdp{
26633965Sjdp  /* instruction name sans width suffix ("mov" for movl insns) */
26733965Sjdp  char *name;
26833965Sjdp
26933965Sjdp  /* how many operands */
27033965Sjdp  unsigned int operands;
27133965Sjdp
27260518Sobrien  /* base_opcode is the fundamental opcode byte without optional
27360518Sobrien     prefix(es).  */
27433965Sjdp  unsigned int base_opcode;
27533965Sjdp
27633965Sjdp  /* extension_opcode is the 3 bit extension for group <n> insns.
27760518Sobrien     This field is also used to store the 8-bit opcode suffix for the
27860518Sobrien     AMD 3DNow! instructions.
27933965Sjdp     If this template has no extension opcode (the usual case) use None */
28060518Sobrien  unsigned int extension_opcode;
28177312Sobrien#define None 0xffff		/* If no extension_opcode is possible.  */
28233965Sjdp
28377312Sobrien  /* cpu feature flags */
28477312Sobrien  unsigned int cpu_flags;
28577312Sobrien#define Cpu086		  0x1	/* Any old cpu will do, 0 does the same */
28677312Sobrien#define Cpu186		  0x2	/* i186 or better required */
28777312Sobrien#define Cpu286		  0x4	/* i286 or better required */
28877312Sobrien#define Cpu386		  0x8	/* i386 or better required */
28977312Sobrien#define Cpu486		 0x10	/* i486 or better required */
29077312Sobrien#define Cpu586		 0x20	/* i585 or better required */
29177312Sobrien#define Cpu686		 0x40	/* i686 or better required */
29277312Sobrien#define CpuP4		 0x80	/* Pentium4 or better required */
29377312Sobrien#define CpuK6		0x100	/* AMD K6 or better required*/
29477312Sobrien#define CpuAthlon	0x200	/* AMD Athlon or better required*/
29577312Sobrien#define CpuSledgehammer 0x400	/* Sledgehammer or better required */
29677312Sobrien#define CpuMMX		0x800	/* MMX support required */
29777312Sobrien#define CpuSSE	       0x1000	/* Streaming SIMD extensions required */
29877312Sobrien#define CpuSSE2	       0x2000	/* Streaming SIMD extensions 2 required */
29977312Sobrien#define Cpu3dnow       0x4000	/* 3dnow! support required */
30077312Sobrien#define CpuUnknown     0x8000	/* The CPU is unknown,  be on the safe side.  */
30177312Sobrien
30277312Sobrien  /* These flags are set by gas depending on the flag_code.  */
30377312Sobrien#define Cpu64	     0x4000000   /* 64bit support required  */
30477312Sobrien#define CpuNo64      0x8000000   /* Not supported in the 64bit mode  */
30577312Sobrien
30677312Sobrien  /* The default value for unknown CPUs - enable all features to avoid problems.  */
30777312Sobrien#define CpuUnknownFlags (Cpu086|Cpu186|Cpu286|Cpu386|Cpu486|Cpu586|Cpu686|CpuP4|CpuSledgehammer|CpuMMX|CpuSSE|CpuSSE2|Cpu3dnow|CpuK6|CpuAthlon)
30877312Sobrien
30933965Sjdp  /* the bits in opcode_modifier are used to generate the final opcode from
31033965Sjdp     the base_opcode.  These bits also are used to detect alternate forms of
31133965Sjdp     the same instruction */
31233965Sjdp  unsigned int opcode_modifier;
31333965Sjdp
31433965Sjdp  /* opcode_modifier bits: */
31560518Sobrien#define W		   0x1	/* set if operands can be words or dwords
31660518Sobrien				   encoded the canonical way */
31760518Sobrien#define D		   0x2	/* D = 0 if Reg --> Regmem;
31860518Sobrien				   D = 1 if Regmem --> Reg:    MUST BE 0x2 */
31960518Sobrien#define Modrm		   0x4
32060518Sobrien#define FloatR		   0x8	/* src/dest swap for floats:   MUST BE 0x8 */
32160518Sobrien#define ShortForm	  0x10	/* register is in low 3 bits of opcode */
32260518Sobrien#define FloatMF		  0x20	/* FP insn memory format bit, sized by 0x4 */
32377312Sobrien#define Jump		  0x40	/* special case for jump insns.  */
32460518Sobrien#define JumpDword	  0x80  /* call and jump */
32560518Sobrien#define JumpByte	 0x100  /* loop and jecxz */
32633965Sjdp#define JumpInterSegment 0x200	/* special case for intersegment leaps/calls */
32760518Sobrien#define FloatD		 0x400	/* direction for float insns:  MUST BE 0x400 */
32860518Sobrien#define Seg2ShortForm	 0x800	/* encoding of load segment reg insns */
32977312Sobrien#define Seg3ShortForm	0x1000	/* fs/gs segment register insns.  */
33060518Sobrien#define Size16		0x2000	/* needs size prefix if in 32-bit mode */
33160518Sobrien#define Size32		0x4000	/* needs size prefix if in 16-bit mode */
33277312Sobrien#define Size64		0x8000	/* needs size prefix if in 16-bit mode */
33377312Sobrien#define IgnoreSize     0x10000  /* instruction ignores operand size prefix */
33477312Sobrien#define DefaultSize    0x20000  /* default insn size depends on mode */
33577312Sobrien#define No_bSuf	       0x40000	/* b suffix on instruction illegal */
33677312Sobrien#define No_wSuf	       0x80000	/* w suffix on instruction illegal */
33777312Sobrien#define No_lSuf	      0x100000 	/* l suffix on instruction illegal */
33877312Sobrien#define No_sSuf	      0x200000	/* s suffix on instruction illegal */
33977312Sobrien#define No_qSuf       0x400000  /* q suffix on instruction illegal */
34077312Sobrien#define No_xSuf       0x800000  /* x suffix on instruction illegal */
34177312Sobrien#define FWait	     0x1000000	/* instruction needs FWAIT */
34277312Sobrien#define IsString     0x2000000	/* quick test for string instructions */
34377312Sobrien#define regKludge    0x4000000	/* fake an extra reg operand for clr, imul */
34477312Sobrien#define IsPrefix     0x8000000	/* opcode is a prefix */
34577312Sobrien#define ImmExt	    0x10000000	/* instruction has extension in 8 bit imm */
34677312Sobrien#define NoRex64	    0x20000000  /* instruction don't need Rex64 prefix.  */
34777312Sobrien#define Rex64	    0x40000000  /* instruction require Rex64 prefix.  */
34860518Sobrien#define Ugh	    0x80000000	/* deprecated fp insn, gets a warning */
34933965Sjdp
35033965Sjdp  /* operand_types[i] describes the type of operand i.  This is made
35133965Sjdp     by OR'ing together all of the possible type masks.  (e.g.
35233965Sjdp     'operand_types[i] = Reg|Imm' specifies that operand i can be
35377312Sobrien     either a register or an immediate operand.  */
35433965Sjdp  unsigned int operand_types[3];
35577312Sobrien
35677312Sobrien  /* operand_types[i] bits */
35777312Sobrien  /* register */
35877312Sobrien#define Reg8		   0x1	/* 8 bit reg */
35977312Sobrien#define Reg16		   0x2	/* 16 bit reg */
36077312Sobrien#define Reg32		   0x4	/* 32 bit reg */
36177312Sobrien#define Reg64		   0x8	/* 64 bit reg */
36277312Sobrien  /* immediate */
36377312Sobrien#define Imm8		  0x10	/* 8 bit immediate */
36477312Sobrien#define Imm8S		  0x20	/* 8 bit immediate sign extended */
36577312Sobrien#define Imm16		  0x40	/* 16 bit immediate */
36677312Sobrien#define Imm32		  0x80	/* 32 bit immediate */
36777312Sobrien#define Imm32S		 0x100	/* 32 bit immediate sign extended */
36877312Sobrien#define Imm64		 0x200	/* 64 bit immediate */
36977312Sobrien#define Imm1		 0x400	/* 1 bit immediate */
37077312Sobrien  /* memory */
37177312Sobrien#define BaseIndex	 0x800
37277312Sobrien  /* Disp8,16,32 are used in different ways, depending on the
37377312Sobrien     instruction.  For jumps, they specify the size of the PC relative
37477312Sobrien     displacement, for baseindex type instructions, they specify the
37577312Sobrien     size of the offset relative to the base register, and for memory
37677312Sobrien     offset instructions such as `mov 1234,%al' they specify the size of
37777312Sobrien     the offset relative to the segment base.  */
37877312Sobrien#define Disp8		0x1000	/* 8 bit displacement */
37977312Sobrien#define Disp16		0x2000	/* 16 bit displacement */
38077312Sobrien#define Disp32		0x4000	/* 32 bit displacement */
38177312Sobrien#define Disp32S	        0x8000	/* 32 bit signed displacement */
38277312Sobrien#define Disp64	       0x10000	/* 64 bit displacement */
38377312Sobrien  /* specials */
38477312Sobrien#define InOutPortReg   0x20000	/* register to hold in/out port addr = dx */
38577312Sobrien#define ShiftCount     0x40000	/* register to hold shift cound = cl */
38677312Sobrien#define Control	       0x80000	/* Control register */
38777312Sobrien#define Debug	      0x100000	/* Debug register */
38877312Sobrien#define Test	      0x200000	/* Test register */
38977312Sobrien#define FloatReg      0x400000	/* Float register */
39077312Sobrien#define FloatAcc      0x800000	/* Float stack top %st(0) */
39177312Sobrien#define SReg2	     0x1000000	/* 2 bit segment register */
39277312Sobrien#define SReg3	     0x2000000	/* 3 bit segment register */
39377312Sobrien#define Acc	     0x4000000	/* Accumulator %al or %ax or %eax */
39477312Sobrien#define JumpAbsolute 0x8000000
39577312Sobrien#define RegMMX	    0x10000000	/* MMX register */
39677312Sobrien#define RegXMM	    0x20000000	/* XMM registers in PIII */
39777312Sobrien#define EsSeg	    0x40000000	/* String insn operand with fixed es segment */
39877312Sobrien
39977312Sobrien  /* InvMem is for instructions with a modrm byte that only allow a
40077312Sobrien     general register encoding in the i.tm.mode and i.tm.regmem fields,
40177312Sobrien     eg. control reg moves.  They really ought to support a memory form,
40277312Sobrien     but don't, so we add an InvMem flag to the register operand to
40377312Sobrien     indicate that it should be encoded in the i.tm.regmem field.  */
40477312Sobrien#define InvMem	    0x80000000
40577312Sobrien
40677312Sobrien#define Reg	(Reg8|Reg16|Reg32|Reg64) /* gen'l register */
40777312Sobrien#define WordReg (Reg16|Reg32|Reg64)
40877312Sobrien#define ImplicitRegister (InOutPortReg|ShiftCount|Acc|FloatAcc)
40977312Sobrien#define Imm	(Imm8|Imm8S|Imm16|Imm32S|Imm32|Imm64) /* gen'l immediate */
41077312Sobrien#define EncImm	(Imm8|Imm16|Imm32|Imm32S) /* Encodable gen'l immediate */
41177312Sobrien#define Disp	(Disp8|Disp16|Disp32|Disp32S|Disp64) /* General displacement */
41277312Sobrien#define AnyMem	(Disp8|Disp16|Disp32|Disp32S|BaseIndex|InvMem)	/* General memory */
41377312Sobrien  /* The following aliases are defined because the opcode table
41477312Sobrien     carefully specifies the allowed memory types for each instruction.
41577312Sobrien     At the moment we can only tell a memory reference size by the
41677312Sobrien     instruction suffix, so there's not much point in defining Mem8,
41777312Sobrien     Mem16, Mem32 and Mem64 opcode modifiers - We might as well just use
41877312Sobrien     the suffix directly to check memory operands.  */
41977312Sobrien#define LLongMem AnyMem		/* 64 bits (or more) */
42077312Sobrien#define LongMem AnyMem		/* 32 bit memory ref */
42177312Sobrien#define ShortMem AnyMem		/* 16 bit memory ref */
42277312Sobrien#define WordMem AnyMem		/* 16 or 32 bit memory ref */
42377312Sobrien#define ByteMem AnyMem		/* 8 bit memory ref */
42433965Sjdp}
42533965Sjdptemplate;
42633965Sjdp
42733965Sjdp/*
42833965Sjdp  'templates' is for grouping together 'template' structures for opcodes
42933965Sjdp  of the same name.  This is only used for storing the insns in the grand
43033965Sjdp  ole hash table of insns.
43133965Sjdp  The templates themselves start at START and range up to (but not including)
43233965Sjdp  END.
43333965Sjdp  */
43433965Sjdptypedef struct
43577312Sobrien{
43677312Sobrien  const template *start;
43777312Sobrien  const template *end;
43877312Sobrien}
43977312Sobrientemplates;
44033965Sjdp
44133965Sjdp/* these are for register name --> number & type hash lookup */
44233965Sjdptypedef struct
44377312Sobrien{
44477312Sobrien  char *reg_name;
44577312Sobrien  unsigned int reg_type;
44677312Sobrien  unsigned int reg_flags;
44777312Sobrien#define RegRex	    0x1  /* Extended register.  */
44877312Sobrien#define RegRex64    0x2  /* Extended 8 bit register.  */
44977312Sobrien  unsigned int reg_num;
45077312Sobrien}
45133965Sjdpreg_entry;
45233965Sjdp
45333965Sjdptypedef struct
45477312Sobrien{
45577312Sobrien  char *seg_name;
45677312Sobrien  unsigned int seg_prefix;
45777312Sobrien}
45833965Sjdpseg_entry;
45933965Sjdp
46077312Sobrien/* 386 operand encoding bytes:  see 386 book for details of this.  */
46133965Sjdptypedef struct
46277312Sobrien{
46377312Sobrien  unsigned int regmem;	/* codes register or memory operand */
46477312Sobrien  unsigned int reg;	/* codes register operand (or extended opcode) */
46577312Sobrien  unsigned int mode;	/* how to interpret regmem & reg */
46677312Sobrien}
46733965Sjdpmodrm_byte;
46833965Sjdp
46977312Sobrien/* x86-64 extension prefix.  */
47033965Sjdptypedef struct
47133965Sjdp  {
47277312Sobrien    unsigned int mode64;
47377312Sobrien    unsigned int extX;		/* Used to extend modrm reg field.  */
47477312Sobrien    unsigned int extY;		/* Used to extend SIB index field.  */
47577312Sobrien    unsigned int extZ;		/* Used to extend modrm reg/mem, SIB base, modrm base fields.  */
47677312Sobrien    unsigned int empty;		/* Used to old-style byte registers to new style.  */
47733965Sjdp  }
47877312Sobrienrex_byte;
47977312Sobrien
48077312Sobrien/* 386 opcode byte to code indirect addressing.  */
48177312Sobrientypedef struct
48277312Sobrien{
48377312Sobrien  unsigned base;
48477312Sobrien  unsigned index;
48577312Sobrien  unsigned scale;
48677312Sobrien}
48760518Sobriensib_byte;
48833965Sjdp
48977312Sobrien/* x86 arch names and features */
49077312Sobrientypedef struct
49177312Sobrien{
49277312Sobrien  const char *name;	/* arch name */
49377312Sobrien  unsigned int flags;	/* cpu feature flags */
49477312Sobrien}
49577312Sobrienarch_entry;
49677312Sobrien
49733965Sjdp/* The name of the global offset table generated by the compiler. Allow
49877312Sobrien   this to be overridden if need be.  */
49933965Sjdp#ifndef GLOBAL_OFFSET_TABLE_NAME
50033965Sjdp#define GLOBAL_OFFSET_TABLE_NAME "_GLOBAL_OFFSET_TABLE_"
50133965Sjdp#endif
50233965Sjdp
50333965Sjdp#ifdef BFD_ASSEMBLER
50433965Sjdpvoid i386_validate_fix PARAMS ((struct fix *));
50533965Sjdp#define TC_VALIDATE_FIX(FIXP,SEGTYPE,SKIP) i386_validate_fix(FIXP)
50633965Sjdp#endif
50733965Sjdp
50833965Sjdp#endif /* TC_I386 */
50933965Sjdp
51033965Sjdp#define md_operand(x)
51133965Sjdp
51233965Sjdpextern const struct relax_type md_relax_table[];
51333965Sjdp#define TC_GENERIC_RELAX_TABLE md_relax_table
51433965Sjdp
51533965Sjdp#define md_do_align(n, fill, len, max, around)				\
51633965Sjdpif ((n) && !need_pass_2							\
51733965Sjdp    && (!(fill) || ((char)*(fill) == (char)0x90 && (len) == 1))		\
51860518Sobrien    && subseg_text_p (now_seg))						\
51933965Sjdp  {									\
52077312Sobrien    frag_align_code ((n), (max));					\
52133965Sjdp    goto around;							\
52233965Sjdp  }
52333965Sjdp
52477312Sobrien#define MAX_MEM_FOR_RS_ALIGN_CODE  15
52577312Sobrien
52633965Sjdpextern void i386_align_code PARAMS ((fragS *, int));
52733965Sjdp
52833965Sjdp#define HANDLE_ALIGN(fragP)						\
52933965Sjdpif (fragP->fr_type == rs_align_code) 					\
53033965Sjdp  i386_align_code (fragP, (fragP->fr_next->fr_address			\
53133965Sjdp			   - fragP->fr_address				\
53233965Sjdp			   - fragP->fr_fix));
53333965Sjdp
53433965Sjdp/* call md_apply_fix3 with segment instead of md_apply_fix */
53533965Sjdp#define MD_APPLY_FIX3
53633965Sjdp
53733965Sjdpvoid i386_print_statistics PARAMS ((FILE *));
53833965Sjdp#define tc_print_statistics i386_print_statistics
53933965Sjdp
54033965Sjdp#define md_number_to_chars number_to_chars_littleendian
54133965Sjdp
54233965Sjdp#ifdef SCO_ELF
54333965Sjdp#define tc_init_after_args() sco_id ()
54433965Sjdpextern void sco_id PARAMS ((void));
54533965Sjdp#endif
54633965Sjdp
54738891Sjdp#define DIFF_EXPR_OK    /* foo-. gets turned into PC relative relocs */
548