[llvm-commits] [llvm] r165292 - in /llvm/trunk: include/llvm/TableGen/Record.h lib/TableGen/Record.cpp
Sean Silva
silvas at purdue.edu
Thu Oct 4 20:32:00 PDT 2012
Author: silvas
Date: Thu Oct 4 22:32:00 2012
New Revision: 165292
URL: http://llvm.org/viewvc/llvm-project?rev=165292&view=rev
Log:
tblgen: Use appropriate LLVM-style RTTI functions.
Use isa<> or cast<> when semantically that is what is happening. Also
some trivial "style" cleanups at fix sites.
Modified:
llvm/trunk/include/llvm/TableGen/Record.h
llvm/trunk/lib/TableGen/Record.cpp
Modified: llvm/trunk/include/llvm/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=165292&r1=165291&r2=165292&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/Record.h (original)
+++ llvm/trunk/include/llvm/TableGen/Record.h Thu Oct 4 22:32:00 2012
@@ -1085,9 +1085,9 @@
VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) {
assert(T->getType() &&
- (dyn_cast<IntRecTy>(T->getType()) ||
- (dyn_cast<BitsRecTy>(T->getType()) &&
- dyn_cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
+ (isa<IntRecTy>(T->getType()) ||
+ (isa<BitsRecTy>(T->getType()) &&
+ cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
"Illegal VarBitInit expression!");
}
@@ -1120,9 +1120,9 @@
unsigned Element;
VarListElementInit(TypedInit *T, unsigned E)
- : TypedInit(dyn_cast<ListRecTy>(T->getType())->getElementType()),
+ : TypedInit(cast<ListRecTy>(T->getType())->getElementType()),
TI(T), Element(E) {
- assert(T->getType() && dyn_cast<ListRecTy>(T->getType()) &&
+ assert(T->getType() && isa<ListRecTy>(T->getType()) &&
"Illegal VarBitInit expression!");
}
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=165292&r1=165291&r2=165292&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Thu Oct 4 22:32:00 2012
@@ -113,9 +113,7 @@
Init *BitRecTy::convertValue(TypedInit *VI) {
RecTy *Ty = VI->getType();
- if (dyn_cast<BitRecTy>(Ty) ||
- dyn_cast<BitsRecTy>(Ty) ||
- dyn_cast<IntRecTy>(Ty))
+ if (isa<BitRecTy>(Ty) || isa<BitsRecTy>(Ty) || isa<IntRecTy>(Ty))
return VI; // Accept variable if it is already of bit type!
return 0;
}
@@ -181,7 +179,7 @@
}
Init *BitsRecTy::convertValue(TypedInit *VI) {
- if (Size == 1 && dyn_cast<BitRecTy>(VI->getType()))
+ if (Size == 1 && isa<BitRecTy>(VI->getType()))
return BitsInit::get(VI);
if (VI->getType()->typeIsConvertibleTo(this)) {
@@ -243,7 +241,7 @@
Init *StringRecTy::convertValue(TypedInit *TI) {
- if (dyn_cast<StringRecTy>(TI->getType()))
+ if (isa<StringRecTy>(TI->getType()))
return TI; // Accept variable if already of the right type!
return 0;
}
@@ -263,10 +261,8 @@
else
return 0;
- ListRecTy *LType = dyn_cast<ListRecTy>(LI->getType());
- if (LType == 0) {
+ if (!isa<ListRecTy>(LI->getType()))
return 0;
- }
return ListInit::get(Elements, this);
}
@@ -1039,9 +1035,6 @@
DagInit *MHSd = dynamic_cast<DagInit*>(MHS);
ListInit *MHSl = dynamic_cast<ListInit*>(MHS);
- DagRecTy *DagType = dyn_cast<DagRecTy>(Type);
- ListRecTy *ListType = dyn_cast<ListRecTy>(Type);
-
OpInit *RHSo = dynamic_cast<OpInit*>(RHS);
if (!RHSo) {
@@ -1054,7 +1047,7 @@
throw TGError(CurRec->getLoc(), "!foreach requires typed variable\n");
}
- if ((MHSd && DagType) || (MHSl && ListType)) {
+ if ((MHSd && isa<DagRecTy>(Type)) || (MHSl && isa<ListRecTy>(Type))) {
if (MHSd) {
Init *Val = MHSd->getOperator();
Init *Result = EvaluateOperation(RHSo, LHS, Val,
@@ -1235,13 +1228,9 @@
}
RecTy *TypedInit::getFieldType(const std::string &FieldName) const {
- RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType());
- if (RecordType) {
- RecordVal *Field = RecordType->getRecord()->getValue(FieldName);
- if (Field) {
+ if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType()))
+ if (RecordVal *Field = RecordType->getRecord()->getValue(FieldName))
return Field->getType();
- }
- }
return 0;
}
@@ -1344,7 +1333,7 @@
Init *VarInit::getFieldInit(Record &R, const RecordVal *RV,
const std::string &FieldName) const {
- if (dyn_cast<RecordRecTy>(getType()))
+ if (isa<RecordRecTy>(getType()))
if (const RecordVal *Val = R.getValue(VarName)) {
if (RV != Val && (RV || dynamic_cast<UnsetInit*>(Val->getValue())))
return 0;
@@ -1655,9 +1644,8 @@
const TypedInit *TypedName = dynamic_cast<const TypedInit *>(Name);
assert(TypedName && "Record name is not typed!");
RecTy *Type = TypedName->getType();
- if (dyn_cast<StringRecTy>(Type) == 0) {
+ if (!isa<StringRecTy>(Type))
throw TGError(getLoc(), "Record name is not a string!");
- }
}
DefInit *Record::getDefInit() {
More information about the llvm-commits
mailing list