namespace llvm {
class ListRecTy;
-struct MultiClass;
class Record;
-class RecordVal;
class RecordKeeper;
+class RecordVal;
+class StringInit;
+struct MultiClass;
//===----------------------------------------------------------------------===//
// Type Classes
/// Implementors of this method should return the type of the named field if
/// they are of record type.
///
- virtual RecTy *getFieldType(StringRef FieldName) const {
+ virtual RecTy *getFieldType(StringInit *FieldName) const {
return nullptr;
}
/// this method should return non-null, otherwise it returns null.
///
virtual Init *getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const {
+ StringInit *FieldName) const {
return nullptr;
}
/// Implementors of this method should return the type of the named field if
/// they are of record type.
///
- RecTy *getFieldType(StringRef FieldName) const override;
+ RecTy *getFieldType(StringInit *FieldName) const override;
/// This method is used to implement
/// VarListElementInit::resolveReferences. If the list element is resolvable
Init *resolveListElementReference(Record &R, const RecordVal *RV,
unsigned Elt) const override;
- RecTy *getFieldType(StringRef FieldName) const override;
+ RecTy *getFieldType(StringInit *FieldName) const override;
Init *getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const override;
+ StringInit *FieldName) const override;
/// This method is used by classes that refer to other
/// variables which may not be defined at the time they expression is formed.
//virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
- RecTy *getFieldType(StringRef FieldName) const override;
+ RecTy *getFieldType(StringInit *FieldName) const override;
Init *getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const override;
+ StringInit *FieldName) const override;
std::string getAsString() const override;
///
class FieldInit : public TypedInit {
Init *Rec; // Record we are referring to
- std::string FieldName; // Field we are accessing
+ StringInit *FieldName; // Field we are accessing
- FieldInit(Init *R, StringRef FN)
+ FieldInit(Init *R, StringInit *FN)
: TypedInit(IK_FieldInit, R->getFieldType(FN)), Rec(R), FieldName(FN) {
assert(getType() && "FieldInit with non-record type!");
}
return I->getKind() == IK_FieldInit;
}
- static FieldInit *get(Init *R, StringRef FN);
+ static FieldInit *get(Init *R, StringInit *FN);
Init *getBit(unsigned Bit) const override;
Init *resolveReferences(Record &R, const RecordVal *RV) const override;
std::string getAsString() const override {
- return Rec->getAsString() + "." + FieldName;
+ return Rec->getAsString() + "." + FieldName->getValue().str();
}
};
Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
Init *Name, StringRef Scoper);
-/// Return an Init with a qualifier prefix referring
-/// to CurRec's name.
-Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- StringRef Name, StringRef Scoper);
-
} // end namespace llvm
#endif // LLVM_TABLEGEN_RECORD_H
if (IntInit *LHSi = dyn_cast<IntInit>(LHS))
return StringInit::get(LHSi->getAsString());
} else {
- if (StringInit *LHSs = dyn_cast<StringInit>(LHS)) {
- StringRef Name = LHSs->getValue();
-
+ if (StringInit *Name = dyn_cast<StringInit>(LHS)) {
// From TGParser::ParseIDValue
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name)) {
}
}
assert(CurRec && "NULL pointer");
- if (Record *D = (CurRec->getRecords()).getDef(Name))
+ if (Record *D = (CurRec->getRecords()).getDef(Name->getValue()))
return DefInit::get(D);
PrintFatalError(CurRec->getLoc(),
- "Undefined reference:'" + Name + "'\n");
+ "Undefined reference:'" + Name->getValue() + "'\n");
}
if (isa<IntRecTy>(getType())) {
RHS->getAsString() + ")";
}
-RecTy *TypedInit::getFieldType(StringRef FieldName) const {
+RecTy *TypedInit::getFieldType(StringInit *FieldName) const {
if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType()))
if (RecordVal *Field = RecordType->getRecord()->getValue(FieldName))
return Field->getType();
return nullptr;
}
-RecTy *VarInit::getFieldType(StringRef FieldName) const {
+RecTy *VarInit::getFieldType(StringInit *FieldName) const {
if (RecordRecTy *RTy = dyn_cast<RecordRecTy>(getType()))
if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName))
return RV->getType();
}
Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const {
+ StringInit *FieldName) const {
if (isa<RecordRecTy>(getType()))
if (const RecordVal *Val = R.getValue(VarName)) {
if (RV != Val && (RV || isa<UnsetInit>(Val->getValue())))
return nullptr;
}
-RecTy *DefInit::getFieldType(StringRef FieldName) const {
+RecTy *DefInit::getFieldType(StringInit *FieldName) const {
if (const RecordVal *RV = Def->getValue(FieldName))
return RV->getType();
return nullptr;
}
Init *DefInit::getFieldInit(Record &R, const RecordVal *RV,
- StringRef FieldName) const {
+ StringInit *FieldName) const {
return Def->getValue(FieldName)->getValue();
}
return Def->getName();
}
-FieldInit *FieldInit::get(Init *R, StringRef FN) {
- typedef std::pair<Init *, TableGenStringKey> Key;
+FieldInit *FieldInit::get(Init *R, StringInit *FN) {
+ typedef std::pair<Init *, StringInit *> Key;
static DenseMap<Key, FieldInit*> ThePool;
Key TheKey(std::make_pair(R, FN));
NewName = BinOp->Fold(&CurRec, CurMultiClass);
return NewName;
}
-
-Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- StringRef Name, StringRef Scoper) {
- return QualifyName(CurRec, CurMultiClass, StringInit::get(Name), Scoper);
-}
/// has already been read.
Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
IDParseMode Mode) {
+ StringInit *NameInit;
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name))
return VarInit::get(Name, RV->getType());
- Init *TemplateArgName = QualifyName(*CurRec, CurMultiClass, Name, ":");
+ NameInit = StringInit::get(Name);
+ Init *TemplateArgName = QualifyName(*CurRec, CurMultiClass, NameInit, ":");
if (CurMultiClass)
- TemplateArgName = QualifyName(CurMultiClass->Rec, CurMultiClass, Name,
+ TemplateArgName = QualifyName(CurMultiClass->Rec, CurMultiClass, NameInit,
"::");
if (CurRec->isTemplateArg(TemplateArgName)) {
assert(RV && "Template arg doesn't exist??");
return VarInit::get(TemplateArgName, RV->getType());
}
- }
+ } else
+ NameInit = StringInit::get(Name);
if (CurMultiClass) {
- Init *MCName = QualifyName(CurMultiClass->Rec, CurMultiClass, Name,
+ Init *MCName = QualifyName(CurMultiClass->Rec, CurMultiClass, NameInit,
"::");
if (CurMultiClass->Rec.isTemplateArg(MCName)) {
// If this is in a foreach loop, make sure it's not a loop iterator
for (const auto &L : Loops) {
VarInit *IterVar = dyn_cast<VarInit>(L.IterVar);
- if (IterVar && IterVar->getName() == Name)
+ if (IterVar && IterVar->getNameInit() == NameInit)
return IterVar;
}
if (Mode == ParseNameMode)
- return StringInit::get(Name);
+ return NameInit;
if (Record *D = Records.getDef(Name))
return DefInit::get(D);
return nullptr;
}
- return StringInit::get(Name);
+ return NameInit;
}
/// ParseOperation - Parse an operator. This returns null on error.
Lex.Lex();
break;
}
- case tgtok::period:
+ case tgtok::period: {
if (Lex.Lex() != tgtok::Id) { // eat the .
TokError("expected field identifier after '.'");
return nullptr;
}
- if (!Result->getFieldType(Lex.getCurStrVal())) {
+ StringInit *FieldName = StringInit::get(Lex.getCurStrVal());
+ if (!Result->getFieldType(FieldName)) {
TokError("Cannot access field '" + Lex.getCurStrVal() + "' of value '" +
Result->getAsString() + "'");
return nullptr;
}
- Result = FieldInit::get(Result, Lex.getCurStrVal());
+ Result = FieldInit::get(Result, FieldName);
Lex.Lex(); // eat field name
break;
+ }
case tgtok::paste:
SMLoc PasteLoc = Lex.getLoc();