Skip to content

Commit f21c0d4

Browse files
committed
Move IgnoreNonDecodableOperands check out of addOneOperandFields
1 parent 983c8b6 commit f21c0d4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ struct EncodingField {
159159
};
160160

161161
struct OperandInfo {
162+
StringRef Name;
163+
bool HasNoEncoding = false;
162164
std::vector<EncodingField> Fields;
163165
std::string Decoder;
164166
bool HasCompleteDecoder;
@@ -621,6 +623,7 @@ class DecoderTableBuilder {
621623

622624
private:
623625
void emitBinaryParser(raw_ostream &OS, indent Indent,
626+
const InstructionEncoding &Encoding,
624627
const OperandInfo &OpInfo) const;
625628

626629
void emitDecoder(raw_ostream &OS, indent Indent, unsigned EncodingID) const;
@@ -1089,7 +1092,18 @@ FilterChooser::getIslands(const KnownBits &EncodingBits) const {
10891092
}
10901093

10911094
void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
1095+
const InstructionEncoding &Encoding,
10921096
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+
10931107
// Special case for 'bits<0>'.
10941108
if (OpInfo.Fields.empty() && !OpInfo.InitValue) {
10951109
if (IgnoreNonDecodableOperands)
@@ -1154,7 +1168,7 @@ void DecoderTableBuilder::emitDecoder(raw_ostream &OS, indent Indent,
11541168
}
11551169

11561170
for (const OperandInfo &Op : Encoding.getOperands())
1157-
emitBinaryParser(OS, Indent, Op);
1171+
emitBinaryParser(OS, Indent, Encoding, Op);
11581172
}
11591173

11601174
unsigned DecoderTableBuilder::getDecoderIndex(unsigned EncodingID) const {
@@ -1903,6 +1917,8 @@ static void addOneOperandFields(const Record *EncodingDef,
19031917
std::map<StringRef, StringRef> &TiedNames,
19041918
const Record *OpRec, StringRef OpName,
19051919
OperandInfo &OpInfo) {
1920+
OpInfo.Name = OpName;
1921+
19061922
// Find a field with the operand's name.
19071923
const RecordVal *OpEncodingField = EncodingDef->getValue(OpName);
19081924

@@ -1911,13 +1927,9 @@ static void addOneOperandFields(const Record *EncodingDef,
19111927
if (auto I = TiedNames.find(OpName); I != TiedNames.end())
19121928
OpEncodingField = EncodingDef->getValue(I->second);
19131929

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.
19171931
if (!OpEncodingField) {
1918-
if (!IgnoreNonDecodableOperands)
1919-
PrintError(EncodingDef->getLoc(),
1920-
"could not find field for operand '" + OpName + "'");
1932+
OpInfo.HasNoEncoding = true;
19211933
return;
19221934
}
19231935
}

0 commit comments

Comments
 (0)