diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-01-13 03:16:35 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-01-13 03:16:35 +0000 |
commit | ebaf92c67dac4974f98a08f8096d3eb2f4edd09d (patch) | |
tree | 0b6bd99eaa776f048d2d5f10cde189cf7f177e63 /lib/TableGen/Record.cpp | |
parent | c4b527ac06c8e2e7c43020a56f000a53ab1dc9de (diff) | |
download | llvm-ebaf92c67dac4974f98a08f8096d3eb2f4edd09d.tar.gz llvm-ebaf92c67dac4974f98a08f8096d3eb2f4edd09d.tar.bz2 llvm-ebaf92c67dac4974f98a08f8096d3eb2f4edd09d.tar.xz |
Use uniqued StringInit pointers for lookups.
This avoids a gazillion StringMap and dynamic_cast calls, making
TableGen run 3x faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148091 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen/Record.cpp')
-rw-r--r-- | lib/TableGen/Record.cpp | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp index 1d6131c692..d328d893fd 100644 --- a/lib/TableGen/Record.cpp +++ b/lib/TableGen/Record.cpp @@ -573,7 +573,7 @@ IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const { void StringInit::anchor() { } -StringInit *StringInit::get(const std::string &V) { +StringInit *StringInit::get(StringRef V) { typedef StringMap<StringInit *> Pool; static Pool ThePool; @@ -584,7 +584,7 @@ StringInit *StringInit::get(const std::string &V) { void CodeInit::anchor() { } -CodeInit *CodeInit::get(const std::string &V) { +CodeInit *CodeInit::get(StringRef V) { typedef StringMap<CodeInit *> Pool; static Pool ThePool; @@ -1336,10 +1336,10 @@ const std::string &VarInit::getName() const { Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, unsigned Bit) const { - if (R.isTemplateArg(getName())) return 0; - if (IRV && IRV->getName() != getName()) return 0; + if (R.isTemplateArg(getNameInit())) return 0; + if (IRV && IRV->getNameInit() != getNameInit()) return 0; - RecordVal *RV = R.getValue(getName()); + RecordVal *RV = R.getValue(getNameInit()); assert(RV && "Reference to a non-existent variable?"); assert(dynamic_cast<BitsInit*>(RV->getValue())); BitsInit *BI = (BitsInit*)RV->getValue(); @@ -1358,10 +1358,10 @@ Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, Init *VarInit::resolveListElementReference(Record &R, const RecordVal *IRV, unsigned Elt) const { - if (R.isTemplateArg(getName())) return 0; - if (IRV && IRV->getName() != getName()) return 0; + if (R.isTemplateArg(getNameInit())) return 0; + if (IRV && IRV->getNameInit() != getNameInit()) return 0; - RecordVal *RV = R.getValue(getName()); + RecordVal *RV = R.getValue(getNameInit()); assert(RV && "Reference to a non-existent variable?"); ListInit *LI = dynamic_cast<ListInit*>(RV->getValue()); if (!LI) { @@ -1759,18 +1759,6 @@ void Record::setName(const std::string &Name) { setName(StringInit::get(Name)); } -const RecordVal *Record::getValue(Init *Name) const { - for (unsigned i = 0, e = Values.size(); i != e; ++i) - if (Values[i].getNameInit() == Name) return &Values[i]; - return 0; -} - -RecordVal *Record::getValue(Init *Name) { - for (unsigned i = 0, e = Values.size(); i != e; ++i) - if (Values[i].getNameInit() == Name) return &Values[i]; - return 0; -} - /// resolveReferencesTo - If anything in this record refers to RV, replace the /// reference to RV with the RHS of RV. If RV is null, we resolve all possible /// references. |