@@ -1109,6 +1109,9 @@ void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
11091109 if (IgnoreNonDecodableOperands)
11101110 return ;
11111111 assert (!OpInfo.Decoder .empty ());
1112+ // The operand has no encoding, so the corresponding argument is omitted.
1113+ // This avoids confusion and allows the function to be overloaded if the
1114+ // operand does have an encoding in other instructions.
11121115 OS << Indent << " if (!Check(S, " << OpInfo.Decoder << " (MI, Decoder)))\n "
11131116 << Indent << " return MCDisassembler::Fail;\n " ;
11141117 return ;
@@ -1117,6 +1120,8 @@ void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
11171120 if (OpInfo.Fields .empty () && OpInfo.InitValue && IgnoreFullyDefinedOperands)
11181121 return ;
11191122
1123+ // We need to construct the encoding of the operand from pieces if it is not
1124+ // encoded sequentially or has a non-zero constant part in the encoding.
11201125 bool UseInsertBits = OpInfo.numFields () > 1 || OpInfo.InitValue .value_or (0 );
11211126
11221127 if (UseInsertBits) {
@@ -1989,6 +1994,19 @@ static void addOneOperandFields(const Record *EncodingDef, const BitsInit &Bits,
19891994 }
19901995 }
19911996
1997+ // Find out where the variable bits of the operand are encoded.
1998+ // The bits don't have to be consecutive or in ascending order.
1999+ // For example, an operand could be encoded as follows:
2000+ //
2001+ // 7 6 5 4 3 2 1 0
2002+ // {1, op{5}, op{2}, op{1}, 0, op{4}, op{3}, ?}
2003+ //
2004+ // In this example the operand is encoded in three segments:
2005+ //
2006+ // Base Width Offset
2007+ // op{2...1} 4 2 1
2008+ // op{4...3} 1 2 3
2009+ // op{5} 6 1 5
19922010 for (unsigned I = 0 , J = 0 ; I != Bits.getNumBits (); I = J) {
19932011 const VarInit *Var;
19942012 unsigned Offset = 0 ;
0 commit comments