diff options
Diffstat (limited to 'llvm/utils/TableGen/X86InstrMappingEmitter.cpp')
| -rw-r--r-- | llvm/utils/TableGen/X86InstrMappingEmitter.cpp | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/llvm/utils/TableGen/X86InstrMappingEmitter.cpp b/llvm/utils/TableGen/X86InstrMappingEmitter.cpp index 5a2b669dbcd4..950ff1394b9f 100644 --- a/llvm/utils/TableGen/X86InstrMappingEmitter.cpp +++ b/llvm/utils/TableGen/X86InstrMappingEmitter.cpp @@ -25,15 +25,6 @@ using namespace X86Disassembler; namespace { -const std::map<StringRef, StringRef> ManualMap = { -#define ENTRY(OLD, NEW) {#OLD, #NEW}, -#include "X86ManualCompressEVEXTables.def" -}; -const std::set<StringRef> NoCompressSet = { -#define NOCOMP(INSN) #INSN, -#include "X86ManualCompressEVEXTables.def" -}; - class X86InstrMappingEmitter { RecordKeeper &Records; CodeGenTarget Target; @@ -176,6 +167,16 @@ static bool isInteresting(const Record *Rec) { void X86InstrMappingEmitter::emitCompressEVEXTable( ArrayRef<const CodeGenInstruction *> Insts, raw_ostream &OS) { + + const std::map<StringRef, StringRef> ManualMap = { +#define ENTRY(OLD, NEW) {#OLD, #NEW}, +#include "X86ManualInstrMapping.def" + }; + const std::set<StringRef> NoCompressSet = { +#define NOCOMP(INSN) #INSN, +#include "X86ManualInstrMapping.def" + }; + for (const CodeGenInstruction *Inst : Insts) { const Record *Rec = Inst->TheDef; StringRef Name = Rec->getName(); @@ -219,13 +220,10 @@ void X86InstrMappingEmitter::emitCompressEVEXTable( } else if (Name.ends_with("_EVEX")) { if (auto *NewRec = Records.getDef(Name.drop_back(5))) NewInst = &Target.getInstruction(NewRec); - } else if (Name.ends_with("_ND")) { - if (auto *NewRec = Records.getDef(Name.drop_back(3))) { - auto &TempInst = Target.getInstruction(NewRec); - if (isRegisterOperand(TempInst.Operands[0].Rec)) - NewInst = &TempInst; - } - } else { + } else if (Name.ends_with("_ND")) + // Leave it to ND2NONND table. + continue; + else { // For each pre-compression instruction look for a match in the // appropriate vector (instructions with the same opcode) using function // object IsMatch. @@ -301,11 +299,31 @@ void X86InstrMappingEmitter::emitNFTransformTable( void X86InstrMappingEmitter::emitND2NonNDTable( ArrayRef<const CodeGenInstruction *> Insts, raw_ostream &OS) { + + const std::map<StringRef, StringRef> ManualMap = { +#define ENTRY_ND(OLD, NEW) {#OLD, #NEW}, +#include "X86ManualInstrMapping.def" + }; + const std::set<StringRef> NoCompressSet = { +#define NOCOMP_ND(INSN) #INSN, +#include "X86ManualInstrMapping.def" + }; + std::vector<Entry> Table; for (const CodeGenInstruction *Inst : Insts) { const Record *Rec = Inst->TheDef; StringRef Name = Rec->getName(); - if (!isInteresting(Rec) || !Name.ends_with("_ND")) + if (!isInteresting(Rec) || NoCompressSet.find(Name) != NoCompressSet.end()) + continue; + if (ManualMap.find(Name) != ManualMap.end()) { + auto *NewRec = Records.getDef(ManualMap.at(Rec->getName())); + assert(NewRec && "Instruction not found!"); + auto &NewInst = Target.getInstruction(NewRec); + Table.push_back(std::pair(Inst, &NewInst)); + continue; + } + + if (!Name.ends_with("_ND")) continue; auto *NewRec = Records.getDef(Name.drop_back(3)); if (!NewRec) |
