Skip to content

Commit 39fbec0

Browse files
authored
[AArch64][llvm] Improve writeback reg handling for FEAT_MOPS (#167763)
As mentioned in comments for #164913, the `if()` statements here can't be externally triggered, since these writeback registers are passed in from the caller. So they should really be `assert()`s so it's obvious we don't need testcases for them, and more optimal.
1 parent fb2563d commit 39fbec0

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5923,21 +5923,15 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
59235923
case AArch64::CPYETWN:
59245924
case AArch64::CPYETRN:
59255925
case AArch64::CPYETN: {
5926-
MCRegister Xd_wb = Inst.getOperand(0).getReg();
5927-
MCRegister Xs_wb = Inst.getOperand(1).getReg();
5928-
MCRegister Xn_wb = Inst.getOperand(2).getReg();
5926+
// Xd_wb == op0, Xs_wb == op1, Xn_wb == op2
59295927
MCRegister Xd = Inst.getOperand(3).getReg();
59305928
MCRegister Xs = Inst.getOperand(4).getReg();
59315929
MCRegister Xn = Inst.getOperand(5).getReg();
5932-
if (Xd_wb != Xd)
5933-
return Error(Loc[0],
5934-
"invalid CPY instruction, Xd_wb and Xd do not match");
5935-
if (Xs_wb != Xs)
5936-
return Error(Loc[0],
5937-
"invalid CPY instruction, Xs_wb and Xs do not match");
5938-
if (Xn_wb != Xn)
5939-
return Error(Loc[0],
5940-
"invalid CPY instruction, Xn_wb and Xn do not match");
5930+
5931+
assert(Xd == Inst.getOperand(0).getReg() && "Xd_wb and Xd do not match");
5932+
assert(Xs == Inst.getOperand(1).getReg() && "Xs_wb and Xs do not match");
5933+
assert(Xn == Inst.getOperand(2).getReg() && "Xn_wb and Xn do not match");
5934+
59415935
if (Xd == Xs)
59425936
return Error(Loc[0], "invalid CPY instruction, destination and source"
59435937
" registers are the same");
@@ -5973,17 +5967,14 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
59735967
case AArch64::MOPSSETGET:
59745968
case AArch64::MOPSSETGEN:
59755969
case AArch64::MOPSSETGETN: {
5976-
MCRegister Xd_wb = Inst.getOperand(0).getReg();
5977-
MCRegister Xn_wb = Inst.getOperand(1).getReg();
5970+
// Xd_wb == op0, Xn_wb == op1
59785971
MCRegister Xd = Inst.getOperand(2).getReg();
59795972
MCRegister Xn = Inst.getOperand(3).getReg();
59805973
MCRegister Xm = Inst.getOperand(4).getReg();
5981-
if (Xd_wb != Xd)
5982-
return Error(Loc[0],
5983-
"invalid SET instruction, Xd_wb and Xd do not match");
5984-
if (Xn_wb != Xn)
5985-
return Error(Loc[0],
5986-
"invalid SET instruction, Xn_wb and Xn do not match");
5974+
5975+
assert(Xd == Inst.getOperand(0).getReg() && "Xd_wb and Xd do not match");
5976+
assert(Xn == Inst.getOperand(1).getReg() && "Xn_wb and Xn do not match");
5977+
59875978
if (Xd == Xn)
59885979
return Error(Loc[0], "invalid SET instruction, destination and size"
59895980
" registers are the same");
@@ -6007,16 +5998,13 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
60075998
case AArch64::SETGOET:
60085999
case AArch64::SETGOEN:
60096000
case AArch64::SETGOETN: {
6010-
MCRegister Xd_wb = Inst.getOperand(0).getReg();
6011-
MCRegister Xn_wb = Inst.getOperand(1).getReg();
6001+
// Xd_wb == op0, Xn_wb == op1
60126002
MCRegister Xd = Inst.getOperand(2).getReg();
60136003
MCRegister Xn = Inst.getOperand(3).getReg();
6014-
if (Xd_wb != Xd)
6015-
return Error(Loc[0],
6016-
"invalid SET instruction, Xd_wb and Xd do not match");
6017-
if (Xn_wb != Xn)
6018-
return Error(Loc[0],
6019-
"invalid SET instruction, Xn_wb and Xn do not match");
6004+
6005+
assert(Xd == Inst.getOperand(0).getReg() && "Xd_wb and Xd do not match");
6006+
assert(Xn == Inst.getOperand(1).getReg() && "Xn_wb and Xn do not match");
6007+
60206008
if (Xd == Xn)
60216009
return Error(Loc[0], "invalid SET instruction, destination and size"
60226010
" registers are the same");

0 commit comments

Comments
 (0)