Reduce code duplication a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218563 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2014-09-27 05:26:42 +00:00
parent 72c3b07dfd
commit 2895d9527d

View File

@ -1047,23 +1047,17 @@ void FilterChooser::emitBinaryParser(raw_ostream &o, unsigned &Indentation,
const OperandInfo &OpInfo) const {
const std::string &Decoder = OpInfo.Decoder;
if (OpInfo.numFields() == 1) {
OperandInfo::const_iterator OI = OpInfo.begin();
o.indent(Indentation) << "tmp = fieldFromInstruction"
<< "(insn, " << OI->Base << ", " << OI->Width
<< ")";
if (OI->Offset)
o << " << " << OI->Offset;
o << ";\n";
} else {
if (OpInfo.numFields() != 1)
o.indent(Indentation) << "tmp = 0;\n";
for (OperandInfo::const_iterator OI = OpInfo.begin(), OE = OpInfo.end();
OI != OE; ++OI) {
o.indent(Indentation) << "tmp |= (fieldFromInstruction"
<< "(insn, " << OI->Base << ", " << OI->Width
<< ") << " << OI->Offset << ");\n";
}
for (const EncodingField &EF : OpInfo) {
o.indent(Indentation) << "tmp ";
if (OpInfo.numFields() != 1) o << '|';
o << "= fieldFromInstruction"
<< "(insn, " << EF.Base << ", " << EF.Width << ')';
if (OpInfo.numFields() != 1 || EF.Offset != 0)
o << " << " << EF.Offset;
o << ";\n";
}
if (Decoder != "")