summaryrefslogtreecommitdiffstats
path: root/lib/TableGen/Record.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TableGen/Record.cpp')
-rw-r--r--lib/TableGen/Record.cpp190
1 files changed, 98 insertions, 92 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp
index a43665b..c553a21 100644
--- a/lib/TableGen/Record.cpp
+++ b/lib/TableGen/Record.cpp
@@ -101,13 +101,13 @@ bool RecTy::baseClassOf(const RecTy *RHS) const{
}
Init *BitRecTy::convertValue(BitsInit *BI) {
- if (BI->getNumBits() != 1) return 0; // Only accept if just one bit!
+ if (BI->getNumBits() != 1) return nullptr; // Only accept if just one bit!
return BI->getBit(0);
}
Init *BitRecTy::convertValue(IntInit *II) {
int64_t Val = II->getValue();
- if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit!
+ if (Val != 0 && Val != 1) return nullptr; // Only accept 0 or 1 for a bit!
return BitInit::get(Val != 0);
}
@@ -116,7 +116,7 @@ Init *BitRecTy::convertValue(TypedInit *VI) {
RecTy *Ty = VI->getType();
if (isa<BitRecTy>(Ty) || isa<BitsRecTy>(Ty) || isa<IntRecTy>(Ty))
return VI; // Accept variable if it is already of bit type!
- return 0;
+ return nullptr;
}
bool BitRecTy::baseClassOf(const RecTy *RHS) const{
@@ -151,7 +151,7 @@ Init *BitsRecTy::convertValue(UnsetInit *UI) {
}
Init *BitsRecTy::convertValue(BitInit *UI) {
- if (Size != 1) return 0; // Can only convert single bit.
+ if (Size != 1) return nullptr; // Can only convert single bit.
return BitsInit::get(UI);
}
@@ -170,7 +170,7 @@ Init *BitsRecTy::convertValue(IntInit *II) {
int64_t Value = II->getValue();
// Make sure this bitfield is large enough to hold the integer value.
if (!canFitInBitfield(Value, Size))
- return 0;
+ return nullptr;
SmallVector<Init *, 16> NewBits(Size);
@@ -184,7 +184,7 @@ Init *BitsRecTy::convertValue(BitsInit *BI) {
// If the number of bits is right, return it. Otherwise we need to expand or
// truncate.
if (BI->getNumBits() == Size) return BI;
- return 0;
+ return nullptr;
}
Init *BitsRecTy::convertValue(TypedInit *VI) {
@@ -199,7 +199,7 @@ Init *BitsRecTy::convertValue(TypedInit *VI) {
return BitsInit::get(NewBits);
}
- return 0;
+ return nullptr;
}
bool BitsRecTy::baseClassOf(const RecTy *RHS) const{
@@ -219,7 +219,7 @@ Init *IntRecTy::convertValue(BitsInit *BI) {
if (BitInit *Bit = dyn_cast<BitInit>(BI->getBit(i))) {
Result |= Bit->getValue() << i;
} else {
- return 0;
+ return nullptr;
}
return IntInit::get(Result);
}
@@ -227,7 +227,7 @@ Init *IntRecTy::convertValue(BitsInit *BI) {
Init *IntRecTy::convertValue(TypedInit *TI) {
if (TI->getType()->typeIsConvertibleTo(this))
return TI; // Accept variable if already of the right type!
- return 0;
+ return nullptr;
}
bool IntRecTy::baseClassOf(const RecTy *RHS) const{
@@ -238,7 +238,7 @@ bool IntRecTy::baseClassOf(const RecTy *RHS) const{
Init *StringRecTy::convertValue(UnOpInit *BO) {
if (BO->getOpcode() == UnOpInit::CAST) {
Init *L = BO->getOperand()->convertInitializerTo(this);
- if (L == 0) return 0;
+ if (!L) return nullptr;
if (L != BO->getOperand())
return UnOpInit::get(UnOpInit::CAST, L, new StringRecTy);
return BO;
@@ -251,7 +251,7 @@ Init *StringRecTy::convertValue(BinOpInit *BO) {
if (BO->getOpcode() == BinOpInit::STRCONCAT) {
Init *L = BO->getLHS()->convertInitializerTo(this);
Init *R = BO->getRHS()->convertInitializerTo(this);
- if (L == 0 || R == 0) return 0;
+ if (!L || !R) return nullptr;
if (L != BO->getLHS() || R != BO->getRHS())
return BinOpInit::get(BinOpInit::STRCONCAT, L, R, new StringRecTy);
return BO;
@@ -264,7 +264,7 @@ Init *StringRecTy::convertValue(BinOpInit *BO) {
Init *StringRecTy::convertValue(TypedInit *TI) {
if (isa<StringRecTy>(TI->getType()))
return TI; // Accept variable if already of the right type!
- return 0;
+ return nullptr;
}
std::string ListRecTy::getAsString() const {
@@ -280,10 +280,10 @@ Init *ListRecTy::convertValue(ListInit *LI) {
if (Init *CI = LI->getElement(i)->convertInitializerTo(Ty))
Elements.push_back(CI);
else
- return 0;
+ return nullptr;
if (!isa<ListRecTy>(LI->getType()))
- return 0;
+ return nullptr;
return ListInit::get(Elements, this);
}
@@ -293,7 +293,7 @@ Init *ListRecTy::convertValue(TypedInit *TI) {
if (ListRecTy *LRT = dyn_cast<ListRecTy>(TI->getType()))
if (LRT->getElementType()->typeIsConvertibleTo(getElementType()))
return TI;
- return 0;
+ return nullptr;
}
bool ListRecTy::baseClassOf(const RecTy *RHS) const{
@@ -305,30 +305,30 @@ bool ListRecTy::baseClassOf(const RecTy *RHS) const{
Init *DagRecTy::convertValue(TypedInit *TI) {
if (TI->getType()->typeIsConvertibleTo(this))
return TI;
- return 0;
+ return nullptr;
}
Init *DagRecTy::convertValue(UnOpInit *BO) {
if (BO->getOpcode() == UnOpInit::CAST) {
Init *L = BO->getOperand()->convertInitializerTo(this);
- if (L == 0) return 0;
+ if (!L) return nullptr;
if (L != BO->getOperand())
return UnOpInit::get(UnOpInit::CAST, L, new DagRecTy);
return BO;
}
- return 0;
+ return nullptr;
}
Init *DagRecTy::convertValue(BinOpInit *BO) {
if (BO->getOpcode() == BinOpInit::CONCAT) {
Init *L = BO->getLHS()->convertInitializerTo(this);
Init *R = BO->getRHS()->convertInitializerTo(this);
- if (L == 0 || R == 0) return 0;
+ if (!L || !R) return nullptr;
if (L != BO->getLHS() || R != BO->getRHS())
return BinOpInit::get(BinOpInit::CONCAT, L, R, new DagRecTy);
return BO;
}
- return 0;
+ return nullptr;
}
RecordRecTy *RecordRecTy::get(Record *R) {
@@ -342,7 +342,7 @@ std::string RecordRecTy::getAsString() const {
Init *RecordRecTy::convertValue(DefInit *DI) {
// Ensure that DI is a subclass of Rec.
if (!DI->getDef()->isSubClassOf(Rec))
- return 0;
+ return nullptr;
return DI;
}
@@ -352,7 +352,7 @@ Init *RecordRecTy::convertValue(TypedInit *TI) {
if (RRT->getRecord()->isSubClassOf(getRecord()) ||
RRT->getRecord() == getRecord())
return TI;
- return 0;
+ return nullptr;
}
bool RecordRecTy::baseClassOf(const RecTy *RHS) const{
@@ -391,7 +391,7 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) {
++i) {
RecordRecTy *SuperRecTy1 = RecordRecTy::get(*i);
RecTy *NewType1 = resolveTypes(SuperRecTy1, T2);
- if (NewType1 != 0) {
+ if (NewType1) {
if (NewType1 != SuperRecTy1) {
delete SuperRecTy1;
}
@@ -409,7 +409,7 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) {
++i) {
RecordRecTy *SuperRecTy2 = RecordRecTy::get(*i);
RecTy *NewType2 = resolveTypes(T1, SuperRecTy2);
- if (NewType2 != 0) {
+ if (NewType2) {
if (NewType2 != SuperRecTy2) {
delete SuperRecTy2;
}
@@ -417,7 +417,7 @@ RecTy *llvm::resolveTypes(RecTy *T1, RecTy *T2) {
}
}
}
- return 0;
+ return nullptr;
}
@@ -462,7 +462,7 @@ BitsInit *BitsInit::get(ArrayRef<Init *> Range) {
FoldingSetNodeID ID;
ProfileBitsInit(ID, Range);
- void *IP = 0;
+ void *IP = nullptr;
if (BitsInit *I = ThePool.FindNodeOrInsertPos(ID, IP))
return I;
@@ -482,7 +482,7 @@ BitsInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
if (Bits[i] >= getNumBits())
- return 0;
+ return nullptr;
NewBits[i] = getBit(Bits[i]);
}
return BitsInit::get(NewBits);
@@ -516,8 +516,8 @@ Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) const {
bool Changed = false;
SmallVector<Init *, 16> NewBits(getNumBits());
- Init *CachedInit = 0;
- Init *CachedBitVar = 0;
+ Init *CachedInit = nullptr;
+ Init *CachedBitVar = nullptr;
bool CachedBitVarChanged = false;
for (unsigned i = 0, e = getNumBits(); i != e; ++i) {
@@ -590,7 +590,7 @@ IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
if (Bits[i] >= 64)
- return 0;
+ return nullptr;
NewBits[i] = BitInit::get(Value & (INT64_C(1) << Bits[i]));
}
@@ -623,18 +623,18 @@ static void ProfileListInit(FoldingSetNodeID &ID,
ListInit *ListInit::get(ArrayRef<Init *> Range, RecTy *EltTy) {
typedef FoldingSet<ListInit> Pool;
static Pool ThePool;
+ static std::vector<std::unique_ptr<ListInit>> TheActualPool;
- // Just use the FoldingSetNodeID to compute a hash. Use a DenseMap
- // for actual storage.
FoldingSetNodeID ID;
ProfileListInit(ID, Range, EltTy);
- void *IP = 0;
+ void *IP = nullptr;
if (ListInit *I = ThePool.FindNodeOrInsertPos(ID, IP))
return I;
ListInit *I = new ListInit(Range, EltTy);
ThePool.InsertNode(I, IP);
+ TheActualPool.push_back(std::unique_ptr<ListInit>(I));
return I;
}
@@ -651,7 +651,7 @@ ListInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
std::vector<Init*> Vals;
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
if (Elements[i] >= getSize())
- return 0;
+ return nullptr;
Vals.push_back(getElement(Elements[i]));
}
return ListInit::get(Vals, getType());
@@ -660,7 +660,7 @@ ListInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
Record *ListInit::getElementAsRecord(unsigned i) const {
assert(i < Values.size() && "List element index out of range!");
DefInit *DI = dyn_cast<DefInit>(Values[i]);
- if (DI == 0)
+ if (!DI)
PrintFatalError("Expected record in list!");
return DI->getDef();
}
@@ -690,14 +690,14 @@ Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) const {
Init *ListInit::resolveListElementReference(Record &R, const RecordVal *IRV,
unsigned Elt) const {
if (Elt >= getSize())
- return 0; // Out of range reference.
+ return nullptr; // Out of range reference.
Init *E = getElement(Elt);
// If the element is set to some value, or if we are resolving a reference
// to a specific variable and that variable is explicitly unset, then
// replace the VarListElementInit with it.
if (IRV || !isa<UnsetInit>(E))
return E;
- return 0;
+ return nullptr;
}
std::string ListInit::getAsString() const {
@@ -714,7 +714,7 @@ Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV,
Init *Resolved = resolveReferences(R, IRV);
OpInit *OResolved = dyn_cast<OpInit>(Resolved);
if (OResolved) {
- Resolved = OResolved->Fold(&R, 0);
+ Resolved = OResolved->Fold(&R, nullptr);
}
if (Resolved != this) {
@@ -728,7 +728,7 @@ Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV,
}
}
- return 0;
+ return nullptr;
}
Init *OpInit::getBit(unsigned Bit) const {
@@ -813,7 +813,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
if (LHSl->getSize() == 0) {
assert(0 && "Empty list in car");
- return 0;
+ return nullptr;
}
return LHSl->getElement(0);
}
@@ -823,7 +823,7 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
if (LHSl->getSize() == 0) {
assert(0 && "Empty list in cdr");
- return 0;
+ return nullptr;
}
// Note the +1. We can't just pass the result of getValues()
// directly.
@@ -862,8 +862,8 @@ Init *UnOpInit::resolveReferences(Record &R, const RecordVal *RV) const {
Init *lhs = LHS->resolveReferences(R, RV);
if (LHS != lhs)
- return (UnOpInit::get(getOpcode(), lhs, getType()))->Fold(&R, 0);
- return Fold(&R, 0);
+ return (UnOpInit::get(getOpcode(), lhs, getType()))->Fold(&R, nullptr);
+ return Fold(&R, nullptr);
}
std::string UnOpInit::getAsString() const {
@@ -902,7 +902,7 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
if (LHSs && RHSs) {
DefInit *LOp = dyn_cast<DefInit>(LHSs->getOperator());
DefInit *ROp = dyn_cast<DefInit>(RHSs->getOperator());
- if (LOp == 0 || ROp == 0 || LOp->getDef() != ROp->getDef())
+ if (!LOp || !ROp || LOp->getDef() != ROp->getDef())
PrintFatalError("Concated Dag operators do not match!");
std::vector<Init*> Args;
std::vector<std::string> ArgNames;
@@ -918,6 +918,18 @@ Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
}
break;
}
+ case LISTCONCAT: {
+ ListInit *LHSs = dyn_cast<ListInit>(LHS);
+ ListInit *RHSs = dyn_cast<ListInit>(RHS);
+ if (LHSs && RHSs) {
+ std::vector<Init *> Args;
+ Args.insert(Args.end(), LHSs->begin(), LHSs->end());
+ Args.insert(Args.end(), RHSs->begin(), RHSs->end());
+ return ListInit::get(
+ Args, static_cast<ListRecTy *>(LHSs->getType())->getElementType());
+ }
+ break;
+ }
case STRCONCAT: {
StringInit *LHSs = dyn_cast<StringInit>(LHS);
StringInit *RHSs = dyn_cast<StringInit>(RHS);
@@ -974,8 +986,8 @@ Init *BinOpInit::resolveReferences(Record &R, const RecordVal *RV) const {
Init *rhs = RHS->resolveReferences(R, RV);
if (LHS != lhs || RHS != rhs)
- return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0);
- return Fold(&R, 0);
+ return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))->Fold(&R,nullptr);
+ return Fold(&R, nullptr);
}
std::string BinOpInit::getAsString() const {
@@ -987,6 +999,7 @@ std::string BinOpInit::getAsString() const {
case SRA: Result = "!sra"; break;
case SRL: Result = "!srl"; break;
case EQ: Result = "!eq"; break;
+ case LISTCONCAT: Result = "!listconcat"; break;
case STRCONCAT: Result = "!strconcat"; break;
}
return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")";
@@ -1031,11 +1044,7 @@ static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg,
if (TArg && TArg->getType()->getAsString() == "dag") {
Init *Result = ForeachHelper(LHS, Arg, RHSo, Type,
CurRec, CurMultiClass);
- if (Result != 0) {
- return Result;
- } else {
- return 0;
- }
+ return Result;
}
for (int i = 0; i < RHSo->getNumOperands(); ++i) {
@@ -1044,7 +1053,7 @@ static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg,
if (RHSoo) {
Init *Result = EvaluateOperation(RHSoo, LHS, Arg,
Type, CurRec, CurMultiClass);
- if (Result != 0) {
+ if (Result) {
NewOperands.push_back(Result);
} else {
NewOperands.push_back(Arg);
@@ -1059,10 +1068,7 @@ static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg,
// Now run the operator and use its result as the new leaf
const OpInit *NewOp = RHSo->clone(NewOperands);
Init *NewVal = NewOp->Fold(CurRec, CurMultiClass);
- if (NewVal != NewOp)
- return NewVal;
-
- return 0;
+ return (NewVal != NewOp) ? NewVal : nullptr;
}
static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
@@ -1086,7 +1092,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
Init *Val = MHSd->getOperator();
Init *Result = EvaluateOperation(RHSo, LHS, Val,
Type, CurRec, CurMultiClass);
- if (Result != 0) {
+ if (Result) {
Val = Result;
}
@@ -1100,7 +1106,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
// Process args
Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type,
CurRec, CurMultiClass);
- if (Result != 0) {
+ if (Result) {
Arg = Result;
}
@@ -1138,7 +1144,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
return ListInit::get(NewList, MHSl->getType());
}
}
- return 0;
+ return nullptr;
}
Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
@@ -1195,7 +1201,7 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
case FOREACH: {
Init *Result = ForeachHelper(LHS, MHS, RHS, getType(),
CurRec, CurMultiClass);
- if (Result != 0) {
+ if (Result) {
return Result;
}
break;
@@ -1227,16 +1233,16 @@ Init *TernOpInit::resolveReferences(Record &R,
IntInit *Value = dyn_cast<IntInit>(lhs);
if (Init *I = lhs->convertInitializerTo(IntRecTy::get()))
Value = dyn_cast<IntInit>(I);
- if (Value != 0) {
+ if (Value) {
// Short-circuit
if (Value->getValue()) {
Init *mhs = MHS->resolveReferences(R, RV);
return (TernOpInit::get(getOpcode(), lhs, mhs,
- RHS, getType()))->Fold(&R, 0);
+ RHS, getType()))->Fold(&R, nullptr);
} else {
Init *rhs = RHS->resolveReferences(R, RV);
return (TernOpInit::get(getOpcode(), lhs, MHS,
- rhs, getType()))->Fold(&R, 0);
+ rhs, getType()))->Fold(&R, nullptr);
}
}
}
@@ -1246,8 +1252,8 @@ Init *TernOpInit::resolveReferences(Record &R,
if (LHS != lhs || MHS != mhs || RHS != rhs)
return (TernOpInit::get(getOpcode(), lhs, mhs, rhs,
- getType()))->Fold(&R, 0);
- return Fold(&R, 0);
+ getType()))->Fold(&R, nullptr);
+ return Fold(&R, nullptr);
}
std::string TernOpInit::getAsString() const {
@@ -1265,19 +1271,19 @@ RecTy *TypedInit::getFieldType(const std::string &FieldName) const {
if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType()))
if (RecordVal *Field = RecordType->getRecord()->getValue(FieldName))
return Field->getType();
- return 0;
+ return nullptr;
}
Init *
TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
BitsRecTy *T = dyn_cast<BitsRecTy>(getType());
- if (T == 0) return 0; // Cannot subscript a non-bits variable.
+ if (!T) return nullptr; // Cannot subscript a non-bits variable.
unsigned NumBits = T->getNumBits();
SmallVector<Init *, 16> NewBits(Bits.size());
for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
if (Bits[i] >= NumBits)
- return 0;
+ return nullptr;
NewBits[i] = VarBitInit::get(const_cast<TypedInit *>(this), Bits[i]);
}
@@ -1287,7 +1293,7 @@ TypedInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
Init *
TypedInit::convertInitListSlice(const std::vector<unsigned> &Elements) const {
ListRecTy *T = dyn_cast<ListRecTy>(getType());
- if (T == 0) return 0; // Cannot subscript a non-list variable.
+ if (!T) return nullptr; // Cannot subscript a non-list variable.
if (Elements.size() == 1)
return VarListElementInit::get(const_cast<TypedInit *>(this), Elements[0]);
@@ -1332,8 +1338,8 @@ Init *VarInit::getBit(unsigned Bit) const {
Init *VarInit::resolveListElementReference(Record &R,
const RecordVal *IRV,
unsigned Elt) const {
- if (R.isTemplateArg(getNameInit())) return 0;
- if (IRV && IRV->getNameInit() != getNameInit()) return 0;
+ if (R.isTemplateArg(getNameInit())) return nullptr;
+ if (IRV && IRV->getNameInit() != getNameInit()) return nullptr;
RecordVal *RV = R.getValue(getNameInit());
assert(RV && "Reference to a non-existent variable?");
@@ -1345,14 +1351,14 @@ Init *VarInit::resolveListElementReference(Record &R,
}
if (Elt >= LI->getSize())
- return 0; // Out of range reference.
+ return nullptr; // Out of range reference.
Init *E = LI->getElement(Elt);
// If the element is set to some value, or if we are resolving a reference
// to a specific variable and that variable is explicitly unset, then
// replace the VarListElementInit with it.
if (IRV || !isa<UnsetInit>(E))
return E;
- return 0;
+ return nullptr;
}
@@ -1360,7 +1366,7 @@ RecTy *VarInit::getFieldType(const std::string &FieldName) const {
if (RecordRecTy *RTy = dyn_cast<RecordRecTy>(getType()))
if (const RecordVal *RV = RTy->getRecord()->getValue(FieldName))
return RV->getType();
- return 0;
+ return nullptr;
}
Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
@@ -1368,15 +1374,15 @@ Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
if (isa<RecordRecTy>(getType()))
if (const RecordVal *Val = R.getValue(VarName)) {
if (RV != Val && (RV || isa<UnsetInit>(Val->getValue())))
- return 0;
+ return nullptr;
Init *TheInit = Val->getValue();
assert(TheInit != this && "Infinite loop detected!");
if (Init *I = TheInit->getFieldInit(R, RV, FieldName))
return I;
else
- return 0;
+ return nullptr;
}
- return 0;
+ return nullptr;
}
/// resolveReferences - This method is used by classes that refer to other
@@ -1386,7 +1392,7 @@ Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
///
Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) const {
if (RecordVal *Val = R.getValue(VarName))
- if (RV == Val || (RV == 0 && !isa<UnsetInit>(Val->getValue())))
+ if (RV == Val || (!RV && !isa<UnsetInit>(Val->getValue())))
return Val->getValue();
return const_cast<VarInit *>(this);
}
@@ -1462,7 +1468,7 @@ Init *VarListElementInit:: resolveListElementReference(Record &R,
return Result;
}
- return 0;
+ return nullptr;
}
DefInit *DefInit::get(Record *R) {
@@ -1472,7 +1478,7 @@ DefInit *DefInit::get(Record *R) {
RecTy *DefInit::getFieldType(const std::string &FieldName) const {
if (const RecordVal *RV = Def->getValue(FieldName))
return RV->getType();
- return 0;
+ return nullptr;
}
Init *DefInit::getFieldInit(Record &R, const RecordVal *RV,
@@ -1507,7 +1513,7 @@ Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV,
unsigned Elt) const {
if (Init *ListVal = Rec->getFieldInit(R, RV, FieldName))
if (ListInit *LI = dyn_cast<ListInit>(ListVal)) {
- if (Elt >= LI->getSize()) return 0;
+ if (Elt >= LI->getSize()) return nullptr;
Init *E = LI->getElement(Elt);
// If the element is set to some value, or if we are resolving a
@@ -1516,7 +1522,7 @@ Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV,
if (RV || !isa<UnsetInit>(E))
return E;
}
- return 0;
+ return nullptr;
}
Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) const {
@@ -1560,7 +1566,7 @@ DagInit::get(Init *V, const std::string &VN,
FoldingSetNodeID ID;
ProfileDagInit(ID, V, VN, ArgRange, NameRange);
- void *IP = 0;
+ void *IP = nullptr;
if (DagInit *I = ThePool.FindNodeOrInsertPos(ID, IP))
return I;
@@ -1784,7 +1790,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const Record &R) {
///
Init *Record::getValueInit(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
return R->getValue();
@@ -1797,7 +1803,7 @@ Init *Record::getValueInit(StringRef FieldName) const {
///
std::string Record::getValueAsString(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
@@ -1813,7 +1819,7 @@ std::string Record::getValueAsString(StringRef FieldName) const {
///
BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
@@ -1829,7 +1835,7 @@ BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const {
///
ListInit *Record::getValueAsListInit(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
@@ -1864,7 +1870,7 @@ Record::getValueAsListOfDefs(StringRef FieldName) const {
///
int64_t Record::getValueAsInt(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
@@ -1918,7 +1924,7 @@ Record::getValueAsListOfStrings(StringRef FieldName) const {
///
Record *Record::getValueAsDef(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
@@ -1934,7 +1940,7 @@ Record *Record::getValueAsDef(StringRef FieldName) const {
///
bool Record::getValueAsBit(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");
@@ -1946,7 +1952,7 @@ bool Record::getValueAsBit(StringRef FieldName) const {
bool Record::getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName.str() + "'!\n");
@@ -1967,7 +1973,7 @@ bool Record::getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const {
///
DagInit *Record::getValueAsDag(StringRef FieldName) const {
const RecordVal *R = getValue(FieldName);
- if (R == 0 || R->getValue() == 0)
+ if (!R || !R->getValue())
PrintFatalError(getLoc(), "Record `" + getName() +
"' does not have a field named `" + FieldName + "'!\n");