xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86InstrAsmAlias.td (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1//==- X86InstrAsmAlias.td - Assembler Instruction Aliases --*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file describes the assembler mnemonic/instruction aliases in the X86
10// architecture.
11//
12//===----------------------------------------------------------------------===//
13
14// Reversed version with ".s" suffix for GAS compatibility.
15def : InstAlias<"mov{b}.s\t{$src, $dst|$dst, $src}",
16                (MOV8rr_REV GR8:$dst, GR8:$src), 0>;
17def : InstAlias<"mov{w}.s\t{$src, $dst|$dst, $src}",
18                (MOV16rr_REV GR16:$dst, GR16:$src), 0>;
19def : InstAlias<"mov{l}.s\t{$src, $dst|$dst, $src}",
20                (MOV32rr_REV GR32:$dst, GR32:$src), 0>;
21def : InstAlias<"mov{q}.s\t{$src, $dst|$dst, $src}",
22                (MOV64rr_REV GR64:$dst, GR64:$src), 0>;
23def : InstAlias<"mov.s\t{$src, $dst|$dst, $src}",
24                (MOV8rr_REV GR8:$dst, GR8:$src), 0, "att">;
25def : InstAlias<"mov.s\t{$src, $dst|$dst, $src}",
26                (MOV16rr_REV GR16:$dst, GR16:$src), 0, "att">;
27def : InstAlias<"mov.s\t{$src, $dst|$dst, $src}",
28                (MOV32rr_REV GR32:$dst, GR32:$src), 0, "att">;
29def : InstAlias<"mov.s\t{$src, $dst|$dst, $src}",
30                (MOV64rr_REV GR64:$dst, GR64:$src), 0, "att">;
31
32// MONITORX/MWAITX Instructions Alias
33def : InstAlias<"mwaitx\t{%eax, %ecx, %ebx|ebx, ecx, eax}", (MWAITXrrr)>,
34      Requires<[ Not64BitMode ]>;
35def : InstAlias<"mwaitx\t{%rax, %rcx, %rbx|rbx, rcx, rax}", (MWAITXrrr)>,
36      Requires<[ In64BitMode ]>;
37
38// MONITORX/MWAITX Instructions Alias
39def : InstAlias<"monitorx\t{%eax, %ecx, %edx|edx, ecx, eax}", (MONITORX32rrr)>,
40      Requires<[ Not64BitMode ]>;
41def : InstAlias<"monitorx\t{%rax, %rcx, %rdx|rdx, rcx, rax}", (MONITORX64rrr)>,
42      Requires<[ In64BitMode ]>;
43
44// CLZERO Instruction Alias
45def : InstAlias<"clzero\t{%eax|eax}", (CLZERO32r)>, Requires<[Not64BitMode]>;
46def : InstAlias<"clzero\t{%rax|rax}", (CLZERO64r)>, Requires<[In64BitMode]>;
47
48// INVLPGB Instruction Alias
49def : InstAlias<"invlpgb\t{%eax, %edx|eax, edx}", (INVLPGB32)>, Requires<[Not64BitMode]>;
50def : InstAlias<"invlpgb\t{%rax, %edx|rax, edx}", (INVLPGB64)>, Requires<[In64BitMode]>;
51
52// CMPCCXADD Instructions Alias
53multiclass CMPCCXADD_Aliases<string Cond, int CC> {
54  def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
55                  (CMPCCXADDmr32 GR32:$dst, i32mem:$dstsrc2, GR32:$src3, CC), 0>;
56  def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
57                  (CMPCCXADDmr64 GR64:$dst, i64mem:$dstsrc2, GR64:$src3, CC), 0>;
58}
59
60//===----------------------------------------------------------------------===//
61// Assembler Mnemonic Aliases
62//===----------------------------------------------------------------------===//
63
64defm : CMPCCXADD_Aliases<"o" ,  0>;
65defm : CMPCCXADD_Aliases<"no",  1>;
66defm : CMPCCXADD_Aliases<"b" ,  2>;
67defm : CMPCCXADD_Aliases<"ae",  3>;
68defm : CMPCCXADD_Aliases<"nb",  3>;
69defm : CMPCCXADD_Aliases<"e" ,  4>;
70defm : CMPCCXADD_Aliases<"z" ,  4>;
71defm : CMPCCXADD_Aliases<"ne",  5>;
72defm : CMPCCXADD_Aliases<"nz",  5>;
73defm : CMPCCXADD_Aliases<"be",  6>;
74defm : CMPCCXADD_Aliases<"nbe", 7>;
75defm : CMPCCXADD_Aliases<"a",   7>;
76defm : CMPCCXADD_Aliases<"s" ,  8>;
77defm : CMPCCXADD_Aliases<"ns",  9>;
78defm : CMPCCXADD_Aliases<"p" , 10>;
79defm : CMPCCXADD_Aliases<"np", 11>;
80defm : CMPCCXADD_Aliases<"l" , 12>;
81defm : CMPCCXADD_Aliases<"ge", 13>;
82defm : CMPCCXADD_Aliases<"nl", 13>;
83defm : CMPCCXADD_Aliases<"le", 14>;
84defm : CMPCCXADD_Aliases<"g",  15>;
85defm : CMPCCXADD_Aliases<"nle",15>;
86
87
88def : MnemonicAlias<"call", "callw", "att">, Requires<[In16BitMode]>;
89def : MnemonicAlias<"call", "calll", "att">, Requires<[In32BitMode]>;
90def : MnemonicAlias<"call", "callq", "att">, Requires<[In64BitMode]>;
91
92def : MnemonicAlias<"cbw",  "cbtw", "att">;
93def : MnemonicAlias<"cwde", "cwtl", "att">;
94def : MnemonicAlias<"cwd",  "cwtd", "att">;
95def : MnemonicAlias<"cdq",  "cltd", "att">;
96def : MnemonicAlias<"cdqe", "cltq", "att">;
97def : MnemonicAlias<"cqo",  "cqto", "att">;
98
99// In 64-bit mode lret maps to lretl; it is not ambiguous with lretq.
100def : MnemonicAlias<"lret", "lretw", "att">, Requires<[In16BitMode]>;
101def : MnemonicAlias<"lret", "lretl", "att">, Requires<[Not16BitMode]>;
102
103def : MnemonicAlias<"leavel", "leave", "att">, Requires<[Not64BitMode]>;
104def : MnemonicAlias<"leaveq", "leave", "att">, Requires<[In64BitMode]>;
105
106def : MnemonicAlias<"loopz",  "loope">;
107def : MnemonicAlias<"loopnz", "loopne">;
108
109def : MnemonicAlias<"pop",   "popw",  "att">, Requires<[In16BitMode]>;
110def : MnemonicAlias<"pop",   "popl",  "att">, Requires<[In32BitMode]>;
111def : MnemonicAlias<"pop",   "popq",  "att">, Requires<[In64BitMode]>;
112def : MnemonicAlias<"popf",  "popfw", "att">, Requires<[In16BitMode]>;
113def : MnemonicAlias<"popf",  "popfl", "att">, Requires<[In32BitMode]>;
114def : MnemonicAlias<"popf",  "popfq", "att">, Requires<[In64BitMode]>;
115def : MnemonicAlias<"popf",  "popfq", "intel">, Requires<[In64BitMode]>;
116def : MnemonicAlias<"popfd", "popfl", "att">;
117def : MnemonicAlias<"popfw", "popf",  "intel">, Requires<[In32BitMode]>;
118def : MnemonicAlias<"popfw", "popf",  "intel">, Requires<[In64BitMode]>;
119
120// FIXME: This is wrong for "push reg".  "push %bx" should turn into pushw in
121// all modes.  However: "push (addr)" and "push $42" should default to
122// pushl/pushq depending on the current mode.  Similar for "pop %bx"
123def : MnemonicAlias<"push",   "pushw",  "att">, Requires<[In16BitMode]>;
124def : MnemonicAlias<"push",   "pushl",  "att">, Requires<[In32BitMode]>;
125def : MnemonicAlias<"push",   "pushq",  "att">, Requires<[In64BitMode]>;
126def : MnemonicAlias<"pushf",  "pushfw", "att">, Requires<[In16BitMode]>;
127def : MnemonicAlias<"pushf",  "pushfl", "att">, Requires<[In32BitMode]>;
128def : MnemonicAlias<"pushf",  "pushfq", "att">, Requires<[In64BitMode]>;
129def : MnemonicAlias<"pushf",  "pushfq", "intel">, Requires<[In64BitMode]>;
130def : MnemonicAlias<"pushfd", "pushfl", "att">;
131def : MnemonicAlias<"pushfw", "pushf",  "intel">, Requires<[In32BitMode]>;
132def : MnemonicAlias<"pushfw", "pushf",  "intel">, Requires<[In64BitMode]>;
133
134def : MnemonicAlias<"popad",  "popal",  "intel">, Requires<[Not64BitMode]>;
135def : MnemonicAlias<"pushad", "pushal", "intel">, Requires<[Not64BitMode]>;
136def : MnemonicAlias<"popa",   "popaw",  "intel">, Requires<[In16BitMode]>;
137def : MnemonicAlias<"pusha",  "pushaw", "intel">, Requires<[In16BitMode]>;
138def : MnemonicAlias<"popa",   "popal",  "intel">, Requires<[In32BitMode]>;
139def : MnemonicAlias<"pusha",  "pushal", "intel">, Requires<[In32BitMode]>;
140
141def : MnemonicAlias<"popa",   "popaw",  "att">, Requires<[In16BitMode]>;
142def : MnemonicAlias<"pusha",  "pushaw", "att">, Requires<[In16BitMode]>;
143def : MnemonicAlias<"popa",   "popal",  "att">, Requires<[In32BitMode]>;
144def : MnemonicAlias<"pusha",  "pushal", "att">, Requires<[In32BitMode]>;
145
146def : MnemonicAlias<"repe",  "rep">;
147def : MnemonicAlias<"repz",  "rep">;
148def : MnemonicAlias<"repnz", "repne">;
149
150def : MnemonicAlias<"ret", "retw", "att">, Requires<[In16BitMode]>;
151def : MnemonicAlias<"ret", "retl", "att">, Requires<[In32BitMode]>;
152def : MnemonicAlias<"ret", "retq", "att">, Requires<[In64BitMode]>;
153
154// Apply 'ret' behavior to 'retn'
155def : MnemonicAlias<"retn", "retw", "att">, Requires<[In16BitMode]>;
156def : MnemonicAlias<"retn", "retl", "att">, Requires<[In32BitMode]>;
157def : MnemonicAlias<"retn", "retq", "att">, Requires<[In64BitMode]>;
158def : MnemonicAlias<"retn", "ret", "intel">;
159
160def : MnemonicAlias<"sal", "shl", "intel">;
161def : MnemonicAlias<"salb", "shlb", "att">;
162def : MnemonicAlias<"salw", "shlw", "att">;
163def : MnemonicAlias<"sall", "shll", "att">;
164def : MnemonicAlias<"salq", "shlq", "att">;
165
166def : MnemonicAlias<"smovb", "movsb", "att">;
167def : MnemonicAlias<"smovw", "movsw", "att">;
168def : MnemonicAlias<"smovl", "movsl", "att">;
169def : MnemonicAlias<"smovq", "movsq", "att">;
170
171def : MnemonicAlias<"ud2a",  "ud2",  "att">;
172def : MnemonicAlias<"ud2bw", "ud1w", "att">;
173def : MnemonicAlias<"ud2bl", "ud1l", "att">;
174def : MnemonicAlias<"ud2bq", "ud1q", "att">;
175def : MnemonicAlias<"verrw", "verr", "att">;
176
177// MS recognizes 'xacquire'/'xrelease' as 'acquire'/'release'
178def : MnemonicAlias<"acquire", "xacquire", "intel">;
179def : MnemonicAlias<"release", "xrelease", "intel">;
180
181// System instruction aliases.
182def : MnemonicAlias<"iret",    "iretw",    "att">, Requires<[In16BitMode]>;
183def : MnemonicAlias<"iret",    "iretl",    "att">, Requires<[Not16BitMode]>;
184def : MnemonicAlias<"sysret",  "sysretl",  "att">;
185def : MnemonicAlias<"sysexit", "sysexitl", "att">;
186
187def : MnemonicAlias<"lgdt", "lgdtw", "att">, Requires<[In16BitMode]>;
188def : MnemonicAlias<"lgdt", "lgdtl", "att">, Requires<[In32BitMode]>;
189def : MnemonicAlias<"lgdt", "lgdtq", "att">, Requires<[In64BitMode]>;
190def : MnemonicAlias<"lidt", "lidtw", "att">, Requires<[In16BitMode]>;
191def : MnemonicAlias<"lidt", "lidtl", "att">, Requires<[In32BitMode]>;
192def : MnemonicAlias<"lidt", "lidtq", "att">, Requires<[In64BitMode]>;
193def : MnemonicAlias<"sgdt", "sgdtw", "att">, Requires<[In16BitMode]>;
194def : MnemonicAlias<"sgdt", "sgdtl", "att">, Requires<[In32BitMode]>;
195def : MnemonicAlias<"sgdt", "sgdtq", "att">, Requires<[In64BitMode]>;
196def : MnemonicAlias<"sidt", "sidtw", "att">, Requires<[In16BitMode]>;
197def : MnemonicAlias<"sidt", "sidtl", "att">, Requires<[In32BitMode]>;
198def : MnemonicAlias<"sidt", "sidtq", "att">, Requires<[In64BitMode]>;
199def : MnemonicAlias<"lgdt", "lgdtw", "intel">, Requires<[In16BitMode]>;
200def : MnemonicAlias<"lgdt", "lgdtd", "intel">, Requires<[In32BitMode]>;
201def : MnemonicAlias<"lidt", "lidtw", "intel">, Requires<[In16BitMode]>;
202def : MnemonicAlias<"lidt", "lidtd", "intel">, Requires<[In32BitMode]>;
203def : MnemonicAlias<"sgdt", "sgdtw", "intel">, Requires<[In16BitMode]>;
204def : MnemonicAlias<"sgdt", "sgdtd", "intel">, Requires<[In32BitMode]>;
205def : MnemonicAlias<"sidt", "sidtw", "intel">, Requires<[In16BitMode]>;
206def : MnemonicAlias<"sidt", "sidtd", "intel">, Requires<[In32BitMode]>;
207
208
209// Floating point stack aliases.
210def : MnemonicAlias<"fcmovz",   "fcmove",   "att">;
211def : MnemonicAlias<"fcmova",   "fcmovnbe", "att">;
212def : MnemonicAlias<"fcmovnae", "fcmovb",   "att">;
213def : MnemonicAlias<"fcmovna",  "fcmovbe",  "att">;
214def : MnemonicAlias<"fcmovae",  "fcmovnb",  "att">;
215def : MnemonicAlias<"fcomip",   "fcompi">;
216def : MnemonicAlias<"fildq",    "fildll",   "att">;
217def : MnemonicAlias<"fistpq",   "fistpll",  "att">;
218def : MnemonicAlias<"fisttpq",  "fisttpll", "att">;
219def : MnemonicAlias<"fldcww",   "fldcw",    "att">;
220def : MnemonicAlias<"fnstcww",  "fnstcw",   "att">;
221def : MnemonicAlias<"fnstsww",  "fnstsw",   "att">;
222def : MnemonicAlias<"fucomip",  "fucompi">;
223def : MnemonicAlias<"fwait",    "wait">;
224
225def : MnemonicAlias<"fxsaveq",   "fxsave64",   "att">;
226def : MnemonicAlias<"fxrstorq",  "fxrstor64",  "att">;
227def : MnemonicAlias<"xsaveq",    "xsave64",    "att">;
228def : MnemonicAlias<"xrstorq",   "xrstor64",   "att">;
229def : MnemonicAlias<"xsaveoptq", "xsaveopt64", "att">;
230def : MnemonicAlias<"xrstorsq",  "xrstors64",  "att">;
231def : MnemonicAlias<"xsavecq",   "xsavec64",   "att">;
232def : MnemonicAlias<"xsavesq",   "xsaves64",   "att">;
233
234class CondCodeAlias<string Prefix,string Suffix, string OldCond, string NewCond,
235                    string VariantName>
236  : MnemonicAlias<!strconcat(Prefix, OldCond, Suffix),
237                  !strconcat(Prefix, NewCond, Suffix), VariantName>;
238
239/// IntegerCondCodeMnemonicAlias - This multiclass defines a bunch of
240/// MnemonicAlias's that canonicalize the condition code in a mnemonic, for
241/// example "setz" -> "sete".
242multiclass IntegerCondCodeMnemonicAlias<string Prefix, string Suffix,
243                                        string V = ""> {
244  def C   : CondCodeAlias<Prefix, Suffix, "c",   "b",  V>; // setc   -> setb
245  def Z   : CondCodeAlias<Prefix, Suffix, "z" ,  "e",  V>; // setz   -> sete
246  def NA  : CondCodeAlias<Prefix, Suffix, "na",  "be", V>; // setna  -> setbe
247  def NB  : CondCodeAlias<Prefix, Suffix, "nb",  "ae", V>; // setnb  -> setae
248  def NC  : CondCodeAlias<Prefix, Suffix, "nc",  "ae", V>; // setnc  -> setae
249  def NG  : CondCodeAlias<Prefix, Suffix, "ng",  "le", V>; // setng  -> setle
250  def NL  : CondCodeAlias<Prefix, Suffix, "nl",  "ge", V>; // setnl  -> setge
251  def NZ  : CondCodeAlias<Prefix, Suffix, "nz",  "ne", V>; // setnz  -> setne
252  def PE  : CondCodeAlias<Prefix, Suffix, "pe",  "p",  V>; // setpe  -> setp
253  def PO  : CondCodeAlias<Prefix, Suffix, "po",  "np", V>; // setpo  -> setnp
254
255  def NAE : CondCodeAlias<Prefix, Suffix, "nae", "b",  V>; // setnae -> setb
256  def NBE : CondCodeAlias<Prefix, Suffix, "nbe", "a",  V>; // setnbe -> seta
257  def NGE : CondCodeAlias<Prefix, Suffix, "nge", "l",  V>; // setnge -> setl
258  def NLE : CondCodeAlias<Prefix, Suffix, "nle", "g",  V>; // setnle -> setg
259}
260
261// Aliases for set<CC>
262defm : IntegerCondCodeMnemonicAlias<"set", "">;
263// Aliases for j<CC>
264defm : IntegerCondCodeMnemonicAlias<"j", "">;
265// Aliases for cmov<CC>{w,l,q}
266defm : IntegerCondCodeMnemonicAlias<"cmov", "w", "att">;
267defm : IntegerCondCodeMnemonicAlias<"cmov", "l", "att">;
268defm : IntegerCondCodeMnemonicAlias<"cmov", "q", "att">;
269// No size suffix for intel-style asm.
270defm : IntegerCondCodeMnemonicAlias<"cmov", "", "intel">;
271
272//===----------------------------------------------------------------------===//
273// Assembler Instruction Aliases
274//===----------------------------------------------------------------------===//
275
276// aad/aam default to base 10 if no operand is specified.
277def : InstAlias<"aad", (AAD8i8 10)>, Requires<[Not64BitMode]>;
278def : InstAlias<"aam", (AAM8i8 10)>, Requires<[Not64BitMode]>;
279
280// Disambiguate the mem/imm form of bt-without-a-suffix as btl.
281// Likewise for btc/btr/bts.
282def : InstAlias<"bt\t{$imm, $mem|$mem, $imm}",
283                (BT32mi8 i32mem:$mem, i32u8imm:$imm), 0, "att">;
284def : InstAlias<"btc\t{$imm, $mem|$mem, $imm}",
285                (BTC32mi8 i32mem:$mem, i32u8imm:$imm), 0, "att">;
286def : InstAlias<"btr\t{$imm, $mem|$mem, $imm}",
287                (BTR32mi8 i32mem:$mem, i32u8imm:$imm), 0, "att">;
288def : InstAlias<"bts\t{$imm, $mem|$mem, $imm}",
289                (BTS32mi8 i32mem:$mem, i32u8imm:$imm), 0, "att">;
290
291// clr aliases.
292def : InstAlias<"clr{b}\t$reg", (XOR8rr  GR8 :$reg, GR8 :$reg), 0>;
293def : InstAlias<"clr{w}\t$reg", (XOR16rr GR16:$reg, GR16:$reg), 0>;
294def : InstAlias<"clr{l}\t$reg", (XOR32rr GR32:$reg, GR32:$reg), 0>;
295def : InstAlias<"clr{q}\t$reg", (XOR64rr GR64:$reg, GR64:$reg), 0>;
296
297// lods aliases. Accept the destination being omitted because it's implicit
298// in the mnemonic, or the mnemonic suffix being omitted because it's implicit
299// in the destination.
300def : InstAlias<"lodsb\t$src", (LODSB srcidx8:$src),  0>;
301def : InstAlias<"lodsw\t$src", (LODSW srcidx16:$src), 0>;
302def : InstAlias<"lods{l|d}\t$src", (LODSL srcidx32:$src), 0>;
303def : InstAlias<"lodsq\t$src", (LODSQ srcidx64:$src), 0>, Requires<[In64BitMode]>;
304def : InstAlias<"lods\t{$src, %al|al, $src}", (LODSB srcidx8:$src),  0>;
305def : InstAlias<"lods\t{$src, %ax|ax, $src}", (LODSW srcidx16:$src), 0>;
306def : InstAlias<"lods\t{$src, %eax|eax, $src}", (LODSL srcidx32:$src), 0>;
307def : InstAlias<"lods\t{$src, %rax|rax, $src}", (LODSQ srcidx64:$src), 0>, Requires<[In64BitMode]>;
308def : InstAlias<"lods\t$src", (LODSB srcidx8:$src),  0, "intel">;
309def : InstAlias<"lods\t$src", (LODSW srcidx16:$src), 0, "intel">;
310def : InstAlias<"lods\t$src", (LODSL srcidx32:$src), 0, "intel">;
311def : InstAlias<"lods\t$src", (LODSQ srcidx64:$src), 0, "intel">, Requires<[In64BitMode]>;
312
313
314// stos aliases. Accept the source being omitted because it's implicit in
315// the mnemonic, or the mnemonic suffix being omitted because it's implicit
316// in the source.
317def : InstAlias<"stosb\t$dst", (STOSB dstidx8:$dst),  0>;
318def : InstAlias<"stosw\t$dst", (STOSW dstidx16:$dst), 0>;
319def : InstAlias<"stos{l|d}\t$dst", (STOSL dstidx32:$dst), 0>;
320def : InstAlias<"stosq\t$dst", (STOSQ dstidx64:$dst), 0>, Requires<[In64BitMode]>;
321def : InstAlias<"stos\t{%al, $dst|$dst, al}", (STOSB dstidx8:$dst),  0>;
322def : InstAlias<"stos\t{%ax, $dst|$dst, ax}", (STOSW dstidx16:$dst), 0>;
323def : InstAlias<"stos\t{%eax, $dst|$dst, eax}", (STOSL dstidx32:$dst), 0>;
324def : InstAlias<"stos\t{%rax, $dst|$dst, rax}", (STOSQ dstidx64:$dst), 0>, Requires<[In64BitMode]>;
325def : InstAlias<"stos\t$dst", (STOSB dstidx8:$dst),  0, "intel">;
326def : InstAlias<"stos\t$dst", (STOSW dstidx16:$dst), 0, "intel">;
327def : InstAlias<"stos\t$dst", (STOSL dstidx32:$dst), 0, "intel">;
328def : InstAlias<"stos\t$dst", (STOSQ dstidx64:$dst), 0, "intel">, Requires<[In64BitMode]>;
329
330
331// scas aliases. Accept the destination being omitted because it's implicit
332// in the mnemonic, or the mnemonic suffix being omitted because it's implicit
333// in the destination.
334def : InstAlias<"scasb\t$dst", (SCASB dstidx8:$dst),  0>;
335def : InstAlias<"scasw\t$dst", (SCASW dstidx16:$dst), 0>;
336def : InstAlias<"scas{l|d}\t$dst", (SCASL dstidx32:$dst), 0>;
337def : InstAlias<"scasq\t$dst", (SCASQ dstidx64:$dst), 0>, Requires<[In64BitMode]>;
338def : InstAlias<"scas\t{$dst, %al|al, $dst}", (SCASB dstidx8:$dst),  0>;
339def : InstAlias<"scas\t{$dst, %ax|ax, $dst}", (SCASW dstidx16:$dst), 0>;
340def : InstAlias<"scas\t{$dst, %eax|eax, $dst}", (SCASL dstidx32:$dst), 0>;
341def : InstAlias<"scas\t{$dst, %rax|rax, $dst}", (SCASQ dstidx64:$dst), 0>, Requires<[In64BitMode]>;
342def : InstAlias<"scas\t$dst", (SCASB dstidx8:$dst),  0, "intel">;
343def : InstAlias<"scas\t$dst", (SCASW dstidx16:$dst), 0, "intel">;
344def : InstAlias<"scas\t$dst", (SCASL dstidx32:$dst), 0, "intel">;
345def : InstAlias<"scas\t$dst", (SCASQ dstidx64:$dst), 0, "intel">, Requires<[In64BitMode]>;
346
347// cmps aliases. Mnemonic suffix being omitted because it's implicit
348// in the destination.
349def : InstAlias<"cmps\t{$dst, $src|$src, $dst}", (CMPSB dstidx8:$dst, srcidx8:$src),   0, "intel">;
350def : InstAlias<"cmps\t{$dst, $src|$src, $dst}", (CMPSW dstidx16:$dst, srcidx16:$src), 0, "intel">;
351def : InstAlias<"cmps\t{$dst, $src|$src, $dst}", (CMPSL dstidx32:$dst, srcidx32:$src), 0, "intel">;
352def : InstAlias<"cmps\t{$dst, $src|$src, $dst}", (CMPSQ dstidx64:$dst, srcidx64:$src), 0, "intel">, Requires<[In64BitMode]>;
353
354// movs aliases. Mnemonic suffix being omitted because it's implicit
355// in the destination.
356def : InstAlias<"movs\t{$src, $dst|$dst, $src}", (MOVSB dstidx8:$dst, srcidx8:$src),   0, "intel">;
357def : InstAlias<"movs\t{$src, $dst|$dst, $src}", (MOVSW dstidx16:$dst, srcidx16:$src), 0, "intel">;
358def : InstAlias<"movs\t{$src, $dst|$dst, $src}", (MOVSL dstidx32:$dst, srcidx32:$src), 0, "intel">;
359def : InstAlias<"movs\t{$src, $dst|$dst, $src}", (MOVSQ dstidx64:$dst, srcidx64:$src), 0, "intel">, Requires<[In64BitMode]>;
360
361// div and idiv aliases for explicit A register.
362def : InstAlias<"div{b}\t{$src, %al|al, $src}", (DIV8r  GR8 :$src)>;
363def : InstAlias<"div{w}\t{$src, %ax|ax, $src}", (DIV16r GR16:$src)>;
364def : InstAlias<"div{l}\t{$src, %eax|eax, $src}", (DIV32r GR32:$src)>;
365def : InstAlias<"div{q}\t{$src, %rax|rax, $src}", (DIV64r GR64:$src)>;
366def : InstAlias<"div{b}\t{$src, %al|al, $src}", (DIV8m  i8mem :$src)>;
367def : InstAlias<"div{w}\t{$src, %ax|ax, $src}", (DIV16m i16mem:$src)>;
368def : InstAlias<"div{l}\t{$src, %eax|eax, $src}", (DIV32m i32mem:$src)>;
369def : InstAlias<"div{q}\t{$src, %rax|rax, $src}", (DIV64m i64mem:$src)>;
370def : InstAlias<"idiv{b}\t{$src, %al|al, $src}", (IDIV8r  GR8 :$src)>;
371def : InstAlias<"idiv{w}\t{$src, %ax|ax, $src}", (IDIV16r GR16:$src)>;
372def : InstAlias<"idiv{l}\t{$src, %eax|eax, $src}", (IDIV32r GR32:$src)>;
373def : InstAlias<"idiv{q}\t{$src, %rax|rax, $src}", (IDIV64r GR64:$src)>;
374def : InstAlias<"idiv{b}\t{$src, %al|al, $src}", (IDIV8m  i8mem :$src)>;
375def : InstAlias<"idiv{w}\t{$src, %ax|ax, $src}", (IDIV16m i16mem:$src)>;
376def : InstAlias<"idiv{l}\t{$src, %eax|eax, $src}", (IDIV32m i32mem:$src)>;
377def : InstAlias<"idiv{q}\t{$src, %rax|rax, $src}", (IDIV64m i64mem:$src)>;
378
379
380
381// Various unary fpstack operations default to operating on ST1.
382// For example, "fxch" -> "fxch %st(1)"
383def : InstAlias<"faddp",        (ADD_FPrST0  ST1), 0>;
384def:  InstAlias<"fadd",         (ADD_FPrST0  ST1), 0>;
385def : InstAlias<"fsub{|r}p",    (SUBR_FPrST0 ST1), 0>;
386def : InstAlias<"fsub{r|}p",    (SUB_FPrST0  ST1), 0>;
387def : InstAlias<"fmul",         (MUL_FPrST0  ST1), 0>;
388def : InstAlias<"fmulp",        (MUL_FPrST0  ST1), 0>;
389def : InstAlias<"fdiv{|r}p",    (DIVR_FPrST0 ST1), 0>;
390def : InstAlias<"fdiv{r|}p",    (DIV_FPrST0  ST1), 0>;
391def : InstAlias<"fxch",         (XCH_F       ST1), 0>;
392def : InstAlias<"fcom",         (COM_FST0r   ST1), 0>;
393def : InstAlias<"fcomp",        (COMP_FST0r  ST1), 0>;
394def : InstAlias<"fcomi",        (COM_FIr     ST1), 0>;
395def : InstAlias<"fcompi",       (COM_FIPr    ST1), 0>;
396def : InstAlias<"fucom",        (UCOM_Fr     ST1), 0>;
397def : InstAlias<"fucomp",       (UCOM_FPr    ST1), 0>;
398def : InstAlias<"fucomi",       (UCOM_FIr    ST1), 0>;
399def : InstAlias<"fucompi",      (UCOM_FIPr   ST1), 0>;
400
401// Handle fmul/fadd/fsub/fdiv instructions with explicitly written st(0) op.
402// For example, "fadd %st(4), %st(0)" -> "fadd %st(4)".  We also disambiguate
403// instructions like "fadd %st(0), %st(0)" as "fadd %st(0)" for consistency with
404// gas.
405multiclass FpUnaryAlias<string Mnemonic, Instruction Inst, bit EmitAlias = 1> {
406 def : InstAlias<!strconcat(Mnemonic, "\t$op"),
407                 (Inst RSTi:$op), EmitAlias>;
408 def : InstAlias<!strconcat(Mnemonic, "\t{%st, %st|st, st}"),
409                 (Inst ST0), EmitAlias>;
410}
411
412defm : FpUnaryAlias<"fadd",   ADD_FST0r, 0>;
413defm : FpUnaryAlias<"faddp",  ADD_FPrST0, 0>;
414defm : FpUnaryAlias<"fsub",   SUB_FST0r, 0>;
415defm : FpUnaryAlias<"fsub{|r}p",  SUBR_FPrST0, 0>;
416defm : FpUnaryAlias<"fsubr",  SUBR_FST0r, 0>;
417defm : FpUnaryAlias<"fsub{r|}p", SUB_FPrST0, 0>;
418defm : FpUnaryAlias<"fmul",   MUL_FST0r, 0>;
419defm : FpUnaryAlias<"fmulp",  MUL_FPrST0, 0>;
420defm : FpUnaryAlias<"fdiv",   DIV_FST0r, 0>;
421defm : FpUnaryAlias<"fdiv{|r}p",  DIVR_FPrST0, 0>;
422defm : FpUnaryAlias<"fdivr",  DIVR_FST0r, 0>;
423defm : FpUnaryAlias<"fdiv{r|}p", DIV_FPrST0, 0>;
424defm : FpUnaryAlias<"fcomi",   COM_FIr, 0>;
425defm : FpUnaryAlias<"fucomi",  UCOM_FIr, 0>;
426defm : FpUnaryAlias<"fcompi",   COM_FIPr, 0>;
427defm : FpUnaryAlias<"fucompi",  UCOM_FIPr, 0>;
428
429
430// Handle "f{mulp,addp} $op, %st(0)" the same as "f{mulp,addp} $op", since they
431// commute.  We also allow fdiv[r]p/fsubrp even though they don't commute,
432// solely because gas supports it.
433def : InstAlias<"faddp\t{$op, %st|st, $op}", (ADD_FPrST0 RSTi:$op), 0>;
434def : InstAlias<"fmulp\t{$op, %st|st, $op}", (MUL_FPrST0 RSTi:$op), 0>;
435def : InstAlias<"fsub{|r}p\t{$op, %st|st, $op}", (SUBR_FPrST0 RSTi:$op), 0>;
436def : InstAlias<"fsub{r|}p\t{$op, %st|st, $op}", (SUB_FPrST0 RSTi:$op), 0>;
437def : InstAlias<"fdiv{|r}p\t{$op, %st|st, $op}", (DIVR_FPrST0 RSTi:$op), 0>;
438def : InstAlias<"fdiv{r|}p\t{$op, %st|st, $op}", (DIV_FPrST0 RSTi:$op), 0>;
439
440def : InstAlias<"fnstsw"     , (FNSTSW16r), 0>;
441
442// lcall and ljmp aliases.  This seems to be an odd mapping in 64-bit mode, but
443// this is compatible with what GAS does.
444def : InstAlias<"lcall\t$seg, $off", (FARCALL32i i32imm:$off, i16imm:$seg), 0>, Requires<[In32BitMode]>;
445def : InstAlias<"ljmp\t$seg, $off",  (FARJMP32i  i32imm:$off, i16imm:$seg), 0>, Requires<[In32BitMode]>;
446def : InstAlias<"lcall\t{*}$dst",    (FARCALL32m opaquemem:$dst), 0>, Requires<[Not16BitMode]>;
447def : InstAlias<"ljmp\t{*}$dst",     (FARJMP32m  opaquemem:$dst), 0>, Requires<[Not16BitMode]>;
448def : InstAlias<"lcall\t$seg, $off", (FARCALL16i i16imm:$off, i16imm:$seg), 0>, Requires<[In16BitMode]>;
449def : InstAlias<"ljmp\t$seg, $off",  (FARJMP16i  i16imm:$off, i16imm:$seg), 0>, Requires<[In16BitMode]>;
450def : InstAlias<"lcall\t{*}$dst",    (FARCALL16m opaquemem:$dst), 0>, Requires<[In16BitMode]>;
451def : InstAlias<"ljmp\t{*}$dst",     (FARJMP16m  opaquemem:$dst), 0>, Requires<[In16BitMode]>;
452
453def : InstAlias<"jmp\t{*}$dst",      (JMP64m  i64mem:$dst), 0, "att">, Requires<[In64BitMode]>;
454def : InstAlias<"jmp\t{*}$dst",      (JMP32m  i32mem:$dst), 0, "att">, Requires<[In32BitMode]>;
455def : InstAlias<"jmp\t{*}$dst",      (JMP16m  i16mem:$dst), 0, "att">, Requires<[In16BitMode]>;
456
457
458// "imul <imm>, B" is an alias for "imul <imm>, B, B".
459def : InstAlias<"imul{w}\t{$imm, $r|$r, $imm}", (IMUL16rri  GR16:$r, GR16:$r, i16imm:$imm), 0>;
460def : InstAlias<"imul{w}\t{$imm, $r|$r, $imm}", (IMUL16rri8 GR16:$r, GR16:$r, i16i8imm:$imm), 0>;
461def : InstAlias<"imul{l}\t{$imm, $r|$r, $imm}", (IMUL32rri  GR32:$r, GR32:$r, i32imm:$imm), 0>;
462def : InstAlias<"imul{l}\t{$imm, $r|$r, $imm}", (IMUL32rri8 GR32:$r, GR32:$r, i32i8imm:$imm), 0>;
463def : InstAlias<"imul{q}\t{$imm, $r|$r, $imm}", (IMUL64rri32 GR64:$r, GR64:$r, i64i32imm:$imm), 0>;
464def : InstAlias<"imul{q}\t{$imm, $r|$r, $imm}", (IMUL64rri8 GR64:$r, GR64:$r, i64i8imm:$imm), 0>;
465
466// ins aliases. Accept the mnemonic suffix being omitted because it's implicit
467// in the destination.
468def : InstAlias<"ins\t{%dx, $dst|$dst, dx}", (INSB dstidx8:$dst),  0, "intel">;
469def : InstAlias<"ins\t{%dx, $dst|$dst, dx}", (INSW dstidx16:$dst), 0, "intel">;
470def : InstAlias<"ins\t{%dx, $dst|$dst, dx}", (INSL dstidx32:$dst), 0, "intel">;
471
472// outs aliases. Accept the mnemonic suffix being omitted because it's implicit
473// in the source.
474def : InstAlias<"outs\t{$src, %dx|dx, $src}", (OUTSB srcidx8:$src),  0, "intel">;
475def : InstAlias<"outs\t{$src, %dx|dx, $src}", (OUTSW srcidx16:$src), 0, "intel">;
476def : InstAlias<"outs\t{$src, %dx|dx, $src}", (OUTSL srcidx32:$src), 0, "intel">;
477
478// inb %dx -> inb %al, %dx
479def : InstAlias<"inb\t{%dx|dx}", (IN8rr), 0>;
480def : InstAlias<"inw\t{%dx|dx}", (IN16rr), 0>;
481def : InstAlias<"inl\t{%dx|dx}", (IN32rr), 0>;
482def : InstAlias<"inb\t$port", (IN8ri u8imm:$port), 0>;
483def : InstAlias<"inw\t$port", (IN16ri u8imm:$port), 0>;
484def : InstAlias<"inl\t$port", (IN32ri u8imm:$port), 0>;
485
486
487// jmp and call aliases for lcall and ljmp.  jmp $42,$5 -> ljmp
488def : InstAlias<"call\t$seg, $off",  (FARCALL16i i16imm:$off, i16imm:$seg)>, Requires<[In16BitMode]>;
489def : InstAlias<"jmp\t$seg, $off",   (FARJMP16i  i16imm:$off, i16imm:$seg)>, Requires<[In16BitMode]>;
490def : InstAlias<"call\t$seg, $off",  (FARCALL32i i32imm:$off, i16imm:$seg)>, Requires<[In32BitMode]>;
491def : InstAlias<"jmp\t$seg, $off",   (FARJMP32i  i32imm:$off, i16imm:$seg)>, Requires<[In32BitMode]>;
492def : InstAlias<"callw\t$seg, $off", (FARCALL16i i16imm:$off, i16imm:$seg)>, Requires<[Not64BitMode]>;
493def : InstAlias<"jmpw\t$seg, $off",  (FARJMP16i  i16imm:$off, i16imm:$seg)>, Requires<[Not64BitMode]>;
494def : InstAlias<"calll\t$seg, $off", (FARCALL32i i32imm:$off, i16imm:$seg)>, Requires<[Not64BitMode]>;
495def : InstAlias<"jmpl\t$seg, $off",  (FARJMP32i  i32imm:$off, i16imm:$seg)>, Requires<[Not64BitMode]>;
496
497// Match 'movq <largeimm>, <reg>' as an alias for movabsq.
498def : InstAlias<"mov{q}\t{$imm, $reg|$reg, $imm}", (MOV64ri GR64:$reg, i64imm:$imm), 0>;
499
500// Match 'movd GR64, MMX' as an alias for movq to be compatible with gas,
501// which supports this due to an old AMD documentation bug when 64-bit mode was
502// created.
503def : InstAlias<"movd\t{$src, $dst|$dst, $src}",
504                (MMX_MOVD64to64rr VR64:$dst, GR64:$src), 0>;
505def : InstAlias<"movd\t{$src, $dst|$dst, $src}",
506                (MMX_MOVD64from64rr GR64:$dst, VR64:$src), 0>;
507
508// movsx aliases
509def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX16rr8 GR16:$dst, GR8:$src), 0, "att">;
510def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX16rm8 GR16:$dst, i8mem:$src), 0, "att">;
511def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX32rr8 GR32:$dst, GR8:$src), 0, "att">;
512def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX32rr16 GR32:$dst, GR16:$src), 0, "att">;
513def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX64rr8 GR64:$dst, GR8:$src), 0, "att">;
514def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX64rr16 GR64:$dst, GR16:$src), 0, "att">;
515def : InstAlias<"movsx\t{$src, $dst|$dst, $src}", (MOVSX64rr32 GR64:$dst, GR32:$src), 0, "att">;
516
517// movzx aliases
518def : InstAlias<"movzx\t{$src, $dst|$dst, $src}", (MOVZX16rr8 GR16:$dst, GR8:$src), 0, "att">;
519def : InstAlias<"movzx\t{$src, $dst|$dst, $src}", (MOVZX16rm8 GR16:$dst, i8mem:$src), 0, "att">;
520def : InstAlias<"movzx\t{$src, $dst|$dst, $src}", (MOVZX32rr8 GR32:$dst, GR8:$src), 0, "att">;
521def : InstAlias<"movzx\t{$src, $dst|$dst, $src}", (MOVZX32rr16 GR32:$dst, GR16:$src), 0, "att">;
522def : InstAlias<"movzx\t{$src, $dst|$dst, $src}", (MOVZX64rr8 GR64:$dst, GR8:$src), 0, "att">;
523def : InstAlias<"movzx\t{$src, $dst|$dst, $src}", (MOVZX64rr16 GR64:$dst, GR16:$src), 0, "att">;
524// Note: No GR32->GR64 movzx form.
525
526// outb %dx -> outb %al, %dx
527def : InstAlias<"outb\t{%dx|dx}", (OUT8rr), 0>;
528def : InstAlias<"outw\t{%dx|dx}", (OUT16rr), 0>;
529def : InstAlias<"outl\t{%dx|dx}", (OUT32rr), 0>;
530def : InstAlias<"outb\t$port", (OUT8ir u8imm:$port), 0>;
531def : InstAlias<"outw\t$port", (OUT16ir u8imm:$port), 0>;
532def : InstAlias<"outl\t$port", (OUT32ir u8imm:$port), 0>;
533
534// 'sldt <mem>' can be encoded with either sldtw or sldtq with the same
535// effect (both store to a 16-bit mem).  Force to sldtw to avoid ambiguity
536// errors, since its encoding is the most compact.
537def : InstAlias<"sldt $mem", (SLDT16m i16mem:$mem), 0>;
538
539// shld/shrd op,op -> shld op, op, CL
540def : InstAlias<"shld{w}\t{$r2, $r1|$r1, $r2}", (SHLD16rrCL GR16:$r1, GR16:$r2), 0>;
541def : InstAlias<"shld{l}\t{$r2, $r1|$r1, $r2}", (SHLD32rrCL GR32:$r1, GR32:$r2), 0>;
542def : InstAlias<"shld{q}\t{$r2, $r1|$r1, $r2}", (SHLD64rrCL GR64:$r1, GR64:$r2), 0>;
543def : InstAlias<"shrd{w}\t{$r2, $r1|$r1, $r2}", (SHRD16rrCL GR16:$r1, GR16:$r2), 0>;
544def : InstAlias<"shrd{l}\t{$r2, $r1|$r1, $r2}", (SHRD32rrCL GR32:$r1, GR32:$r2), 0>;
545def : InstAlias<"shrd{q}\t{$r2, $r1|$r1, $r2}", (SHRD64rrCL GR64:$r1, GR64:$r2), 0>;
546
547def : InstAlias<"shld{w}\t{$reg, $mem|$mem, $reg}", (SHLD16mrCL i16mem:$mem, GR16:$reg), 0>;
548def : InstAlias<"shld{l}\t{$reg, $mem|$mem, $reg}", (SHLD32mrCL i32mem:$mem, GR32:$reg), 0>;
549def : InstAlias<"shld{q}\t{$reg, $mem|$mem, $reg}", (SHLD64mrCL i64mem:$mem, GR64:$reg), 0>;
550def : InstAlias<"shrd{w}\t{$reg, $mem|$mem, $reg}", (SHRD16mrCL i16mem:$mem, GR16:$reg), 0>;
551def : InstAlias<"shrd{l}\t{$reg, $mem|$mem, $reg}", (SHRD32mrCL i32mem:$mem, GR32:$reg), 0>;
552def : InstAlias<"shrd{q}\t{$reg, $mem|$mem, $reg}", (SHRD64mrCL i64mem:$mem, GR64:$reg), 0>;
553
554// test: We accept "testX <reg>, <mem>" and "testX <mem>, <reg>" as synonyms.
555def : InstAlias<"test{b}\t{$mem, $val|$val, $mem}",
556                (TEST8mr  i8mem :$mem, GR8 :$val), 0>;
557def : InstAlias<"test{w}\t{$mem, $val|$val, $mem}",
558                (TEST16mr i16mem:$mem, GR16:$val), 0>;
559def : InstAlias<"test{l}\t{$mem, $val|$val, $mem}",
560                (TEST32mr i32mem:$mem, GR32:$val), 0>;
561def : InstAlias<"test{q}\t{$mem, $val|$val, $mem}",
562                (TEST64mr i64mem:$mem, GR64:$val), 0>;
563
564// xchg: We accept "xchgX <reg>, <mem>" and "xchgX <mem>, <reg>" as synonyms.
565def : InstAlias<"xchg{b}\t{$mem, $val|$val, $mem}",
566                (XCHG8rm  GR8 :$val, i8mem :$mem), 0>;
567def : InstAlias<"xchg{w}\t{$mem, $val|$val, $mem}",
568                (XCHG16rm GR16:$val, i16mem:$mem), 0>;
569def : InstAlias<"xchg{l}\t{$mem, $val|$val, $mem}",
570                (XCHG32rm GR32:$val, i32mem:$mem), 0>;
571def : InstAlias<"xchg{q}\t{$mem, $val|$val, $mem}",
572                (XCHG64rm GR64:$val, i64mem:$mem), 0>;
573
574// xchg: We accept "xchgX <reg>, %eax" and "xchgX %eax, <reg>" as synonyms.
575def : InstAlias<"xchg{w}\t{%ax, $src|$src, ax}", (XCHG16ar GR16:$src), 0>;
576def : InstAlias<"xchg{l}\t{%eax, $src|$src, eax}", (XCHG32ar GR32:$src), 0>;
577def : InstAlias<"xchg{q}\t{%rax, $src|$src, rax}", (XCHG64ar GR64:$src), 0>;
578
579// In 64-bit mode, xchg %eax, %eax can't be encoded with the 0x90 opcode we
580// would get by default because it's defined as NOP. But xchg %eax, %eax implies
581// implicit zeroing of the upper 32 bits. So alias to the longer encoding.
582def : InstAlias<"xchg{l}\t{%eax, %eax|eax, eax}",
583                (XCHG32rr EAX, EAX), 0>, Requires<[In64BitMode]>;
584
585// xchg %rax, %rax is a nop in x86-64 and can be encoded as such. Without this
586// we emit an unneeded REX.w prefix.
587def : InstAlias<"xchg{q}\t{%rax, %rax|rax, rax}", (NOOP), 0>;
588
589// These aliases exist to get the parser to prioritize matching 8-bit
590// immediate encodings over matching the implicit ax/eax/rax encodings. By
591// explicitly mentioning the A register here, these entries will be ordered
592// first due to the more explicit immediate type.
593def : InstAlias<"adc{w}\t{$imm, %ax|ax, $imm}", (ADC16ri8 AX, i16i8imm:$imm), 0>;
594def : InstAlias<"add{w}\t{$imm, %ax|ax, $imm}", (ADD16ri8 AX, i16i8imm:$imm), 0>;
595def : InstAlias<"and{w}\t{$imm, %ax|ax, $imm}", (AND16ri8 AX, i16i8imm:$imm), 0>;
596def : InstAlias<"cmp{w}\t{$imm, %ax|ax, $imm}", (CMP16ri8 AX, i16i8imm:$imm), 0>;
597def : InstAlias<"or{w}\t{$imm, %ax|ax, $imm}",  (OR16ri8 AX,  i16i8imm:$imm), 0>;
598def : InstAlias<"sbb{w}\t{$imm, %ax|ax, $imm}", (SBB16ri8 AX, i16i8imm:$imm), 0>;
599def : InstAlias<"sub{w}\t{$imm, %ax|ax, $imm}", (SUB16ri8 AX, i16i8imm:$imm), 0>;
600def : InstAlias<"xor{w}\t{$imm, %ax|ax, $imm}", (XOR16ri8 AX, i16i8imm:$imm), 0>;
601
602def : InstAlias<"adc{l}\t{$imm, %eax|eax, $imm}", (ADC32ri8 EAX, i32i8imm:$imm), 0>;
603def : InstAlias<"add{l}\t{$imm, %eax|eax, $imm}", (ADD32ri8 EAX, i32i8imm:$imm), 0>;
604def : InstAlias<"and{l}\t{$imm, %eax|eax, $imm}", (AND32ri8 EAX, i32i8imm:$imm), 0>;
605def : InstAlias<"cmp{l}\t{$imm, %eax|eax, $imm}", (CMP32ri8 EAX, i32i8imm:$imm), 0>;
606def : InstAlias<"or{l}\t{$imm, %eax|eax, $imm}",  (OR32ri8 EAX,  i32i8imm:$imm), 0>;
607def : InstAlias<"sbb{l}\t{$imm, %eax|eax, $imm}", (SBB32ri8 EAX, i32i8imm:$imm), 0>;
608def : InstAlias<"sub{l}\t{$imm, %eax|eax, $imm}", (SUB32ri8 EAX, i32i8imm:$imm), 0>;
609def : InstAlias<"xor{l}\t{$imm, %eax|eax, $imm}", (XOR32ri8 EAX, i32i8imm:$imm), 0>;
610
611def : InstAlias<"adc{q}\t{$imm, %rax|rax, $imm}", (ADC64ri8 RAX, i64i8imm:$imm), 0>;
612def : InstAlias<"add{q}\t{$imm, %rax|rax, $imm}", (ADD64ri8 RAX, i64i8imm:$imm), 0>;
613def : InstAlias<"and{q}\t{$imm, %rax|rax, $imm}", (AND64ri8 RAX, i64i8imm:$imm), 0>;
614def : InstAlias<"cmp{q}\t{$imm, %rax|rax, $imm}", (CMP64ri8 RAX, i64i8imm:$imm), 0>;
615def : InstAlias<"or{q}\t{$imm, %rax|rax, $imm}",  (OR64ri8 RAX,  i64i8imm:$imm), 0>;
616def : InstAlias<"sbb{q}\t{$imm, %rax|rax, $imm}", (SBB64ri8 RAX, i64i8imm:$imm), 0>;
617def : InstAlias<"sub{q}\t{$imm, %rax|rax, $imm}", (SUB64ri8 RAX, i64i8imm:$imm), 0>;
618def : InstAlias<"xor{q}\t{$imm, %rax|rax, $imm}", (XOR64ri8 RAX, i64i8imm:$imm), 0>;
619
620//  MMX instr alia
621def : InstAlias<"movq.s\t{$src, $dst|$dst, $src}",
622                (MMX_MOVQ64rr_REV VR64:$dst, VR64:$src), 0>;
623
624//  CMOV SETCC Aliases
625multiclass CMOV_SETCC_Aliases<string Cond, int CC> {
626  def : InstAlias<"cmov"#Cond#"{w}\t{$src, $dst|$dst, $src}",
627                  (CMOV16rr GR16:$dst, GR16:$src, CC), 0>;
628  def : InstAlias<"cmov"#Cond#"{w}\t{$src, $dst|$dst, $src}",
629                  (CMOV16rm GR16:$dst, i16mem:$src, CC), 0>;
630  def : InstAlias<"cmov"#Cond#"{l}\t{$src, $dst|$dst, $src}",
631                  (CMOV32rr GR32:$dst, GR32:$src, CC), 0>;
632  def : InstAlias<"cmov"#Cond#"{l}\t{$src, $dst|$dst, $src}",
633                  (CMOV32rm GR32:$dst, i32mem:$src, CC), 0>;
634  def : InstAlias<"cmov"#Cond#"{q}\t{$src, $dst|$dst, $src}",
635                  (CMOV64rr GR64:$dst, GR64:$src, CC), 0>;
636  def : InstAlias<"cmov"#Cond#"{q}\t{$src, $dst|$dst, $src}",
637                  (CMOV64rm GR64:$dst, i64mem:$src, CC), 0>;
638
639  def : InstAlias<"set"#Cond#"\t$dst", (SETCCr GR8:$dst, CC), 0>;
640  def : InstAlias<"set"#Cond#"\t$dst", (SETCCm i8mem:$dst, CC), 0>;
641}
642
643defm : CMOV_SETCC_Aliases<"o" ,  0>;
644defm : CMOV_SETCC_Aliases<"no",  1>;
645defm : CMOV_SETCC_Aliases<"b" ,  2>;
646defm : CMOV_SETCC_Aliases<"ae",  3>;
647defm : CMOV_SETCC_Aliases<"e" ,  4>;
648defm : CMOV_SETCC_Aliases<"ne",  5>;
649defm : CMOV_SETCC_Aliases<"be",  6>;
650defm : CMOV_SETCC_Aliases<"a" ,  7>;
651defm : CMOV_SETCC_Aliases<"s" ,  8>;
652defm : CMOV_SETCC_Aliases<"ns",  9>;
653defm : CMOV_SETCC_Aliases<"p" , 10>;
654defm : CMOV_SETCC_Aliases<"np", 11>;
655defm : CMOV_SETCC_Aliases<"l" , 12>;
656defm : CMOV_SETCC_Aliases<"ge", 13>;
657defm : CMOV_SETCC_Aliases<"le", 14>;
658defm : CMOV_SETCC_Aliases<"g" , 15>;
659
660// Condition dump instructions Alias
661def : InstAlias<"jo\t$dst",  (JCC_1 brtarget8:$dst,  0), 0>;
662def : InstAlias<"jno\t$dst", (JCC_1 brtarget8:$dst,  1), 0>;
663def : InstAlias<"jb\t$dst",  (JCC_1 brtarget8:$dst,  2), 0>;
664def : InstAlias<"jae\t$dst", (JCC_1 brtarget8:$dst,  3), 0>;
665def : InstAlias<"je\t$dst",  (JCC_1 brtarget8:$dst,  4), 0>;
666def : InstAlias<"jne\t$dst", (JCC_1 brtarget8:$dst,  5), 0>;
667def : InstAlias<"jbe\t$dst", (JCC_1 brtarget8:$dst,  6), 0>;
668def : InstAlias<"ja\t$dst",  (JCC_1 brtarget8:$dst,  7), 0>;
669def : InstAlias<"js\t$dst",  (JCC_1 brtarget8:$dst,  8), 0>;
670def : InstAlias<"jns\t$dst", (JCC_1 brtarget8:$dst,  9), 0>;
671def : InstAlias<"jp\t$dst",  (JCC_1 brtarget8:$dst, 10), 0>;
672def : InstAlias<"jnp\t$dst", (JCC_1 brtarget8:$dst, 11), 0>;
673def : InstAlias<"jl\t$dst",  (JCC_1 brtarget8:$dst, 12), 0>;
674def : InstAlias<"jge\t$dst", (JCC_1 brtarget8:$dst, 13), 0>;
675def : InstAlias<"jle\t$dst", (JCC_1 brtarget8:$dst, 14), 0>;
676def : InstAlias<"jg\t$dst",  (JCC_1 brtarget8:$dst, 15), 0>;
677
678// SVM instructions Alias
679def : InstAlias<"skinit\t{%eax|eax}", (SKINIT), 0>;
680def : InstAlias<"vmrun\t{%eax|eax}", (VMRUN32), 0>, Requires<[Not64BitMode]>;
681def : InstAlias<"vmrun\t{%rax|rax}", (VMRUN64), 0>, Requires<[In64BitMode]>;
682def : InstAlias<"vmload\t{%eax|eax}", (VMLOAD32), 0>, Requires<[Not64BitMode]>;
683def : InstAlias<"vmload\t{%rax|rax}", (VMLOAD64), 0>, Requires<[In64BitMode]>;
684def : InstAlias<"vmsave\t{%eax|eax}", (VMSAVE32), 0>, Requires<[Not64BitMode]>;
685def : InstAlias<"vmsave\t{%rax|rax}", (VMSAVE64), 0>, Requires<[In64BitMode]>;
686def : InstAlias<"invlpga\t{%eax, %ecx|eax, ecx}", (INVLPGA32), 0>, Requires<[Not64BitMode]>;
687def : InstAlias<"invlpga\t{%rax, %ecx|rax, ecx}", (INVLPGA64), 0>, Requires<[In64BitMode]>;
688
689