@@ -1109,6 +1109,9 @@ void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
1109
1109
if (IgnoreNonDecodableOperands)
1110
1110
return ;
1111
1111
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.
1112
1115
OS << Indent << " if (!Check(S, " << OpInfo.Decoder << " (MI, Decoder)))\n "
1113
1116
<< Indent << " return MCDisassembler::Fail;\n " ;
1114
1117
return ;
@@ -1117,6 +1120,8 @@ void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
1117
1120
if (OpInfo.Fields .empty () && OpInfo.InitValue && IgnoreFullyDefinedOperands)
1118
1121
return ;
1119
1122
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.
1120
1125
bool UseInsertBits = OpInfo.numFields () > 1 || OpInfo.InitValue .value_or (0 );
1121
1126
1122
1127
if (UseInsertBits) {
@@ -1989,6 +1994,19 @@ static void addOneOperandFields(const Record *EncodingDef, const BitsInit &Bits,
1989
1994
}
1990
1995
}
1991
1996
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
1992
2010
for (unsigned I = 0 , J = 0 ; I != Bits.getNumBits (); I = J) {
1993
2011
const VarInit *Var;
1994
2012
unsigned Offset = 0 ;
0 commit comments