summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/Record.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2015-07-31 01:12:06 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2015-07-31 01:12:06 +0000
commita7bc7db53c9e6a1beeed5c52639a13e42fe4bea9 (patch)
tree283876a4a5650b9cd0f357f8c3c86d50b001bbb1 /llvm/lib/TableGen/Record.cpp
parent4fca6e8063e2d7c41af2ca71a1b498123cf66722 (diff)
downloadbcm5719-llvm-a7bc7db53c9e6a1beeed5c52639a13e42fe4bea9.tar.gz
bcm5719-llvm-a7bc7db53c9e6a1beeed5c52639a13e42fe4bea9.zip
TableGen: Support folding casts from bits to int
This is to fix an incorrect error when trying to initialize DwarfNumbers with a !cast<int> of a bits initializer. getValuesAsListOfInts("DwarfNumbers") would not see an IntInit and instead the cast, so would give up. It seems likely that this could be generalized to attempt the convertInitializerTo for any type. I'm not really sure why the existing code seems to special case the string cast cases when convertInitializerTo seems like it should generally handle this sort of thing. llvm-svn: 243722
Diffstat (limited to 'llvm/lib/TableGen/Record.cpp')
-rw-r--r--llvm/lib/TableGen/Record.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index c9a31b64cfd..271e52567a2 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -673,6 +673,14 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const {
PrintFatalError(CurRec->getLoc(),
"Undefined reference:'" + Name + "'\n");
}
+
+ if (isa<IntRecTy>(getType())) {
+ if (BitsInit *BI = dyn_cast<BitsInit>(LHS)) {
+ if (Init *NewInit = BI->convertInitializerTo(IntRecTy::get()))
+ return NewInit;
+ break;
+ }
+ }
}
break;
}
OpenPOWER on IntegriCloud