Skip to content

Commit ca02ab4

Browse files
committed
fixup! [AArch64][llvm] Add instructions for FEAT_MOPS_GO
Adjust assembly so that `Rm` is ignored, since it is always 0b11111.
1 parent 114e418 commit ca02ab4

File tree

3 files changed

+65
-20
lines changed

3 files changed

+65
-20
lines changed

llvm/lib/Target/AArch64/AArch64InstrFormats.td

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12588,12 +12588,10 @@ class MOPSMemoryCopy<bits<2> opcode, bits<2> op1, bits<2> op2, string asm>
1258812588
class MOPSMemoryMove<bits<2> opcode, bits<2> op1, bits<2> op2, string asm>
1258912589
: MOPSMemoryCopyMoveBase<1, opcode, op1, op2, asm>;
1259012590

12591-
class MOPSMemorySetBase<bit isTagging, bits<2> opcode, bit op1, bit op2,
12592-
bit op3, string asm>
12593-
: I<(outs GPR64common:$Rd_wb, GPR64:$Rn_wb),
12594-
(ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm),
12595-
asm, "\t[$Rd]!, $Rn!, $Rm",
12596-
"$Rd = $Rd_wb,$Rn = $Rn_wb", []>,
12591+
class MOPSMemorySetBase<dag ins, string operands, bit isTagging, bits<2> opcode,
12592+
bit op1, bit op2, bit op3, string asm>
12593+
: I<(outs GPR64common:$Rd_wb, GPR64:$Rn_wb), ins,
12594+
asm, operands, "$Rd = $Rd_wb,$Rn = $Rn_wb", []>,
1259712595
Sched<[]> {
1259812596
bits<5> Rd;
1259912597
bits<5> Rn;
@@ -12610,22 +12608,28 @@ class MOPSMemorySetBase<bit isTagging, bits<2> opcode, bit op1, bit op2,
1261012608
let Inst{9-5} = Rn;
1261112609
let Inst{4-0} = Rd;
1261212610

12613-
let DecoderMethod = "DecodeSETMemOpInstruction";
1261412611
let mayLoad = 0;
1261512612
let mayStore = 1;
1261612613
}
1261712614

1261812615
class MOPSMemorySet<bits<2> opcode, bit op1, bit op2, bit op3, string asm>
12619-
: MOPSMemorySetBase<0, opcode, op1, op2, op3, asm>;
12616+
: MOPSMemorySetBase<(ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm),
12617+
"\t[$Rd]!, $Rn!, $Rm", 0, opcode, op1, op2, op3, asm> {
12618+
let DecoderMethod = "DecodeSETMemOpInstruction";
12619+
}
1262012620

1262112621
class MOPSMemorySetTagging<bits<2> opcode, bit op1, bit op2, bit op3, string asm>
12622-
: MOPSMemorySetBase<1, opcode, op1, op2, op3, asm>;
12622+
: MOPSMemorySetBase<(ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm),
12623+
"\t[$Rd]!, $Rn!, $Rm", 1, opcode, op1, op2, op3, asm> {
12624+
let DecoderMethod = "DecodeSETMemOpInstruction";
12625+
}
1262312626

1262412627
class MOPSGoMemorySetTagging<bits<2> opcode, bit op1, bit op2, bit op3, string asm>
12625-
: MOPSMemorySetBase<1, opcode, op1, op2, op3, asm> {
12626-
// No `Rm` operand is required, as all bits are set to 1
12627-
let AsmString = !strconcat(asm, "\t[$Rd]!, $Rn!");
12628+
: MOPSMemorySetBase<(ins GPR64common:$Rd, GPR64:$Rn),
12629+
"\t[$Rd]!, $Rn!", 1, opcode, op1, op2, op3, asm> {
12630+
// No `Rm` operand, as all bits must be set to 1
1262812631
let Inst{20-16} = 0b11111;
12632+
let DecoderMethod = "DecodeSETMemGoOpInstruction";
1262912633
}
1263012634

1263112635
multiclass MOPSMemoryCopyInsns<bits<2> opcode, string asm> {

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5972,7 +5972,29 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
59725972
case AArch64::MOPSSETGE:
59735973
case AArch64::MOPSSETGET:
59745974
case AArch64::MOPSSETGEN:
5975-
case AArch64::MOPSSETGETN:
5975+
case AArch64::MOPSSETGETN: {
5976+
MCRegister Xd_wb = Inst.getOperand(0).getReg();
5977+
MCRegister Xn_wb = Inst.getOperand(1).getReg();
5978+
MCRegister Xd = Inst.getOperand(2).getReg();
5979+
MCRegister Xn = Inst.getOperand(3).getReg();
5980+
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");
5987+
if (Xd == Xn)
5988+
return Error(Loc[0], "invalid SET instruction, destination and size"
5989+
" registers are the same");
5990+
if (Xd == Xm)
5991+
return Error(Loc[0], "invalid SET instruction, destination and source"
5992+
" registers are the same");
5993+
if (Xn == Xm)
5994+
return Error(Loc[0], "invalid SET instruction, source and size"
5995+
" registers are the same");
5996+
break;
5997+
}
59765998
case AArch64::SETGOP:
59775999
case AArch64::SETGOPT:
59786000
case AArch64::SETGOPN:
@@ -5989,7 +6011,6 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
59896011
MCRegister Xn_wb = Inst.getOperand(1).getReg();
59906012
MCRegister Xd = Inst.getOperand(2).getReg();
59916013
MCRegister Xn = Inst.getOperand(3).getReg();
5992-
MCRegister Xm = Inst.getOperand(4).getReg();
59936014
if (Xd_wb != Xd)
59946015
return Error(Loc[0],
59956016
"invalid SET instruction, Xd_wb and Xd do not match");
@@ -5999,12 +6020,6 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
59996020
if (Xd == Xn)
60006021
return Error(Loc[0], "invalid SET instruction, destination and size"
60016022
" registers are the same");
6002-
if (Xd == Xm)
6003-
return Error(Loc[0], "invalid SET instruction, destination and source"
6004-
" registers are the same");
6005-
if (Xn == Xm)
6006-
return Error(Loc[0], "invalid SET instruction, source and size"
6007-
" registers are the same");
60086023
break;
60096024
}
60106025
}

llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,32 @@ static DecodeStatus DecodeSETMemOpInstruction(MCInst &Inst, uint32_t insn,
15321532
return MCDisassembler::Success;
15331533
}
15341534

1535+
static DecodeStatus DecodeSETMemGoOpInstruction(MCInst &Inst, uint32_t insn,
1536+
uint64_t Addr,
1537+
const MCDisassembler *Decoder) {
1538+
unsigned Rd = fieldFromInstruction(insn, 0, 5);
1539+
unsigned Rn = fieldFromInstruction(insn, 5, 5);
1540+
1541+
// None of the registers may alias: if they do, then the instruction is not
1542+
// merely unpredictable but actually entirely unallocated.
1543+
if (Rd == Rn)
1544+
return MCDisassembler::Fail;
1545+
1546+
// Rd and Rn register operands are written back, so they appear
1547+
// twice in the operand list, once as outputs and once as inputs.
1548+
if (!DecodeSimpleRegisterClass<AArch64::GPR64commonRegClassID, 0, 31>(
1549+
Inst, Rd, Addr, Decoder) ||
1550+
!DecodeSimpleRegisterClass<AArch64::GPR64RegClassID, 0, 32>(
1551+
Inst, Rn, Addr, Decoder) ||
1552+
!DecodeSimpleRegisterClass<AArch64::GPR64commonRegClassID, 0, 31>(
1553+
Inst, Rd, Addr, Decoder) ||
1554+
!DecodeSimpleRegisterClass<AArch64::GPR64RegClassID, 0, 32>(
1555+
Inst, Rn, Addr, Decoder))
1556+
return MCDisassembler::Fail;
1557+
1558+
return MCDisassembler::Success;
1559+
}
1560+
15351561
static DecodeStatus DecodePRFMRegInstruction(MCInst &Inst, uint32_t insn,
15361562
uint64_t Addr,
15371563
const MCDisassembler *Decoder) {

0 commit comments

Comments
 (0)