@@ -159,6 +159,8 @@ struct EncodingField {
159
159
};
160
160
161
161
struct OperandInfo {
162
+ StringRef Name;
163
+ bool HasNoEncoding = false ;
162
164
std::vector<EncodingField> Fields;
163
165
std::string Decoder;
164
166
bool HasCompleteDecoder;
@@ -621,6 +623,7 @@ class DecoderTableBuilder {
621
623
622
624
private:
623
625
void emitBinaryParser (raw_ostream &OS, indent Indent,
626
+ const InstructionEncoding &Encoding,
624
627
const OperandInfo &OpInfo) const ;
625
628
626
629
void emitDecoder (raw_ostream &OS, indent Indent, unsigned EncodingID) const ;
@@ -1089,7 +1092,18 @@ FilterChooser::getIslands(const KnownBits &EncodingBits) const {
1089
1092
}
1090
1093
1091
1094
void DecoderTableBuilder::emitBinaryParser (raw_ostream &OS, indent Indent,
1095
+ const InstructionEncoding &Encoding,
1092
1096
const OperandInfo &OpInfo) const {
1097
+ if (OpInfo.HasNoEncoding ) {
1098
+ // If an operand has no encoding, the old behavior is to not decode it
1099
+ // automatically and let the target do it. This is error-prone, so the
1100
+ // new behavior is to report an error.
1101
+ if (!IgnoreNonDecodableOperands)
1102
+ PrintError (Encoding.getRecord ()->getLoc (),
1103
+ " could not find field for operand '" + OpInfo.Name + " '" );
1104
+ return ;
1105
+ }
1106
+
1093
1107
// Special case for 'bits<0>'.
1094
1108
if (OpInfo.Fields .empty () && !OpInfo.InitValue ) {
1095
1109
if (IgnoreNonDecodableOperands)
@@ -1154,7 +1168,7 @@ void DecoderTableBuilder::emitDecoder(raw_ostream &OS, indent Indent,
1154
1168
}
1155
1169
1156
1170
for (const OperandInfo &Op : Encoding.getOperands ())
1157
- emitBinaryParser (OS, Indent, Op);
1171
+ emitBinaryParser (OS, Indent, Encoding, Op);
1158
1172
}
1159
1173
1160
1174
unsigned DecoderTableBuilder::getDecoderIndex (unsigned EncodingID) const {
@@ -1903,6 +1917,8 @@ static void addOneOperandFields(const Record *EncodingDef,
1903
1917
std::map<StringRef, StringRef> &TiedNames,
1904
1918
const Record *OpRec, StringRef OpName,
1905
1919
OperandInfo &OpInfo) {
1920
+ OpInfo.Name = OpName;
1921
+
1906
1922
// Find a field with the operand's name.
1907
1923
const RecordVal *OpEncodingField = EncodingDef->getValue (OpName);
1908
1924
@@ -1911,13 +1927,9 @@ static void addOneOperandFields(const Record *EncodingDef,
1911
1927
if (auto I = TiedNames.find (OpName); I != TiedNames.end ())
1912
1928
OpEncodingField = EncodingDef->getValue (I->second );
1913
1929
1914
- // If still no luck, the old behavior is to not decode this operand
1915
- // automatically and let the target do it. This is error-prone, so
1916
- // the new behavior is to report an error.
1930
+ // If still no luck, we're done with this operand.
1917
1931
if (!OpEncodingField) {
1918
- if (!IgnoreNonDecodableOperands)
1919
- PrintError (EncodingDef->getLoc (),
1920
- " could not find field for operand '" + OpName + " '" );
1932
+ OpInfo.HasNoEncoding = true ;
1921
1933
return ;
1922
1934
}
1923
1935
}
0 commit comments