Switch more code over to using getValueAsListOfDefs. Look at all the -'s. :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24074 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp
index 3a83746..b5a1a2e 100644
--- a/utils/TableGen/InstrInfoEmitter.cpp
+++ b/utils/TableGen/InstrInfoEmitter.cpp
@@ -47,16 +47,6 @@
OS << "} // End llvm namespace \n";
}
-static std::vector<Record*> GetDefList(ListInit *LI, const std::string &Name) {
- std::vector<Record*> Result;
- for (unsigned i = 0, e = LI->getSize(); i != e; ++i)
- if (DefInit *DI = dynamic_cast<DefInit*>(LI->getElement(i)))
- Result.push_back(DI->getDef());
- else
- throw "Illegal value in '" + Name + "' list!";
- return Result;
-}
-
void InstrInfoEmitter::printDefList(const std::vector<Record*> &Uses,
unsigned Num, std::ostream &OS) const {
OS << "static const unsigned ImplicitList" << Num << "[] = { ";
@@ -99,26 +89,21 @@
// Keep track of all of the def lists we have emitted already.
std::map<std::vector<Record*>, unsigned> EmittedLists;
- std::map<ListInit*, unsigned> ListNumbers;
unsigned ListNumber = 0;
// Emit all of the instruction's implicit uses and defs.
for (CodeGenTarget::inst_iterator II = Target.inst_begin(),
E = Target.inst_end(); II != E; ++II) {
Record *Inst = II->second.TheDef;
- ListInit *LI = Inst->getValueAsListInit("Uses");
- if (LI->getSize()) {
- std::vector<Record*> Uses = GetDefList(LI, Inst->getName());
+ std::vector<Record*> Uses = Inst->getValueAsListOfDefs("Uses");
+ if (!Uses.empty()) {
unsigned &IL = EmittedLists[Uses];
if (!IL) printDefList(Uses, IL = ++ListNumber, OS);
- ListNumbers[LI] = IL;
}
- LI = Inst->getValueAsListInit("Defs");
- if (LI->getSize()) {
- std::vector<Record*> Uses = GetDefList(LI, Inst->getName());
- unsigned &IL = EmittedLists[Uses];
- if (!IL) printDefList(Uses, IL = ++ListNumber, OS);
- ListNumbers[LI] = IL;
+ std::vector<Record*> Defs = Inst->getValueAsListOfDefs("Defs");
+ if (!Defs.empty()) {
+ unsigned &IL = EmittedLists[Defs];
+ if (!IL) printDefList(Defs, IL = ++ListNumber, OS);
}
}
@@ -150,14 +135,14 @@
//
OS << "\nstatic const TargetInstrDescriptor " << TargetName
<< "Insts[] = {\n";
- emitRecord(Target.getPHIInstruction(), 0, InstrInfo, ListNumbers,
+ emitRecord(Target.getPHIInstruction(), 0, InstrInfo, EmittedLists,
OperandInfosEmitted, OS);
unsigned i = 0;
for (CodeGenTarget::inst_iterator II = Target.inst_begin(),
E = Target.inst_end(); II != E; ++II)
if (II->second.TheDef != PHI)
- emitRecord(II->second, ++i, InstrInfo, ListNumbers,
+ emitRecord(II->second, ++i, InstrInfo, EmittedLists,
OperandInfosEmitted, OS);
OS << "};\n";
OS << "} // End llvm namespace \n";
@@ -165,7 +150,7 @@
void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
Record *InstrInfo,
- std::map<ListInit*, unsigned> &ListNumbers,
+ std::map<std::vector<Record*>, unsigned> &EmittedLists,
std::map<std::vector<Record*>, unsigned> &OpInfo,
std::ostream &OS) {
int NumOperands;
@@ -215,17 +200,17 @@
OS << ", ";
// Emit the implicit uses and defs lists...
- LI = Inst.TheDef->getValueAsListInit("Uses");
- if (!LI->getSize())
+ std::vector<Record*> UseList = Inst.TheDef->getValueAsListOfDefs("Uses");
+ if (UseList.empty())
OS << "EmptyImpList, ";
else
- OS << "ImplicitList" << ListNumbers[LI] << ", ";
+ OS << "ImplicitList" << EmittedLists[UseList] << ", ";
- LI = Inst.TheDef->getValueAsListInit("Defs");
- if (!LI->getSize())
+ std::vector<Record*> DefList = Inst.TheDef->getValueAsListOfDefs("Defs");
+ if (DefList.empty())
OS << "EmptyImpList, ";
else
- OS << "ImplicitList" << ListNumbers[LI] << ", ";
+ OS << "ImplicitList" << EmittedLists[DefList] << ", ";
// Emit the operand info.
std::vector<Record*> OperandInfo = GetOperandInfo(Inst);
diff --git a/utils/TableGen/InstrInfoEmitter.h b/utils/TableGen/InstrInfoEmitter.h
index a2dbb7c..93f0e60 100644
--- a/utils/TableGen/InstrInfoEmitter.h
+++ b/utils/TableGen/InstrInfoEmitter.h
@@ -41,7 +41,7 @@
std::ostream &OS) const;
void emitRecord(const CodeGenInstruction &Inst, unsigned Num,
Record *InstrInfo,
- std::map<ListInit*, unsigned> &ListNumbers,
+ std::map<std::vector<Record*>, unsigned> &EL,
std::map<std::vector<Record*>, unsigned> &OpInfo,
std::ostream &OS);
void emitShiftedValue(Record *R, StringInit *Val, IntInit *Shift,
diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp
index af53dba..5c3cb8d 100644
--- a/utils/TableGen/RegisterInfoEmitter.cpp
+++ b/utils/TableGen/RegisterInfoEmitter.cpp
@@ -163,23 +163,22 @@
for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
Record *R = Regs[i].TheDef;
- ListInit *LI = Regs[i].TheDef->getValueAsListInit("Aliases");
+ std::vector<Record*> LI = Regs[i].TheDef->getValueAsListOfDefs("Aliases");
// Add information that R aliases all of the elements in the list... and
// that everything in the list aliases R.
- for (unsigned j = 0, e = LI->getSize(); j != e; ++j) {
- DefInit *Reg = dynamic_cast<DefInit*>(LI->getElement(j));
- if (!Reg) throw "ERROR: Alias list element is not a def!";
- if (RegisterAliases[R].count(Reg->getDef()))
+ for (unsigned j = 0, e = LI.size(); j != e; ++j) {
+ Record *Reg = LI[j];
+ if (RegisterAliases[R].count(Reg))
std::cerr << "Warning: register alias between " << getQualifiedName(R)
- << " and " << getQualifiedName(Reg->getDef())
+ << " and " << getQualifiedName(Reg)
<< " specified multiple times!\n";
- RegisterAliases[R].insert(Reg->getDef());
+ RegisterAliases[R].insert(Reg);
- if (RegisterAliases[Reg->getDef()].count(R))
+ if (RegisterAliases[Reg].count(R))
std::cerr << "Warning: register alias between " << getQualifiedName(R)
- << " and " << getQualifiedName(Reg->getDef())
+ << " and " << getQualifiedName(Reg)
<< " specified multiple times!\n";
- RegisterAliases[Reg->getDef()].insert(R);
+ RegisterAliases[Reg].insert(R);
}
}