Add rawfrm flags
[oota-llvm.git] / lib / Target / X86 / X86InstrInfo.def
1 //===-- X86InstructionInfo.def - X86 Instruction Information ----*- C++ -*-===//
2 //
3 // This file describes all of the instructions that the X86 backend uses.  It
4 // relys on an external 'I' macro being defined that takes the arguments
5 // specified below, and is used to make all of the information relevant to an
6 // instruction be in one place.
7 //
8 // Note that X86 Instructions always have the destination register listed as
9 // operand 0, unless it does not produce a value (in which case the TSFlags will
10 // include X86II::Void).
11 //
12 //===----------------------------------------------------------------------===//
13
14 // NOTE: No include guards desired
15
16 #ifndef I
17 #errror "Must define I macro before including X86/X86InstructionInfo.def!"
18 #endif
19
20 // Arguments to be passed into the I macro
21 //  #1: Enum name - This ends up being the opcode symbol in the X86 namespace
22 //  #2: Opcode name, as used by the gnu assembler
23 //  #3: The base opcode for the instruction
24 //  #4: Instruction Flags - This should be a field or'd together that contains
25 //      constants from the MachineInstrInfo.h file.
26 //  #5: Target Specific Flags - Another bitfield containing X86 specific flags
27 //      that we are interested in for each instruction.  These should be flags
28 //      defined in X86InstrInfo.h in the X86II namespace.
29 //
30
31 // The first instruction must always be the PHI instruction:
32 I(PHI         , "phi",      0,             0, 0)
33
34 // The second instruction must always be the noop instruction:
35 I(NOOP        , "nop",   0x90,             0, X86II::RawFrm | X86II::Void)       // nop
36
37 // Flow control instructions
38 I(RET         , "ret",   0xCB,    M_RET_FLAG, X86II::RawFrm | X86II::Void)       // ret
39 I(JMP         , "jmp",   0xE9, M_BRANCH_FLAG, X86II::RawFrm | X86II::Void)       // jmp foo
40 I(JNE         , "jne",   0x85, M_BRANCH_FLAG, X86II::RawFrm | X86II::TB | X86II::Void)
41 I(JE          , "je",    0x84, M_BRANCH_FLAG, X86II::RawFrm | X86II::TB | X86II::Void)
42 I(CALLpcrel32 , "call",  0xE8, M_BRANCH_FLAG, X86II::Void)
43
44 // Misc instructions
45 I(LEAVE       , "leave", 0xC9,             0, X86II::RawFrm)                     // leave
46
47 // Move instructions
48 I(MOVrr8      , "movb",  0x88,             0, X86II::MRMDestReg)                 // R8  = R8
49 I(MOVrr16     , "movw",  0x89,             0, X86II::MRMDestReg | X86II::OpSize) // R16 = R16
50 I(MOVrr32     , "movl",  0x89,             0, X86II::MRMDestReg)                 // R32 = R32
51 I(MOVir8      , "movb",  0xB0,             0, X86II::AddRegFrm)                  // R8  = imm8
52 I(MOVir16     , "movw",  0xB8,             0, X86II::AddRegFrm  | X86II::OpSize) // R16 = imm16
53 I(MOVir32     , "movl",  0xB8,             0, X86II::AddRegFrm)                  // R32 = imm32
54 I(MOVmr8      , "movb",  0x8A,             0, X86II::MRMSrcMem)                  // R8  = [mem]  8A/r
55 I(MOVmr16     , "movw",  0x8B,             0, X86II::MRMSrcMem  | X86II::OpSize) // R16 = [mem]  8B/r
56 I(MOVmr32     , "movl",  0x8B,             0, X86II::MRMSrcMem)                  // R32 = [mem]  8B/r
57 I(MOVrm8      , "movb",  0x88,             0, X86II::MRMDestMem | X86II::Void)   // [mem] = R8   88/r
58 I(MOVrm16     , "movw",  0x89,             0, X86II::MRMDestMem | X86II::Void |  // [mem] = R16  89/r
59                                               X86II::OpSize)
60 I(MOVrm32     , "movl",  0x89,             0, X86II::MRMDestMem | X86II::Void)   // [mem] = R32  89/r
61
62 I(PUSHr32     , "pushl", 0x50,             0, X86II::AddRegFrm | X86II::Void)
63
64 // Arithmetic instructions
65 I(ADDrr8      , "addb",  0x00,             0, X86II::MRMDestReg)                 // R8  += R8
66 I(ADDrr16     , "addw",  0x01,             0, X86II::MRMDestReg | X86II::OpSize) // R16 += R16
67 I(ADDrr32     , "addl",  0x01,             0, X86II::MRMDestReg)                 // R32 += R32
68 I(SUBrr8      , "subb",  0x2A,             0, X86II::MRMDestReg)                 // R8  -= R8
69 I(SUBrr16     , "subw",  0x2B,             0, X86II::MRMDestReg | X86II::OpSize) // R16 -= R16
70 I(SUBrr32     , "subl",  0x2B,             0, X86II::MRMDestReg)                 // R32 -= R32
71 I(MULrr8      , "mulb",  0xF6,             0, X86II::MRMS4r     | X86II::Void)   // AX   = AL*R8
72 I(MULrr16     , "mulw",  0xF7,             0, X86II::MRMS4r     | X86II::Void |  // DX:AX= AX*R16
73                                               X86II::OpSize)
74 I(MULrr32     , "mull",  0xF7,             0, X86II::MRMS4r     | X86II::Void)   // ED:EA= EA*R32
75
76 // unsigned division/remainder
77 I(DIVrr8      , "divb",  0xF6,             0, X86II::MRMS6r     | X86II::Void)   // AX/r8= AL&AH
78 I(DIVrr16     , "divw",  0xF7,             0, X86II::MRMS6r     | X86II::Void |  // DA/r16=AX&DX
79                                               X86II::OpSize)
80 I(DIVrr32     , "divl",  0xF7,             0, X86II::MRMS6r     | X86II::Void)   // DA/r32=EAX&DX
81
82 // signed division/remainder
83 I(IDIVrr8     , "idivb", 0xF6,             0, X86II::MRMS7r     | X86II::Void)   // AX/r8= AL&AH
84 I(IDIVrr16    , "idivw", 0xF7,             0, X86II::MRMS7r     | X86II::Void |  // DA/r16=AX&DX
85                                               X86II::OpSize)
86 I(IDIVrr32    , "idivl", 0xF7,             0, X86II::MRMS7r     | X86II::Void)   // DA/r32=EAX&DX
87
88 // Logical operators
89 I(ANDrr8      , "andb",  0x20,             0, X86II::MRMDestReg)                 // R8  &= R8
90 I(ANDrr16     , "andw",  0x21,             0, X86II::MRMDestReg | X86II::OpSize) // R16 &= R16
91 I(ANDrr32     , "andl",  0x21,             0, X86II::MRMDestReg)                 // R32 &= R32
92 I(ORrr8       , "orb",   0x08,             0, X86II::MRMDestReg)                 // R8  |= R8
93 I(ORrr16      , "orw",   0x09,             0, X86II::MRMDestReg | X86II::OpSize) // R16 |= R16
94 I(ORrr32      , "orl",   0x09,             0, X86II::MRMDestReg)                 // R32 |= R32
95 I(XORrr8      , "xorb",  0x30,             0, X86II::MRMDestReg)                 // R8  ^= R8
96 I(XORrr16     , "xorw",  0x31,             0, X86II::MRMDestReg | X86II::OpSize) // R16 ^= R16
97 I(XORrr32     , "xorl",  0x31,             0, X86II::MRMDestReg)                 // R32 ^= R32
98
99 // Shift instructions
100 I(SHLrr8      , "shlb",  0xD2,             0, X86II::MRMS4r)                     // R8   <<= cl   D2/4
101 I(SHLrr16     , "shlw",  0xD3,             0, X86II::MRMS4r | X86II::OpSize)     // R16  <<= cl   D3/4
102 I(SHLrr32     , "shll",  0xD3,             0, X86II::MRMS4r)                     // R32  <<= cl   D3/4
103 I(SHLir8      , "shlb",  0xC0,             0, X86II::MRMS4r)                     // R8   <<= imm8 C0/4 ib
104 I(SHLir16     , "shlw",  0xC1,             0, X86II::MRMS4r | X86II::OpSize)     // R16  <<= imm8 C1/4 ib
105 I(SHLir32     , "shll",  0xC1,             0, X86II::MRMS4r)                     // R32  <<= imm8 C1/4 ib
106 I(SHRrr8      , "shrb",  0xD2,             0, X86II::MRMS5r)                     // R8  >>>= cl   D2/5
107 I(SHRrr16     , "shrw",  0xD3,             0, X86II::MRMS5r | X86II::OpSize)     // R16 >>>= cl   D3/5
108 I(SHRrr32     , "shrl",  0xD3,             0, X86II::MRMS5r)                     // R32 >>>= cl   D3/5
109 I(SHRir8      , "shrb",  0xC0,             0, X86II::MRMS5r)                     // R8  >>>= imm8 C0/5 ib
110 I(SHRir16     , "shrw",  0xC1,             0, X86II::MRMS5r | X86II::OpSize)     // R16 >>>= imm8 C1/5 ib
111 I(SHRir32     , "shrl",  0xC1,             0, X86II::MRMS5r)                     // R32 >>>= imm8 C1/5 ib
112 I(SARrr8      , "sarb",  0xD2,             0, X86II::MRMS7r)                     // R8   >>= cl   D2/7
113 I(SARrr16     , "sarw",  0xD3,             0, X86II::MRMS7r | X86II::OpSize)     // R16  >>= cl   D3/7
114 I(SARrr32     , "sarl",  0xD3,             0, X86II::MRMS7r)                     // R32  >>= cl   D3/7
115 I(SARir8      , "sarb",  0xC0,             0, X86II::MRMS7r)                     // R8   >>= imm8 C0/7 ib
116 I(SARir16     , "sarw",  0xC1,             0, X86II::MRMS7r | X86II::OpSize)     // R16  >>= imm8 C1/7 ib
117 I(SARir32     , "sarl",  0xC1,             0, X86II::MRMS7r)                     // R32  >>= imm8 C1/7 ib
118
119 // Floating point loads
120 I(FLDr4       , "flds",  0xD9,             0, X86II::MRMS0m)                     // push float    D9/0
121 I(FLDr8       , "fldl ", 0xDD,             0, X86II::MRMS0m)                     // push double   DD/0
122
123 // Floating point compares
124 I(FUCOMPP     , "fucompp", 0xDA,           0, X86II::Void)                       // compare+pop2x DA E9
125
126 // Floating point flag ops
127 I(FNSTSWr8    , "fnstsw", 0xDF,            0, X86II::Void)                       // AX = fp flags DF E0
128
129 // Condition code ops, incl. set if equal/not equal/...
130 I(SAHF        , "sahf",  0x9E,             0, X86II::RawFrm)                     // flags = AH
131 I(SETBr       , "setb",  0x92,             0, X86II::TB | X86II::MRMS0r)         // R8 = < unsign
132 I(SETAEr      , "setae", 0x93,             0, X86II::TB | X86II::MRMS0r)         // R8 = >=unsign
133 I(SETEr       , "sete",  0x94,             0, X86II::TB | X86II::MRMS0r)         // R8 = ==
134 I(SETNEr      , "setne", 0x95,             0, X86II::TB | X86II::MRMS0r)         // R8 = !=
135 I(SETBEr      , "setbe", 0x96,             0, X86II::TB | X86II::MRMS0r)         // R8 = <=unsign
136 I(SETAr       , "seta",  0x97,             0, X86II::TB | X86II::MRMS0r)         // R8 = > unsign
137 I(SETLr       , "setl",  0x9C,             0, X86II::TB | X86II::MRMS0r)         // R8 = < signed
138 I(SETGEr      , "setge", 0x9D,             0, X86II::TB | X86II::MRMS0r)         // R8 = >=signed
139 I(SETLEr      , "setle", 0x9E,             0, X86II::TB | X86II::MRMS0r)         // R8 = <=signed
140 I(SETGr       , "setg",  0x9F,             0, X86II::TB | X86II::MRMS0r)         // R8 = > signed
141
142 // Integer comparisons
143 I(CMPrr8      , "cmpb",  0x38,             0, X86II::MRMDestReg)                 // compare R8,R8
144 I(CMPrr16     , "cmpw",  0x39,             0, X86II::MRMDestReg | X86II::OpSize) // compare R16,R16
145 I(CMPrr32     , "cmpl",  0x39,             0, X86II::MRMDestReg)                 // compare R32,R32
146 I(CMPri8      , "cmp",   0x80,             0, X86II::MRMS7r)                     // compare R8, imm8
147
148 // Sign extenders (first 3 are good for DIV/IDIV; the others are more general)
149 I(CBW         , "cbw",   0x98,             0, X86II::RawFrm)                     // AX = signext(AL)
150 I(CWD         , "cwd",   0x99,             0, X86II::RawFrm)                     // DX:AX = signext(AX)
151 I(CDQ         , "cdq",   0x99,             0, X86II::RawFrm)                     // EDX:EAX = signext(EAX)
152 I(MOVSXr16r8  , "movsx", 0xBE,             0, X86II::MRMSrcReg | X86II::TB |   // R16 = signext(R8)
153                                               X86II::OpSize)
154 I(MOVSXr32r8  , "movsx", 0xBE,             0, X86II::MRMSrcReg | X86II::TB)    // R32 = signext(R8)
155 I(MOVSXr32r16 , "movsx", 0xBF,             0, X86II::MRMSrcReg | X86II::TB)    // R32 = signext(R16)
156 I(MOVZXr16r8  , "movzx", 0xB6,             0, X86II::MRMSrcReg | X86II::TB |   // R16 = zeroext(R8)
157                                               X86II::OpSize)
158 I(MOVZXr32r8  , "movzx", 0xB6,             0, X86II::MRMSrcReg | X86II::TB)    // R32 = zeroext(R8)
159 I(MOVZXr32r16 , "movzx", 0xB7,             0, X86II::MRMSrcReg | X86II::TB)    // R32 = zeroext(R16)
160
161 // At this point, I is dead, so undefine the macro
162 #undef I