summaryrefslogtreecommitdiff
path: root/utils/TableGen/FixedLenDecoderEmitter.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-08-01 22:45:43 +0000
committerOwen Anderson <resistor@mac.com>2011-08-01 22:45:43 +0000
commitcf6039548bd7ee4ad960da0a480b399869f6fc6f (patch)
tree30a2959eab52a19d14d02a519152956b7d60dbf8 /utils/TableGen/FixedLenDecoderEmitter.cpp
parent02c8460a7428b9721d8784bc320f045d022ce699 (diff)
downloadllvm-cf6039548bd7ee4ad960da0a480b399869f6fc6f.tar.gz
llvm-cf6039548bd7ee4ad960da0a480b399869f6fc6f.tar.bz2
llvm-cf6039548bd7ee4ad960da0a480b399869f6fc6f.tar.xz
Make the FixedLengthDecoderEmitter smart enough to autogenerate decoders for encodings like "let Inst{11-7} = foo;", where the RHS has no bitwidth specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/FixedLenDecoderEmitter.cpp')
-rw-r--r--utils/TableGen/FixedLenDecoderEmitter.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp
index 249da8e25f..a262394d5b 100644
--- a/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -1267,8 +1267,14 @@ static bool populateInstruction(const CodeGenInstruction &CGI,
unsigned Offset = 0;
for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) {
+ VarInit *Var = 0;
VarBitInit *BI = dynamic_cast<VarBitInit*>(Bits.getBit(bi));
- if (!BI) {
+ if (BI)
+ Var = dynamic_cast<VarInit*>(BI->getVariable());
+ else
+ Var = dynamic_cast<VarInit*>(Bits.getBit(bi));
+
+ if (!Var) {
if (Base != ~0U) {
OpInfo.addField(Base, Width, Offset);
Base = ~0U;
@@ -1278,8 +1284,6 @@ static bool populateInstruction(const CodeGenInstruction &CGI,
continue;
}
- VarInit *Var = dynamic_cast<VarInit*>(BI->getVariable());
- assert(Var);
if (Var->getName() != NI->second &&
Var->getName() != TiedNames[NI->second]) {
if (Base != ~0U) {
@@ -1294,8 +1298,8 @@ static bool populateInstruction(const CodeGenInstruction &CGI,
if (Base == ~0U) {
Base = bi;
Width = 1;
- Offset = BI->getBitNum();
- } else if (BI->getBitNum() != Offset + Width) {
+ Offset = BI ? BI->getBitNum() : 0;
+ } else if (BI && BI->getBitNum() != Offset + Width) {
OpInfo.addField(Base, Width, Offset);
Base = bi;
Width = 1;