llvm.org GIT mirror llvm / 25f6dfd
Revert part of r141274. Only need to change encoding for xchg %eax, %eax in 64-bit mode. This is because in 64-bit mode xchg %eax, %eax implies zeroing the upper 32-bits of RAX which makes it not a NOP. In 32-bit mode using NOP encoding is fine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141353 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 8 years ago
5 changed file(s) with 21 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
11531153 "xchg{q}\t{$val, $src|$src, $val}", []>;
11541154 }
11551155
1156 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16_NOAX:$src),
1156 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
11571157 "xchg{w}\t{$src, %ax|AX, $src}", []>, OpSize;
1158 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32_NOAX:$src),
1159 "xchg{l}\t{$src, %eax|EAX, $src}", []>;
1160 def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64_NOAX:$src),
1158 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
1159 "xchg{l}\t{$src, %eax|EAX, $src}", []>, Requires<[In32BitMode]>;
1160 // Uses GR32_NOAX in 64-bit mode to prevent encoding using the 0x90 NOP encoding.
1161 // xchg %eax, %eax needs to clear upper 32-bits of RAX so is not a NOP.
1162 def XCHG32ar64 : I<0x90, AddRegFrm, (outs), (ins GR32_NOAX:$src),
1163 "xchg{l}\t{$src, %eax|EAX, $src}", []>, Requires<[In64BitMode]>;
1164 def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64:$src),
11611165 "xchg{q}\t{$src, %rax|RAX, $src}", []>;
11621166
11631167
17151719 def : InstAlias<"xchgq $mem, $val", (XCHG64rm GR64:$val, i64mem:$mem)>;
17161720
17171721 // xchg: We accept "xchgX , %eax" and "xchgX %eax, " as synonyms.
1718 def : InstAlias<"xchgw %ax, $src", (XCHG16ar GR16_NOAX:$src)>;
1719 def : InstAlias<"xchgl %eax, $src", (XCHG32ar GR32_NOAX:$src)>;
1720 def : InstAlias<"xchgq %rax, $src", (XCHG64ar GR64_NOAX:$src)>;
1722 def : InstAlias<"xchgw %ax, $src", (XCHG16ar GR16:$src)>;
1723 def : InstAlias<"xchgl %eax, $src", (XCHG32ar GR32:$src)>, Requires<[In32BitMode]>;
1724 def : InstAlias<"xchgl %eax, $src", (XCHG32ar64 GR32_NOAX:$src)>, Requires<[In64BitMode]>;
1725 def : InstAlias<"xchgq %rax, $src", (XCHG64ar GR64:$src)>;
389389 (GR32_NOREX sub_32bit)];
390390 }
391391
392 // GR16_NOAX - GR16 registers except AX.
393 def GR16_NOAX : RegisterClass<"X86", [i16], 16, (sub GR16, AX)> {
394 let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi)];
395 }
396
397 // GR32_NOAX - GR32 registers except EAX.
392 // GR32_NOAX - GR32 registers except EAX. Used by AddRegFrm of XCHG32 in 64-bit
393 // mode to prevent encoding using the 0x90 NOP encoding. xchg %eax, %eax needs
394 // to clear upper 32-bits of RAX so is not a NOP.
398395 def GR32_NOAX : RegisterClass<"X86", [i32], 32, (sub GR32, EAX)> {
399 let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi), (GR16_NOAX sub_16bit)];
400 }
401
402 // GR64_NOAX - GR64 registers except RAX.
403 def GR64_NOAX : RegisterClass<"X86", [i64], 64, (sub GR64, RAX)> {
404 let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi),
405 (GR16_NOAX sub_16bit),
406 (GR32_NOAX sub_32bit)];
396 let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi), (GR16 sub_16bit)];
407397 }
408398
409399 // GR32_NOSP - GR32 registers except ESP.
947947
948948 // PR10345
949949 // CHECK: xchgl %eax, %eax
950 // CHECK: encoding: [0x87,0xc0]
950 // CHECK: encoding: [0x90]
951951 xchgl %eax, %eax
952952
953953 // CHECK: xchgw %ax, %ax
954 // CHECK: encoding: [0x66,0x87,0xc0]
954 // CHECK: encoding: [0x66,0x90]
955955 xchgw %ax, %ax
956956
957957 // CHECK: xchgl %ecx, %eax
11721172
11731173 // PR10345
11741174 // CHECK: xchgq %rax, %rax
1175 // CHECK: encoding: [0x48,0x87,0xc0]
1175 // CHECK: encoding: [0x48,0x90]
11761176 xchgq %rax, %rax
11771177
11781178 // CHECK: xchgl %eax, %eax
11801180 xchgl %eax, %eax
11811181
11821182 // CHECK: xchgw %ax, %ax
1183 // CHECK: encoding: [0x66,0x87,0xc0]
1183 // CHECK: encoding: [0x66,0x90]
11841184 xchgw %ax, %ax
11851185
11861186 // CHECK: xchgl %ecx, %eax
619619
620620 if(previousInfo.name == "NOOP" && (newInfo.name == "XCHG16ar" ||
621621 newInfo.name == "XCHG32ar" ||
622 newInfo.name == "XCHG32ar64" ||
622623 newInfo.name == "XCHG64ar"))
623624 continue; // special case for XCHG*ar and NOOP
624625