@@ -1110,9 +1110,9 @@ struct RISCVOperand final : public MCParsedAsmOperand {
1110
1110
}
1111
1111
1112
1112
static std::unique_ptr<RISCVOperand>
1113
- createReg (unsigned RegNo , SMLoc S, SMLoc E, bool IsGPRAsFPR = false ) {
1113
+ createReg (MCRegister Reg , SMLoc S, SMLoc E, bool IsGPRAsFPR = false ) {
1114
1114
auto Op = std::make_unique<RISCVOperand>(KindTy::Register);
1115
- Op->Reg .RegNum = RegNo ;
1115
+ Op->Reg .RegNum = Reg. id () ;
1116
1116
Op->Reg .IsGPRAsFPR = IsGPRAsFPR;
1117
1117
Op->StartLoc = S;
1118
1118
Op->EndLoc = E;
@@ -1181,11 +1181,11 @@ struct RISCVOperand final : public MCParsedAsmOperand {
1181
1181
return Op;
1182
1182
}
1183
1183
1184
- static std::unique_ptr<RISCVOperand> createRegReg (unsigned Reg1No ,
1185
- unsigned Reg2No , SMLoc S) {
1184
+ static std::unique_ptr<RISCVOperand> createRegReg (MCRegister Reg1 ,
1185
+ MCRegister Reg2 , SMLoc S) {
1186
1186
auto Op = std::make_unique<RISCVOperand>(KindTy::RegReg);
1187
- Op->RegReg .Reg1 = Reg1No ;
1188
- Op->RegReg .Reg2 = Reg2No ;
1187
+ Op->RegReg .Reg1 = Reg1. id () ;
1188
+ Op->RegReg .Reg2 = Reg2. id () ;
1189
1189
Op->StartLoc = S;
1190
1190
Op->EndLoc = S;
1191
1191
return Op;
@@ -1310,7 +1310,7 @@ static MCRegister convertVRToVRMx(const MCRegisterInfo &RI, MCRegister Reg,
1310
1310
else if (Kind == MCK_VRM8)
1311
1311
RegClassID = RISCV::VRM8RegClassID;
1312
1312
else
1313
- return 0 ;
1313
+ return MCRegister () ;
1314
1314
return RI.getMatchingSuperReg (Reg, RISCV::sub_vrm1_0,
1315
1315
&RISCVMCRegisterClasses[RegClassID]);
1316
1316
}
@@ -1661,9 +1661,9 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
1661
1661
}
1662
1662
1663
1663
// Attempts to match Name as a register (either using the default name or
1664
- // alternative ABI names), setting RegNo to the matching register. Upon
1665
- // failure, returns a non-valid MCRegister. If IsRVE, then registers x16-x31
1666
- // will be rejected.
1664
+ // alternative ABI names), returning the matching register. Upon failure,
1665
+ // returns a non-valid MCRegister. If IsRVE, then registers x16-x31 will be
1666
+ // rejected.
1667
1667
MCRegister RISCVAsmParser::matchRegisterNameHelper (StringRef Name) const {
1668
1668
MCRegister Reg = MatchRegisterName (Name);
1669
1669
// The 16-/32- and 64-bit FPRs have the same asm name. Check that the initial
@@ -1676,7 +1676,7 @@ MCRegister RISCVAsmParser::matchRegisterNameHelper(StringRef Name) const {
1676
1676
if (!Reg)
1677
1677
Reg = MatchRegisterAltName (Name);
1678
1678
if (isRVE () && Reg >= RISCV::X16 && Reg <= RISCV::X31)
1679
- Reg = RISCV::NoRegister ;
1679
+ Reg = MCRegister () ;
1680
1680
return Reg;
1681
1681
}
1682
1682
@@ -1727,9 +1727,9 @@ ParseStatus RISCVAsmParser::parseRegister(OperandVector &Operands,
1727
1727
return ParseStatus::NoMatch;
1728
1728
case AsmToken::Identifier:
1729
1729
StringRef Name = getLexer ().getTok ().getIdentifier ();
1730
- MCRegister RegNo = matchRegisterNameHelper (Name);
1730
+ MCRegister Reg = matchRegisterNameHelper (Name);
1731
1731
1732
- if (!RegNo ) {
1732
+ if (!Reg ) {
1733
1733
if (HadParens)
1734
1734
getLexer ().UnLex (LParen);
1735
1735
return ParseStatus::NoMatch;
@@ -1739,7 +1739,7 @@ ParseStatus RISCVAsmParser::parseRegister(OperandVector &Operands,
1739
1739
SMLoc S = getLoc ();
1740
1740
SMLoc E = SMLoc::getFromPointer (S.getPointer () + Name.size ());
1741
1741
getLexer ().Lex ();
1742
- Operands.push_back (RISCVOperand::createReg (RegNo , S, E));
1742
+ Operands.push_back (RISCVOperand::createReg (Reg , S, E));
1743
1743
}
1744
1744
1745
1745
if (HadParens) {
@@ -2305,16 +2305,16 @@ ParseStatus RISCVAsmParser::parseMaskReg(OperandVector &Operands) {
2305
2305
StringRef Name = getLexer ().getTok ().getIdentifier ();
2306
2306
if (!Name.consume_back (" .t" ))
2307
2307
return Error (getLoc (), " expected '.t' suffix" );
2308
- MCRegister RegNo = matchRegisterNameHelper (Name);
2308
+ MCRegister Reg = matchRegisterNameHelper (Name);
2309
2309
2310
- if (!RegNo )
2310
+ if (!Reg )
2311
2311
return ParseStatus::NoMatch;
2312
- if (RegNo != RISCV::V0)
2312
+ if (Reg != RISCV::V0)
2313
2313
return ParseStatus::NoMatch;
2314
2314
SMLoc S = getLoc ();
2315
2315
SMLoc E = SMLoc::getFromPointer (S.getPointer () + Name.size ());
2316
2316
getLexer ().Lex ();
2317
- Operands.push_back (RISCVOperand::createReg (RegNo , S, E));
2317
+ Operands.push_back (RISCVOperand::createReg (Reg , S, E));
2318
2318
return ParseStatus::Success;
2319
2319
}
2320
2320
@@ -2323,15 +2323,15 @@ ParseStatus RISCVAsmParser::parseGPRAsFPR(OperandVector &Operands) {
2323
2323
return ParseStatus::NoMatch;
2324
2324
2325
2325
StringRef Name = getLexer ().getTok ().getIdentifier ();
2326
- MCRegister RegNo = matchRegisterNameHelper (Name);
2326
+ MCRegister Reg = matchRegisterNameHelper (Name);
2327
2327
2328
- if (!RegNo )
2328
+ if (!Reg )
2329
2329
return ParseStatus::NoMatch;
2330
2330
SMLoc S = getLoc ();
2331
2331
SMLoc E = SMLoc::getFromPointer (S.getPointer () + Name.size ());
2332
2332
getLexer ().Lex ();
2333
2333
Operands.push_back (RISCVOperand::createReg (
2334
- RegNo , S, E, !getSTI ().hasFeature (RISCV::FeatureStdExtF)));
2334
+ Reg , S, E, !getSTI ().hasFeature (RISCV::FeatureStdExtF)));
2335
2335
return ParseStatus::Success;
2336
2336
}
2337
2337
@@ -2354,24 +2354,24 @@ ParseStatus RISCVAsmParser::parseGPRPair(OperandVector &Operands,
2354
2354
return ParseStatus::NoMatch;
2355
2355
2356
2356
StringRef Name = getLexer ().getTok ().getIdentifier ();
2357
- MCRegister RegNo = matchRegisterNameHelper (Name);
2357
+ MCRegister Reg = matchRegisterNameHelper (Name);
2358
2358
2359
- if (!RegNo )
2359
+ if (!Reg )
2360
2360
return ParseStatus::NoMatch;
2361
2361
2362
- if (!RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains (RegNo ))
2362
+ if (!RISCVMCRegisterClasses[RISCV::GPRRegClassID].contains (Reg ))
2363
2363
return ParseStatus::NoMatch;
2364
2364
2365
- if ((RegNo - RISCV::X0) & 1 )
2365
+ if ((Reg - RISCV::X0) & 1 )
2366
2366
return TokError (" register must be even" );
2367
2367
2368
2368
SMLoc S = getLoc ();
2369
2369
SMLoc E = SMLoc::getFromPointer (S.getPointer () + Name.size ());
2370
2370
getLexer ().Lex ();
2371
2371
2372
2372
const MCRegisterInfo *RI = getContext ().getRegisterInfo ();
2373
- unsigned Pair = RI->getMatchingSuperReg (
2374
- RegNo , RISCV::sub_gpr_even,
2373
+ MCRegister Pair = RI->getMatchingSuperReg (
2374
+ Reg , RISCV::sub_gpr_even,
2375
2375
&RISCVMCRegisterClasses[RISCV::GPRPairRegClassID]);
2376
2376
Operands.push_back (RISCVOperand::createReg (Pair, S, E));
2377
2377
return ParseStatus::Success;
@@ -2629,7 +2629,7 @@ ParseStatus RISCVAsmParser::parseReglist(OperandVector &Operands) {
2629
2629
if (getLexer ().isNot (AsmToken::Identifier))
2630
2630
return Error (getLoc (), " invalid register" );
2631
2631
EndName = getLexer ().getTok ().getIdentifier ();
2632
- if (MatchRegisterName (EndName) == RISCV::NoRegister )
2632
+ if (! MatchRegisterName (EndName))
2633
2633
return Error (getLoc (), " invalid register" );
2634
2634
getLexer ().Lex ();
2635
2635
}
@@ -2644,7 +2644,7 @@ ParseStatus RISCVAsmParser::parseReglist(OperandVector &Operands) {
2644
2644
if (parseToken (AsmToken::RCurly, " register list must end with '}'" ))
2645
2645
return ParseStatus::Failure;
2646
2646
2647
- if (RegEnd == RISCV::NoRegister )
2647
+ if (! RegEnd)
2648
2648
RegEnd = RegStart;
2649
2649
2650
2650
auto Encode = RISCVZC::encodeRlist (RegEnd, IsEABI);
@@ -3356,7 +3356,7 @@ void RISCVAsmParser::emitVMSGE(MCInst &Inst, unsigned Opcode, SMLoc IDLoc,
3356
3356
.addOperand (Inst.getOperand (0 ))
3357
3357
.addOperand (Inst.getOperand (1 ))
3358
3358
.addOperand (Inst.getOperand (2 ))
3359
- .addReg (RISCV::NoRegister )
3359
+ .addReg (MCRegister () )
3360
3360
.setLoc (IDLoc));
3361
3361
emitToStreamer (Out, MCInstBuilder (RISCV::VMNAND_MM)
3362
3362
.addOperand (Inst.getOperand (0 ))
@@ -3395,7 +3395,7 @@ void RISCVAsmParser::emitVMSGE(MCInst &Inst, unsigned Opcode, SMLoc IDLoc,
3395
3395
.addOperand (Inst.getOperand (1 ))
3396
3396
.addOperand (Inst.getOperand (2 ))
3397
3397
.addOperand (Inst.getOperand (3 ))
3398
- .addReg (RISCV::NoRegister )
3398
+ .addReg (MCRegister () )
3399
3399
.setLoc (IDLoc));
3400
3400
emitToStreamer (Out, MCInstBuilder (RISCV::VMANDN_MM)
3401
3401
.addOperand (Inst.getOperand (0 ))
@@ -3414,7 +3414,7 @@ void RISCVAsmParser::emitVMSGE(MCInst &Inst, unsigned Opcode, SMLoc IDLoc,
3414
3414
.addOperand (Inst.getOperand (1 ))
3415
3415
.addOperand (Inst.getOperand (2 ))
3416
3416
.addOperand (Inst.getOperand (3 ))
3417
- .addReg (RISCV::NoRegister )
3417
+ .addReg (MCRegister () )
3418
3418
.setLoc (IDLoc));
3419
3419
emitToStreamer (Out, MCInstBuilder (RISCV::VMANDN_MM)
3420
3420
.addOperand (Inst.getOperand (1 ))
@@ -3461,8 +3461,7 @@ bool RISCVAsmParser::checkPseudoTLSDESCCall(MCInst &Inst,
3461
3461
}
3462
3462
3463
3463
std::unique_ptr<RISCVOperand> RISCVAsmParser::defaultMaskRegOp () const {
3464
- return RISCVOperand::createReg (RISCV::NoRegister, llvm::SMLoc (),
3465
- llvm::SMLoc ());
3464
+ return RISCVOperand::createReg (MCRegister (), llvm::SMLoc (), llvm::SMLoc ());
3466
3465
}
3467
3466
3468
3467
std::unique_ptr<RISCVOperand> RISCVAsmParser::defaultFRMArgOp () const {
@@ -3481,8 +3480,8 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
3481
3480
3482
3481
if (Opcode == RISCV::PseudoVMSGEU_VX_M_T ||
3483
3482
Opcode == RISCV::PseudoVMSGE_VX_M_T) {
3484
- unsigned DestReg = Inst.getOperand (0 ).getReg ();
3485
- unsigned TempReg = Inst.getOperand (1 ).getReg ();
3483
+ MCRegister DestReg = Inst.getOperand (0 ).getReg ();
3484
+ MCRegister TempReg = Inst.getOperand (1 ).getReg ();
3486
3485
if (DestReg == TempReg) {
3487
3486
SMLoc Loc = Operands.back ()->getStartLoc ();
3488
3487
return Error (Loc, " the temporary vector register cannot be the same as "
@@ -3492,9 +3491,9 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
3492
3491
3493
3492
if (Opcode == RISCV::TH_LDD || Opcode == RISCV::TH_LWUD ||
3494
3493
Opcode == RISCV::TH_LWD) {
3495
- unsigned Rd1 = Inst.getOperand (0 ).getReg ();
3496
- unsigned Rd2 = Inst.getOperand (1 ).getReg ();
3497
- unsigned Rs1 = Inst.getOperand (2 ).getReg ();
3494
+ MCRegister Rd1 = Inst.getOperand (0 ).getReg ();
3495
+ MCRegister Rd2 = Inst.getOperand (1 ).getReg ();
3496
+ MCRegister Rs1 = Inst.getOperand (2 ).getReg ();
3498
3497
// The encoding with rd1 == rd2 == rs1 is reserved for XTHead load pair.
3499
3498
if (Rs1 == Rd1 && Rs1 == Rd2) {
3500
3499
SMLoc Loc = Operands[1 ]->getStartLoc ();
@@ -3503,8 +3502,8 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
3503
3502
}
3504
3503
3505
3504
if (Opcode == RISCV::CM_MVSA01) {
3506
- unsigned Rd1 = Inst.getOperand (0 ).getReg ();
3507
- unsigned Rd2 = Inst.getOperand (1 ).getReg ();
3505
+ MCRegister Rd1 = Inst.getOperand (0 ).getReg ();
3506
+ MCRegister Rd2 = Inst.getOperand (1 ).getReg ();
3508
3507
if (Rd1 == Rd2) {
3509
3508
SMLoc Loc = Operands[1 ]->getStartLoc ();
3510
3509
return Error (Loc, " rs1 and rs2 must be different" );
@@ -3531,24 +3530,24 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
3531
3530
if (Opcode == RISCV::VC_V_XVW || Opcode == RISCV::VC_V_IVW ||
3532
3531
Opcode == RISCV::VC_V_FVW || Opcode == RISCV::VC_V_VVW) {
3533
3532
// Operands Opcode, Dst, uimm, Dst, Rs2, Rs1 for VC_V_XVW.
3534
- unsigned VCIXDst = Inst.getOperand (0 ).getReg ();
3533
+ MCRegister VCIXDst = Inst.getOperand (0 ).getReg ();
3535
3534
SMLoc VCIXDstLoc = Operands[2 ]->getStartLoc ();
3536
3535
if (MCID.TSFlags & RISCVII::VS1Constraint) {
3537
- unsigned VCIXRs1 = Inst.getOperand (Inst.getNumOperands () - 1 ).getReg ();
3536
+ MCRegister VCIXRs1 = Inst.getOperand (Inst.getNumOperands () - 1 ).getReg ();
3538
3537
if (VCIXDst == VCIXRs1)
3539
3538
return Error (VCIXDstLoc, " the destination vector register group cannot"
3540
3539
" overlap the source vector register group" );
3541
3540
}
3542
3541
if (MCID.TSFlags & RISCVII::VS2Constraint) {
3543
- unsigned VCIXRs2 = Inst.getOperand (Inst.getNumOperands () - 2 ).getReg ();
3542
+ MCRegister VCIXRs2 = Inst.getOperand (Inst.getNumOperands () - 2 ).getReg ();
3544
3543
if (VCIXDst == VCIXRs2)
3545
3544
return Error (VCIXDstLoc, " the destination vector register group cannot"
3546
3545
" overlap the source vector register group" );
3547
3546
}
3548
3547
return false ;
3549
3548
}
3550
3549
3551
- unsigned DestReg = Inst.getOperand (0 ).getReg ();
3550
+ MCRegister DestReg = Inst.getOperand (0 ).getReg ();
3552
3551
unsigned Offset = 0 ;
3553
3552
int TiedOp = MCID.getOperandConstraint (1 , MCOI::TIED_TO);
3554
3553
if (TiedOp == 0 )
@@ -3557,13 +3556,13 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
3557
3556
// Operands[1] will be the first operand, DestReg.
3558
3557
SMLoc Loc = Operands[1 ]->getStartLoc ();
3559
3558
if (MCID.TSFlags & RISCVII::VS2Constraint) {
3560
- unsigned CheckReg = Inst.getOperand (Offset + 1 ).getReg ();
3559
+ MCRegister CheckReg = Inst.getOperand (Offset + 1 ).getReg ();
3561
3560
if (DestReg == CheckReg)
3562
3561
return Error (Loc, " the destination vector register group cannot overlap"
3563
3562
" the source vector register group" );
3564
3563
}
3565
3564
if ((MCID.TSFlags & RISCVII::VS1Constraint) && Inst.getOperand (Offset + 2 ).isReg ()) {
3566
- unsigned CheckReg = Inst.getOperand (Offset + 2 ).getReg ();
3565
+ MCRegister CheckReg = Inst.getOperand (Offset + 2 ).getReg ();
3567
3566
if (DestReg == CheckReg)
3568
3567
return Error (Loc, " the destination vector register group cannot overlap"
3569
3568
" the source vector register group" );
@@ -3582,8 +3581,8 @@ bool RISCVAsmParser::validateInstruction(MCInst &Inst,
3582
3581
// same. For example, "viota.m v0, v2" is "viota.m v0, v2, NoRegister"
3583
3582
// actually. We need to check the last operand to ensure whether it is
3584
3583
// masked or not.
3585
- unsigned CheckReg = Inst.getOperand (Inst.getNumOperands () - 1 ).getReg ();
3586
- assert ((CheckReg == RISCV::V0 || CheckReg == RISCV::NoRegister ) &&
3584
+ MCRegister CheckReg = Inst.getOperand (Inst.getNumOperands () - 1 ).getReg ();
3585
+ assert ((CheckReg == RISCV::V0 || ! CheckReg) &&
3587
3586
" Unexpected register for mask operand" );
3588
3587
3589
3588
if (DestReg == CheckReg)
0 commit comments