Skip to content

Commit 7cd3268

Browse files
committed
[X86][TableGen] Fix the mnemonic table for CMPCCXADD
The mnemonic of CMPCCXADD is `cmp${cond}xadd` and the condition code is in the middle of mnemonic. When generating the function name for CMPCCXADD, the substring `xadd` should be kept. Before this patch, the name is `isCMPCC`. After this patch, the name is `isCMPCCXADD`.
1 parent 9dab2e3 commit 7cd3268

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86InstPrinterCommon.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,29 @@ using namespace llvm;
2929
void X86InstPrinterCommon::printCondCode(const MCInst *MI, unsigned Op,
3030
raw_ostream &O) {
3131
int64_t Imm = MI->getOperand(Op).getImm();
32-
bool Flavor = MI->getOpcode() == X86::CMPCCXADDmr32 ||
33-
MI->getOpcode() == X86::CMPCCXADDmr64 ||
34-
MI->getOpcode() == X86::CMPCCXADDmr32_EVEX ||
35-
MI->getOpcode() == X86::CMPCCXADDmr64_EVEX;
32+
bool IsCMPCCXADD = X86::isCMPCCXADD(MI->getOpcode());
33+
34+
// clang-format off
3635
switch (Imm) {
3736
default: llvm_unreachable("Invalid condcode argument!");
3837
case 0: O << "o"; break;
3938
case 1: O << "no"; break;
4039
case 2: O << "b"; break;
41-
case 3: O << (Flavor ? "nb" : "ae"); break;
42-
case 4: O << (Flavor ? "z" : "e"); break;
43-
case 5: O << (Flavor ? "nz" : "ne"); break;
40+
case 3: O << (IsCMPCCXADD ? "nb" : "ae"); break;
41+
case 4: O << (IsCMPCCXADD ? "z" : "e"); break;
42+
case 5: O << (IsCMPCCXADD ? "nz" : "ne"); break;
4443
case 6: O << "be"; break;
45-
case 7: O << (Flavor ? "nbe" : "a"); break;
44+
case 7: O << (IsCMPCCXADD ? "nbe" : "a"); break;
4645
case 8: O << "s"; break;
4746
case 9: O << "ns"; break;
4847
case 0xa: O << "p"; break;
4948
case 0xb: O << "np"; break;
5049
case 0xc: O << "l"; break;
51-
case 0xd: O << (Flavor ? "nl" : "ge"); break;
50+
case 0xd: O << (IsCMPCCXADD ? "nl" : "ge"); break;
5251
case 0xe: O << "le"; break;
53-
case 0xf: O << (Flavor ? "nle" : "g"); break;
52+
case 0xf: O << (IsCMPCCXADD ? "nle" : "g"); break;
5453
}
54+
// clang-format on
5555
}
5656

5757
void X86InstPrinterCommon::printSSEAVXCC(const MCInst *MI, unsigned Op,

llvm/utils/TableGen/X86RecognizableInstr.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ using namespace X86Disassembler;
2626

2727
std::string X86Disassembler::getMnemonic(const CodeGenInstruction *I,
2828
unsigned Variant) {
29-
std::string AsmString = I->FlattenAsmStringVariants(I->AsmString, Variant);
30-
StringRef Mnemonic(AsmString);
3129
// Extract a mnemonic assuming it's separated by \t
32-
Mnemonic = Mnemonic.take_until([](char C) { return C == '\t'; });
30+
std::string Mnemonic =
31+
StringRef(I->FlattenAsmStringVariants(I->AsmString, Variant))
32+
.take_until([](char C) { return C == '\t'; })
33+
.str();
3334

34-
// Special case: CMOVCC, JCC, SETCC have "${cond}" in mnemonic.
35+
// Special case: CMOVCC, JCC, SETCC, CMPCCXADD have "${cond}" in mnemonic.
3536
// Replace it with "CC" in-place.
36-
size_t CondPos = Mnemonic.find("${cond}");
37-
if (CondPos != StringRef::npos)
38-
Mnemonic = AsmString.replace(CondPos, StringRef::npos, "CC");
39-
return Mnemonic.upper();
37+
auto CondPos = Mnemonic.find("${cond}");
38+
if (CondPos != std::string::npos)
39+
Mnemonic = Mnemonic.replace(CondPos, 7, "CC");
40+
return StringRef(Mnemonic).upper();
4041
}
4142

4243
bool X86Disassembler::isRegisterOperand(const Record *Rec) {

0 commit comments

Comments
 (0)