summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-13 03:16:35 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-01-13 03:16:35 +0000
commitebaf92c67dac4974f98a08f8096d3eb2f4edd09d (patch)
tree0b6bd99eaa776f048d2d5f10cde189cf7f177e63 /include
parentc4b527ac06c8e2e7c43020a56f000a53ab1dc9de (diff)
downloadllvm-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 'include')
-rw-r--r--include/llvm/TableGen/Record.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h
index f9ade8f144..5e9e28d44b 100644
--- a/include/llvm/TableGen/Record.h
+++ b/include/llvm/TableGen/Record.h
@@ -757,7 +757,7 @@ class StringInit : public TypedInit {
virtual void anchor();
public:
- static StringInit *get(const std::string &V);
+ static StringInit *get(StringRef);
const std::string &getValue() const { return Value; }
@@ -800,7 +800,7 @@ class CodeInit : public Init {
virtual void anchor();
public:
- static CodeInit *get(const std::string &V);
+ static CodeInit *get(StringRef);
const std::string &getValue() const { return Value; }
@@ -1454,19 +1454,22 @@ public:
return isTemplateArg(StringInit::get(Name.str()));
}
- const RecordVal *getValue(StringRef Name) const {
+ const RecordVal *getValue(const Init *Name) const {
for (unsigned i = 0, e = Values.size(); i != e; ++i)
- if (Values[i].getName() == Name) return &Values[i];
+ if (Values[i].getNameInit() == Name) return &Values[i];
return 0;
}
- RecordVal *getValue(StringRef Name) {
+ const RecordVal *getValue(StringRef Name) const {
+ return getValue(StringInit::get(Name));
+ }
+ RecordVal *getValue(const Init *Name) {
for (unsigned i = 0, e = Values.size(); i != e; ++i)
- if (Values[i].getName() == Name) return &Values[i];
+ if (Values[i].getNameInit() == Name) return &Values[i];
return 0;
}
-
- const RecordVal *getValue(Init *Name) const;
- RecordVal *getValue(Init *Name);
+ RecordVal *getValue(StringRef Name) {
+ return getValue(StringInit::get(Name));
+ }
void addTemplateArg(Init *Name) {
assert(!isTemplateArg(Name) && "Template arg already defined!");
@@ -1477,7 +1480,7 @@ public:
}
void addValue(const RecordVal &RV) {
- assert(getValue(RV.getName()) == 0 && "Value already added!");
+ assert(getValue(RV.getNameInit()) == 0 && "Value already added!");
Values.push_back(RV);
if (Values.size() > 1)
// Keep NAME at the end of the list. It makes record dumps a