@@ -849,8 +849,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
849849
850850 // ULEB128 encoded start value.
851851 const char *ErrMsg = nullptr ;
852- unsigned Start = decodeULEB128 (Table.data () + Pos + 1 , nullptr ,
853- Table.data () + Table.size (), &ErrMsg);
852+ unsigned Start = decodeULEB128 (&*I, nullptr , &*E, &ErrMsg);
854853 assert (ErrMsg == nullptr && " ULEB128 value too large!" );
855854 emitULEB128 (I, OS);
856855
@@ -904,8 +903,7 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
904903 ++I;
905904 // Decode the Opcode value.
906905 const char *ErrMsg = nullptr ;
907- unsigned Opc = decodeULEB128 (Table.data () + Pos + 1 , nullptr ,
908- Table.data () + Table.size (), &ErrMsg);
906+ unsigned Opc = decodeULEB128 (&*I, nullptr , &*E, &ErrMsg);
909907 assert (ErrMsg == nullptr && " ULEB128 value too large!" );
910908
911909 OS << Indent << " MCD::OPC_" << (IsTry ? " Try" : " " ) << " Decode, " ;
@@ -935,30 +933,23 @@ void DecoderEmitter::emitTable(formatted_raw_ostream &OS, DecoderTable &Table,
935933 case MCD::OPC_SoftFail: {
936934 ++I;
937935 OS << Indent << " MCD::OPC_SoftFail" ;
938- // Positive mask
939- uint64_t Value = 0 ;
940- unsigned Shift = 0 ;
941- do {
942- OS << " , " << (unsigned )*I;
943- Value += ((uint64_t )(*I & 0x7f )) << Shift;
944- Shift += 7 ;
945- } while (*I++ >= 128 );
946- if (Value > 127 ) {
936+ // Decode the positive mask.
937+ const char *ErrMsg = nullptr ;
938+ uint64_t PositiveMask = decodeULEB128 (&*I, nullptr , &*E, &ErrMsg);
939+ assert (ErrMsg == nullptr && " ULEB128 value too large!" );
940+ emitULEB128 (I, OS);
941+ if (PositiveMask > 127 ) {
947942 OS << " /* 0x" ;
948- OS.write_hex (Value );
943+ OS.write_hex (PositiveMask );
949944 OS << " */" ;
950945 }
951- // Negative mask
952- Value = 0 ;
953- Shift = 0 ;
954- do {
955- OS << " , " << (unsigned )*I;
956- Value += ((uint64_t )(*I & 0x7f )) << Shift;
957- Shift += 7 ;
958- } while (*I++ >= 128 );
959- if (Value > 127 ) {
946+ // Decode the negative mask.
947+ uint64_t NegativeMask = decodeULEB128 (&*I, nullptr , &*E, &ErrMsg);
948+ assert (ErrMsg == nullptr && " ULEB128 value too large!" );
949+ emitULEB128 (I, OS);
950+ if (NegativeMask > 127 ) {
960951 OS << " /* 0x" ;
961- OS.write_hex (Value );
952+ OS.write_hex (NegativeMask );
962953 OS << " */" ;
963954 }
964955 OS << " ,\n " ;
0 commit comments