Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[TableGen] Fix crash when using HwModes in CodeEmitterGen
When an instruction has an encoding definition for only a subset of
the available HwModes, ensure we just avoid generating an encoding
rather than crash.

llvm-svn: 374150
  • Loading branch information
James Molloy committed Oct 9, 2019
1 parent 66f05d7 commit 9948fe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions llvm/test/TableGen/HwModeEncodeDecode.td
Expand Up @@ -56,6 +56,15 @@ def bar: Instruction {
let Inst{1-0} = 0b10;
let AsmString = "bar $factor";
}

def baz : Instruction {
let InOperandList = (ins i32imm:$factor);
bits<32> Inst;
let EncodingInfos = EncodingByHwMode<
[ModeB], [fooTypeEncA]
>;
let AsmString = "foo $factor";
}
}

// DECODER-LABEL: DecoderTable_ModeA32[] =
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/CodeEmitterGen.cpp
Expand Up @@ -367,7 +367,8 @@ void CodeEmitterGen::emitInstructionBaseValues(
if (const RecordVal *RV = R->getValue("EncodingInfos")) {
if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
EncodingDef = EBM.get(HwMode);
if (EBM.hasMode(HwMode))
EncodingDef = EBM.get(HwMode);
}
}
BitsInit *BI = EncodingDef->getValueAsBitsInit("Inst");
Expand Down

0 comments on commit 9948fe6

Please sign in to comment.