summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/CodeGenTarget.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-19 01:07:44 +0000
committerChris Lattner <sabre@nondot.org>2010-03-19 01:07:44 +0000
commit1802b17b6570a71af889b258f1d7bce3648710b9 (patch)
treeaa3f67dc6a14e39c544bfea1b5a9859caf58f86f /llvm/utils/TableGen/CodeGenTarget.cpp
parent4763dbeaf6df50ade250e37ded535a791551489d (diff)
downloadbcm5719-llvm-1802b17b6570a71af889b258f1d7bce3648710b9.tar.gz
bcm5719-llvm-1802b17b6570a71af889b258f1d7bce3648710b9.zip
Finally change the instruction looking map to be a densemap from
record* -> instrinfo instead of std::string -> instrinfo. This speeds up tblgen on cellcpu from 7.28 -> 5.98s with a debug build (20%). llvm-svn: 98916
Diffstat (limited to 'llvm/utils/TableGen/CodeGenTarget.cpp')
-rw-r--r--llvm/utils/TableGen/CodeGenTarget.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp
index d697217ff68..a0c2c212871 100644
--- a/llvm/utils/TableGen/CodeGenTarget.cpp
+++ b/llvm/utils/TableGen/CodeGenTarget.cpp
@@ -135,11 +135,6 @@ Record *CodeGenTarget::getInstructionSet() const {
}
-CodeGenInstruction &CodeGenTarget::getInstruction(const Record *InstRec) const {
- return getInstruction(InstRec->getName());
-}
-
-
/// getAsmParser - Return the AssemblyParser definition for this target.
///
Record *CodeGenTarget::getAsmParser() const {
@@ -279,25 +274,37 @@ void CodeGenTarget::ReadInstructions() const {
for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
std::string AsmStr = Insts[i]->getValueAsString(InstFormatName);
- Instructions.insert(std::make_pair(Insts[i]->getName(),
- CodeGenInstruction(Insts[i], AsmStr)));
+ Instructions[Insts[i]] = new CodeGenInstruction(Insts[i], AsmStr);
}
}
static const CodeGenInstruction *
GetInstByName(const char *Name,
- const std::map<std::string, CodeGenInstruction> &Insts) {
- std::map<std::string, CodeGenInstruction>::const_iterator
- I = Insts.find(Name);
- if (I == Insts.end())
+ const DenseMap<const Record*, CodeGenInstruction*> &Insts) {
+ const Record *Rec = Records.getDef(Name);
+
+ DenseMap<const Record*, CodeGenInstruction*>::const_iterator
+ I = Insts.find(Rec);
+ if (Rec == 0 || I == Insts.end())
throw std::string("Could not find '") + Name + "' instruction!";
- return &I->second;
+ return I->second;
+}
+
+namespace {
+/// SortInstByName - Sorting predicate to sort instructions by name.
+///
+struct SortInstByName {
+ bool operator()(const CodeGenInstruction *Rec1,
+ const CodeGenInstruction *Rec2) const {
+ return Rec1->TheDef->getName() < Rec2->TheDef->getName();
+ }
+};
}
/// getInstructionsByEnumValue - Return all of the instructions defined by the
/// target, ordered by their enum value.
void CodeGenTarget::ComputeInstrsByEnum() const {
- const std::map<std::string, CodeGenInstruction> &Insts = getInstructions();
+ const DenseMap<const Record*, CodeGenInstruction*> &Insts = getInstructions();
const CodeGenInstruction *PHI = GetInstByName("PHI", Insts);
const CodeGenInstruction *INLINEASM = GetInstByName("INLINEASM", Insts);
const CodeGenInstruction *DBG_LABEL = GetInstByName("DBG_LABEL", Insts);
@@ -329,10 +336,11 @@ void CodeGenTarget::ComputeInstrsByEnum() const {
InstrsByEnum.push_back(COPY_TO_REGCLASS);
InstrsByEnum.push_back(DBG_VALUE);
- for (std::map<std::string, CodeGenInstruction>::const_iterator
- I = Insts.begin(), E = Insts.end(); I != E; ++I) {
- const CodeGenInstruction *CGI = &I->second;
+ unsigned EndOfPredefines = InstrsByEnum.size();
+ for (DenseMap<const Record*, CodeGenInstruction*>::const_iterator
+ I = Insts.begin(), E = Insts.end(); I != E; ++I) {
+ const CodeGenInstruction *CGI = I->second;
if (CGI != PHI &&
CGI != INLINEASM &&
CGI != DBG_LABEL &&
@@ -347,6 +355,11 @@ void CodeGenTarget::ComputeInstrsByEnum() const {
CGI != DBG_VALUE)
InstrsByEnum.push_back(CGI);
}
+
+ // All of the instructions are now in random order based on the map iteration.
+ // Sort them by name.
+ std::sort(InstrsByEnum.begin()+EndOfPredefines, InstrsByEnum.end(),
+ SortInstByName());
}
OpenPOWER on IntegriCloud