Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 1 | //===- X86InstrSystem.td - System Instructions -------------*- tablegen -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the X86 instructions that are generally used in |
| 11 | // privileged modes. These are not typically used by the compiler, but are |
| 12 | // supported for the assembler and disassembler. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | let Defs = [RAX, RDX] in |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 17 | def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 18 | |
| 19 | let Defs = [RAX, RCX, RDX] in |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 20 | def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 21 | |
| 22 | // CPU flow control instructions |
| 23 | |
Kevin Enderby | 529b1a4 | 2010-10-27 20:46:49 +0000 | [diff] [blame] | 24 | let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in { |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 25 | def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB; |
Kevin Enderby | 529b1a4 | 2010-10-27 20:46:49 +0000 | [diff] [blame] | 26 | def UD2B : I<0xB9, RawFrm, (outs), (ins), "ud2b", []>, TB; |
| 27 | } |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 28 | |
| 29 | def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>; |
| 30 | def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB; |
| 31 | |
| 32 | // Interrupt and SysCall Instructions. |
| 33 | let Uses = [EFLAGS] in |
| 34 | def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>; |
| 35 | def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", |
| 36 | [(int_x86_int (i8 3))]>; |
Chris Lattner | 15f8951 | 2011-04-09 19:41:05 +0000 | [diff] [blame] | 37 | |
| 38 | // The long form of "int $3" turns into int3 as a size optimization. |
| 39 | // FIXME: This doesn't work because InstAlias can't match immediate constants. |
| 40 | //def : InstAlias<"int\t$3", (INT3)>; |
| 41 | |
| 42 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 43 | def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", |
| 44 | [(int_x86_int imm:$trap)]>; |
| 45 | |
Chris Lattner | 15f8951 | 2011-04-09 19:41:05 +0000 | [diff] [blame] | 46 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 47 | def SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", []>, TB; |
| 48 | def SYSRETL : I<0x07, RawFrm, (outs), (ins), "sysretl", []>, TB; |
| 49 | def SYSRETQ :RI<0x07, RawFrm, (outs), (ins), "sysretq", []>, TB, |
| 50 | Requires<[In64BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 51 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 52 | def SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", []>, TB; |
| 53 | |
| 54 | def SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit", []>, TB, |
| 55 | Requires<[In32BitMode]>; |
| 56 | def SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexit", []>, TB, |
| 57 | Requires<[In64BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 58 | |
| 59 | def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iretw", []>, OpSize; |
| 60 | def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l|d}", []>; |
| 61 | def IRET64 : RI<0xcf, RawFrm, (outs), (ins), "iretq", []>, |
| 62 | Requires<[In64BitMode]>; |
| 63 | |
| 64 | |
| 65 | //===----------------------------------------------------------------------===// |
| 66 | // Input/Output Instructions. |
| 67 | // |
| 68 | let Defs = [AL], Uses = [DX] in |
| 69 | def IN8rr : I<0xEC, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 70 | "in{b}\t{%dx, %al|AL, DX}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 71 | let Defs = [AX], Uses = [DX] in |
| 72 | def IN16rr : I<0xED, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 73 | "in{w}\t{%dx, %ax|AX, DX}", []>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 74 | let Defs = [EAX], Uses = [DX] in |
| 75 | def IN32rr : I<0xED, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 76 | "in{l}\t{%dx, %eax|EAX, DX}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 77 | |
| 78 | let Defs = [AL] in |
| 79 | def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i8imm:$port), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 80 | "in{b}\t{$port, %al|AL, $port}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 81 | let Defs = [AX] in |
| 82 | def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 83 | "in{w}\t{$port, %ax|AX, $port}", []>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 84 | let Defs = [EAX] in |
| 85 | def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 86 | "in{l}\t{$port, %eax|EAX, $port}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 87 | |
| 88 | let Uses = [DX, AL] in |
| 89 | def OUT8rr : I<0xEE, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 90 | "out{b}\t{%al, %dx|DX, AL}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 91 | let Uses = [DX, AX] in |
| 92 | def OUT16rr : I<0xEF, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 93 | "out{w}\t{%ax, %dx|DX, AX}", []>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 94 | let Uses = [DX, EAX] in |
| 95 | def OUT32rr : I<0xEF, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 96 | "out{l}\t{%eax, %dx|DX, EAX}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 97 | |
| 98 | let Uses = [AL] in |
| 99 | def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i8imm:$port), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 100 | "out{b}\t{%al, $port|$port, AL}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 101 | let Uses = [AX] in |
| 102 | def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 103 | "out{w}\t{%ax, $port|$port, AX}", []>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 104 | let Uses = [EAX] in |
| 105 | def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 106 | "out{l}\t{%eax, $port|$port, EAX}", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 107 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 108 | def IN8 : I<0x6C, RawFrm, (outs), (ins), "ins{b}", []>; |
| 109 | def IN16 : I<0x6D, RawFrm, (outs), (ins), "ins{w}", []>, OpSize; |
| 110 | def IN32 : I<0x6D, RawFrm, (outs), (ins), "ins{l}", []>; |
| 111 | |
| 112 | //===----------------------------------------------------------------------===// |
| 113 | // Moves to and from debug registers |
| 114 | |
| 115 | def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src), |
| 116 | "mov{l}\t{$src, $dst|$dst, $src}", []>, TB; |
| 117 | def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src), |
| 118 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 119 | |
| 120 | def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src), |
| 121 | "mov{l}\t{$src, $dst|$dst, $src}", []>, TB; |
| 122 | def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src), |
| 123 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 124 | |
| 125 | //===----------------------------------------------------------------------===// |
| 126 | // Moves to and from control registers |
| 127 | |
| 128 | def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src), |
| 129 | "mov{l}\t{$src, $dst|$dst, $src}", []>, TB; |
| 130 | def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src), |
| 131 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 132 | |
| 133 | def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src), |
| 134 | "mov{l}\t{$src, $dst|$dst, $src}", []>, TB; |
| 135 | def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src), |
| 136 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 137 | |
| 138 | //===----------------------------------------------------------------------===// |
| 139 | // Segment override instruction prefixes |
| 140 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 141 | def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>; |
| 142 | def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>; |
| 143 | def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>; |
| 144 | def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>; |
| 145 | def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>; |
| 146 | def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 147 | |
| 148 | |
| 149 | //===----------------------------------------------------------------------===// |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 150 | // Moves to and from segment registers. |
| 151 | // |
| 152 | |
| 153 | def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src), |
| 154 | "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize; |
| 155 | def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src), |
| 156 | "mov{l}\t{$src, $dst|$dst, $src}", []>; |
| 157 | def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src), |
| 158 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 159 | |
| 160 | def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src), |
| 161 | "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize; |
| 162 | def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src), |
| 163 | "mov{l}\t{$src, $dst|$dst, $src}", []>; |
| 164 | def MOV64ms : RI<0x8C, MRMDestMem, (outs i64mem:$dst), (ins SEGMENT_REG:$src), |
| 165 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 166 | |
| 167 | def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src), |
| 168 | "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize; |
| 169 | def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src), |
| 170 | "mov{l}\t{$src, $dst|$dst, $src}", []>; |
| 171 | def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src), |
| 172 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 173 | |
| 174 | def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src), |
| 175 | "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize; |
| 176 | def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src), |
| 177 | "mov{l}\t{$src, $dst|$dst, $src}", []>; |
| 178 | def MOV64sm : RI<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i64mem:$src), |
| 179 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 180 | |
| 181 | //===----------------------------------------------------------------------===// |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 182 | // Segmentation support instructions. |
| 183 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 184 | def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB; |
| 185 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 186 | def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src), |
| 187 | "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 188 | def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src), |
| 189 | "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 190 | |
| 191 | // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo. |
| 192 | def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src), |
| 193 | "lar{l}\t{$src, $dst|$dst, $src}", []>, TB; |
| 194 | def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src), |
| 195 | "lar{l}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 196 | // i16mem operand in LAR64rm and GR32 operand in LAR32rr is not a typo. |
| 197 | def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
| 198 | "lar{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 199 | def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
| 200 | "lar{q}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 201 | |
| 202 | def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src), |
| 203 | "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 204 | def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src), |
| 205 | "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 206 | def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src), |
| 207 | "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB; |
| 208 | def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src), |
| 209 | "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 210 | def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 211 | "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 212 | def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
| 213 | "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 214 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 215 | def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB; |
| 216 | |
Eli Friedman | ac39bd5 | 2011-03-04 00:10:17 +0000 | [diff] [blame] | 217 | def STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins), |
| 218 | "str{w}\t{$dst}", []>, TB, OpSize; |
| 219 | def STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins), |
| 220 | "str{l}\t{$dst}", []>, TB; |
| 221 | def STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins), |
| 222 | "str{q}\t{$dst}", []>, TB; |
| 223 | def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins), |
| 224 | "str{w}\t{$dst}", []>, TB; |
| 225 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 226 | def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src), |
| 227 | "ltr{w}\t{$src}", []>, TB; |
| 228 | def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src), |
| 229 | "ltr{w}\t{$src}", []>, TB; |
| 230 | |
| 231 | def PUSHCS16 : I<0x0E, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 232 | "push{w}\t{%cs|CS}", []>, Requires<[In32BitMode]>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 233 | def PUSHCS32 : I<0x0E, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 234 | "push{l}\t{%cs|CS}", []>, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 235 | def PUSHSS16 : I<0x16, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 236 | "push{w}\t{%ss|SS}", []>, Requires<[In32BitMode]>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 237 | def PUSHSS32 : I<0x16, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 238 | "push{l}\t{%ss|SS}", []>, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 239 | def PUSHDS16 : I<0x1E, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 240 | "push{w}\t{%ds|DS}", []>, Requires<[In32BitMode]>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 241 | def PUSHDS32 : I<0x1E, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 242 | "push{l}\t{%ds|DS}", []>, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 243 | def PUSHES16 : I<0x06, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 244 | "push{w}\t{%es|ES}", []>, Requires<[In32BitMode]>, OpSize; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 245 | def PUSHES32 : I<0x06, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 246 | "push{l}\t{%es|ES}", []>, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 247 | |
| 248 | def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 249 | "push{w}\t{%fs|FS}", []>, OpSize, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 250 | def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 251 | "push{l}\t{%fs|FS}", []>, TB, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 252 | def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 253 | "push{w}\t{%gs|GS}", []>, OpSize, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 254 | def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 255 | "push{l}\t{%gs|GS}", []>, TB, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 256 | |
| 257 | def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 258 | "push{q}\t{%fs|FS}", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 259 | def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 260 | "push{q}\t{%gs|GS}", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 261 | |
| 262 | // No "pop cs" instruction. |
| 263 | def POPSS16 : I<0x17, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 264 | "pop{w}\t{%ss|SS}", []>, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 265 | def POPSS32 : I<0x17, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 266 | "pop{l}\t{%ss|SS}", []> , Requires<[In32BitMode]>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 267 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 268 | def POPDS16 : I<0x1F, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 269 | "pop{w}\t{%ds|DS}", []>, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 270 | def POPDS32 : I<0x1F, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 271 | "pop{l}\t{%ds|DS}", []> , Requires<[In32BitMode]>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 272 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 273 | def POPES16 : I<0x07, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 274 | "pop{w}\t{%es|ES}", []>, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 275 | def POPES32 : I<0x07, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 276 | "pop{l}\t{%es|ES}", []> , Requires<[In32BitMode]>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 277 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 278 | def POPFS16 : I<0xa1, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 279 | "pop{w}\t{%fs|FS}", []>, OpSize, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 280 | def POPFS32 : I<0xa1, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 281 | "pop{l}\t{%fs|FS}", []>, TB , Requires<[In32BitMode]>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 282 | def POPFS64 : I<0xa1, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 283 | "pop{q}\t{%fs|FS}", []>, TB; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 284 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 285 | def POPGS16 : I<0xa9, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 286 | "pop{w}\t{%gs|GS}", []>, OpSize, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 287 | def POPGS32 : I<0xa9, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 288 | "pop{l}\t{%gs|GS}", []>, TB , Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 289 | def POPGS64 : I<0xa9, RawFrm, (outs), (ins), |
Craig Topper | adf01b3 | 2011-09-22 07:01:50 +0000 | [diff] [blame^] | 290 | "pop{q}\t{%gs|GS}", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 291 | |
| 292 | |
| 293 | def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src), |
| 294 | "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize; |
| 295 | def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src), |
| 296 | "lds{l}\t{$src, $dst|$dst, $src}", []>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 297 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 298 | def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src), |
| 299 | "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 300 | def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src), |
| 301 | "lss{l}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 302 | def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src), |
| 303 | "lss{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 304 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 305 | def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src), |
| 306 | "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize; |
| 307 | def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src), |
| 308 | "les{l}\t{$src, $dst|$dst, $src}", []>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 309 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 310 | def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src), |
| 311 | "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 312 | def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src), |
| 313 | "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 314 | def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src), |
| 315 | "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 316 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 317 | def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src), |
| 318 | "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize; |
| 319 | def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src), |
| 320 | "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 321 | |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 322 | def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src), |
| 323 | "lgs{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 324 | |
| 325 | |
| 326 | def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg), |
Andrew Trick | 0966ec0 | 2010-10-22 03:58:29 +0000 | [diff] [blame] | 327 | "verr\t$seg", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 328 | def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg), |
Andrew Trick | 0966ec0 | 2010-10-22 03:58:29 +0000 | [diff] [blame] | 329 | "verr\t$seg", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 330 | def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg), |
Andrew Trick | 0966ec0 | 2010-10-22 03:58:29 +0000 | [diff] [blame] | 331 | "verw\t$seg", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 332 | def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg), |
Andrew Trick | 0966ec0 | 2010-10-22 03:58:29 +0000 | [diff] [blame] | 333 | "verw\t$seg", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 334 | |
| 335 | //===----------------------------------------------------------------------===// |
| 336 | // Descriptor-table support instructions |
| 337 | |
Kevin Enderby | 87f4a1a | 2010-10-19 00:01:44 +0000 | [diff] [blame] | 338 | def SGDT16m : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins), |
| 339 | "sgdtw\t$dst", []>, TB, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 340 | def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins), |
| 341 | "sgdt\t$dst", []>, TB; |
Kevin Enderby | 87f4a1a | 2010-10-19 00:01:44 +0000 | [diff] [blame] | 342 | def SIDT16m : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins), |
| 343 | "sidtw\t$dst", []>, TB, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 344 | def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins), |
| 345 | "sidt\t$dst", []>, TB; |
| 346 | def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins), |
| 347 | "sldt{w}\t$dst", []>, TB, OpSize; |
| 348 | def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins), |
| 349 | "sldt{w}\t$dst", []>, TB; |
| 350 | def SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins), |
| 351 | "sldt{l}\t$dst", []>, TB; |
Chris Lattner | 010496c | 2010-10-05 06:22:35 +0000 | [diff] [blame] | 352 | |
| 353 | // LLDT is not interpreted specially in 64-bit mode because there is no sign |
| 354 | // extension. |
| 355 | def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins), |
| 356 | "sldt{q}\t$dst", []>, TB; |
| 357 | def SLDT64m : RI<0x00, MRM0m, (outs i16mem:$dst), (ins), |
| 358 | "sldt{q}\t$dst", []>, TB; |
| 359 | |
Kevin Enderby | 87f4a1a | 2010-10-19 00:01:44 +0000 | [diff] [blame] | 360 | def LGDT16m : I<0x01, MRM2m, (outs), (ins opaque48mem:$src), |
| 361 | "lgdtw\t$src", []>, TB, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 362 | def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src), |
| 363 | "lgdt\t$src", []>, TB; |
Kevin Enderby | 87f4a1a | 2010-10-19 00:01:44 +0000 | [diff] [blame] | 364 | def LIDT16m : I<0x01, MRM3m, (outs), (ins opaque48mem:$src), |
| 365 | "lidtw\t$src", []>, TB, OpSize, Requires<[In32BitMode]>; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 366 | def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src), |
| 367 | "lidt\t$src", []>, TB; |
| 368 | def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src), |
| 369 | "lldt{w}\t$src", []>, TB; |
| 370 | def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src), |
| 371 | "lldt{w}\t$src", []>, TB; |
| 372 | |
| 373 | //===----------------------------------------------------------------------===// |
| 374 | // Specialized register support |
| 375 | def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB; |
| 376 | def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB; |
| 377 | def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB; |
| 378 | |
| 379 | def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins), |
| 380 | "smsw{w}\t$dst", []>, OpSize, TB; |
| 381 | def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins), |
| 382 | "smsw{l}\t$dst", []>, TB; |
Chris Lattner | 434c7cb | 2010-10-05 05:32:15 +0000 | [diff] [blame] | 383 | // no m form encodable; use SMSW16m |
| 384 | def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins), |
| 385 | "smsw{q}\t$dst", []>, TB; |
| 386 | |
| 387 | // For memory operands, there is only a 16-bit form |
| 388 | def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins), |
| 389 | "smsw{w}\t$dst", []>, TB; |
| 390 | |
| 391 | def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src), |
| 392 | "lmsw{w}\t$src", []>, TB; |
| 393 | def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src), |
| 394 | "lmsw{w}\t$src", []>, TB; |
| 395 | |
| 396 | def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB; |
| 397 | |
| 398 | //===----------------------------------------------------------------------===// |
| 399 | // Cache instructions |
| 400 | def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB; |
| 401 | def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB; |
| 402 | |
Rafael Espindola | 87ca0e0 | 2011-02-22 00:35:18 +0000 | [diff] [blame] | 403 | let Defs = [RDX, RAX], Uses = [RCX] in |
| 404 | def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB; |
| 405 | |
| 406 | let Uses = [RDX, RAX, RCX] in |
| 407 | def XSETBV : I<0x01, MRM_D1, (outs), (ins), "xsetbv", []>, TB; |
Joerg Sonnenberger | 4a8ac8d | 2011-04-04 16:58:13 +0000 | [diff] [blame] | 408 | |
| 409 | //===----------------------------------------------------------------------===// |
| 410 | // VIA PadLock crypto instructions |
| 411 | let Defs = [RAX, RDI], Uses = [RDX, RDI] in |
| 412 | def XSTORE : I<0xc0, RawFrm, (outs), (ins), "xstore", []>, A7; |
| 413 | |
Joerg Sonnenberger | ca0ede7 | 2011-06-30 01:38:03 +0000 | [diff] [blame] | 414 | def : InstAlias<"xstorerng", (XSTORE)>; |
| 415 | |
Joerg Sonnenberger | 4a8ac8d | 2011-04-04 16:58:13 +0000 | [diff] [blame] | 416 | let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in { |
| 417 | def XCRYPTECB : I<0xc8, RawFrm, (outs), (ins), "xcryptecb", []>, A7; |
| 418 | def XCRYPTCBC : I<0xd0, RawFrm, (outs), (ins), "xcryptcbc", []>, A7; |
| 419 | def XCRYPTCTR : I<0xd8, RawFrm, (outs), (ins), "xcryptctr", []>, A7; |
| 420 | def XCRYPTCFB : I<0xe0, RawFrm, (outs), (ins), "xcryptcfb", []>, A7; |
| 421 | def XCRYPTOFB : I<0xe8, RawFrm, (outs), (ins), "xcryptofb", []>, A7; |
| 422 | } |
| 423 | |
| 424 | let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in { |
| 425 | def XSHA1 : I<0xc8, RawFrm, (outs), (ins), "xsha1", []>, A6; |
| 426 | def XSHA256 : I<0xd0, RawFrm, (outs), (ins), "xsha256", []>, A6; |
| 427 | } |
| 428 | let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in |
| 429 | def MONTMUL : I<0xc0, RawFrm, (outs), (ins), "montmul", []>, A6; |