@@ -525,18 +525,6 @@ class DecoderTableBuilder {
525
525
}
526
526
527
527
private:
528
- void emitBinaryParser (raw_ostream &OS, indent Indent,
529
- const InstructionEncoding &Encoding,
530
- const OperandInfo &OpInfo) const ;
531
-
532
- void emitDecoder (raw_ostream &OS, indent Indent, unsigned EncodingID) const ;
533
-
534
- unsigned getDecoderIndex (unsigned EncodingID) const ;
535
-
536
- unsigned getPredicateIndex (StringRef P) const ;
537
-
538
- bool emitPredicateMatch (raw_ostream &OS, unsigned EncodingID) const ;
539
-
540
528
void emitPredicateTableEntry (unsigned EncodingID) const ;
541
529
542
530
void emitSoftFailTableEntry (unsigned EncodingID) const ;
@@ -1013,9 +1001,9 @@ FilterChooser::getIslands(const KnownBits &EncodingBits) const {
1013
1001
return Islands;
1014
1002
}
1015
1003
1016
- void DecoderTableBuilder:: emitBinaryParser (raw_ostream &OS, indent Indent,
1017
- const InstructionEncoding &Encoding,
1018
- const OperandInfo &OpInfo) const {
1004
+ static void emitBinaryParser (raw_ostream &OS, indent Indent,
1005
+ const InstructionEncoding &Encoding,
1006
+ const OperandInfo &OpInfo) {
1019
1007
if (OpInfo.HasNoEncoding ) {
1020
1008
// If an operand has no encoding, the old behavior is to not decode it
1021
1009
// automatically and let the target do it. This is error-prone, so the
@@ -1075,10 +1063,8 @@ void DecoderTableBuilder::emitBinaryParser(raw_ostream &OS, indent Indent,
1075
1063
}
1076
1064
}
1077
1065
1078
- void DecoderTableBuilder::emitDecoder (raw_ostream &OS, indent Indent,
1079
- unsigned EncodingID) const {
1080
- const InstructionEncoding &Encoding = Encodings[EncodingID];
1081
-
1066
+ static void emitDecoder (raw_ostream &OS, indent Indent,
1067
+ const InstructionEncoding &Encoding) {
1082
1068
// If a custom instruction decoder was specified, use that.
1083
1069
StringRef DecoderMethod = Encoding.getDecoderMethod ();
1084
1070
if (!DecoderMethod.empty ()) {
@@ -1093,14 +1079,15 @@ void DecoderTableBuilder::emitDecoder(raw_ostream &OS, indent Indent,
1093
1079
emitBinaryParser (OS, Indent, Encoding, Op);
1094
1080
}
1095
1081
1096
- unsigned DecoderTableBuilder::getDecoderIndex (unsigned EncodingID) const {
1082
+ static unsigned getDecoderIndex (const InstructionEncoding &Encoding,
1083
+ DecoderTableInfo &TableInfo) {
1097
1084
// Build up the predicate string.
1098
1085
SmallString<256 > Decoder;
1099
1086
// FIXME: emitDecoder() function can take a buffer directly rather than
1100
1087
// a stream.
1101
1088
raw_svector_ostream S (Decoder);
1102
1089
indent Indent (UseFnTableInDecodeToMCInst ? 2 : 4 );
1103
- emitDecoder (S, Indent, EncodingID );
1090
+ emitDecoder (S, Indent, Encoding );
1104
1091
1105
1092
// Using the full decoder string as the key value here is a bit
1106
1093
// heavyweight, but is effective. If the string comparisons become a
@@ -1112,21 +1099,23 @@ unsigned DecoderTableBuilder::getDecoderIndex(unsigned EncodingID) const {
1112
1099
}
1113
1100
1114
1101
// Returns true if there was any predicate emitted.
1115
- bool DecoderTableBuilder::emitPredicateMatch (raw_ostream &OS,
1116
- unsigned EncodingID) const {
1102
+ static bool emitPredicateMatch (raw_ostream &OS,
1103
+ const InstructionEncoding &Encoding,
1104
+ StringRef TargetName) {
1117
1105
std::vector<const Record *> Predicates =
1118
- Encodings[EncodingID] .getRecord ()->getValueAsListOfDefs (" Predicates" );
1106
+ Encoding .getRecord ()->getValueAsListOfDefs (" Predicates" );
1119
1107
auto It = llvm::find_if (Predicates, [](const Record *R) {
1120
1108
return R->getValueAsBit (" AssemblerMatcherPredicate" );
1121
1109
});
1122
1110
bool AnyAsmPredicate = It != Predicates.end ();
1123
1111
if (!AnyAsmPredicate)
1124
1112
return false ;
1125
- SubtargetFeatureInfo::emitMCPredicateCheck (OS, Target. getName () , Predicates);
1113
+ SubtargetFeatureInfo::emitMCPredicateCheck (OS, TargetName , Predicates);
1126
1114
return true ;
1127
1115
}
1128
1116
1129
- unsigned DecoderTableBuilder::getPredicateIndex (StringRef Predicate) const {
1117
+ static unsigned getPredicateIndex (StringRef Predicate,
1118
+ DecoderTableInfo &TableInfo) {
1130
1119
// Using the full predicate string as the key value here is a bit
1131
1120
// heavyweight, but is effective. If the string comparisons become a
1132
1121
// performance concern, we can implement a mangling of the predicate
@@ -1137,15 +1126,16 @@ unsigned DecoderTableBuilder::getPredicateIndex(StringRef Predicate) const {
1137
1126
}
1138
1127
1139
1128
void DecoderTableBuilder::emitPredicateTableEntry (unsigned EncodingID) const {
1129
+ const InstructionEncoding &Encoding = Encodings[EncodingID];
1140
1130
// Build up the predicate string.
1141
1131
SmallString<256 > Predicate;
1142
1132
raw_svector_ostream PS (Predicate);
1143
- if (!emitPredicateMatch (PS, EncodingID ))
1133
+ if (!emitPredicateMatch (PS, Encoding, Target. getName () ))
1144
1134
return ;
1145
1135
1146
1136
// Figure out the index into the predicate table for the predicate just
1147
1137
// computed.
1148
- unsigned PIdx = getPredicateIndex (PS.str ());
1138
+ unsigned PIdx = getPredicateIndex (PS.str (), TableInfo );
1149
1139
1150
1140
TableInfo.Table .insertOpcode (OPC_CheckPredicate);
1151
1141
TableInfo.Table .insertULEB128 (PIdx);
@@ -1191,7 +1181,7 @@ void DecoderTableBuilder::emitSingletonTableEntry(
1191
1181
// Check for soft failure of the match.
1192
1182
emitSoftFailTableEntry (EncodingID);
1193
1183
1194
- unsigned DIdx = getDecoderIndex (EncodingID );
1184
+ unsigned DIdx = getDecoderIndex (Encoding, TableInfo );
1195
1185
1196
1186
// Produce OPC_Decode or OPC_TryDecode opcode based on the information
1197
1187
// whether the instruction decoder is complete or not. If it is complete
0 commit comments