mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
TableGen/Record: Replace std::vector with SmallVector/ArrayRef
llvm-svn: 288648
This commit is contained in:
parent
8c8bbdcc14
commit
5d6cd19170
@ -342,8 +342,7 @@ public:
|
|||||||
/// out, returning them as a new init of bits type. If it is not legal to use
|
/// out, returning them as a new init of bits type. If it is not legal to use
|
||||||
/// the bit subscript operator on this initializer, return null.
|
/// the bit subscript operator on this initializer, return null.
|
||||||
///
|
///
|
||||||
virtual Init *
|
virtual Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
|
||||||
convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,8 +351,7 @@ public:
|
|||||||
/// elements, returning them as a new init of list type. If it is not legal
|
/// elements, returning them as a new init of list type. If it is not legal
|
||||||
/// to take a slice of this, return null.
|
/// to take a slice of this, return null.
|
||||||
///
|
///
|
||||||
virtual Init *
|
virtual Init *convertInitListSlice(ArrayRef<unsigned> Elements) const {
|
||||||
convertInitListSlice(const std::vector<unsigned> &Elements) const {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,10 +421,8 @@ public:
|
|||||||
|
|
||||||
Init *convertInitializerTo(RecTy *Ty) const override;
|
Init *convertInitializerTo(RecTy *Ty) const override;
|
||||||
|
|
||||||
Init *
|
Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
|
||||||
convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
|
Init *convertInitListSlice(ArrayRef<unsigned> Elements) const override;
|
||||||
Init *
|
|
||||||
convertInitListSlice(const std::vector<unsigned> &Elements) const override;
|
|
||||||
|
|
||||||
/// This method is used to implement the FieldInit class.
|
/// This method is used to implement the FieldInit class.
|
||||||
/// Implementors of this method should return the type of the named field if
|
/// Implementors of this method should return the type of the named field if
|
||||||
@ -523,8 +519,7 @@ public:
|
|||||||
unsigned getNumBits() const { return NumBits; }
|
unsigned getNumBits() const { return NumBits; }
|
||||||
|
|
||||||
Init *convertInitializerTo(RecTy *Ty) const override;
|
Init *convertInitializerTo(RecTy *Ty) const override;
|
||||||
Init *
|
Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
|
||||||
convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
|
|
||||||
|
|
||||||
bool isComplete() const override {
|
bool isComplete() const override {
|
||||||
for (unsigned i = 0; i != getNumBits(); ++i)
|
for (unsigned i = 0; i != getNumBits(); ++i)
|
||||||
@ -577,8 +572,7 @@ public:
|
|||||||
int64_t getValue() const { return Value; }
|
int64_t getValue() const { return Value; }
|
||||||
|
|
||||||
Init *convertInitializerTo(RecTy *Ty) const override;
|
Init *convertInitializerTo(RecTy *Ty) const override;
|
||||||
Init *
|
Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
|
||||||
convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
|
|
||||||
|
|
||||||
std::string getAsString() const override;
|
std::string getAsString() const override;
|
||||||
|
|
||||||
@ -708,8 +702,7 @@ public:
|
|||||||
|
|
||||||
Record *getElementAsRecord(unsigned i) const;
|
Record *getElementAsRecord(unsigned i) const;
|
||||||
|
|
||||||
Init *
|
Init *convertInitListSlice(ArrayRef<unsigned> Elements) const override;
|
||||||
convertInitListSlice(const std::vector<unsigned> &Elements) const override;
|
|
||||||
|
|
||||||
Init *convertInitializerTo(RecTy *Ty) const override;
|
Init *convertInitializerTo(RecTy *Ty) const override;
|
||||||
|
|
||||||
@ -760,7 +753,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clone - Clone this operator, replacing arguments with the new list
|
// Clone - Clone this operator, replacing arguments with the new list
|
||||||
virtual OpInit *clone(std::vector<Init *> &Operands) const = 0;
|
virtual OpInit *clone(ArrayRef<Init *> Operands) const = 0;
|
||||||
|
|
||||||
virtual unsigned getNumOperands() const = 0;
|
virtual unsigned getNumOperands() const = 0;
|
||||||
virtual Init *getOperand(unsigned i) const = 0;
|
virtual Init *getOperand(unsigned i) const = 0;
|
||||||
@ -800,7 +793,7 @@ public:
|
|||||||
void Profile(FoldingSetNodeID &ID) const;
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
|
|
||||||
// Clone - Clone this operator, replacing arguments with the new list
|
// Clone - Clone this operator, replacing arguments with the new list
|
||||||
OpInit *clone(std::vector<Init *> &Operands) const override {
|
OpInit *clone(ArrayRef<Init *> Operands) const override {
|
||||||
assert(Operands.size() == 1 &&
|
assert(Operands.size() == 1 &&
|
||||||
"Wrong number of operands for unary operation");
|
"Wrong number of operands for unary operation");
|
||||||
return UnOpInit::get(getOpcode(), *Operands.begin(), getType());
|
return UnOpInit::get(getOpcode(), *Operands.begin(), getType());
|
||||||
@ -852,7 +845,7 @@ public:
|
|||||||
void Profile(FoldingSetNodeID &ID) const;
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
|
|
||||||
// Clone - Clone this operator, replacing arguments with the new list
|
// Clone - Clone this operator, replacing arguments with the new list
|
||||||
OpInit *clone(std::vector<Init *> &Operands) const override {
|
OpInit *clone(ArrayRef<Init *> Operands) const override {
|
||||||
assert(Operands.size() == 2 &&
|
assert(Operands.size() == 2 &&
|
||||||
"Wrong number of operands for binary operation");
|
"Wrong number of operands for binary operation");
|
||||||
return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType());
|
return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType());
|
||||||
@ -908,7 +901,7 @@ public:
|
|||||||
void Profile(FoldingSetNodeID &ID) const;
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
|
|
||||||
// Clone - Clone this operator, replacing arguments with the new list
|
// Clone - Clone this operator, replacing arguments with the new list
|
||||||
OpInit *clone(std::vector<Init *> &Operands) const override {
|
OpInit *clone(ArrayRef<Init *> Operands) const override {
|
||||||
assert(Operands.size() == 3 &&
|
assert(Operands.size() == 3 &&
|
||||||
"Wrong number of operands for ternary operation");
|
"Wrong number of operands for ternary operation");
|
||||||
return TernOpInit::get(getOpcode(), Operands[0], Operands[1], Operands[2],
|
return TernOpInit::get(getOpcode(), Operands[0], Operands[1], Operands[2],
|
||||||
@ -1086,7 +1079,7 @@ public:
|
|||||||
|
|
||||||
Record *getDef() const { return Def; }
|
Record *getDef() const { return Def; }
|
||||||
|
|
||||||
//virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
|
//virtual Init *convertInitializerBitRange(ArrayRef<unsigned> Bits);
|
||||||
|
|
||||||
RecTy *getFieldType(StringInit *FieldName) const override;
|
RecTy *getFieldType(StringInit *FieldName) const override;
|
||||||
Init *getFieldInit(Record &R, const RecordVal *RV,
|
Init *getFieldInit(Record &R, const RecordVal *RV,
|
||||||
@ -1147,8 +1140,8 @@ public:
|
|||||||
class DagInit : public TypedInit, public FoldingSetNode {
|
class DagInit : public TypedInit, public FoldingSetNode {
|
||||||
Init *Val;
|
Init *Val;
|
||||||
StringInit *ValName;
|
StringInit *ValName;
|
||||||
std::vector<Init*> Args;
|
SmallVector<Init*, 4> Args;
|
||||||
std::vector<StringInit*> ArgNames;
|
SmallVector<StringInit*, 4> ArgNames;
|
||||||
|
|
||||||
DagInit(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
|
DagInit(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
|
||||||
ArrayRef<StringInit *> NameRange)
|
ArrayRef<StringInit *> NameRange)
|
||||||
@ -1165,9 +1158,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DagInit *get(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
|
static DagInit *get(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
|
||||||
ArrayRef<StringInit *> NameRange);
|
ArrayRef<StringInit*> NameRange);
|
||||||
static DagInit *get(Init *V, StringInit *VN,
|
static DagInit *get(Init *V, StringInit *VN,
|
||||||
const std::vector<std::pair<Init*, StringInit*>> &args);
|
ArrayRef<std::pair<Init*, StringInit*>> Args);
|
||||||
|
|
||||||
void Profile(FoldingSetNodeID &ID) const;
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
|
|
||||||
@ -1198,8 +1191,8 @@ public:
|
|||||||
|
|
||||||
std::string getAsString() const override;
|
std::string getAsString() const override;
|
||||||
|
|
||||||
typedef std::vector<Init*>::const_iterator const_arg_iterator;
|
typedef SmallVectorImpl<Init*>::const_iterator const_arg_iterator;
|
||||||
typedef std::vector<StringInit*>::const_iterator const_name_iterator;
|
typedef SmallVectorImpl<StringInit*>::const_iterator const_name_iterator;
|
||||||
|
|
||||||
inline const_arg_iterator arg_begin() const { return Args.begin(); }
|
inline const_arg_iterator arg_begin() const { return Args.begin(); }
|
||||||
inline const_arg_iterator arg_end () const { return Args.end(); }
|
inline const_arg_iterator arg_end () const { return Args.end(); }
|
||||||
|
@ -320,7 +320,7 @@ Init *BitsInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Init *
|
Init *
|
||||||
BitsInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
BitsInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
|
||||||
SmallVector<Init *, 16> NewBits(Bits.size());
|
SmallVector<Init *, 16> NewBits(Bits.size());
|
||||||
|
|
||||||
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
|
||||||
@ -445,7 +445,7 @@ Init *IntInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Init *
|
Init *
|
||||||
IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
IntInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
|
||||||
SmallVector<Init *, 16> NewBits(Bits.size());
|
SmallVector<Init *, 16> NewBits(Bits.size());
|
||||||
|
|
||||||
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
|
||||||
@ -537,7 +537,7 @@ Init *ListInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
return const_cast<ListInit*>(this);
|
return const_cast<ListInit*>(this);
|
||||||
|
|
||||||
if (auto *LRT = dyn_cast<ListRecTy>(Ty)) {
|
if (auto *LRT = dyn_cast<ListRecTy>(Ty)) {
|
||||||
std::vector<Init*> Elements;
|
SmallVector<Init*, 8> Elements;
|
||||||
Elements.reserve(getValues().size());
|
Elements.reserve(getValues().size());
|
||||||
|
|
||||||
// Verify that all of the elements of the list are subclasses of the
|
// Verify that all of the elements of the list are subclasses of the
|
||||||
@ -560,9 +560,8 @@ Init *ListInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Init *
|
Init *ListInit::convertInitListSlice(ArrayRef<unsigned> Elements) const {
|
||||||
ListInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
|
SmallVector<Init*, 8> Vals;
|
||||||
std::vector<Init*> Vals;
|
|
||||||
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
|
||||||
if (Elements[i] >= size())
|
if (Elements[i] >= size())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -580,7 +579,7 @@ Record *ListInit::getElementAsRecord(unsigned i) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) const {
|
Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) const {
|
||||||
std::vector<Init*> Resolved;
|
SmallVector<Init*, 8> Resolved;
|
||||||
Resolved.reserve(size());
|
Resolved.reserve(size());
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
@ -837,8 +836,8 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
|
|||||||
DefInit *ROp = dyn_cast<DefInit>(RHSs->getOperator());
|
DefInit *ROp = dyn_cast<DefInit>(RHSs->getOperator());
|
||||||
if (!LOp || !ROp || LOp->getDef() != ROp->getDef())
|
if (!LOp || !ROp || LOp->getDef() != ROp->getDef())
|
||||||
PrintFatalError("Concated Dag operators do not match!");
|
PrintFatalError("Concated Dag operators do not match!");
|
||||||
std::vector<Init*> Args;
|
SmallVector<Init*, 8> Args;
|
||||||
std::vector<StringInit*> ArgNames;
|
SmallVector<StringInit*, 8> ArgNames;
|
||||||
for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) {
|
for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) {
|
||||||
Args.push_back(LHSs->getArg(i));
|
Args.push_back(LHSs->getArg(i));
|
||||||
ArgNames.push_back(LHSs->getArgName(i));
|
ArgNames.push_back(LHSs->getArgName(i));
|
||||||
@ -855,7 +854,7 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
|
|||||||
ListInit *LHSs = dyn_cast<ListInit>(LHS);
|
ListInit *LHSs = dyn_cast<ListInit>(LHS);
|
||||||
ListInit *RHSs = dyn_cast<ListInit>(RHS);
|
ListInit *RHSs = dyn_cast<ListInit>(RHS);
|
||||||
if (LHSs && RHSs) {
|
if (LHSs && RHSs) {
|
||||||
std::vector<Init *> Args;
|
SmallVector<Init *, 8> Args;
|
||||||
Args.insert(Args.end(), LHSs->begin(), LHSs->end());
|
Args.insert(Args.end(), LHSs->begin(), LHSs->end());
|
||||||
Args.insert(Args.end(), RHSs->begin(), RHSs->end());
|
Args.insert(Args.end(), RHSs->begin(), RHSs->end());
|
||||||
return ListInit::get(
|
return ListInit::get(
|
||||||
@ -989,7 +988,7 @@ static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg,
|
|||||||
if (isa<DagRecTy>(TArg->getType()))
|
if (isa<DagRecTy>(TArg->getType()))
|
||||||
return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass);
|
return ForeachHelper(LHS, Arg, RHSo, Type, CurRec, CurMultiClass);
|
||||||
|
|
||||||
std::vector<Init *> NewOperands;
|
SmallVector<Init *, 8> NewOperands;
|
||||||
for (unsigned i = 0; i < RHSo->getNumOperands(); ++i) {
|
for (unsigned i = 0; i < RHSo->getNumOperands(); ++i) {
|
||||||
if (auto *RHSoo = dyn_cast<OpInit>(RHSo->getOperand(i))) {
|
if (auto *RHSoo = dyn_cast<OpInit>(RHSo->getOperand(i))) {
|
||||||
if (Init *Result = EvaluateOperation(RHSoo, LHS, Arg,
|
if (Init *Result = EvaluateOperation(RHSoo, LHS, Arg,
|
||||||
@ -1030,7 +1029,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
|
|||||||
Type, CurRec, CurMultiClass))
|
Type, CurRec, CurMultiClass))
|
||||||
Val = Result;
|
Val = Result;
|
||||||
|
|
||||||
std::vector<std::pair<Init *, StringInit*> > args;
|
SmallVector<std::pair<Init *, StringInit*>, 8> args;
|
||||||
for (unsigned int i = 0; i < MHSd->getNumArgs(); ++i) {
|
for (unsigned int i = 0; i < MHSd->getNumArgs(); ++i) {
|
||||||
Init *Arg = MHSd->getArg(i);
|
Init *Arg = MHSd->getArg(i);
|
||||||
StringInit *ArgName = MHSd->getArgName(i);
|
StringInit *ArgName = MHSd->getArgName(i);
|
||||||
@ -1049,8 +1048,8 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
|
|||||||
|
|
||||||
ListInit *MHSl = dyn_cast<ListInit>(MHS);
|
ListInit *MHSl = dyn_cast<ListInit>(MHS);
|
||||||
if (MHSl && isa<ListRecTy>(Type)) {
|
if (MHSl && isa<ListRecTy>(Type)) {
|
||||||
std::vector<Init *> NewOperands;
|
SmallVector<Init *, 8> NewOperands;
|
||||||
std::vector<Init *> NewList(MHSl->begin(), MHSl->end());
|
SmallVector<Init *, 8> NewList(MHSl->begin(), MHSl->end());
|
||||||
|
|
||||||
for (Init *&Item : NewList) {
|
for (Init *&Item : NewList) {
|
||||||
NewOperands.clear();
|
NewOperands.clear();
|
||||||
@ -1271,8 +1270,7 @@ TypedInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Init *
|
Init *TypedInit::convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
|
||||||
TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
|
||||||
BitsRecTy *T = dyn_cast<BitsRecTy>(getType());
|
BitsRecTy *T = dyn_cast<BitsRecTy>(getType());
|
||||||
if (!T) return nullptr; // Cannot subscript a non-bits variable.
|
if (!T) return nullptr; // Cannot subscript a non-bits variable.
|
||||||
unsigned NumBits = T->getNumBits();
|
unsigned NumBits = T->getNumBits();
|
||||||
@ -1287,15 +1285,14 @@ TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
|||||||
return BitsInit::get(NewBits);
|
return BitsInit::get(NewBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
Init *
|
Init *TypedInit::convertInitListSlice(ArrayRef<unsigned> Elements) const {
|
||||||
TypedInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
|
|
||||||
ListRecTy *T = dyn_cast<ListRecTy>(getType());
|
ListRecTy *T = dyn_cast<ListRecTy>(getType());
|
||||||
if (!T) return nullptr; // Cannot subscript a non-list variable.
|
if (!T) return nullptr; // Cannot subscript a non-list variable.
|
||||||
|
|
||||||
if (Elements.size() == 1)
|
if (Elements.size() == 1)
|
||||||
return VarListElementInit::get(const_cast<TypedInit *>(this), Elements[0]);
|
return VarListElementInit::get(const_cast<TypedInit *>(this), Elements[0]);
|
||||||
|
|
||||||
std::vector<Init*> ListInits;
|
SmallVector<Init*, 8> ListInits;
|
||||||
ListInits.reserve(Elements.size());
|
ListInits.reserve(Elements.size());
|
||||||
for (unsigned i = 0, e = Elements.size(); i != e; ++i)
|
for (unsigned i = 0, e = Elements.size(); i != e; ++i)
|
||||||
ListInits.push_back(VarListElementInit::get(const_cast<TypedInit *>(this),
|
ListInits.push_back(VarListElementInit::get(const_cast<TypedInit *>(this),
|
||||||
@ -1569,9 +1566,9 @@ DagInit::get(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
|
|||||||
|
|
||||||
DagInit *
|
DagInit *
|
||||||
DagInit::get(Init *V, StringInit *VN,
|
DagInit::get(Init *V, StringInit *VN,
|
||||||
const std::vector<std::pair<Init*, StringInit*> > &args) {
|
ArrayRef<std::pair<Init*, StringInit*>> args) {
|
||||||
std::vector<Init *> Args;
|
SmallVector<Init *, 8> Args;
|
||||||
std::vector<StringInit *> Names;
|
SmallVector<StringInit *, 8> Names;
|
||||||
|
|
||||||
for (const auto &Arg : args) {
|
for (const auto &Arg : args) {
|
||||||
Args.push_back(Arg.first);
|
Args.push_back(Arg.first);
|
||||||
@ -1593,13 +1590,17 @@ Init *DagInit::convertInitializerTo(RecTy *Ty) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) const {
|
Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) const {
|
||||||
std::vector<Init*> NewArgs;
|
SmallVector<Init*, 8> NewArgs;
|
||||||
for (unsigned i = 0, e = Args.size(); i != e; ++i)
|
NewArgs.reserve(Args.size());
|
||||||
NewArgs.push_back(Args[i]->resolveReferences(R, RV));
|
bool ArgsChanged = false;
|
||||||
|
for (const Init *Arg : Args) {
|
||||||
|
Init *NewArg = Arg->resolveReferences(R, RV);
|
||||||
|
NewArgs.push_back(NewArg);
|
||||||
|
ArgsChanged |= NewArg != Arg;
|
||||||
|
}
|
||||||
|
|
||||||
Init *Op = Val->resolveReferences(R, RV);
|
Init *Op = Val->resolveReferences(R, RV);
|
||||||
|
if (Op != Val || ArgsChanged)
|
||||||
if (Args != NewArgs || Op != Val)
|
|
||||||
return DagInit::get(Op, ValName, NewArgs, ArgNames);
|
return DagInit::get(Op, ValName, NewArgs, ArgNames);
|
||||||
|
|
||||||
return const_cast<DagInit *>(this);
|
return const_cast<DagInit *>(this);
|
||||||
|
@ -1428,9 +1428,9 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
|
|||||||
Lex.Lex(); // eat the VarName.
|
Lex.Lex(); // eat the VarName.
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<llvm::Init*, StringInit*> > DagArgs;
|
SmallVector<std::pair<llvm::Init*, StringInit*>, 8> DagArgs;
|
||||||
if (Lex.getCode() != tgtok::r_paren) {
|
if (Lex.getCode() != tgtok::r_paren) {
|
||||||
DagArgs = ParseDagArgList(CurRec);
|
ParseDagArgList(DagArgs, CurRec);
|
||||||
if (DagArgs.empty()) return nullptr;
|
if (DagArgs.empty()) return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1603,9 +1603,9 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType, IDParseMode Mode) {
|
|||||||
/// DagArg ::= VARNAME
|
/// DagArg ::= VARNAME
|
||||||
/// DagArgList ::= DagArg
|
/// DagArgList ::= DagArg
|
||||||
/// DagArgList ::= DagArgList ',' DagArg
|
/// DagArgList ::= DagArgList ',' DagArg
|
||||||
std::vector<std::pair<llvm::Init*, StringInit*> >
|
void TGParser::ParseDagArgList(
|
||||||
TGParser::ParseDagArgList(Record *CurRec) {
|
SmallVectorImpl<std::pair<llvm::Init*, StringInit*>> &Result,
|
||||||
std::vector<std::pair<llvm::Init*, StringInit*> > Result;
|
Record *CurRec) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// DagArg ::= VARNAME
|
// DagArg ::= VARNAME
|
||||||
@ -1617,15 +1617,18 @@ TGParser::ParseDagArgList(Record *CurRec) {
|
|||||||
} else {
|
} else {
|
||||||
// DagArg ::= Value (':' VARNAME)?
|
// DagArg ::= Value (':' VARNAME)?
|
||||||
Init *Val = ParseValue(CurRec);
|
Init *Val = ParseValue(CurRec);
|
||||||
if (!Val)
|
if (!Val) {
|
||||||
return std::vector<std::pair<llvm::Init*, StringInit*> >();
|
Result.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the variable name is present, add it.
|
// If the variable name is present, add it.
|
||||||
StringInit *VarName = nullptr;
|
StringInit *VarName = nullptr;
|
||||||
if (Lex.getCode() == tgtok::colon) {
|
if (Lex.getCode() == tgtok::colon) {
|
||||||
if (Lex.Lex() != tgtok::VarName) { // eat the ':'
|
if (Lex.Lex() != tgtok::VarName) { // eat the ':'
|
||||||
TokError("expected variable name in dag literal");
|
TokError("expected variable name in dag literal");
|
||||||
return std::vector<std::pair<llvm::Init*, StringInit*> >();
|
Result.clear();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
VarName = StringInit::get(Lex.getCurStrVal());
|
VarName = StringInit::get(Lex.getCurStrVal());
|
||||||
Lex.Lex(); // eat the VarName.
|
Lex.Lex(); // eat the VarName.
|
||||||
@ -1636,8 +1639,6 @@ TGParser::ParseDagArgList(Record *CurRec) {
|
|||||||
if (Lex.getCode() != tgtok::comma) break;
|
if (Lex.getCode() != tgtok::comma) break;
|
||||||
Lex.Lex(); // eat the ','
|
Lex.Lex(); // eat the ','
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseValueList - Parse a comma separated list of values, returning them as a
|
/// ParseValueList - Parse a comma separated list of values, returning them as a
|
||||||
|
@ -175,7 +175,9 @@ private: // Parser methods.
|
|||||||
IDParseMode Mode = ParseValueMode);
|
IDParseMode Mode = ParseValueMode);
|
||||||
std::vector<Init*> ParseValueList(Record *CurRec, Record *ArgsRec = nullptr,
|
std::vector<Init*> ParseValueList(Record *CurRec, Record *ArgsRec = nullptr,
|
||||||
RecTy *EltTy = nullptr);
|
RecTy *EltTy = nullptr);
|
||||||
std::vector<std::pair<llvm::Init*, StringInit*> > ParseDagArgList(Record *);
|
void ParseDagArgList(
|
||||||
|
SmallVectorImpl<std::pair<llvm::Init*, StringInit*>> &Result,
|
||||||
|
Record *CurRec);
|
||||||
bool ParseOptionalRangeList(std::vector<unsigned> &Ranges);
|
bool ParseOptionalRangeList(std::vector<unsigned> &Ranges);
|
||||||
bool ParseOptionalBitList(std::vector<unsigned> &Ranges);
|
bool ParseOptionalBitList(std::vector<unsigned> &Ranges);
|
||||||
std::vector<unsigned> ParseRangeList();
|
std::vector<unsigned> ParseRangeList();
|
||||||
|
Loading…
Reference in New Issue
Block a user