@@ -34,6 +34,30 @@ def th_swd : SDNode<"RISCVISD::TH_SWD", SDT_StorePair,
34
34
def th_sdd : SDNode<"RISCVISD::TH_SDD", SDT_StorePair,
35
35
[SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
36
36
37
+ def ImmThreeAsmOperand : AsmOperandClass {
38
+ let Name = "ImmThree";
39
+ let RenderMethod = "addImmOperands";
40
+ let DiagnosticType = !strconcat("Invalid", Name);
41
+ let DiagnosticString = "operand must be constant 3";
42
+ }
43
+
44
+ def immthree : RISCVOp {
45
+ let ParserMatchClass = ImmThreeAsmOperand;
46
+ let OperandType = "OPERAND_THREE";
47
+ }
48
+
49
+ def ImmFourAsmOperand : AsmOperandClass {
50
+ let Name = "ImmFour";
51
+ let RenderMethod = "addImmOperands";
52
+ let DiagnosticType = !strconcat("Invalid", Name);
53
+ let DiagnosticString = "operand must be constant 4";
54
+ }
55
+
56
+ def immfour : RISCVOp {
57
+ let ParserMatchClass = ImmFourAsmOperand;
58
+ let OperandType = "OPERAND_FOUR";
59
+ }
60
+
37
61
//===----------------------------------------------------------------------===//
38
62
// Instruction class templates
39
63
//===----------------------------------------------------------------------===//
@@ -131,10 +155,10 @@ class THMulAccumulate_rr<bits<7> funct7, string opcodestr>
131
155
}
132
156
133
157
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in
134
- class THLoadPair<bits<5> funct5, string opcodestr>
158
+ class THLoadPair<bits<5> funct5, string opcodestr, Operand consttype >
135
159
: RVInstRBase<0b100, OPC_CUSTOM_0,
136
160
(outs GPR:$rd, GPR:$rs2),
137
- (ins GPR:$rs1, uimm2:$uimm2, uimm7 :$const3or4),
161
+ (ins GPR:$rs1, uimm2:$uimm2, consttype :$const3or4),
138
162
opcodestr, "$rd, $rs2, (${rs1}), $uimm2, $const3or4"> {
139
163
bits<2> uimm2;
140
164
let Inst{31-27} = funct5;
@@ -144,9 +168,9 @@ class THLoadPair<bits<5> funct5, string opcodestr>
144
168
}
145
169
146
170
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in
147
- class THStorePair<bits<5> funct5, string opcodestr>
171
+ class THStorePair<bits<5> funct5, string opcodestr, Operand consttype >
148
172
: RVInstRBase<0b101, OPC_CUSTOM_0, (outs),
149
- (ins GPR:$rd, GPR:$rs2, GPR:$rs1, uimm2:$uimm2, uimm7 :$const3or4),
173
+ (ins GPR:$rd, GPR:$rs2, GPR:$rs1, uimm2:$uimm2, consttype :$const3or4),
150
174
opcodestr, "$rd, $rs2, (${rs1}), $uimm2, $const3or4"> {
151
175
bits<2> uimm2;
152
176
let Inst{31-27} = funct5;
@@ -290,19 +314,19 @@ def TH_MULSW : THMulAccumulate_rr<0b0010011, "th.mulsw">;
290
314
} // Predicates = [HasVendorXTHeadMac, IsRV64]
291
315
292
316
let Predicates = [HasVendorXTHeadMemPair] in {
293
- def TH_LWUD : THLoadPair<0b11110, "th.lwud">,
317
+ def TH_LWUD : THLoadPair<0b11110, "th.lwud", immthree >,
294
318
Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
295
- def TH_SWD : THStorePair<0b11100, "th.swd">,
319
+ def TH_SWD : THStorePair<0b11100, "th.swd", immthree >,
296
320
Sched<[WriteSTW, WriteSTW, ReadStoreData, ReadMemBase]>;
297
321
let IsSignExtendingOpW = 1 in
298
- def TH_LWD : THLoadPair<0b11100, "th.lwd">,
322
+ def TH_LWD : THLoadPair<0b11100, "th.lwd", immthree >,
299
323
Sched<[WriteLDW, WriteLDW, ReadMemBase]>;
300
324
}
301
325
302
326
let Predicates = [HasVendorXTHeadMemPair, IsRV64] in {
303
- def TH_LDD : THLoadPair<0b11111, "th.ldd">,
327
+ def TH_LDD : THLoadPair<0b11111, "th.ldd", immfour >,
304
328
Sched<[WriteLDD, WriteLDD, ReadMemBase]>;
305
- def TH_SDD : THStorePair<0b11111, "th.sdd">,
329
+ def TH_SDD : THStorePair<0b11111, "th.sdd", immfour >,
306
330
Sched<[WriteSTD, WriteSTD, ReadStoreData, ReadMemBase]>;
307
331
}
308
332
0 commit comments