Skip to content

Commit ff4a270

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 28c4b64 commit ff4a270

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
@@ -12603,12 +12603,10 @@ class MOPSMemoryCopy<bits<2> opcode, bits<2> op1, bits<2> op2, string asm>
1260312603
class MOPSMemoryMove<bits<2> opcode, bits<2> op1, bits<2> op2, string asm>
1260412604
: MOPSMemoryCopyMoveBase<1, opcode, op1, op2, asm>;
1260512605

12606-
class MOPSMemorySetBase<bit isTagging, bits<2> opcode, bit op1, bit op2,
12607-
bit op3, string asm>
12608-
: I<(outs GPR64common:$Rd_wb, GPR64:$Rn_wb),
12609-
(ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm),
12610-
asm, "\t[$Rd]!, $Rn!, $Rm",
12611-
"$Rd = $Rd_wb,$Rn = $Rn_wb", []>,
12606+
class MOPSMemorySetBase<dag ins, string operands, bit isTagging, bits<2> opcode,
12607+
bit op1, bit op2, bit op3, string asm>
12608+
: I<(outs GPR64common:$Rd_wb, GPR64:$Rn_wb), ins,
12609+
asm, operands, "$Rd = $Rd_wb,$Rn = $Rn_wb", []>,
1261212610
Sched<[]> {
1261312611
bits<5> Rd;
1261412612
bits<5> Rn;
@@ -12625,22 +12623,28 @@ class MOPSMemorySetBase<bit isTagging, bits<2> opcode, bit op1, bit op2,
1262512623
let Inst{9-5} = Rn;
1262612624
let Inst{4-0} = Rd;
1262712625

12628-
let DecoderMethod = "DecodeSETMemOpInstruction";
1262912626
let mayLoad = 0;
1263012627
let mayStore = 1;
1263112628
}
1263212629

1263312630
class MOPSMemorySet<bits<2> opcode, bit op1, bit op2, bit op3, string asm>
12634-
: MOPSMemorySetBase<0, opcode, op1, op2, op3, asm>;
12631+
: MOPSMemorySetBase<(ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm),
12632+
"\t[$Rd]!, $Rn!, $Rm", 0, opcode, op1, op2, op3, asm> {
12633+
let DecoderMethod = "DecodeSETMemOpInstruction";
12634+
}
1263512635

1263612636
class MOPSMemorySetTagging<bits<2> opcode, bit op1, bit op2, bit op3, string asm>
12637-
: MOPSMemorySetBase<1, opcode, op1, op2, op3, asm>;
12637+
: MOPSMemorySetBase<(ins GPR64common:$Rd, GPR64:$Rn, GPR64:$Rm),
12638+
"\t[$Rd]!, $Rn!, $Rm", 1, opcode, op1, op2, op3, asm> {
12639+
let DecoderMethod = "DecodeSETMemOpInstruction";
12640+
}
1263812641

1263912642
class MOPSGoMemorySetTagging<bits<2> opcode, bit op1, bit op2, bit op3, string asm>
12640-
: MOPSMemorySetBase<1, opcode, op1, op2, op3, asm> {
12641-
// No `Rm` operand is required, as all bits are set to 1
12642-
let AsmString = !strconcat(asm, "\t[$Rd]!, $Rn!");
12643+
: MOPSMemorySetBase<(ins GPR64common:$Rd, GPR64:$Rn),
12644+
"\t[$Rd]!, $Rn!", 1, opcode, op1, op2, op3, asm> {
12645+
// No `Rm` operand, as all bits must be set to 1
1264312646
let Inst{20-16} = 0b11111;
12647+
let DecoderMethod = "DecodeSETMemGoOpInstruction";
1264412648
}
1264512649

1264612650
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
@@ -6051,7 +6051,29 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
60516051
case AArch64::MOPSSETGE:
60526052
case AArch64::MOPSSETGET:
60536053
case AArch64::MOPSSETGEN:
6054-
case AArch64::MOPSSETGETN:
6054+
case AArch64::MOPSSETGETN: {
6055+
MCRegister Xd_wb = Inst.getOperand(0).getReg();
6056+
MCRegister Xn_wb = Inst.getOperand(1).getReg();
6057+
MCRegister Xd = Inst.getOperand(2).getReg();
6058+
MCRegister Xn = Inst.getOperand(3).getReg();
6059+
MCRegister Xm = Inst.getOperand(4).getReg();
6060+
if (Xd_wb != Xd)
6061+
return Error(Loc[0],
6062+
"invalid SET instruction, Xd_wb and Xd do not match");
6063+
if (Xn_wb != Xn)
6064+
return Error(Loc[0],
6065+
"invalid SET instruction, Xn_wb and Xn do not match");
6066+
if (Xd == Xn)
6067+
return Error(Loc[0], "invalid SET instruction, destination and size"
6068+
" registers are the same");
6069+
if (Xd == Xm)
6070+
return Error(Loc[0], "invalid SET instruction, destination and source"
6071+
" registers are the same");
6072+
if (Xn == Xm)
6073+
return Error(Loc[0], "invalid SET instruction, source and size"
6074+
" registers are the same");
6075+
break;
6076+
}
60556077
case AArch64::SETGOP:
60566078
case AArch64::SETGOPT:
60576079
case AArch64::SETGOPN:
@@ -6068,7 +6090,6 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
60686090
MCRegister Xn_wb = Inst.getOperand(1).getReg();
60696091
MCRegister Xd = Inst.getOperand(2).getReg();
60706092
MCRegister Xn = Inst.getOperand(3).getReg();
6071-
MCRegister Xm = Inst.getOperand(4).getReg();
60726093
if (Xd_wb != Xd)
60736094
return Error(Loc[0],
60746095
"invalid SET instruction, Xd_wb and Xd do not match");
@@ -6078,12 +6099,6 @@ bool AArch64AsmParser::validateInstruction(MCInst &Inst, SMLoc &IDLoc,
60786099
if (Xd == Xn)
60796100
return Error(Loc[0], "invalid SET instruction, destination and size"
60806101
" registers are the same");
6081-
if (Xd == Xm)
6082-
return Error(Loc[0], "invalid SET instruction, destination and source"
6083-
" registers are the same");
6084-
if (Xn == Xm)
6085-
return Error(Loc[0], "invalid SET instruction, source and size"
6086-
" registers are the same");
60876102
break;
60886103
}
60896104
}

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)