aboutsummaryrefslogtreecommitdiffstats
path: root/support/tools/TableGen
diff options
context:
space:
mode:
Diffstat (limited to 'support/tools/TableGen')
-rw-r--r--support/tools/TableGen/Record.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/support/tools/TableGen/Record.cpp b/support/tools/TableGen/Record.cpp
index ef7d9a0..204929e 100644
--- a/support/tools/TableGen/Record.cpp
+++ b/support/tools/TableGen/Record.cpp
@@ -53,10 +53,19 @@ Init *BitsRecTy::convertValue(BitInit *UI) {
//
Init *BitsRecTy::convertValue(IntInit *II) {
int Value = II->getValue();
+ // Make sure this bitfield is large enough to hold the integer value...
+ if (Value >= 0) {
+ if (Value & ~((1 << Size)-1))
+ return 0;
+ } else {
+ if ((Value >> Size) != -1 || ((Value & (1 << Size-1)) == 0))
+ return 0;
+ }
BitsInit *Ret = new BitsInit(Size);
for (unsigned i = 0; i != Size; ++i)
Ret->setBit(i, new BitInit(Value & (1 << i)));
+
return Ret;
}