blob: 74683bc3daefb5f4015282aaca56ac9eb416d1be [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
Chris Lattnerae33f5d2010-10-05 06:04:14 +000022 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, 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
Dan Gohman164fe182012-05-14 18:58:10 +000041def : Pat<(debugtrap),
Dan Gohmandfab4432012-05-11 00:19:32 +000042 (INT3)>;
43
Chris Lattnerfc4fe002011-04-09 19:41:05 +000044// The long form of "int $3" turns into int3 as a size optimization.
45// FIXME: This doesn't work because InstAlias can't match immediate constants.
46//def : InstAlias<"int\t$3", (INT3)>;
47
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000048let SchedRW = [WriteSystem] in {
Chris Lattnerfc4fe002011-04-09 19:41:05 +000049
Chris Lattnerdec85b82010-10-05 05:32:15 +000050def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap",
Preston Gurdd6c440c2012-05-04 19:26:37 +000051 [(int_x86_int imm:$trap)], IIC_INT>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000052
Chris Lattnerfc4fe002011-04-09 19:41:05 +000053
Preston Gurdd6c440c2012-05-04 19:26:37 +000054def SYSCALL : I<0x05, RawFrm, (outs), (ins), "syscall", [], IIC_SYSCALL>, TB;
55def SYSRET : I<0x07, RawFrm, (outs), (ins), "sysret{l}", [], IIC_SYSCALL>, TB;
56def SYSRET64 :RI<0x07, RawFrm, (outs), (ins), "sysret{q}", [], IIC_SYSCALL>, TB,
Chris Lattnerae33f5d2010-10-05 06:04:14 +000057 Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000058
Preston Gurdd6c440c2012-05-04 19:26:37 +000059def SYSENTER : I<0x34, RawFrm, (outs), (ins), "sysenter", [],
60 IIC_SYS_ENTER_EXIT>, TB;
61
62def SYSEXIT : I<0x35, RawFrm, (outs), (ins), "sysexit{l}", [],
63 IIC_SYS_ENTER_EXIT>, TB;
Bill Wendlingebb10df2012-03-10 07:37:27 +000064def SYSEXIT64 :RI<0x35, RawFrm, (outs), (ins), "sysexit{q}", []>, TB,
Chris Lattnerae33f5d2010-10-05 06:04:14 +000065 Requires<[In64BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000066
Preston Gurdd6c440c2012-05-04 19:26:37 +000067def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", [], IIC_IRET>, OpSize;
68def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l|d}", [], IIC_IRET>;
69def IRET64 : RI<0xcf, RawFrm, (outs), (ins), "iretq", [], IIC_IRET>,
Chris Lattnerdec85b82010-10-05 05:32:15 +000070 Requires<[In64BitMode]>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000071} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +000072
73
74//===----------------------------------------------------------------------===//
75// Input/Output Instructions.
76//
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +000077let SchedRW = [WriteSystem] in {
Chris Lattnerdec85b82010-10-05 05:32:15 +000078let Defs = [AL], Uses = [DX] in
79def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +000080 "in{b}\t{%dx, %al|AL, DX}", [], IIC_IN_RR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000081let Defs = [AX], Uses = [DX] in
82def IN16rr : I<0xED, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +000083 "in{w}\t{%dx, %ax|AX, DX}", [], IIC_IN_RR>, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +000084let Defs = [EAX], Uses = [DX] in
85def IN32rr : I<0xED, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +000086 "in{l}\t{%dx, %eax|EAX, DX}", [], IIC_IN_RR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000087
88let Defs = [AL] in
89def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i8imm:$port),
Preston Gurdd6c440c2012-05-04 19:26:37 +000090 "in{b}\t{$port, %al|AL, $port}", [], IIC_IN_RI>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000091let Defs = [AX] in
92def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port),
Preston Gurdd6c440c2012-05-04 19:26:37 +000093 "in{w}\t{$port, %ax|AX, $port}", [], IIC_IN_RI>, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +000094let Defs = [EAX] in
95def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port),
Preston Gurdd6c440c2012-05-04 19:26:37 +000096 "in{l}\t{$port, %eax|EAX, $port}", [], IIC_IN_RI>;
Chris Lattnerdec85b82010-10-05 05:32:15 +000097
98let Uses = [DX, AL] in
99def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000100 "out{b}\t{%al, %dx|DX, AL}", [], IIC_OUT_RR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000101let Uses = [DX, AX] in
102def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000103 "out{w}\t{%ax, %dx|DX, AX}", [], IIC_OUT_RR>, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000104let Uses = [DX, EAX] in
105def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000106 "out{l}\t{%eax, %dx|DX, EAX}", [], IIC_OUT_RR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000107
108let Uses = [AL] in
109def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i8imm:$port),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000110 "out{b}\t{%al, $port|$port, AL}", [], IIC_OUT_IR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000111let Uses = [AX] in
112def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000113 "out{w}\t{%ax, $port|$port, AX}", [], IIC_OUT_IR>, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000114let Uses = [EAX] in
115def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000116 "out{l}\t{%eax, $port|$port, EAX}", [], IIC_OUT_IR>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000117
Preston Gurdd6c440c2012-05-04 19:26:37 +0000118def IN8 : I<0x6C, RawFrm, (outs), (ins), "ins{b}", [], IIC_INS>;
119def IN16 : I<0x6D, RawFrm, (outs), (ins), "ins{w}", [], IIC_INS>, OpSize;
120def IN32 : I<0x6D, RawFrm, (outs), (ins), "ins{l}", [], IIC_INS>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000121} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000122
123//===----------------------------------------------------------------------===//
124// Moves to and from debug registers
125
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000126let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000127def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000128 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_DR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000129def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000130 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_DR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000131
132def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000133 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_DR_REG>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000134def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000135 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_DR_REG>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000136} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000137
138//===----------------------------------------------------------------------===//
139// Moves to and from control registers
140
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000141let SchedRW = [WriteSystem] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000142def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000143 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_CR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000144def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000145 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_CR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000146
147def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000148 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_CR_REG>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000149def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR64:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000150 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_CR_REG>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000151} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000152
153//===----------------------------------------------------------------------===//
154// Segment override instruction prefixes
155
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000156def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
157def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
158def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
159def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
160def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
161def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000162
163
164//===----------------------------------------------------------------------===//
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000165// Moves to and from segment registers.
166//
167
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000168let SchedRW = [WriteMove] in {
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000169def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000170 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_SR>, OpSize;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000171def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000172 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_SR>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000173def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000174 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_REG_SR>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000175
176def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000177 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_MEM_SR>, OpSize;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000178def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000179 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_MEM_SR>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000180def MOV64ms : RI<0x8C, MRMDestMem, (outs i64mem:$dst), (ins SEGMENT_REG:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000181 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_MEM_SR>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000182
183def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000184 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_REG>, OpSize;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000185def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000186 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_REG>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000187def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000188 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_REG>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000189
190def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000191 "mov{w}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_MEM>, OpSize;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000192def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000193 "mov{l}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_MEM>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000194def MOV64sm : RI<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i64mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000195 "mov{q}\t{$src, $dst|$dst, $src}", [], IIC_MOV_SR_MEM>;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000196} // SchedRW
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000197
198//===----------------------------------------------------------------------===//
Chris Lattnerdec85b82010-10-05 05:32:15 +0000199// Segmentation support instructions.
200
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000201let SchedRW = [WriteSystem] in {
Preston Gurdd6c440c2012-05-04 19:26:37 +0000202def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", [], IIC_SWAPGS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000203
Chris Lattnerdec85b82010-10-05 05:32:15 +0000204def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000205 "lar{w}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RM>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000206def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000207 "lar{w}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RR>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000208
209// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
210def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000211 "lar{l}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000212def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000213 "lar{l}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000214// i16mem operand in LAR64rm and GR32 operand in LAR32rr is not a typo.
215def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000216 "lar{q}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RM>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000217def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000218 "lar{q}\t{$src, $dst|$dst, $src}", [], IIC_LAR_RR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000219
220def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000221 "lsl{w}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RM>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000222def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000223 "lsl{w}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RR>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000224def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000225 "lsl{l}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000226def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000227 "lsl{l}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000228def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000229 "lsl{q}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RM>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000230def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000231 "lsl{q}\t{$src, $dst|$dst, $src}", [], IIC_LSL_RR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000232
Preston Gurdd6c440c2012-05-04 19:26:37 +0000233def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr",
234 [], IIC_INVLPG>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000235
Eli Friedmanf63614a2011-03-04 00:10:17 +0000236def STR16r : I<0x00, MRM1r, (outs GR16:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000237 "str{w}\t$dst", [], IIC_STR>, TB, OpSize;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000238def STR32r : I<0x00, MRM1r, (outs GR32:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000239 "str{l}\t$dst", [], IIC_STR>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000240def STR64r : RI<0x00, MRM1r, (outs GR64:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000241 "str{q}\t$dst", [], IIC_STR>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000242def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000243 "str{w}\t$dst", [], IIC_STR>, TB;
Eli Friedmanf63614a2011-03-04 00:10:17 +0000244
Chris Lattnerdec85b82010-10-05 05:32:15 +0000245def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000246 "ltr{w}\t$src", [], IIC_LTR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000247def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000248 "ltr{w}\t$src", [], IIC_LTR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000249
250def PUSHCS16 : I<0x0E, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000251 "push{w}\t{%cs|CS}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>,
252 OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000253def PUSHCS32 : I<0x0E, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000254 "push{l}\t{%cs|CS}", [], IIC_PUSH_CS>, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000255def PUSHSS16 : I<0x16, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000256 "push{w}\t{%ss|SS}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>,
257 OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000258def PUSHSS32 : I<0x16, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000259 "push{l}\t{%ss|SS}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000260def PUSHDS16 : I<0x1E, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000261 "push{w}\t{%ds|DS}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>,
262 OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000263def PUSHDS32 : I<0x1E, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000264 "push{l}\t{%ds|DS}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000265def PUSHES16 : I<0x06, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000266 "push{w}\t{%es|ES}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>,
267 OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000268def PUSHES32 : I<0x06, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000269 "push{l}\t{%es|ES}", [], IIC_PUSH_SR>, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000270
271def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000272 "push{w}\t{%fs|FS}", [], IIC_PUSH_SR>, OpSize, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000273def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000274 "push{l}\t{%fs|FS}", [], IIC_PUSH_SR>, TB, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000275def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000276 "push{w}\t{%gs|GS}", [], IIC_PUSH_SR>, OpSize, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000277def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000278 "push{l}\t{%gs|GS}", [], IIC_PUSH_SR>, TB, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000279
280def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000281 "push{q}\t{%fs|FS}", [], IIC_PUSH_SR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000282def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000283 "push{q}\t{%gs|GS}", [], IIC_PUSH_SR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000284
285// No "pop cs" instruction.
286def POPSS16 : I<0x17, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000287 "pop{w}\t{%ss|SS}", [], IIC_POP_SR_SS>,
288 OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000289def POPSS32 : I<0x17, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000290 "pop{l}\t{%ss|SS}", [], IIC_POP_SR_SS>,
291 Requires<[In32BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000292
Chris Lattnerdec85b82010-10-05 05:32:15 +0000293def POPDS16 : I<0x1F, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000294 "pop{w}\t{%ds|DS}", [], IIC_POP_SR>,
295 OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000296def POPDS32 : I<0x1F, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000297 "pop{l}\t{%ds|DS}", [], IIC_POP_SR>,
298 Requires<[In32BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000299
Chris Lattnerdec85b82010-10-05 05:32:15 +0000300def POPES16 : I<0x07, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000301 "pop{w}\t{%es|ES}", [], IIC_POP_SR>,
302 OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000303def POPES32 : I<0x07, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000304 "pop{l}\t{%es|ES}", [], IIC_POP_SR>,
305 Requires<[In32BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000306
Chris Lattnerdec85b82010-10-05 05:32:15 +0000307def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000308 "pop{w}\t{%fs|FS}", [], IIC_POP_SR>, OpSize, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000309def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000310 "pop{l}\t{%fs|FS}", [], IIC_POP_SR>, TB, Requires<[In32BitMode]>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000311def POPFS64 : I<0xa1, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000312 "pop{q}\t{%fs|FS}", [], IIC_POP_SR>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000313
Chris Lattnerdec85b82010-10-05 05:32:15 +0000314def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000315 "pop{w}\t{%gs|GS}", [], IIC_POP_SR>, OpSize, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000316def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000317 "pop{l}\t{%gs|GS}", [], IIC_POP_SR>, TB, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000318def POPGS64 : I<0xa9, RawFrm, (outs), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000319 "pop{q}\t{%gs|GS}", [], IIC_POP_SR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000320
321
322def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000323 "lds{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000324def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000325 "lds{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000326
Chris Lattnerdec85b82010-10-05 05:32:15 +0000327def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000328 "lss{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000329def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000330 "lss{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000331def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000332 "lss{q}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000333
Chris Lattnerdec85b82010-10-05 05:32:15 +0000334def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000335 "les{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000336def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000337 "les{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000338
Chris Lattnerdec85b82010-10-05 05:32:15 +0000339def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000340 "lfs{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000341def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000342 "lfs{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000343def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000344 "lfs{q}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000345
Chris Lattnerdec85b82010-10-05 05:32:15 +0000346def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000347 "lgs{w}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000348def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000349 "lgs{l}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerae33f5d2010-10-05 06:04:14 +0000350
Chris Lattnerdec85b82010-10-05 05:32:15 +0000351def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000352 "lgs{q}\t{$src, $dst|$dst, $src}", [], IIC_LXS>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000353
354
355def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000356 "verr\t$seg", [], IIC_VERR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000357def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000358 "verr\t$seg", [], IIC_VERR>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000359def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000360 "verw\t$seg", [], IIC_VERW_MEM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000361def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000362 "verw\t$seg", [], IIC_VERW_REG>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000363} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000364
365//===----------------------------------------------------------------------===//
366// Descriptor-table support instructions
367
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000368let SchedRW = [WriteSystem] in {
Kevin Enderby49843c02010-10-19 00:01:44 +0000369def SGDT16m : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
Kay Tiong Khood30b1a22013-02-11 19:46:36 +0000370 "sgdt{w}\t$dst", [], IIC_SGDT>, TB, OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000371def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000372 "sgdt\t$dst", [], IIC_SGDT>, TB;
Kevin Enderby49843c02010-10-19 00:01:44 +0000373def SIDT16m : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
Kay Tiong Khood30b1a22013-02-11 19:46:36 +0000374 "sidt{w}\t$dst", [], IIC_SIDT>, TB, OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000375def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
376 "sidt\t$dst", []>, TB;
377def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000378 "sldt{w}\t$dst", [], IIC_SLDT>, TB, OpSize;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000379def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000380 "sldt{w}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000381def SLDT32r : I<0x00, MRM0r, (outs GR32:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000382 "sldt{l}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerc184a572010-10-05 06:22:35 +0000383
384// LLDT is not interpreted specially in 64-bit mode because there is no sign
385// extension.
386def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000387 "sldt{q}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerc184a572010-10-05 06:22:35 +0000388def SLDT64m : RI<0x00, MRM0m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000389 "sldt{q}\t$dst", [], IIC_SLDT>, TB;
Chris Lattnerc184a572010-10-05 06:22:35 +0000390
Kevin Enderby49843c02010-10-19 00:01:44 +0000391def LGDT16m : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
Kay Tiong Khood30b1a22013-02-11 19:46:36 +0000392 "lgdt{w}\t$src", [], IIC_LGDT>, TB, OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000393def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000394 "lgdt\t$src", [], IIC_LGDT>, TB;
Kevin Enderby49843c02010-10-19 00:01:44 +0000395def LIDT16m : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
Kay Tiong Khood30b1a22013-02-11 19:46:36 +0000396 "lidt{w}\t$src", [], IIC_LIDT>, TB, OpSize, Requires<[In32BitMode]>;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000397def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000398 "lidt\t$src", [], IIC_LIDT>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000399def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000400 "lldt{w}\t$src", [], IIC_LLDT_REG>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000401def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000402 "lldt{w}\t$src", [], IIC_LLDT_MEM>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000403} // SchedRW
404
Chris Lattnerdec85b82010-10-05 05:32:15 +0000405//===----------------------------------------------------------------------===//
406// Specialized register support
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000407let SchedRW = [WriteSystem] in {
Preston Gurdd6c440c2012-05-04 19:26:37 +0000408def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", [], IIC_WRMSR>, TB;
409def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", [], IIC_RDMSR>, TB;
410def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", [], IIC_RDPMC>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000411
412def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000413 "smsw{w}\t$dst", [], IIC_SMSW>, OpSize, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000414def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000415 "smsw{l}\t$dst", [], IIC_SMSW>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000416// no m form encodable; use SMSW16m
417def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000418 "smsw{q}\t$dst", [], IIC_SMSW>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000419
420// For memory operands, there is only a 16-bit form
421def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000422 "smsw{w}\t$dst", [], IIC_SMSW>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000423
424def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000425 "lmsw{w}\t$src", [], IIC_LMSW_MEM>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000426def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
Preston Gurdd6c440c2012-05-04 19:26:37 +0000427 "lmsw{w}\t$src", [], IIC_LMSW_REG>, TB;
Chris Lattnerdec85b82010-10-05 05:32:15 +0000428
Preston Gurdd6c440c2012-05-04 19:26:37 +0000429def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", [], IIC_CPUID>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000430} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000431
432//===----------------------------------------------------------------------===//
433// Cache instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000434let SchedRW = [WriteSystem] in {
Preston Gurdd6c440c2012-05-04 19:26:37 +0000435def INVD : I<0x08, RawFrm, (outs), (ins), "invd", [], IIC_INVD>, TB;
436def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [], IIC_INVD>, TB;
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000437} // SchedRW
Chris Lattnerdec85b82010-10-05 05:32:15 +0000438
Craig Topperd9cfddc2011-10-07 07:02:24 +0000439//===----------------------------------------------------------------------===//
440// XSAVE instructions
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000441let SchedRW = [WriteSystem] in {
Rafael Espindolae3906212011-02-22 00:35:18 +0000442let Defs = [RDX, RAX], Uses = [RCX] in
443 def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, TB;
444
445let Uses = [RDX, RAX, RCX] in
446 def XSETBV : I<0x01, MRM_D1, (outs), (ins), "xsetbv", []>, TB;
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000447
Craig Topperbf136762011-10-07 05:53:50 +0000448let Uses = [RDX, RAX] in {
449 def XSAVE : I<0xAE, MRM4m, (outs opaque512mem:$dst), (ins),
450 "xsave\t$dst", []>, TB;
451 def XSAVE64 : I<0xAE, MRM4m, (outs opaque512mem:$dst), (ins),
452 "xsaveq\t$dst", []>, TB, REX_W, Requires<[In64BitMode]>;
453 def XRSTOR : I<0xAE, MRM5m, (outs), (ins opaque512mem:$dst),
454 "xrstor\t$dst", []>, TB;
455 def XRSTOR64 : I<0xAE, MRM5m, (outs), (ins opaque512mem:$dst),
456 "xrstorq\t$dst", []>, TB, REX_W, Requires<[In64BitMode]>;
457 def XSAVEOPT : I<0xAE, MRM6m, (outs opaque512mem:$dst), (ins),
458 "xsaveopt\t$dst", []>, TB;
459 def XSAVEOPT64 : I<0xAE, MRM6m, (outs opaque512mem:$dst), (ins),
460 "xsaveoptq\t$dst", []>, TB, REX_W, Requires<[In64BitMode]>;
461}
Jakob Stoklund Olesen5b535c92013-03-20 23:09:50 +0000462} // SchedRW
Craig Topperbf136762011-10-07 05:53:50 +0000463
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000464//===----------------------------------------------------------------------===//
465// VIA PadLock crypto instructions
466let Defs = [RAX, RDI], Uses = [RDX, RDI] in
467 def XSTORE : I<0xc0, RawFrm, (outs), (ins), "xstore", []>, A7;
468
Joerg Sonnenberger91e56622011-06-30 01:38:03 +0000469def : InstAlias<"xstorerng", (XSTORE)>;
470
Joerg Sonnenbergerfc4789d2011-04-04 16:58:13 +0000471let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
472 def XCRYPTECB : I<0xc8, RawFrm, (outs), (ins), "xcryptecb", []>, A7;
473 def XCRYPTCBC : I<0xd0, RawFrm, (outs), (ins), "xcryptcbc", []>, A7;
474 def XCRYPTCTR : I<0xd8, RawFrm, (outs), (ins), "xcryptctr", []>, A7;
475 def XCRYPTCFB : I<0xe0, RawFrm, (outs), (ins), "xcryptcfb", []>, A7;
476 def XCRYPTOFB : I<0xe8, RawFrm, (outs), (ins), "xcryptofb", []>, A7;
477}
478
479let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
480 def XSHA1 : I<0xc8, RawFrm, (outs), (ins), "xsha1", []>, A6;
481 def XSHA256 : I<0xd0, RawFrm, (outs), (ins), "xsha256", []>, A6;
482}
483let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
484 def MONTMUL : I<0xc0, RawFrm, (outs), (ins), "montmul", []>, A6;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000485
486//===----------------------------------------------------------------------===//
487// FS/GS Base Instructions
Craig Topper228d9132011-10-30 19:57:21 +0000488let Predicates = [HasFSGSBase, In64BitMode] in {
Craig Topperd9cfddc2011-10-07 07:02:24 +0000489 def RDFSBASE : I<0xAE, MRM0r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000490 "rdfsbase{l}\t$dst",
491 [(set GR32:$dst, (int_x86_rdfsbase_32))]>, TB, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000492 def RDFSBASE64 : RI<0xAE, MRM0r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000493 "rdfsbase{q}\t$dst",
494 [(set GR64:$dst, (int_x86_rdfsbase_64))]>, TB, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000495 def RDGSBASE : I<0xAE, MRM1r, (outs GR32:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000496 "rdgsbase{l}\t$dst",
497 [(set GR32:$dst, (int_x86_rdgsbase_32))]>, TB, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000498 def RDGSBASE64 : RI<0xAE, MRM1r, (outs GR64:$dst), (ins),
Craig Topper228d9132011-10-30 19:57:21 +0000499 "rdgsbase{q}\t$dst",
500 [(set GR64:$dst, (int_x86_rdgsbase_64))]>, TB, XS;
501 def WRFSBASE : I<0xAE, MRM2r, (outs), (ins GR32:$src),
502 "wrfsbase{l}\t$src",
503 [(int_x86_wrfsbase_32 GR32:$src)]>, TB, XS;
504 def WRFSBASE64 : RI<0xAE, MRM2r, (outs), (ins GR64:$src),
505 "wrfsbase{q}\t$src",
506 [(int_x86_wrfsbase_64 GR64:$src)]>, TB, XS;
507 def WRGSBASE : I<0xAE, MRM3r, (outs), (ins GR32:$src),
508 "wrgsbase{l}\t$src",
509 [(int_x86_wrgsbase_32 GR32:$src)]>, TB, XS;
510 def WRGSBASE64 : RI<0xAE, MRM3r, (outs), (ins GR64:$src),
511 "wrgsbase{q}\t$src",
512 [(int_x86_wrgsbase_64 GR64:$src)]>, TB, XS;
Craig Topperd9cfddc2011-10-07 07:02:24 +0000513}
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000514
515//===----------------------------------------------------------------------===//
516// INVPCID Instruction
517def INVPCID32 : I<0x82, MRMSrcMem, (outs), (ins GR32:$src1, i128mem:$src2),
Kay Tiong Khoo6f76c212013-04-10 21:17:58 +0000518 "invpcid\t{$src2, $src1|$src1, $src2}", []>, OpSize, T8,
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000519 Requires<[In32BitMode]>;
520def INVPCID64 : I<0x82, MRMSrcMem, (outs), (ins GR64:$src1, i128mem:$src2),
Kay Tiong Khoo6f76c212013-04-10 21:17:58 +0000521 "invpcid\t{$src2, $src1|$src1, $src2}", []>, OpSize, T8,
Craig Topper0ae8d4d2011-10-16 07:05:40 +0000522 Requires<[In64BitMode]>;