@@ -841,11 +841,11 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
841
841
OS << " /* " << Pos << " */" ;
842
842
OS.PadToColumn (12 );
843
843
844
- switch (*I) {
844
+ const uint8_t DecoderOp = *I++;
845
+ switch (DecoderOp) {
845
846
default :
846
- PrintFatalError (" invalid decode table opcode" );
847
+ PrintFatalError (" Invalid decode table opcode: " + Twine (DecoderOp) );
847
848
case MCD::OPC_ExtractField: {
848
- ++I;
849
849
OS << Indent << " MCD::OPC_ExtractField, " ;
850
850
851
851
// ULEB128 encoded start value.
@@ -862,7 +862,6 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
862
862
break ;
863
863
}
864
864
case MCD::OPC_FilterValue: {
865
- ++I;
866
865
OS << Indent << " MCD::OPC_FilterValue, " ;
867
866
// The filter value is ULEB128 encoded.
868
867
emitULEB128 (I, OS);
@@ -873,7 +872,6 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
873
872
break ;
874
873
}
875
874
case MCD::OPC_CheckField: {
876
- ++I;
877
875
OS << Indent << " MCD::OPC_CheckField, " ;
878
876
// ULEB128 encoded start value.
879
877
emitULEB128 (I, OS);
@@ -889,7 +887,6 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
889
887
break ;
890
888
}
891
889
case MCD::OPC_CheckPredicate: {
892
- ++I;
893
890
OS << Indent << " MCD::OPC_CheckPredicate, " ;
894
891
emitULEB128 (I, OS);
895
892
@@ -900,8 +897,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
900
897
}
901
898
case MCD::OPC_Decode:
902
899
case MCD::OPC_TryDecode: {
903
- bool IsTry = *I == MCD::OPC_TryDecode;
904
- ++I;
900
+ bool IsTry = DecoderOp == MCD::OPC_TryDecode;
905
901
// Decode the Opcode value.
906
902
const char *ErrMsg = nullptr ;
907
903
unsigned Opc = decodeULEB128 (&*I, nullptr , EndPtr, &ErrMsg);
@@ -932,7 +928,6 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
932
928
break ;
933
929
}
934
930
case MCD::OPC_SoftFail: {
935
- ++I;
936
931
OS << Indent << " MCD::OPC_SoftFail, " ;
937
932
// Decode the positive mask.
938
933
const char *ErrMsg = nullptr ;
@@ -952,7 +947,6 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
952
947
break ;
953
948
}
954
949
case MCD::OPC_Fail: {
955
- ++I;
956
950
OS << Indent << " MCD::OPC_Fail,\n " ;
957
951
break ;
958
952
}
@@ -2162,13 +2156,13 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2162
2156
DecodeStatus S = MCDisassembler::Success;
2163
2157
while (true) {
2164
2158
ptrdiff_t Loc = Ptr - DecodeTable;
2165
- switch (*Ptr) {
2159
+ switch (*Ptr++ ) {
2166
2160
default:
2167
2161
errs() << Loc << ": Unexpected decode table opcode!\n";
2168
2162
return MCDisassembler::Fail;
2169
2163
case MCD::OPC_ExtractField: {
2170
2164
// Decode the start value.
2171
- unsigned Start = decodeULEB128AndIncUnsafe(++ Ptr);
2165
+ unsigned Start = decodeULEB128AndIncUnsafe(Ptr);
2172
2166
unsigned Len = *Ptr++;)" ;
2173
2167
if (IsVarLenInst)
2174
2168
OS << " \n makeUp(insn, Start + Len);" ;
@@ -2180,7 +2174,7 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2180
2174
}
2181
2175
case MCD::OPC_FilterValue: {
2182
2176
// Decode the field value.
2183
- uint64_t Val = decodeULEB128AndIncUnsafe(++ Ptr);
2177
+ uint64_t Val = decodeULEB128AndIncUnsafe(Ptr);
2184
2178
bool Failed = Val != CurFieldValue;
2185
2179
// NumToSkip is a plain 24-bit integer.
2186
2180
unsigned NumToSkip = *Ptr++;
@@ -2198,7 +2192,7 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2198
2192
}
2199
2193
case MCD::OPC_CheckField: {
2200
2194
// Decode the start value.
2201
- unsigned Start = decodeULEB128AndIncUnsafe(++ Ptr);
2195
+ unsigned Start = decodeULEB128AndIncUnsafe(Ptr);
2202
2196
unsigned Len = *Ptr;)" ;
2203
2197
if (IsVarLenInst)
2204
2198
OS << " \n makeUp(insn, Start + Len);" ;
@@ -2226,7 +2220,7 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2226
2220
}
2227
2221
case MCD::OPC_CheckPredicate: {
2228
2222
// Decode the Predicate Index value.
2229
- unsigned PIdx = decodeULEB128AndIncUnsafe(++ Ptr);
2223
+ unsigned PIdx = decodeULEB128AndIncUnsafe(Ptr);
2230
2224
// NumToSkip is a plain 24-bit integer.
2231
2225
unsigned NumToSkip = *Ptr++;
2232
2226
NumToSkip |= (*Ptr++) << 8;
@@ -2242,7 +2236,7 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2242
2236
}
2243
2237
case MCD::OPC_Decode: {
2244
2238
// Decode the Opcode value.
2245
- unsigned Opc = decodeULEB128AndIncUnsafe(++ Ptr);
2239
+ unsigned Opc = decodeULEB128AndIncUnsafe(Ptr);
2246
2240
unsigned DecodeIdx = decodeULEB128AndIncUnsafe(Ptr);
2247
2241
2248
2242
MI.clear();
@@ -2263,7 +2257,7 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2263
2257
}
2264
2258
case MCD::OPC_TryDecode: {
2265
2259
// Decode the Opcode value.
2266
- unsigned Opc = decodeULEB128AndIncUnsafe(++ Ptr);
2260
+ unsigned Opc = decodeULEB128AndIncUnsafe(Ptr);
2267
2261
unsigned DecodeIdx = decodeULEB128AndIncUnsafe(Ptr);
2268
2262
// NumToSkip is a plain 24-bit integer.
2269
2263
unsigned NumToSkip = *Ptr++;
@@ -2296,7 +2290,7 @@ static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI,
2296
2290
}
2297
2291
case MCD::OPC_SoftFail: {
2298
2292
// Decode the mask values.
2299
- uint64_t PositiveMask = decodeULEB128AndIncUnsafe(++ Ptr);
2293
+ uint64_t PositiveMask = decodeULEB128AndIncUnsafe(Ptr);
2300
2294
uint64_t NegativeMask = decodeULEB128AndIncUnsafe(Ptr);
2301
2295
bool Fail = (insn & PositiveMask) != 0 || (~insn & NegativeMask) != 0;
2302
2296
if (Fail)
0 commit comments