@@ -216,62 +216,44 @@ void RISCVInstPrinter::printVTypeI(const MCInst *MI, unsigned OpNo,
216
216
RISCVVType::printVType (Imm, O);
217
217
}
218
218
219
+ // Print a Zcmp RList. If we are printing architectural register names rather
220
+ // than ABI register names, we need to print "{x1, x8-x9, x18-x27}" for all
221
+ // registers. Otherwise, we print "{ra, s0-s11}".
219
222
void RISCVInstPrinter::printRlist (const MCInst *MI, unsigned OpNo,
220
223
const MCSubtargetInfo &STI, raw_ostream &O) {
221
224
unsigned Imm = MI->getOperand (OpNo).getImm ();
222
225
O << " {" ;
223
- switch (Imm) {
224
- case RISCVZC::RLISTENCODE::RA:
225
- printRegName (O, RISCV::X1);
226
- break ;
227
- case RISCVZC::RLISTENCODE::RA_S0:
228
- printRegName (O, RISCV::X1);
229
- O << " , " ;
230
- printRegName (O, RISCV::X8);
231
- break ;
232
- case RISCVZC::RLISTENCODE::RA_S0_S1:
233
- printRegName (O, RISCV::X1);
234
- O << " , " ;
235
- printRegName (O, RISCV::X8);
236
- O << ' -' ;
237
- printRegName (O, RISCV::X9);
238
- break ;
239
- case RISCVZC::RLISTENCODE::RA_S0_S2:
240
- printRegName (O, RISCV::X1);
241
- O << " , " ;
242
- printRegName (O, RISCV::X8);
243
- O << ' -' ;
244
- if (ArchRegNames) {
245
- printRegName (O, RISCV::X9);
246
- O << " , " ;
247
- }
248
- printRegName (O, RISCV::X18);
249
- break ;
250
- case RISCVZC::RLISTENCODE::RA_S0_S3:
251
- case RISCVZC::RLISTENCODE::RA_S0_S4:
252
- case RISCVZC::RLISTENCODE::RA_S0_S5:
253
- case RISCVZC::RLISTENCODE::RA_S0_S6:
254
- case RISCVZC::RLISTENCODE::RA_S0_S7:
255
- case RISCVZC::RLISTENCODE::RA_S0_S8:
256
- case RISCVZC::RLISTENCODE::RA_S0_S9:
257
- case RISCVZC::RLISTENCODE::RA_S0_S11:
258
- printRegName (O, RISCV::X1);
226
+ printRegName (O, RISCV::X1);
227
+
228
+ if (Imm >= RISCVZC::RLISTENCODE::RA_S0) {
259
229
O << " , " ;
260
230
printRegName (O, RISCV::X8);
231
+ }
232
+
233
+ if (Imm >= RISCVZC::RLISTENCODE::RA_S0_S1) {
261
234
O << ' -' ;
262
- if (ArchRegNames) {
235
+ if (Imm == RISCVZC::RLISTENCODE::RA_S0_S1 || ArchRegNames)
263
236
printRegName (O, RISCV::X9);
237
+ }
238
+
239
+ if (Imm >= RISCVZC::RLISTENCODE::RA_S0_S2) {
240
+ if (ArchRegNames)
264
241
O << " , " ;
242
+ if (Imm == RISCVZC::RLISTENCODE::RA_S0_S2 || ArchRegNames)
265
243
printRegName (O, RISCV::X18);
244
+ }
245
+
246
+ if (Imm >= RISCVZC::RLISTENCODE::RA_S0_S3) {
247
+ if (ArchRegNames)
266
248
O << ' -' ;
267
- }
268
- printRegName (O, RISCV::X19 + (Imm == RISCVZC::RLISTENCODE::RA_S0_S11
269
- ? 8
270
- : Imm - RISCVZC::RLISTENCODE::RA_S0_S3));
271
- break ;
272
- default :
273
- llvm_unreachable (" invalid register list" );
249
+ unsigned Offset = (Imm - RISCVZC::RLISTENCODE::RA_S0_S3);
250
+ // Encodings for S3-S9 are contiguous. There is no encoding for S10, so we
251
+ // must skip to S11(X27).
252
+ if (Imm == RISCVZC::RLISTENCODE::RA_S0_S11)
253
+ ++Offset;
254
+ printRegName (O, RISCV::X19 + Offset);
274
255
}
256
+
275
257
O << " }" ;
276
258
}
277
259
0 commit comments