Skip to content

Commit 3a10762

Browse files
committed
fix encoding in RVPUnaryImm8 and RVPUnaryImm9 where rd is RVPGPRPairRV32. align equal signs in class templates.
1 parent a7a7448 commit 3a10762

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoP.td

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class RVPUnary<bits<5> funct5, bits<7> wuimm,
4848
}
4949

5050
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
51-
class RVPUnaryImm9<bits<7> funct7, string opcodestr, DAGOperand TyRd = GPR>
52-
: RVInstIBase<0b010, OPC_OP_IMM_32, (outs TyRd:$rd), (ins simm10:$simm10),
51+
class RVPUnaryImm9<bits<7> funct7, string opcodestr>
52+
: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins simm10:$simm10),
5353
opcodestr, "$rd, $simm10"> {
5454
bits<10> simm10;
5555

@@ -58,13 +58,42 @@ class RVPUnaryImm9<bits<7> funct7, string opcodestr, DAGOperand TyRd = GPR>
5858
}
5959

6060
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
61-
class RVPUnaryImm8<bits<8> funct8, string opcodestr, DAGOperand TyRd = GPR>
62-
: RVInstIBase<0b010, OPC_OP_IMM_32, (outs TyRd:$rd), (ins uimm8:$uimm8),
61+
class RVPUnaryImm9Rdp<bits<7> funct7, string opcodestr>
62+
: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
63+
(ins simm10:$simm10),
64+
opcodestr, "$rdp, $simm10"> {
65+
bits<10> simm10;
66+
bits<4> rdp;
67+
68+
let Inst{31-25} = funct7;
69+
let Inst{24-15} = simm10;
70+
let Inst{11-8} = rdp;
71+
let Inst{7} = 0b0;
72+
}
73+
74+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
75+
class RVPUnaryImm8<bits<8> funct8, string opcodestr>
76+
: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins uimm8:$uimm8),
6377
opcodestr, "$rd, $uimm8"> {
6478
bits<8> uimm8;
79+
6580
let Inst{31-24} = funct8;
6681
let Inst{23-16} = uimm8;
67-
let Inst{15} = 0b0;
82+
let Inst{15} = 0b0;
83+
}
84+
85+
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
86+
class RVPUnaryImm8Rdp<bits<8> funct8, string opcodestr>
87+
: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
88+
(ins uimm8:$uimm8), opcodestr, "$rdp, $uimm8"> {
89+
bits<8> uimm8;
90+
bits<4> rdp;
91+
92+
let Inst{31-24} = funct8;
93+
let Inst{23-16} = uimm8;
94+
let Inst{15} = 0b0;
95+
let Inst{11-8} = rdp;
96+
let Inst{7} = 0b0;
6897
}
6998

7099
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
@@ -96,9 +125,9 @@ let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
96125
class RVPUnaryF<bit bfr, bits<3> f, bit aft, bits<7> wuimm, string opcodestr,
97126
bits<3> funct3, dag outs, dag ins, string argstr>
98127
: RVInstIBase<funct3, OPC_OP_IMM_32, outs, ins, opcodestr, argstr> {
99-
let Inst{31} = bfr;
128+
let Inst{31} = bfr;
100129
let Inst{30-28} = f;
101-
let Inst{27} = aft;
130+
let Inst{27} = aft;
102131
let Inst{26-20} = wuimm;
103132
}
104133

@@ -143,9 +172,9 @@ class RVPBinaryFW<bit bfr, bits<3> f, bit aft, bits<2> w, bits<3> funct3,
143172
dag outs = (outs GPR:$rd), dag ins = (ins GPR:$rs1, GPR:$rs2),
144173
string argstr = "$rd, $rs1, $rs2">
145174
: RVInstRBase<funct3, Opcode, outs, ins, opcodestr, argstr> {
146-
let Inst{31} = bfr;
175+
let Inst{31} = bfr;
147176
let Inst{30-28} = f;
148-
let Inst{27} = aft;
177+
let Inst{27} = aft;
149178
let Inst{26-25} = w;
150179
}
151180

@@ -200,15 +229,15 @@ class RVPBinary1FWRs2pRs1pRdp<bits<4> f, bits<2> w, string opcodestr,
200229
bits<4> rs2p;
201230
bits<4> rdp;
202231

203-
let Inst{31} = 0b1;
232+
let Inst{31} = 0b1;
204233
let Inst{30-27} = f;
205234
let Inst{26-25} = w;
206235
let Inst{24-21} = rs2p;
207-
let Inst{20} = aft;
236+
let Inst{20} = aft;
208237
let Inst{19-16} = rs1p;
209-
let Inst{15} = aft;
210-
let Inst{11-8} = rdp;
211-
let Inst{7} = 0b0;
238+
let Inst{15} = aft;
239+
let Inst{11-8} = rdp;
240+
let Inst{7} = 0b0;
212241
}
213242

214243
class RVPBinary1F0WRs2pRs1pRdp<bits<3> f, bits<2> w, string opcodestr,
@@ -233,7 +262,7 @@ class RVPBinaryLongFW<bit bfr = 1, bits<4> f, bits<2> w, bits<3> funct3,
233262
string opcodestr, dag outs, dag ins, string argstr>
234263
: RVInstRBase<funct3, OPC_OP_32, outs, ins,
235264
opcodestr, argstr> {
236-
let Inst{31} = bfr;
265+
let Inst{31} = bfr;
237266
let Inst{30-27} = f;
238267
let Inst{26-25} = w;
239268
}
@@ -795,9 +824,9 @@ def PWSLAI_B : RVPUnary0F0Rdp<0b100, 0b0010000, "pwslai.b">;
795824
def PWSLAI_H : RVPUnary0F0Rdp<0b100, 0b0100000, "pwslai.h">;
796825
def WSLAI : RVPUnary0F0Rdp<0b100, 0b1000000, "wslai">;
797826

798-
def PLI_DH : RVPUnaryImm9<0b0011000, "pli.dh", RVPGPRPairRV32>;
799-
def PLI_DB : RVPUnaryImm8<0b00110100, "pli.db", RVPGPRPairRV32>;
800-
def PLUI_DH : RVPUnaryImm9<0b0111000, "plui.dh", RVPGPRPairRV32>;
827+
def PLI_DH : RVPUnaryImm9Rdp<0b0011000, "pli.dh">;
828+
def PLI_DB : RVPUnaryImm8Rdp<0b00110100, "pli.db">;
829+
def PLUI_DH : RVPUnaryImm9Rdp<0b0111000, "plui.dh">;
801830

802831

803832
def PWSLLI_BS : RVPBinary0F1WRdp<0b000, 0b00, "pwslli.bs">;

llvm/test/MC/RISCV/rv32p-valid.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,13 @@ pwslai.h t5, a4
779779
# CHECK-ASM: encoding: [0x1b,0x23,0x06,0x44]
780780
wslai t1, a2
781781
# CHECK-ASM-AND-OBJ: pli.dh s0, 32
782-
# CHECK-ASM: encoding: [0x1b,0x22,0x10,0x30]
782+
# CHECK-ASM: encoding: [0x1b,0x24,0x10,0x30]
783783
pli.dh s0, 32
784784
# CHECK-ASM-AND-OBJ: pli.db a2, 1
785-
# CHECK-ASM: encoding: [0x1b,0x23,0x01,0x34]
785+
# CHECK-ASM: encoding: [0x1b,0x26,0x01,0x34]
786786
pli.db a2, 1
787787
# CHECK-ASM-AND-OBJ: plui.dh t5, 16
788-
# CHECK-ASM: encoding: [0x9b,0x27,0x08,0x70]
788+
# CHECK-ASM: encoding: [0x1b,0x2f,0x08,0x70]
789789
plui.dh t5, 16
790790
# CHECK-ASM-AND-OBJ: pwslli.bs t3, t1, s0
791791
# CHECK-ASM: encoding: [0x1b,0x2e,0x83,0x08]

0 commit comments

Comments
 (0)