@@ -105,32 +105,37 @@ static const MCPhysReg MR23DecoderTable[] = {Xtensa::M2, Xtensa::M3};
105105static DecodeStatus DecodeMR23RegisterClass (MCInst &Inst, uint64_t RegNo,
106106 uint64_t Address,
107107 const void *Decoder) {
108- if (RegNo != 2 && RegNo != 3 )
108+ if (RegNo != 0 && RegNo != 1 )
109109 return MCDisassembler::Fail;
110110
111- MCPhysReg Reg = MR23DecoderTable[RegNo - 2 ];
111+ MCPhysReg Reg = MR23DecoderTable[RegNo];
112112 Inst.addOperand (MCOperand::createReg (Reg));
113113 return MCDisassembler::Success;
114114}
115115
116- const MCPhysReg SRDecoderTable[] = {
117- Xtensa::LBEG, 0 , Xtensa::LEND, 1 , Xtensa::LCOUNT, 2 ,
118- Xtensa::SAR, 3 , Xtensa::BREG, 4 , Xtensa::SAR, 3 ,
119- Xtensa::LITBASE, 5 , Xtensa::ACCLO, 16 , Xtensa::ACCHI, 17 ,
120- Xtensa::M0, 32 , Xtensa::M1, 33 , Xtensa::M2, 34 ,
121- Xtensa::M3, 35 , Xtensa::WINDOWBASE, 72 , Xtensa::WINDOWSTART, 73 ,
122- Xtensa::MEMCTL, 97 , Xtensa::VECBASE, 231 , Xtensa::MISC0, 244 ,
123- Xtensa::MISC1, 345 , Xtensa::MISC2, 246 , Xtensa::MISC3, 247 };
116+ struct DecodeRegister {
117+ MCPhysReg Reg;
118+ uint32_t RegNo;
119+ };
120+
121+ const DecodeRegister SRDecoderTable[] = {
122+ {Xtensa::LBEG, 0 }, {Xtensa::LEND, 1 }, {Xtensa::LCOUNT, 2 },
123+ {Xtensa::SAR, 3 }, {Xtensa::BREG, 4 }, {Xtensa::SAR, 3 },
124+ {Xtensa::LITBASE, 5 }, {Xtensa::ACCLO, 16 }, {Xtensa::ACCHI, 17 },
125+ {Xtensa::M0, 32 }, {Xtensa::M1, 33 }, {Xtensa::M2, 34 },
126+ {Xtensa::M3, 35 }, {Xtensa::WINDOWBASE, 72 }, {Xtensa::WINDOWSTART, 73 },
127+ {Xtensa::MEMCTL, 97 }, {Xtensa::VECBASE, 231 }, {Xtensa::MISC0, 244 },
128+ {Xtensa::MISC1, 245 }, {Xtensa::MISC2, 246 }, {Xtensa::MISC3, 247 }};
124129
125130static DecodeStatus DecodeSRRegisterClass (MCInst &Inst, uint64_t RegNo,
126131 uint64_t Address,
127132 const MCDisassembler *Decoder) {
128133 if (RegNo > 255 )
129134 return MCDisassembler::Fail;
130135
131- for (unsigned i = 0 ; i < std::size (SRDecoderTable); i += 2 ) {
132- if (SRDecoderTable[i + 1 ] == RegNo) {
133- MCPhysReg Reg = SRDecoderTable[i];
136+ for (unsigned i = 0 ; i < std::size (SRDecoderTable); i++ ) {
137+ if (SRDecoderTable[i]. RegNo == RegNo) {
138+ MCPhysReg Reg = SRDecoderTable[i]. Reg ;
134139
135140 if (!Xtensa::checkRegister (Reg,
136141 Decoder->getSubtargetInfo ().getFeatureBits ()))
0 commit comments