@@ -135,7 +135,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
135135
136136 // Helper to emit a combination of AUIPC and SecondOpcode. Used to implement
137137 // helpers such as emitLoadLocalAddress and emitLoadAddress.
138- void emitAuipcInstPair (MCOperand DestReg, MCOperand TmpReg,
138+ void emitAuipcInstPair (MCRegister DestReg, MCRegister TmpReg,
139139 const MCExpr *Symbol, RISCVMCExpr::Specifier VKHi,
140140 unsigned SecondOpcode, SMLoc IDLoc, MCStreamer &Out);
141141
@@ -3302,7 +3302,7 @@ void RISCVAsmParser::emitLoadImm(MCRegister DestReg, int64_t Value,
33023302 }
33033303}
33043304
3305- void RISCVAsmParser::emitAuipcInstPair (MCOperand DestReg, MCOperand TmpReg,
3305+ void RISCVAsmParser::emitAuipcInstPair (MCRegister DestReg, MCRegister TmpReg,
33063306 const MCExpr *Symbol,
33073307 RISCVMCExpr::Specifier VKHi,
33083308 unsigned SecondOpcode, SMLoc IDLoc,
@@ -3316,15 +3316,15 @@ void RISCVAsmParser::emitAuipcInstPair(MCOperand DestReg, MCOperand TmpReg,
33163316 Out.emitLabel (TmpLabel);
33173317
33183318 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));
33213321
33223322 const MCExpr *RefToLinkTmpLabel = RISCVMCExpr::create (
33233323 MCSymbolRefExpr::create (TmpLabel, Ctx), RISCVMCExpr::VK_PCREL_LO, Ctx);
33243324
33253325 emitToStreamer (Out, MCInstBuilder (SecondOpcode)
3326- .addOperand (DestReg)
3327- .addOperand (TmpReg)
3326+ .addReg (DestReg)
3327+ .addReg (TmpReg)
33283328 .addExpr (RefToLinkTmpLabel));
33293329}
33303330
@@ -3336,7 +3336,7 @@ void RISCVAsmParser::emitLoadLocalAddress(MCInst &Inst, SMLoc IDLoc,
33363336 // expands to
33373337 // TmpLabel: AUIPC rdest, %pcrel_hi(symbol)
33383338 // ADDI rdest, rdest, %pcrel_lo(TmpLabel)
3339- MCOperand DestReg = Inst.getOperand (0 );
3339+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
33403340 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
33413341 emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_PCREL_HI,
33423342 RISCV::ADDI, IDLoc, Out);
@@ -3350,7 +3350,7 @@ void RISCVAsmParser::emitLoadGlobalAddress(MCInst &Inst, SMLoc IDLoc,
33503350 // expands to
33513351 // TmpLabel: AUIPC rdest, %got_pcrel_hi(symbol)
33523352 // Lx rdest, %pcrel_lo(TmpLabel)(rdest)
3353- MCOperand DestReg = Inst.getOperand (0 );
3353+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
33543354 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
33553355 unsigned SecondOpcode = isRV64 () ? RISCV::LD : RISCV::LW;
33563356 emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_GOT_HI,
@@ -3380,7 +3380,7 @@ void RISCVAsmParser::emitLoadTLSIEAddress(MCInst &Inst, SMLoc IDLoc,
33803380 // expands to
33813381 // TmpLabel: AUIPC rdest, %tls_ie_pcrel_hi(symbol)
33823382 // Lx rdest, %pcrel_lo(TmpLabel)(rdest)
3383- MCOperand DestReg = Inst.getOperand (0 );
3383+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
33843384 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
33853385 unsigned SecondOpcode = isRV64 () ? RISCV::LD : RISCV::LW;
33863386 emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_TLS_GOT_HI,
@@ -3395,7 +3395,7 @@ void RISCVAsmParser::emitLoadTLSGDAddress(MCInst &Inst, SMLoc IDLoc,
33953395 // expands to
33963396 // TmpLabel: AUIPC rdest, %tls_gd_pcrel_hi(symbol)
33973397 // ADDI rdest, rdest, %pcrel_lo(TmpLabel)
3398- MCOperand DestReg = Inst.getOperand (0 );
3398+ MCRegister DestReg = Inst.getOperand (0 ). getReg ( );
33993399 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
34003400 emitAuipcInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_TLS_GD_HI,
34013401 RISCV::ADDI, IDLoc, Out);
@@ -3412,9 +3412,16 @@ void RISCVAsmParser::emitLoadStoreSymbol(MCInst &Inst, unsigned Opcode,
34123412 // TmpLabel: AUIPC tmp, %pcrel_hi(symbol)
34133413 // [S|L]X rd, %pcrel_lo(TmpLabel)(tmp)
34143414 unsigned DestRegOpIdx = HasTmpReg ? 1 : 0 ;
3415- MCOperand DestReg = Inst.getOperand (DestRegOpIdx);
3415+ MCRegister DestReg = Inst.getOperand (DestRegOpIdx). getReg ( );
34163416 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+
34183425 const MCExpr *Symbol = Inst.getOperand (SymbolOpIdx).getExpr ();
34193426 emitAuipcInstPair (DestReg, TmpReg, Symbol, RISCVMCExpr::VK_PCREL_HI, Opcode,
34203427 IDLoc, Out);
@@ -3771,6 +3778,9 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
37713778 case RISCV::PseudoLD:
37723779 emitLoadStoreSymbol (Inst, RISCV::LD, IDLoc, Out, /* HasTmpReg=*/ false );
37733780 return false ;
3781+ case RISCV::PseudoLD_RV32:
3782+ emitLoadStoreSymbol (Inst, RISCV::LD_RV32, IDLoc, Out, /* HasTmpReg=*/ false );
3783+ return false ;
37743784 case RISCV::PseudoFLH:
37753785 emitLoadStoreSymbol (Inst, RISCV::FLH, IDLoc, Out, /* HasTmpReg=*/ true );
37763786 return false ;
@@ -3795,6 +3805,9 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
37953805 case RISCV::PseudoSD:
37963806 emitLoadStoreSymbol (Inst, RISCV::SD, IDLoc, Out, /* HasTmpReg=*/ true );
37973807 return false ;
3808+ case RISCV::PseudoSD_RV32:
3809+ emitLoadStoreSymbol (Inst, RISCV::SD_RV32, IDLoc, Out, /* HasTmpReg=*/ true );
3810+ return false ;
37983811 case RISCV::PseudoFSH:
37993812 emitLoadStoreSymbol (Inst, RISCV::FSH, IDLoc, Out, /* HasTmpReg=*/ true );
38003813 return false ;
0 commit comments