blob: 0350566f8b9b6048e23a0cd22008d828d2336cfe [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86InstrSystem.td - System Instructions ------------*- tablegen -*-===//
2//
Chris Lattnerdec85b82010-10-05 05:32:15 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jia Liub22310f2012-02-18 12:03:15 +00007//
Chris Lattnerdec85b82010-10-05 05:32:15 +00008//===----------------------------------------------------------------------===//
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
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000016let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000017let Defs = [RAX, RDX] in
Preston Gurdd6c440c2012-05-04 19:26:37 +000018 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)], IIC_RDTSC>,
19 TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000020
21let Defs = [RAX, RCX, RDX] in
Andrea Di Biagiod1ab8662014-04-24 17:18:27 +000022 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", [(X86rdtscp)]>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000023
24// CPU flow control instructions
25
Kevin Enderby5e7cb5f2010-10-27 20:46:49 +000026let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +000027 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Kevin Enderby5e7cb5f2010-10-27 20:46:49 +000028 def UD2B : I<0xB9, RawFrm, (outs), (ins), "ud2b", []>, TB;
29}
Chris Lattnerdec85b82010-10-05 05:32:15 +000030
Preston Gurdd6c440c2012-05-04 19:26:37 +000031def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", [], IIC_HLT>;
32def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", [], IIC_RSM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +000033
34// Interrupt and SysCall Instructions.
35let Uses = [EFLAGS] in
36 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
37def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3",
Preston Gurdd6c440c2012-05-04 19:26:37 +000038 [(int_x86_int (i8 3))], IIC_INT3>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000039} // SchedRW
Chris Lattnerfc4fe002011-04-09 19:41:05 +000040
41// The long form of "int $3" turns into int3 as a size optimization.
42// FIXME: This doesn't work because InstAlias can't match immediate constants.
43//def : InstAlias<"int\t$3", (INT3)>;
44
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000045let SchedRW = [WriteSystem] in {
Chris Lattnerfc4fe002011-04-09 19:41:05 +000046
Chris Lattnerdec85b82010-10-05 05:32:15 +000047def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap",
Preston Gurdd6c440c2012-05-04 19:26:37 +000048 [(int_x86_int imm:$trap)], IIC_INT>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000049
Chris Lattnerfc4fe002011-04-09 19:41:05 +000050
Preston Gurdd6c440c2012-05-04 19:26:37 +000051def SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", [], IIC_SYSCALL>, TB;
52def SYSRET : I<0x07, RawFrm, (outs), (ins), "sysret{l}", [], IIC_SYSCALL>, TB;
53def SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysret{q}", [], IIC_SYSCALL>, TB,
Chris Lattnerae33f5d2010-10-05 06:04:14 +000054 Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000055
Preston Gurdd6c440c2012-05-04 19:26:37 +000056def SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", [],
57 IIC_SYS_ENTER_EXIT>, TB;
58
59def SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", [],
60 IIC_SYS_ENTER_EXIT>, TB;
Craig Topper9df497e2014-02-26 06:50:27 +000061def SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexit{q}", [],
62 IIC_SYS_ENTER_EXIT>, TB, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000063
Craig Topperfa6298a2014-02-02 09:25:09 +000064def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", [], IIC_IRET>, OpSize16;
David Woodhouse956965c2014-01-08 12:57:40 +000065def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l|d}", [], IIC_IRET>,
Craig Topperfa6298a2014-02-02 09:25:09 +000066 OpSize32;
Preston Gurdd6c440c2012-05-04 19:26:37 +000067def IRET64 : RI<0xcf, RawFrm, (outs), (ins), "iretq", [], IIC_IRET>,
Chris Lattnerdec85b82010-10-05 05:32:15 +000068 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000069} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +000070
Alex Rosenbergb9fefdd2015-01-26 19:09:27 +000071def : Pat<(debugtrap),
72 (INT3)>, Requires<[NotPS4]>;
73def : Pat<(debugtrap),
74 (INT (i8 0x41))>, Requires<[IsPS4]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000075
76//===----------------------------------------------------------------------===//
77// Input/Output Instructions.
78//
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000079let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000080let Defs = [AL], Uses = [DX] in
81def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +000082 "in{b}\t{%dx, %al|al, dx}", [], IIC_IN_RR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000083let Defs = [AX], Uses = [DX] in
84def IN16rr : I<0xED, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +000085 "in{w}\t{%dx, %ax|ax, dx}", [], IIC_IN_RR>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000086let Defs = [EAX], Uses = [DX] in
87def IN32rr : I<0xED, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +000088 "in{l}\t{%dx, %eax|eax, dx}", [], IIC_IN_RR>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000089
90let Defs = [AL] in
91def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i8imm:$port),
Craig Topperefd67d42013-07-31 02:47:52 +000092 "in{b}\t{$port, %al|al, $port}", [], IIC_IN_RI>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000093let Defs = [AX] in
94def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port),
Craig Topperfa6298a2014-02-02 09:25:09 +000095 "in{w}\t{$port, %ax|ax, $port}", [], IIC_IN_RI>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +000096let Defs = [EAX] in
97def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port),
Craig Topperfa6298a2014-02-02 09:25:09 +000098 "in{l}\t{$port, %eax|eax, $port}", [], IIC_IN_RI>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +000099
100let Uses = [DX, AL] in
101def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000102 "out{b}\t{%al, %dx|dx, al}", [], IIC_OUT_RR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000103let Uses = [DX, AX] in
104def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000105 "out{w}\t{%ax, %dx|dx, ax}", [], IIC_OUT_RR>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000106let Uses = [DX, EAX] in
107def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000108 "out{l}\t{%eax, %dx|dx, eax}", [], IIC_OUT_RR>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000109
110let Uses = [AL] in
111def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i8imm:$port),
Craig Topperefd67d42013-07-31 02:47:52 +0000112 "out{b}\t{%al, $port|$port, al}", [], IIC_OUT_IR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000113let Uses = [AX] in
114def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port),
Craig Topperfa6298a2014-02-02 09:25:09 +0000115 "out{w}\t{%ax, $port|$port, ax}", [], IIC_OUT_IR>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000116let Uses = [EAX] in
117def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port),
Craig Topperfa6298a2014-02-02 09:25:09 +0000118 "out{l}\t{%eax, $port|$port, eax}", [], IIC_OUT_IR>, OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000119
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000120} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000121
122//===----------------------------------------------------------------------===//
123// Moves to and from debug registers
124
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000125let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000126def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000127 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_DR>, TB,
128 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000129def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000130 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_DR>, TB,
131 Requires<[In64BitMode]>;
132
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000133def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000134 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_DR_REG>, TB,
135 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000136def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000137 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_DR_REG>, TB,
138 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000139} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000140
141//===----------------------------------------------------------------------===//
142// Moves to and from control registers
143
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000144let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000145def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000146 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_CR>, TB,
147 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000148def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000149 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_CR>, TB,
150 Requires<[In64BitMode]>;
151
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000152def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000153 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_CR_REG>, TB,
154 Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000155def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src),
Craig Topperbc281ad82014-01-04 22:29:41 +0000156 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_CR_REG>, TB,
157 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000158} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000159
160//===----------------------------------------------------------------------===//
161// Segment override instruction prefixes
162
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000163def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
164def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
165def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
166def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
167def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
168def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000169
170
171//===----------------------------------------------------------------------===//
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000172// Moves to and from segment registers.
173//
174
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000175let SchedRW = [WriteMove] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000176def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000177 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_SR>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000178def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000179 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_SR>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000180def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000181 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_SR>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000182
183def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000184 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_MEM_SR>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000185def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000186 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_MEM_SR>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000187def MOV64ms : RI<0x8C, MRMDestMem, (outs i64mem:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000188 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_MEM_SR>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000189
190def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000191 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_REG>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000192def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000193 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_REG>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000194def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000195 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_REG>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000196
197def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000198 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_MEM>, OpSize16;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000199def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000200 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_MEM>, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000201def MOV64sm : RI<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i64mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000202 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_MEM>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000203} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000204
205//===----------------------------------------------------------------------===//
Chris Lattnerdec85b82010-10-05 05:32:15 +0000206// Segmentation support instructions.
207
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000208let SchedRW = [WriteSystem] in {
Preston Gurdd6c440c2012-05-04 19:26:37 +0000209def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", [], IIC_SWAPGS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000210
Michael Liao5bf95782014-12-04 05:20:33 +0000211def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000212 "lar{w}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RM>, TB,
213 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000214def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000215 "lar{w}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RR>, TB,
216 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000217
218// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
Michael Liao5bf95782014-12-04 05:20:33 +0000219def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
David Woodhouse956965c2014-01-08 12:57:40 +0000220 "lar{l}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RM>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000221 OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000222def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
David Woodhouse956965c2014-01-08 12:57:40 +0000223 "lar{l}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RR>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000224 OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000225// i16mem operand in LAR64rm and GR32 operand in LAR32rr is not a typo.
Michael Liao5bf95782014-12-04 05:20:33 +0000226def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000227 "lar{q}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RM>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000228def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000229 "lar{q}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000230
231def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000232 "lsl{w}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RM>, TB,
233 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000234def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000235 "lsl{w}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RR>, TB,
236 OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000237def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
David Woodhouse956965c2014-01-08 12:57:40 +0000238 "lsl{l}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RM>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000239 OpSize32;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000240def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
David Woodhouse956965c2014-01-08 12:57:40 +0000241 "lsl{l}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RR>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000242 OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000243def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Michael Liao5bf95782014-12-04 05:20:33 +0000244 "lsl{q}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RM>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000245def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000246 "lsl{q}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000247
Preston Gurdd6c440c2012-05-04 19:26:37 +0000248def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr",
249 [], IIC_INVLPG>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000250
Eli Friedmanf63614a2011-03-04 00:10:17 +0000251def STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000252 "str{w}\t$dst", [], IIC_STR>, TB, OpSize16;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000253def STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000254 "str{l}\t$dst", [], IIC_STR>, TB, OpSize32;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000255def STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000256 "str{q}\t$dst", [], IIC_STR>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000257def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000258 "str{w}\t$dst", [], IIC_STR>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000259
Chris Lattnerdec85b82010-10-05 05:32:15 +0000260def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000261 "ltr{w}\t$src", [], IIC_LTR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000262def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000263 "ltr{w}\t$src", [], IIC_LTR>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000264
Chris Lattnerdec85b82010-10-05 05:32:15 +0000265def PUSHCS16 : I<0x0E, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000266 "push{w}\t{%cs|cs}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000267 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000268def PUSHCS32 : I<0x0E, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000269 "push{l}\t{%cs|cs}", [], IIC_PUSH_CS>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000270 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000271def PUSHSS16 : I<0x16, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000272 "push{w}\t{%ss|ss}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000273 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000274def PUSHSS32 : I<0x16, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000275 "push{l}\t{%ss|ss}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000276 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000277def PUSHDS16 : I<0x1E, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000278 "push{w}\t{%ds|ds}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000279 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000280def PUSHDS32 : I<0x1E, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000281 "push{l}\t{%ds|ds}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000282 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000283def PUSHES16 : I<0x06, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000284 "push{w}\t{%es|es}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000285 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000286def PUSHES32 : I<0x06, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000287 "push{l}\t{%es|es}", [], IIC_PUSH_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000288 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000289def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000290 "push{w}\t{%fs|fs}", [], IIC_PUSH_SR>, OpSize16, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000291def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000292 "push{l}\t{%fs|fs}", [], IIC_PUSH_SR>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000293 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000294def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000295 "push{w}\t{%gs|gs}", [], IIC_PUSH_SR>, OpSize16, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000296def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000297 "push{l}\t{%gs|gs}", [], IIC_PUSH_SR>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000298 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000299def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins),
Craig Topper6872fd32014-02-18 08:18:29 +0000300 "push{q}\t{%fs|fs}", [], IIC_PUSH_SR>, TB,
301 OpSize32, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000302def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins),
Craig Topper6872fd32014-02-18 08:18:29 +0000303 "push{q}\t{%gs|gs}", [], IIC_PUSH_SR>, TB,
304 OpSize32, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000305
306// No "pop cs" instruction.
307def POPSS16 : I<0x17, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000308 "pop{w}\t{%ss|ss}", [], IIC_POP_SR_SS>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000309 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000310def POPSS32 : I<0x17, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000311 "pop{l}\t{%ss|ss}", [], IIC_POP_SR_SS>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000312 OpSize32, Requires<[Not64BitMode]>;
313
Chris Lattnerdec85b82010-10-05 05:32:15 +0000314def POPDS16 : I<0x1F, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000315 "pop{w}\t{%ds|ds}", [], IIC_POP_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000316 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000317def POPDS32 : I<0x1F, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000318 "pop{l}\t{%ds|ds}", [], IIC_POP_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000319 OpSize32, Requires<[Not64BitMode]>;
320
Chris Lattnerdec85b82010-10-05 05:32:15 +0000321def POPES16 : I<0x07, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000322 "pop{w}\t{%es|es}", [], IIC_POP_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000323 OpSize16, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000324def POPES32 : I<0x07, RawFrm, (outs), (ins),
Craig Topperefd67d42013-07-31 02:47:52 +0000325 "pop{l}\t{%es|es}", [], IIC_POP_SR>,
Craig Topperfa6298a2014-02-02 09:25:09 +0000326 OpSize32, Requires<[Not64BitMode]>;
327
Chris Lattnerdec85b82010-10-05 05:32:15 +0000328def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000329 "pop{w}\t{%fs|fs}", [], IIC_POP_SR>, OpSize16, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000330def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000331 "pop{l}\t{%fs|fs}", [], IIC_POP_SR>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000332 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000333def POPFS64 : I<0xa1, RawFrm, (outs), (ins),
Craig Topper6872fd32014-02-18 08:18:29 +0000334 "pop{q}\t{%fs|fs}", [], IIC_POP_SR>, TB,
335 OpSize32, Requires<[In64BitMode]>;
336
Chris Lattnerdec85b82010-10-05 05:32:15 +0000337def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000338 "pop{w}\t{%gs|gs}", [], IIC_POP_SR>, OpSize16, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000339def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
David Woodhouse956965c2014-01-08 12:57:40 +0000340 "pop{l}\t{%gs|gs}", [], IIC_POP_SR>, TB,
Craig Topperfa6298a2014-02-02 09:25:09 +0000341 OpSize32, Requires<[Not64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000342def POPGS64 : I<0xa9, RawFrm, (outs), (ins),
Craig Topper6872fd32014-02-18 08:18:29 +0000343 "pop{q}\t{%gs|gs}", [], IIC_POP_SR>, TB,
344 OpSize32, Requires<[In64BitMode]>;
345
Chris Lattnerdec85b82010-10-05 05:32:15 +0000346
347def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000348 "lds{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000349def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000350 "lds{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, OpSize32;
Michael Liao5bf95782014-12-04 05:20:33 +0000351
Chris Lattnerdec85b82010-10-05 05:32:15 +0000352def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000353 "lss{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000354def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000355 "lss{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000356def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000357 "lss{q}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000358
Chris Lattnerdec85b82010-10-05 05:32:15 +0000359def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000360 "les{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000361def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000362 "les{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, OpSize32;
Michael Liao5bf95782014-12-04 05:20:33 +0000363
Chris Lattnerdec85b82010-10-05 05:32:15 +0000364def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000365 "lfs{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000366def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000367 "lfs{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize32;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000368def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000369 "lfs{q}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000370
Chris Lattnerdec85b82010-10-05 05:32:15 +0000371def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000372 "lgs{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000373def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000374 "lgs{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize32;
Michael Liao5bf95782014-12-04 05:20:33 +0000375
Chris Lattnerdec85b82010-10-05 05:32:15 +0000376def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000377 "lgs{q}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000378
379
380def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000381 "verr\t$seg", [], IIC_VERR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000382def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000383 "verr\t$seg", [], IIC_VERR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000384def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000385 "verw\t$seg", [], IIC_VERW_MEM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000386def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000387 "verw\t$seg", [], IIC_VERW_REG>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000388} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000389
390//===----------------------------------------------------------------------===//
391// Descriptor-table support instructions
392
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000393let SchedRW = [WriteSystem] in {
Kevin Enderby49843c02010-10-19 00:01:44 +0000394def SGDT16m : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000395 "sgdt{w}\t$dst", [], IIC_SGDT>, TB, OpSize16, Requires<[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000396def SGDT32m : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000397 "sgdt{l}\t$dst", [], IIC_SGDT>, OpSize32, TB, Requires <[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000398def SGDT64m : I<0x01, MRM0m, (outs opaque80mem:$dst), (ins),
399 "sgdt{q}\t$dst", [], IIC_SGDT>, TB, Requires <[In64BitMode]>;
Kevin Enderby49843c02010-10-19 00:01:44 +0000400def SIDT16m : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000401 "sidt{w}\t$dst", [], IIC_SIDT>, TB, OpSize16, Requires<[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000402def SIDT32m : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000403 "sidt{l}\t$dst", []>, OpSize32, TB, Requires <[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000404def SIDT64m : I<0x01, MRM1m, (outs opaque80mem:$dst), (ins),
405 "sidt{q}\t$dst", []>, TB, Requires <[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000406def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000407 "sldt{w}\t$dst", [], IIC_SLDT>, TB, OpSize16;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000408def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000409 "sldt{w}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000410def SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000411 "sldt{l}\t$dst", [], IIC_SLDT>, OpSize32, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000412
Chris Lattnerc184a572010-10-05 06:22:35 +0000413// LLDT is not interpreted specially in 64-bit mode because there is no sign
414// extension.
415def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000416 "sldt{q}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerc184a572010-10-05 06:22:35 +0000417def SLDT64m : RI<0x00, MRM0m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000418 "sldt{q}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerc184a572010-10-05 06:22:35 +0000419
Kevin Enderby49843c02010-10-19 00:01:44 +0000420def LGDT16m : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000421 "lgdt{w}\t$src", [], IIC_LGDT>, TB, OpSize16, Requires<[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000422def LGDT32m : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000423 "lgdt{l}\t$src", [], IIC_LGDT>, OpSize32, TB, Requires<[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000424def LGDT64m : I<0x01, MRM2m, (outs), (ins opaque80mem:$src),
425 "lgdt{q}\t$src", [], IIC_LGDT>, TB, Requires<[In64BitMode]>;
Kevin Enderby49843c02010-10-19 00:01:44 +0000426def LIDT16m : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000427 "lidt{w}\t$src", [], IIC_LIDT>, TB, OpSize16, Requires<[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000428def LIDT32m : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
Craig Topperfa6298a2014-02-02 09:25:09 +0000429 "lidt{l}\t$src", [], IIC_LIDT>, OpSize32, TB, Requires<[Not64BitMode]>;
David Woodhousec178fbe2014-01-08 12:57:55 +0000430def LIDT64m : I<0x01, MRM3m, (outs), (ins opaque80mem:$src),
431 "lidt{q}\t$src", [], IIC_LIDT>, TB, Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000432def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000433 "lldt{w}\t$src", [], IIC_LLDT_REG>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000434def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000435 "lldt{w}\t$src", [], IIC_LLDT_MEM>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000436} // SchedRW
437
Chris Lattnerdec85b82010-10-05 05:32:15 +0000438//===----------------------------------------------------------------------===//
439// Specialized register support
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000440let SchedRW = [WriteSystem] in {
Craig Toppere169c572015-02-07 23:36:51 +0000441let Uses = [EAX, ECX, EDX] in
Preston Gurdd6c440c2012-05-04 19:26:37 +0000442def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", [], IIC_WRMSR>, TB;
Craig Toppere169c572015-02-07 23:36:51 +0000443let Defs = [EAX, EDX], Uses = [ECX] in
Preston Gurdd6c440c2012-05-04 19:26:37 +0000444def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", [], IIC_RDMSR>, TB;
Andrea Di Biagio53b68302014-06-30 17:14:21 +0000445
446let Defs = [RAX, RDX], Uses = [ECX] in
447 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", [(X86rdpmc)], IIC_RDPMC>,
448 TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000449
Michael Liao5bf95782014-12-04 05:20:33 +0000450def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000451 "smsw{w}\t$dst", [], IIC_SMSW>, OpSize16, TB;
Michael Liao5bf95782014-12-04 05:20:33 +0000452def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
Craig Topperfa6298a2014-02-02 09:25:09 +0000453 "smsw{l}\t$dst", [], IIC_SMSW>, OpSize32, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000454// no m form encodable; use SMSW16m
Michael Liao5bf95782014-12-04 05:20:33 +0000455def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000456 "smsw{q}\t$dst", [], IIC_SMSW>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000457
458// For memory operands, there is only a 16-bit form
459def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000460 "smsw{w}\t$dst", [], IIC_SMSW>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000461
462def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000463 "lmsw{w}\t$src", [], IIC_LMSW_MEM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000464def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000465 "lmsw{w}\t$src", [], IIC_LMSW_REG>, TB;
Reid Klecknerb2340d42014-01-28 02:08:22 +0000466
467let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000468 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", [], IIC_CPUID>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000469} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000470
471//===----------------------------------------------------------------------===//
472// Cache instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000473let SchedRW = [WriteSystem] in {
Preston Gurdd6c440c2012-05-04 19:26:37 +0000474def INVD : I<0x08, RawFrm, (outs), (ins), "invd", [], IIC_INVD>, TB;
475def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [], IIC_INVD>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000476} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000477
Craig Topperd9cfddc2011-10-07 07:02:24 +0000478//===----------------------------------------------------------------------===//
479// XSAVE instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000480let SchedRW = [WriteSystem] in {
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000481let Defs = [EDX, EAX], Uses = [ECX] in
Rafael Espindolae3906212011-02-22 00:35:18 +0000482 def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB;
483
Reid Kleckneraedf0d72014-09-04 16:58:25 +0000484let Uses = [EDX, EAX, ECX] in
Rafael Espindolae3906212011-02-22 00:35:18 +0000485 def XSETBV : I<0x01, MRM_D1, (outs), (ins), "xsetbv", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000486
Craig Topperbf136762011-10-07 05:53:50 +0000487let Uses = [RDX, RAX] in {
488 def XSAVE : I<0xAE, MRM4m, (outs opaque512mem:$dst), (ins),
489 "xsave\t$dst", []>, TB;
Craig Topper80ab2682014-01-17 08:16:57 +0000490 def XSAVE64 : RI<0xAE, MRM4m, (outs opaque512mem:$dst), (ins),
Craig Topper6b4499a2015-02-03 11:03:57 +0000491 "xsave64\t$dst", []>, TB, Requires<[In64BitMode]>;
Craig Topperbf136762011-10-07 05:53:50 +0000492 def XRSTOR : I<0xAE, MRM5m, (outs), (ins opaque512mem:$dst),
493 "xrstor\t$dst", []>, TB;
Craig Topper80ab2682014-01-17 08:16:57 +0000494 def XRSTOR64 : RI<0xAE, MRM5m, (outs), (ins opaque512mem:$dst),
Craig Topper6b4499a2015-02-03 11:03:57 +0000495 "xrstor64\t$dst", []>, TB, Requires<[In64BitMode]>;
Craig Topperbf136762011-10-07 05:53:50 +0000496 def XSAVEOPT : I<0xAE, MRM6m, (outs opaque512mem:$dst), (ins),
Craig Topper0857a1d2015-02-05 08:51:06 +0000497 "xsaveopt\t$dst", []>, PS;
Craig Topper80ab2682014-01-17 08:16:57 +0000498 def XSAVEOPT64 : RI<0xAE, MRM6m, (outs opaque512mem:$dst), (ins),
Craig Topper0857a1d2015-02-05 08:51:06 +0000499 "xsaveopt64\t$dst", []>, PS, Requires<[In64BitMode]>;
500
501 def XRSTORS : I<0xC7, MRM3m, (outs), (ins opaque512mem:$dst),
502 "xrstors\t$dst", []>, TB;
503 def XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaque512mem:$dst),
504 "xrstors64\t$dst", []>, TB, Requires<[In64BitMode]>;
505 def XSAVEC : I<0xC7, MRM4m, (outs opaque512mem:$dst), (ins),
506 "xsavec\t$dst", []>, TB;
507 def XSAVEC64 : RI<0xC7, MRM4m, (outs opaque512mem:$dst), (ins),
508 "xsavec64\t$dst", []>, TB, Requires<[In64BitMode]>;
509 def XSAVES : I<0xC7, MRM5m, (outs opaque512mem:$dst), (ins),
510 "xsaves\t$dst", []>, TB;
511 def XSAVES64 : RI<0xC7, MRM5m, (outs opaque512mem:$dst), (ins),
512 "xsaves64\t$dst", []>, TB, Requires<[In64BitMode]>;
Craig Topperbf136762011-10-07 05:53:50 +0000513}
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000514} // SchedRW
Craig Topperbf136762011-10-07 05:53:50 +0000515
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000516//===----------------------------------------------------------------------===//
517// VIA PadLock crypto instructions
518let Defs = [RAX, RDI], Uses = [RDX, RDI] in
Craig Topper0d1fd552014-02-19 05:34:21 +0000519 def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000520
Joerg Sonnenberger91e56622011-06-30 01:38:03 +0000521def : InstAlias<"xstorerng", (XSTORE)>;
522
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000523let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
Craig Topper0d1fd552014-02-19 05:34:21 +0000524 def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB;
525 def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB;
526 def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB;
527 def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB;
528 def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000529}
530
531let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
Craig Topper0d1fd552014-02-19 05:34:21 +0000532 def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB;
533 def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000534}
535let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
Craig Topper0d1fd552014-02-19 05:34:21 +0000536 def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000537
538//===----------------------------------------------------------------------===//
539// FS/GS Base Instructions
Craig Topper228d9132011-10-30 19:57:21 +0000540let Predicates = [HasFSGSBase, In64BitMode] in {
Craig Topperd9cfddc2011-10-07 07:02:24 +0000541 def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000542 "rdfsbase{l}\t$dst",
Craig Topperda7160d2014-02-01 08:17:56 +0000543 [(set GR32:$dst, (int_x86_rdfsbase_32))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000544 def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000545 "rdfsbase{q}\t$dst",
Craig Topperda7160d2014-02-01 08:17:56 +0000546 [(set GR64:$dst, (int_x86_rdfsbase_64))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000547 def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000548 "rdgsbase{l}\t$dst",
Craig Topperda7160d2014-02-01 08:17:56 +0000549 [(set GR32:$dst, (int_x86_rdgsbase_32))]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000550 def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000551 "rdgsbase{q}\t$dst",
Craig Topperda7160d2014-02-01 08:17:56 +0000552 [(set GR64:$dst, (int_x86_rdgsbase_64))]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000553 def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
554 "wrfsbase{l}\t$src",
Craig Topperda7160d2014-02-01 08:17:56 +0000555 [(int_x86_wrfsbase_32 GR32:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000556 def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
557 "wrfsbase{q}\t$src",
Craig Topperda7160d2014-02-01 08:17:56 +0000558 [(int_x86_wrfsbase_64 GR64:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000559 def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
560 "wrgsbase{l}\t$src",
Craig Topperda7160d2014-02-01 08:17:56 +0000561 [(int_x86_wrgsbase_32 GR32:$src)]>, XS;
Craig Topper228d9132011-10-30 19:57:21 +0000562 def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
563 "wrgsbase{q}\t$src",
Craig Topperda7160d2014-02-01 08:17:56 +0000564 [(int_x86_wrgsbase_64 GR64:$src)]>, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000565}
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000566
567//===----------------------------------------------------------------------===//
568// INVPCID Instruction
569def INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
Craig Topperae11aed2014-01-14 07:41:20 +0000570 "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD,
Eric Christopherc0a5aae2013-12-20 02:04:49 +0000571 Requires<[Not64BitMode]>;
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000572def INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
Craig Topperae11aed2014-01-14 07:41:20 +0000573 "invpcid\t{$src2, $src1|$src1, $src2}", []>, T8PD,
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000574 Requires<[In64BitMode]>;
Michael Liao95d944032013-04-11 04:52:28 +0000575
576//===----------------------------------------------------------------------===//
577// SMAP Instruction
Craig Toppera898c2d2015-02-05 08:51:02 +0000578let Defs = [EFLAGS] in {
Michael Liao95d944032013-04-11 04:52:28 +0000579 def CLAC : I<0x01, MRM_CA, (outs), (ins), "clac", []>, TB;
580 def STAC : I<0x01, MRM_CB, (outs), (ins), "stac", []>, TB;
581}
Craig Topper1d472db2015-02-07 23:36:36 +0000582
583//===----------------------------------------------------------------------===//
584// SMX Instruction
585let Uses = [RAX, RBX, RCX, RDX], Defs = [RAX, RBX, RCX] in {
586 def GETSEC : I<0x37, RawFrm, (outs), (ins), "getsec", []>, TB;
587}