@@ -25,7 +25,7 @@ def SImm8UnsignedAsmOperand : SImmAsmOperand<8, "Unsigned"> {
25
25
}
26
26
27
27
// A 8-bit signed immediate allowing range [-128, 255]
28
- // but represented as [-128, 127 ].
28
+ // but represented as [-128, 255 ].
29
29
def simm8_unsigned : RISCVOp {
30
30
let ParserMatchClass = SImm8UnsignedAsmOperand;
31
31
let EncoderMethod = "getImmOpValue";
@@ -62,49 +62,40 @@ def simm10_unsigned : RISCVOp {
62
62
// Instruction class templates
63
63
//===----------------------------------------------------------------------===//
64
64
65
- let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
66
- class PLI_i<bits<7> funct7, string opcodestr>
67
- : RVInst<(outs GPR:$rd), (ins simm10:$imm10), opcodestr, "$rd, $imm10", [],
65
+ // Common base for pli.b/h/w and plui.h/w
66
+ class RVPLoadImm_i<bits<7> funct7, dag ins, string opcodestr,
67
+ string argstr>
68
+ : RVInst<(outs GPR:$rd), ins, opcodestr, argstr, [],
68
69
InstFormatOther> {
69
- bits<10> imm10;
70
70
bits<5> rd;
71
71
72
72
let Inst{31-25} = funct7;
73
- let Inst{24-16} = imm10{8-0};
74
- let Inst{15} = imm10{9};
75
73
let Inst{14-12} = 0b010;
76
74
let Inst{11-7} = rd;
77
75
let Inst{6-0} = OPC_OP_IMM_32.Value;
76
+
77
+ let hasSideEffects = 0;
78
+ let mayLoad = 0;
79
+ let mayStore = 0;
78
80
}
79
81
80
- let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
81
- class PLUI_i<bits<7> funct7, string opcodestr>
82
- : RVInst<(outs GPR:$rd), (ins simm10_unsigned:$imm10), opcodestr,
83
- "$rd, $imm10", [], InstFormatOther> {
82
+ // Base for pli.h/w.
83
+ class PLI_i<bits<7> funct7, string opcodestr>
84
+ : RVPLoadImm_i<funct7, (ins simm10:$imm10), opcodestr, "$rd, $imm10"> {
84
85
bits<10> imm10;
85
- bits<5> rd;
86
86
87
- let Inst{31-25} = funct7;
88
- let Inst{24} = imm10{0};
89
- let Inst{23-15} = imm10{9-1};
90
- let Inst{14-12} = 0b010;
91
- let Inst{11-7} = rd;
92
- let Inst{6-0} = OPC_OP_IMM_32.Value;
87
+ let Inst{24-16} = imm10{8-0};
88
+ let Inst{15} = imm10{9};
93
89
}
94
90
95
- let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
96
- class PLI_B_i<bits<8> funct8, string opcodestr>
97
- : RVInst<(outs GPR:$rd), (ins simm8_unsigned:$imm8), opcodestr,
98
- "$rd, $imm8", [], InstFormatOther> {
99
- bits<8> imm8;
100
- bits<5> rd;
91
+ // Base for plui.h/w.
92
+ class PLUI_i<bits<7> funct7, string opcodestr>
93
+ : RVPLoadImm_i<funct7, (ins simm10_unsigned:$imm10), opcodestr,
94
+ "$rd, $imm10"> {
95
+ bits<10> imm10;
101
96
102
- let Inst{31-24} = funct8;
103
- let Inst{23-16} = imm8;
104
- let Inst{15} = 0b0;
105
- let Inst{14-12} = 0b010;
106
- let Inst{11-7} = rd;
107
- let Inst{6-0} = OPC_OP_IMM_32.Value;
97
+ let Inst{24} = imm10{0};
98
+ let Inst{23-15} = imm10{9-1};
108
99
}
109
100
110
101
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
@@ -180,14 +171,33 @@ class RVPBinary_rr<bits<4> f, bits<2> w, bits<3> funct3, string opcodestr>
180
171
let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
181
172
class RVPTernary_rrr<bits<4> f, bits<2> w, bits<3> funct3, string opcodestr>
182
173
: RVInstRBase<funct3, OPC_OP_32, (outs GPR:$rd_wb),
183
- (ins GPR:$rd, GPR:$rs1, GPR:$rs2), opcodestr, "$rd, $rs1, $rs2"> {
174
+ (ins GPR:$rd, GPR:$rs1, GPR:$rs2), opcodestr,
175
+ "$rd, $rs1, $rs2"> {
184
176
let Inst{31} = 0b1;
185
177
let Inst{30-27} = f;
186
178
let Inst{26-25} = w;
187
179
188
180
let Constraints = "$rd = $rd_wb";
189
181
}
190
182
183
+ // Common base for pli.db/h/w and plui.dh/w
184
+ class RVPPairLoadImm_i<bits<7> funct7, dag ins, string opcodestr,
185
+ string argstr>
186
+ : RVInst<(outs GPRPairRV32:$rd), ins, opcodestr, argstr, [],
187
+ InstFormatOther> {
188
+ bits<5> rd;
189
+
190
+ let Inst{31-25} = funct7;
191
+ let Inst{14-12} = 0b010;
192
+ let Inst{11-8} = rd{4-1};
193
+ let Inst{7} = 0b0;
194
+ let Inst{6-0} = OPC_OP_IMM_32.Value;
195
+
196
+ let hasSideEffects = 0;
197
+ let mayLoad = 0;
198
+ let mayStore = 0;
199
+ }
200
+
191
201
//===----------------------------------------------------------------------===//
192
202
// Instructions
193
203
//===----------------------------------------------------------------------===//
@@ -229,8 +239,16 @@ let Predicates = [HasStdExtP] in
229
239
def PLI_H : PLI_i<0b1011000, "pli.h">;
230
240
let Predicates = [HasStdExtP, IsRV64] in
231
241
def PLI_W : PLI_i<0b1011001, "pli.w">;
232
- let Predicates = [HasStdExtP] in
233
- def PLI_B : PLI_B_i<0b10110100, "pli.b">;
242
+ let Predicates = [HasStdExtP] in {
243
+ def PLI_B : RVPLoadImm_i<0b1011010, (ins simm8_unsigned:$imm8), "pli.b",
244
+ "$rd, $imm8"> {
245
+ bits<8> imm8;
246
+
247
+ let Inst{24} = 0b0;
248
+ let Inst{23-16} = imm8;
249
+ let Inst{15} = 0b0;
250
+ }
251
+ }
234
252
235
253
let Predicates = [HasStdExtP] in {
236
254
def PSEXT_H_B : RVPUnary_ri<0b00, 0b00100, "psext.h.b">;
@@ -578,3 +596,30 @@ let Predicates = [HasStdExtP, IsRV64] in {
578
596
def PPACKT_W : RVPBinary_rr<0b0110, 0b01, 0b100, "ppackt.w">;
579
597
def PACKT_RV64 : RVPBinary_rr<0b0110, 0b11, 0b100, "packt">;
580
598
} // Predicates = [HasStdExtP, IsRV64]
599
+
600
+ let Predicates = [HasStdExtP, IsRV32] in {
601
+ def PLI_DH : RVPPairLoadImm_i<0b0011000, (ins simm10:$imm10), "pli.dh",
602
+ "$rd, $imm10"> {
603
+ bits<10> imm10;
604
+
605
+ let Inst{24-16} = imm10{8-0};
606
+ let Inst{15} = imm10{9};
607
+ }
608
+
609
+ def PLI_DB : RVPPairLoadImm_i<0b0011010, (ins simm8_unsigned:$imm8), "pli.db",
610
+ "$rd, $imm8"> {
611
+ bits<8> imm8;
612
+
613
+ let Inst{24} = 0b0;
614
+ let Inst{23-16} = imm8;
615
+ let Inst{15} = 0b0;
616
+ }
617
+
618
+ def PLUI_DH : RVPPairLoadImm_i<0b0111000, (ins simm10_unsigned:$imm10),
619
+ "plui.dh", "$rd, $imm10"> {
620
+ bits<10> imm10;
621
+
622
+ let Inst{24} = imm10{0};
623
+ let Inst{23-15} = imm10{9-1};
624
+ }
625
+ }
0 commit comments