@@ -135,7 +135,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
135
135
136
136
// Helper to emit a combination of AUIPC and SecondOpcode. Used to implement
137
137
// helpers such as emitLoadLocalAddress and emitLoadAddress.
138
- void emitAuipcInstPair (MCOperand DestReg, MCOperand TmpReg,
138
+ void emitAuipcInstPair (MCRegister DestReg, MCRegister TmpReg,
139
139
const MCExpr *Symbol, RISCVMCExpr::Specifier VKHi,
140
140
unsigned SecondOpcode, SMLoc IDLoc, MCStreamer &Out);
141
141
@@ -3302,7 +3302,7 @@ void RISCVAsmParser::emitLoadImm(MCRegister DestReg, int64_t Value,
3302
3302
}
3303
3303
}
3304
3304
3305
- void RISCVAsmParser::emitAuipcInstPair (MCOperand DestReg, MCOperand TmpReg,
3305
+ void RISCVAsmParser::emitAuipcInstPair (MCRegister DestReg, MCRegister TmpReg,
3306
3306
const MCExpr *Symbol,
3307
3307
RISCVMCExpr::Specifier VKHi,
3308
3308
unsigned SecondOpcode, SMLoc IDLoc,
@@ -3316,15 +3316,15 @@ void RISCVAsmParser::emitAuipcInstPair(MCOperand DestReg, MCOperand TmpReg,
3316
3316
Out.emitLabel (TmpLabel);
3317
3317
3318
3318
const RISCVMCExpr *SymbolHi = RISCVMCExpr::create (Symbol, VKHi, Ctx);
3319
- emitToStreamer (
3320
- Out, MCInstBuilder (RISCV::AUIPC).addOperand (TmpReg).addExpr (SymbolHi));
3319
+ emitToStreamer (Out,
3320
+ MCInstBuilder (RISCV::AUIPC).addReg (TmpReg).addExpr (SymbolHi));
3321
3321
3322
3322
const MCExpr *RefToLinkTmpLabel = RISCVMCExpr::create (
3323
3323
MCSymbolRefExpr::create (TmpLabel, Ctx), RISCVMCExpr::VK_PCREL_LO, Ctx);
3324
3324
3325
3325
emitToStreamer (Out, MCInstBuilder (SecondOpcode)
3326
- .addOperand (DestReg)
3327
- .addOperand (TmpReg)
3326
+ .addReg (DestReg)
3327
+ .addReg (TmpReg)
3328
3328
.addExpr (RefToLinkTmpLabel));
3329
3329
}
3330
3330
@@ -3336,7 +3336,7 @@ void RISCVAsmParser::emitLoadLocalAddress(MCInst &Inst, SMLoc IDLoc,
3336
3336
// expands to
3337
3337
// TmpLabel: AUIPC rdest, %pcrel_hi(symbol)
3338
3338
// ADDI rdest, rdest, %pcrel_lo(TmpLabel)
3339
- MCOperand DestReg = Inst.getOperand (0 );
3339
+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
3340
3340
const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
3341
3341
emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_PCREL_HI,
3342
3342
RISCV::ADDI, IDLoc, Out);
@@ -3350,7 +3350,7 @@ void RISCVAsmParser::emitLoadGlobalAddress(MCInst &Inst, SMLoc IDLoc,
3350
3350
// expands to
3351
3351
// TmpLabel: AUIPC rdest, %got_pcrel_hi(symbol)
3352
3352
// Lx rdest, %pcrel_lo(TmpLabel)(rdest)
3353
- MCOperand DestReg = Inst.getOperand (0 );
3353
+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
3354
3354
const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
3355
3355
unsigned SecondOpcode = isRV64 () ? RISCV::LD : RISCV::LW;
3356
3356
emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_GOT_HI,
@@ -3380,7 +3380,7 @@ void RISCVAsmParser::emitLoadTLSIEAddress(MCInst &Inst, SMLoc IDLoc,
3380
3380
// expands to
3381
3381
// TmpLabel: AUIPC rdest, %tls_ie_pcrel_hi(symbol)
3382
3382
// Lx rdest, %pcrel_lo(TmpLabel)(rdest)
3383
- MCOperand DestReg = Inst.getOperand (0 );
3383
+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
3384
3384
const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
3385
3385
unsigned SecondOpcode = isRV64 () ? RISCV::LD : RISCV::LW;
3386
3386
emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_TLS_GOT_HI,
@@ -3395,7 +3395,7 @@ void RISCVAsmParser::emitLoadTLSGDAddress(MCInst &Inst, SMLoc IDLoc,
3395
3395
// expands to
3396
3396
// TmpLabel: AUIPC rdest, %tls_gd_pcrel_hi(symbol)
3397
3397
// ADDI rdest, rdest, %pcrel_lo(TmpLabel)
3398
- MCOperand DestReg = Inst.getOperand (0 );
3398
+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
3399
3399
const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
3400
3400
emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_TLS_GD_HI,
3401
3401
RISCV::ADDI, IDLoc, Out);
@@ -3412,9 +3412,16 @@ void RISCVAsmParser::emitLoadStoreSymbol(MCInst &Inst, unsigned Opcode,
3412
3412
// TmpLabel: AUIPC tmp, %pcrel_hi(symbol)
3413
3413
// [S|L]X rd, %pcrel_lo(TmpLabel)(tmp)
3414
3414
unsigned DestRegOpIdx = HasTmpReg ? 1 : 0 ;
3415
- MCOperand DestReg = Inst.getOperand (DestRegOpIdx);
3415
+ MCRegister DestReg = Inst.getOperand (DestRegOpIdx). getReg ( );
3416
3416
unsigned SymbolOpIdx = HasTmpReg ? 2 : 1 ;
3417
- MCOperand TmpReg = Inst.getOperand (0 );
3417
+ MCRegister TmpReg = Inst.getOperand (0 ).getReg ();
3418
+
3419
+ // If TmpReg is a GPR pair, get the even register.
3420
+ if (RISCVMCRegisterClasses[RISCV::GPRPairRegClassID].contains (TmpReg)) {
3421
+ const MCRegisterInfo *RI = getContext ().getRegisterInfo ();
3422
+ TmpReg = RI->getSubReg (TmpReg, RISCV::sub_gpr_even);
3423
+ }
3424
+
3418
3425
const MCExpr *Symbol = Inst.getOperand (SymbolOpIdx).getExpr ();
3419
3426
emitAuipcInstPair (DestReg, TmpReg, Symbol, RISCVMCExpr::VK_PCREL_HI, Opcode,
3420
3427
IDLoc, Out);
@@ -3771,6 +3778,9 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
3771
3778
case RISCV::PseudoLD:
3772
3779
emitLoadStoreSymbol (Inst, RISCV::LD, IDLoc, Out, /* HasTmpReg=*/ false );
3773
3780
return false ;
3781
+ case RISCV::PseudoLD_RV32:
3782
+ emitLoadStoreSymbol (Inst, RISCV::LD_RV32, IDLoc, Out, /* HasTmpReg=*/ false );
3783
+ return false ;
3774
3784
case RISCV::PseudoFLH:
3775
3785
emitLoadStoreSymbol (Inst, RISCV::FLH, IDLoc, Out, /* HasTmpReg=*/ true );
3776
3786
return false ;
@@ -3795,6 +3805,9 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
3795
3805
case RISCV::PseudoSD:
3796
3806
emitLoadStoreSymbol (Inst, RISCV::SD, IDLoc, Out, /* HasTmpReg=*/ true );
3797
3807
return false ;
3808
+ case RISCV::PseudoSD_RV32:
3809
+ emitLoadStoreSymbol (Inst, RISCV::SD_RV32, IDLoc, Out, /* HasTmpReg=*/ true );
3810
+ return false ;
3798
3811
case RISCV::PseudoFSH:
3799
3812
emitLoadStoreSymbol (Inst, RISCV::FSH, IDLoc, Out, /* HasTmpReg=*/ true );
3800
3813
return false ;
0 commit comments