mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-03 01:18:47 +00:00
Use uniqued StringInit pointers for lookups.
This avoids a gazillion StringMap and dynamic_cast calls, making TableGen run 3x faster. llvm-svn: 148091
This commit is contained in:
parent
e31c929c2d
commit
3776477761
@ -757,7 +757,7 @@ class StringInit : public TypedInit {
|
|||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static StringInit *get(const std::string &V);
|
static StringInit *get(StringRef);
|
||||||
|
|
||||||
const std::string &getValue() const { return Value; }
|
const std::string &getValue() const { return Value; }
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ class CodeInit : public Init {
|
|||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CodeInit *get(const std::string &V);
|
static CodeInit *get(StringRef);
|
||||||
|
|
||||||
const std::string &getValue() const { return Value; }
|
const std::string &getValue() const { return Value; }
|
||||||
|
|
||||||
@ -1454,20 +1454,23 @@ public:
|
|||||||
return isTemplateArg(StringInit::get(Name.str()));
|
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)
|
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(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].getNameInit() == Name) return &Values[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
RecordVal *getValue(StringRef Name) {
|
RecordVal *getValue(StringRef Name) {
|
||||||
for (unsigned i = 0, e = Values.size(); i != e; ++i)
|
return getValue(StringInit::get(Name));
|
||||||
if (Values[i].getName() == Name) return &Values[i];
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const RecordVal *getValue(Init *Name) const;
|
|
||||||
RecordVal *getValue(Init *Name);
|
|
||||||
|
|
||||||
void addTemplateArg(Init *Name) {
|
void addTemplateArg(Init *Name) {
|
||||||
assert(!isTemplateArg(Name) && "Template arg already defined!");
|
assert(!isTemplateArg(Name) && "Template arg already defined!");
|
||||||
TemplateArgs.push_back(Name);
|
TemplateArgs.push_back(Name);
|
||||||
@ -1477,7 +1480,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addValue(const RecordVal &RV) {
|
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);
|
Values.push_back(RV);
|
||||||
if (Values.size() > 1)
|
if (Values.size() > 1)
|
||||||
// Keep NAME at the end of the list. It makes record dumps a
|
// Keep NAME at the end of the list. It makes record dumps a
|
||||||
|
@ -573,7 +573,7 @@ IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
|||||||
|
|
||||||
void StringInit::anchor() { }
|
void StringInit::anchor() { }
|
||||||
|
|
||||||
StringInit *StringInit::get(const std::string &V) {
|
StringInit *StringInit::get(StringRef V) {
|
||||||
typedef StringMap<StringInit *> Pool;
|
typedef StringMap<StringInit *> Pool;
|
||||||
static Pool ThePool;
|
static Pool ThePool;
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ StringInit *StringInit::get(const std::string &V) {
|
|||||||
|
|
||||||
void CodeInit::anchor() { }
|
void CodeInit::anchor() { }
|
||||||
|
|
||||||
CodeInit *CodeInit::get(const std::string &V) {
|
CodeInit *CodeInit::get(StringRef V) {
|
||||||
typedef StringMap<CodeInit *> Pool;
|
typedef StringMap<CodeInit *> Pool;
|
||||||
static Pool ThePool;
|
static Pool ThePool;
|
||||||
|
|
||||||
@ -1336,10 +1336,10 @@ const std::string &VarInit::getName() const {
|
|||||||
|
|
||||||
Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,
|
Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,
|
||||||
unsigned Bit) const {
|
unsigned Bit) const {
|
||||||
if (R.isTemplateArg(getName())) return 0;
|
if (R.isTemplateArg(getNameInit())) return 0;
|
||||||
if (IRV && IRV->getName() != getName()) 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(RV && "Reference to a non-existent variable?");
|
||||||
assert(dynamic_cast<BitsInit*>(RV->getValue()));
|
assert(dynamic_cast<BitsInit*>(RV->getValue()));
|
||||||
BitsInit *BI = (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,
|
Init *VarInit::resolveListElementReference(Record &R,
|
||||||
const RecordVal *IRV,
|
const RecordVal *IRV,
|
||||||
unsigned Elt) const {
|
unsigned Elt) const {
|
||||||
if (R.isTemplateArg(getName())) return 0;
|
if (R.isTemplateArg(getNameInit())) return 0;
|
||||||
if (IRV && IRV->getName() != getName()) 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(RV && "Reference to a non-existent variable?");
|
||||||
ListInit *LI = dynamic_cast<ListInit*>(RV->getValue());
|
ListInit *LI = dynamic_cast<ListInit*>(RV->getValue());
|
||||||
if (!LI) {
|
if (!LI) {
|
||||||
@ -1759,18 +1759,6 @@ void Record::setName(const std::string &Name) {
|
|||||||
setName(StringInit::get(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
|
/// 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
|
/// reference to RV with the RHS of RV. If RV is null, we resolve all possible
|
||||||
/// references.
|
/// references.
|
||||||
|
@ -64,7 +64,7 @@ bool TGParser::AddValue(Record *CurRec, SMLoc Loc, const RecordVal &RV) {
|
|||||||
if (CurRec == 0)
|
if (CurRec == 0)
|
||||||
CurRec = &CurMultiClass->Rec;
|
CurRec = &CurMultiClass->Rec;
|
||||||
|
|
||||||
if (RecordVal *ERV = CurRec->getValue(RV.getName())) {
|
if (RecordVal *ERV = CurRec->getValue(RV.getNameInit())) {
|
||||||
// The value already exists in the class, treat this as a set.
|
// The value already exists in the class, treat this as a set.
|
||||||
if (ERV->setValue(RV.getValue()))
|
if (ERV->setValue(RV.getValue()))
|
||||||
return Error(Loc, "New definition of '" + RV.getName() + "' of type '" +
|
return Error(Loc, "New definition of '" + RV.getName() + "' of type '" +
|
||||||
|
Loading…
Reference in New Issue
Block a user