summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/Record.cpp
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2014-08-07 05:46:57 +0000
committerPete Cooper <peter_cooper@apple.com>2014-08-07 05:46:57 +0000
commit99ad2a3b6752de11e17460055f02c0a52132eae1 (patch)
tree83cbda4f57279867f2555922a4eb0749da52667a /llvm/lib/TableGen/Record.cpp
parentc18261d467746403d1809c2e728051c4ed0d0788 (diff)
downloadbcm5719-llvm-99ad2a3b6752de11e17460055f02c0a52132eae1.tar.gz
bcm5719-llvm-99ad2a3b6752de11e17460055f02c0a52132eae1.zip
TableGen: Change { } to only accept bits<n> entries when n == 1.
Prior to this change, it was legal to do something like bits<2> opc = { 0, 1 }; bits<2> opc2 = { 1, 0 }; bits<2> a = { opc, opc2 }; This involved silently dropping bits from opc and opc2 which is very hard to debug. Now the above test would be an error. Having tested with an assert, none of LLVM/clang was relying on this behaviour. Thanks to Adam Nemet for the above test. llvm-svn: 215083
Diffstat (limited to 'llvm/lib/TableGen/Record.cpp')
-rw-r--r--llvm/lib/TableGen/Record.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index cf8ef9bbf27..8267a364261 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -114,8 +114,11 @@ Init *BitRecTy::convertValue(IntInit *II) {
Init *BitRecTy::convertValue(TypedInit *VI) {
RecTy *Ty = VI->getType();
- if (isa<BitRecTy>(Ty) || isa<BitsRecTy>(Ty) || isa<IntRecTy>(Ty))
+ if (isa<BitRecTy>(Ty))
return VI; // Accept variable if it is already of bit type!
+ if (auto *BitsTy = dyn_cast<BitsRecTy>(Ty))
+ // Accept only bits<1> expression.
+ return BitsTy->getNumBits() == 1 ? VI : nullptr;
return nullptr;
}
OpenPOWER on IntegriCloud