/// Implementors of this method should return the type of the named field if
/// they are of record type.
///
- virtual RecTy *getFieldType(const std::string &FieldName) const {
+ virtual RecTy *getFieldType(StringRef FieldName) const {
return nullptr;
}
/// this method should return non-null, otherwise it returns null.
///
virtual Init *getFieldInit(Record &R, const RecordVal *RV,
- const std::string &FieldName) const {
+ StringRef FieldName) const {
return nullptr;
}
/// Implementors of this method should return the type of the named field if
/// they are of record type.
///
- RecTy *getFieldType(const std::string &FieldName) const override;
+ RecTy *getFieldType(StringRef FieldName) const override;
/// This method is used to implement
/// VarListElementInit::resolveReferences. If the list element is resolvable
return I->getKind() == IK_VarInit;
}
- static VarInit *get(const std::string &VN, RecTy *T);
+ static VarInit *get(StringRef VN, RecTy *T);
static VarInit *get(Init *VN, RecTy *T);
const std::string &getName() const;
Init *resolveListElementReference(Record &R, const RecordVal *RV,
unsigned Elt) const override;
- RecTy *getFieldType(const std::string &FieldName) const override;
+ RecTy *getFieldType(StringRef FieldName) const override;
Init *getFieldInit(Record &R, const RecordVal *RV,
- const std::string &FieldName) const override;
+ StringRef 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(const std::string &FieldName) const override;
+ RecTy *getFieldType(StringRef FieldName) const override;
Init *getFieldInit(Record &R, const RecordVal *RV,
- const std::string &FieldName) const override;
+ StringRef FieldName) const override;
std::string getAsString() const override;
Init *Rec; // Record we are referring to
std::string FieldName; // Field we are accessing
- FieldInit(Init *R, const std::string &FN)
+ FieldInit(Init *R, StringRef 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, const std::string &FN);
+ static FieldInit *get(Init *R, StringRef FN);
Init *getBit(unsigned Bit) const override;
std::vector<Init*> Args;
std::vector<std::string> ArgNames;
- DagInit(Init *V, const std::string &VN,
- ArrayRef<Init *> ArgRange,
+ DagInit(Init *V, StringRef VN, ArrayRef<Init *> ArgRange,
ArrayRef<std::string> NameRange)
: TypedInit(IK_DagInit, DagRecTy::get()), Val(V), ValName(VN),
Args(ArgRange.begin(), ArgRange.end()),
return I->getKind() == IK_DagInit;
}
- static DagInit *get(Init *V, const std::string &VN,
- ArrayRef<Init *> ArgRange,
+ static DagInit *get(Init *V, StringRef VN, ArrayRef<Init *> ArgRange,
ArrayRef<std::string> NameRange);
- static DagInit *get(Init *V, const std::string &VN,
+ static DagInit *get(Init *V, StringRef VN,
const std::vector<std::pair<Init*, std::string>> &args);
void Profile(FoldingSetNodeID &ID) const;
public:
RecordVal(Init *N, RecTy *T, bool P);
- RecordVal(const std::string &N, RecTy *T, bool P);
+ RecordVal(StringRef N, RecTy *T, bool P);
const std::string &getName() const;
const Init *getNameInit() const { return NameAndPrefix.getPointer(); }
init();
}
- explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
- RecordKeeper &records, bool Anonymous = false)
+ explicit Record(StringRef N, ArrayRef<SMLoc> locs, RecordKeeper &records,
+ bool Anonymous = false)
: Record(StringInit::get(N), locs, records, Anonymous) {}
// When copy-constructing a Record, we must still guarantee a globally unique
return getNameInit()->getAsUnquotedString();
}
- void setName(Init *Name); // Also updates RecordKeeper.
- void setName(const std::string &Name); // Also updates RecordKeeper.
+ void setName(Init *Name); // Also updates RecordKeeper.
+ void setName(StringRef Name); // Also updates RecordKeeper.
ArrayRef<SMLoc> getLoc() const { return Locs; }
void dump() const;
- MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) :
+ MultiClass(StringRef Name, SMLoc Loc, RecordKeeper &Records) :
Rec(Name, Loc, Records) {}
};
const RecordMap &getClasses() const { return Classes; }
const RecordMap &getDefs() const { return Defs; }
- Record *getClass(const std::string &Name) const {
+ Record *getClass(StringRef Name) const {
auto I = Classes.find(Name);
return I == Classes.end() ? nullptr : I->second.get();
}
- Record *getDef(const std::string &Name) const {
+ Record *getDef(StringRef Name) const {
auto I = Defs.find(Name);
return I == Defs.end() ? nullptr : I->second.get();
}
/// This method returns all concrete definitions
/// that derive from the specified class name. A class with the specified
/// name must exist.
- std::vector<Record *>
- getAllDerivedDefinitions(const std::string &ClassName) const;
+ std::vector<Record *> getAllDerivedDefinitions(StringRef ClassName) const;
void dump() const;
};
/// Return an Init with a qualifier prefix referring
/// to CurRec's name.
Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- Init *Name, const std::string &Scoper);
+ Init *Name, StringRef Scoper);
/// Return an Init with a qualifier prefix referring
/// to CurRec's name.
Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- const std::string &Name, const std::string &Scoper);
+ StringRef Name, StringRef Scoper);
} // end namespace llvm
class TableGenStringKey {
public:
- TableGenStringKey(const std::string &str) : data(str) {}
+ TableGenStringKey(StringRef str) : data(str) {}
TableGenStringKey(const char *str) : data(str) {}
const std::string &str() const { return data; }
RHS->getAsString() + ")";
}
-RecTy *TypedInit::getFieldType(const std::string &FieldName) const {
+RecTy *TypedInit::getFieldType(StringRef FieldName) const {
if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType()))
if (RecordVal *Field = RecordType->getRecord()->getValue(FieldName))
return Field->getType();
}
-VarInit *VarInit::get(const std::string &VN, RecTy *T) {
+VarInit *VarInit::get(StringRef VN, RecTy *T) {
Init *Value = StringInit::get(VN);
return VarInit::get(Value, T);
}
return nullptr;
}
-RecTy *VarInit::getFieldType(const std::string &FieldName) const {
+RecTy *VarInit::getFieldType(StringRef 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,
- const std::string &FieldName) const {
+ StringRef 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(const std::string &FieldName) const {
+RecTy *DefInit::getFieldType(StringRef FieldName) const {
if (const RecordVal *RV = Def->getValue(FieldName))
return RV->getType();
return nullptr;
}
Init *DefInit::getFieldInit(Record &R, const RecordVal *RV,
- const std::string &FieldName) const {
+ StringRef FieldName) const {
return Def->getValue(FieldName)->getValue();
}
return Def->getName();
}
-FieldInit *FieldInit::get(Init *R, const std::string &FN) {
+FieldInit *FieldInit::get(Init *R, StringRef FN) {
typedef std::pair<Init *, TableGenStringKey> Key;
static DenseMap<Key, std::unique_ptr<FieldInit>> ThePool;
return const_cast<FieldInit *>(this);
}
-static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, const std::string &VN,
+static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, StringRef VN,
ArrayRef<Init *> ArgRange,
ArrayRef<std::string> NameRange) {
ID.AddPointer(V);
}
DagInit *
-DagInit::get(Init *V, const std::string &VN,
- ArrayRef<Init *> ArgRange,
+DagInit::get(Init *V, StringRef VN, ArrayRef<Init *> ArgRange,
ArrayRef<std::string> NameRange) {
static FoldingSet<DagInit> ThePool;
static std::vector<std::unique_ptr<DagInit>> TheActualPool;
}
DagInit *
-DagInit::get(Init *V, const std::string &VN,
+DagInit::get(Init *V, StringRef VN,
const std::vector<std::pair<Init*, std::string> > &args) {
std::vector<Init *> Args;
std::vector<std::string> Names;
assert(Value && "Cannot create unset value for current type!");
}
-RecordVal::RecordVal(const std::string &N, RecTy *T, bool P)
+RecordVal::RecordVal(StringRef N, RecTy *T, bool P)
: NameAndPrefix(StringInit::get(N), P), Ty(T) {
Value = UnsetInit::get()->convertInitializerTo(Ty);
assert(Value && "Cannot create unset value for current type!");
// this. See TGParser::ParseDef and TGParser::ParseDefm.
}
-void Record::setName(const std::string &Name) {
+void Record::setName(StringRef Name) {
setName(StringInit::get(Name));
}
}
std::vector<Record *>
-RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName) const {
+RecordKeeper::getAllDerivedDefinitions(StringRef ClassName) const {
Record *Class = getClass(ClassName);
if (!Class)
PrintFatalError("ERROR: Couldn't find the `" + ClassName + "' class!\n");
}
Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- Init *Name, const std::string &Scoper) {
+ Init *Name, StringRef Scoper) {
RecTy *Type = cast<TypedInit>(Name)->getType();
BinOpInit *NewName =
}
Init *llvm::QualifyName(Record &CurRec, MultiClass *CurMultiClass,
- const std::string &Name,
- const std::string &Scoper) {
+ StringRef Name, StringRef Scoper) {
return QualifyName(CurRec, CurMultiClass, StringInit::get(Name), Scoper);
}
/// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
/// has already been read.
-Init *TGParser::ParseIDValue(Record *CurRec,
- const std::string &Name, SMLoc NameLoc,
+Init *TGParser::ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
IDParseMode Mode) {
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name))
std::vector<unsigned> Bits;
Init *Value;
SMLoc Loc;
- LetRecord(const std::string &N, const std::vector<unsigned> &B, Init *V,
- SMLoc L)
+ LetRecord(StringRef N, const std::vector<unsigned> &B, Init *V, SMLoc L)
: Name(N), Bits(B), Value(V), Loc(L) {
}
};
bool SetValue(Record *TheRec, SMLoc Loc, Init *ValName,
ArrayRef<unsigned> BitList, Init *V,
bool AllowSelfAssignment = false);
- bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName,
+ bool SetValue(Record *TheRec, SMLoc Loc, StringRef ValName,
ArrayRef<unsigned> BitList, Init *V,
bool AllowSelfAssignment = false) {
return SetValue(TheRec, Loc, StringInit::get(ValName), BitList, V,
SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm);
SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC);
- Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc,
+ Init *ParseIDValue(Record *CurRec, StringRef Name, SMLoc NameLoc,
IDParseMode Mode = ParseValueMode);
Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = nullptr,
IDParseMode Mode = ParseValueMode);