Skip to content

Commit 98d7627

Browse files
committed
[ARM] Auto-decode MVE instructions with VCCR output operand (NFC)
1 parent 23f77e4 commit 98d7627

File tree

2 files changed

+13
-72
lines changed

2 files changed

+13
-72
lines changed

llvm/lib/Target/ARM/ARMInstrMVE.td

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4128,11 +4128,12 @@ defm MVE_VMINNMAf16 : MVE_VMINNMA<MVE_v8f16, 0b1>;
41284128

41294129
// start of MVE compares
41304130

4131+
// Base class for comparing two vector registers
41314132
class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
41324133
VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
41334134
: MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
41344135
NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", vecsize, pattern> {
4135-
// Base class for comparing two vector registers
4136+
bits<0> P0;
41364137
bits<3> fc;
41374138
bits<4> Qn;
41384139
bits<4> Qm;
@@ -4152,16 +4153,6 @@ class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
41524153
let Inst{0} = fc{1};
41534154

41544155
let Constraints = "";
4155-
4156-
// We need a custom decoder method for these instructions because of
4157-
// the output VCCR operand, which isn't encoded in the instruction
4158-
// bits anywhere (there is only one choice for it) but has to be
4159-
// included in the MC operands so that codegen will be able to track
4160-
// its data flow between instructions, spill/reload it when
4161-
// necessary, etc. There seems to be no way to get the Tablegen
4162-
// decoder to emit an operand that isn't affected by any instruction
4163-
// bit.
4164-
let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
41654156
let validForTailPredication = 1;
41664157
}
41674158

@@ -4202,11 +4193,12 @@ def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
42024193
def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
42034194
def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
42044195

4196+
// Base class for comparing a vector register with a scalar
42054197
class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
42064198
VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
42074199
: MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
42084200
NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", vecsize, pattern> {
4209-
// Base class for comparing a vector register with a scalar
4201+
bits<0> P0;
42104202
bits<3> fc;
42114203
bits<4> Qn;
42124204
bits<4> Rm;
@@ -4225,8 +4217,6 @@ class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
42254217
let Inst{3-0} = Rm{3-0};
42264218

42274219
let Constraints = "";
4228-
// Custom decoder method, for the same reason as MVE_VCMPqq
4229-
let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
42304220
let validForTailPredication = 1;
42314221
}
42324222

@@ -5762,6 +5752,7 @@ let isReMaterializable = 1 in
57625752
class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]>
57635753
: MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
57645754
"$Rn", vpred_n, "", size, pattern> {
5755+
bits<0> P0;
57655756
bits<4> Rn;
57665757

57675758
let Inst{28-27} = 0b10;
@@ -5773,7 +5764,6 @@ class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]>
57735764
let Unpredictable{10-0} = 0b11111111111;
57745765

57755766
let Constraints = "";
5776-
let DecoderMethod = "DecodeMveVCTP";
57775767
let validForTailPredication = 1;
57785768
}
57795769

@@ -6813,14 +6803,15 @@ let Predicates = [HasMVEFloat] in {
68136803

68146804
def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary,
68156805
"vpnot", "", "", vpred_n, "", 0b00, []> {
6806+
bits<0> P0;
6807+
bits<0> P0_in;
68166808
let Inst{31-0} = 0b11111110001100010000111101001101;
68176809
let Unpredictable{19-17} = 0b111;
68186810
let Unpredictable{12} = 0b1;
68196811
let Unpredictable{7} = 0b1;
68206812
let Unpredictable{5} = 0b1;
68216813

68226814
let Constraints = "";
6823-
let DecoderMethod = "DecodeMVEVPNOT";
68246815
}
68256816

68266817
let Predicates = [HasMVEInt] in {

llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ static DecodeStatus DecodeMQQQQPRRegisterClass(MCInst &Inst, unsigned RegNo,
602602
return MCDisassembler::Success;
603603
}
604604

605+
static DecodeStatus DecodeVCCRRegisterClass(MCInst &Inst,
606+
const MCDisassembler *Decoder) {
607+
Inst.addOperand(MCOperand::createReg(ARM::VPR));
608+
return MCDisassembler::Success;
609+
}
610+
605611
// Operand decoding functions.
606612

607613
static DecodeStatus DecodePredicateOperand(MCInst &Inst, unsigned Val,
@@ -5992,62 +5998,6 @@ static DecodeStatus DecodeMVEVCVTt1fp(MCInst &Inst, unsigned Insn,
59925998
return S;
59935999
}
59946000

5995-
template <bool scalar, OperandDecoder predicate_decoder>
5996-
static DecodeStatus DecodeMVEVCMP(MCInst &Inst, unsigned Insn, uint64_t Address,
5997-
const MCDisassembler *Decoder) {
5998-
DecodeStatus S = MCDisassembler::Success;
5999-
Inst.addOperand(MCOperand::createReg(ARM::VPR));
6000-
unsigned Qn = fieldFromInstruction(Insn, 17, 3);
6001-
if (!Check(S, DecodeMQPRRegisterClass(Inst, Qn, Address, Decoder)))
6002-
return MCDisassembler::Fail;
6003-
6004-
unsigned fc;
6005-
6006-
if (scalar) {
6007-
fc = fieldFromInstruction(Insn, 12, 1) << 2 |
6008-
fieldFromInstruction(Insn, 7, 1) |
6009-
fieldFromInstruction(Insn, 5, 1) << 1;
6010-
unsigned Rm = fieldFromInstruction(Insn, 0, 4);
6011-
if (!Check(S, DecodeGPRwithZRRegisterClass(Inst, Rm, Address, Decoder)))
6012-
return MCDisassembler::Fail;
6013-
} else {
6014-
fc = fieldFromInstruction(Insn, 12, 1) << 2 |
6015-
fieldFromInstruction(Insn, 7, 1) |
6016-
fieldFromInstruction(Insn, 0, 1) << 1;
6017-
unsigned Qm = fieldFromInstruction(Insn, 5, 1) << 4 |
6018-
fieldFromInstruction(Insn, 1, 3);
6019-
if (!Check(S, DecodeMQPRRegisterClass(Inst, Qm, Address, Decoder)))
6020-
return MCDisassembler::Fail;
6021-
}
6022-
6023-
if (!Check(S, predicate_decoder(Inst, fc, Address, Decoder)))
6024-
return MCDisassembler::Fail;
6025-
6026-
Check(S, DecodeVpredNOperand(Inst, Decoder));
6027-
return S;
6028-
}
6029-
6030-
static DecodeStatus DecodeMveVCTP(MCInst &Inst, unsigned Insn, uint64_t Address,
6031-
const MCDisassembler *Decoder) {
6032-
DecodeStatus S = MCDisassembler::Success;
6033-
Inst.addOperand(MCOperand::createReg(ARM::VPR));
6034-
unsigned Rn = fieldFromInstruction(Insn, 16, 4);
6035-
if (!Check(S, DecoderGPRRegisterClass(Inst, Rn, Address, Decoder)))
6036-
return MCDisassembler::Fail;
6037-
Check(S, DecodeVpredNOperand(Inst, Decoder));
6038-
return S;
6039-
}
6040-
6041-
static DecodeStatus DecodeMVEVPNOT(MCInst &Inst, unsigned Insn,
6042-
uint64_t Address,
6043-
const MCDisassembler *Decoder) {
6044-
DecodeStatus S = MCDisassembler::Success;
6045-
Inst.addOperand(MCOperand::createReg(ARM::VPR));
6046-
Inst.addOperand(MCOperand::createReg(ARM::VPR));
6047-
Check(S, DecodeVpredNOperand(Inst, Decoder));
6048-
return S;
6049-
}
6050-
60516001
static DecodeStatus DecodeT2AddSubSPImm(MCInst &Inst, unsigned Insn,
60526002
uint64_t Address,
60536003
const MCDisassembler *Decoder) {

0 commit comments

Comments
 (0)