@@ -96,31 +96,21 @@ def TuneLDADDFusion
96
96
// slliw r1, r0, 16
97
97
// srliw r1, r1, 16
98
98
def GetLower16BitsFusion
99
- : SimpleFusion <"get-lower-16bits-fusion", "HasGetLower16BitsFusion",
99
+ : SingleFusion <"get-lower-16bits-fusion", "HasGetLower16BitsFusion",
100
100
"Enable SLLIW+SRLIW to be fused to get lower 16 bits",
101
- CheckAll<[
102
- CheckOpcode<[SLLIW]>,
103
- CheckImmOperand<2, 16>
104
- ]>,
105
- CheckAll<[
106
- CheckOpcode<[SRLIW]>,
107
- CheckImmOperand<2, 16>
108
- ]>>;
101
+ SLLIW, SRLIW,
102
+ CheckImmOperand<2, 16>,
103
+ CheckImmOperand<2, 16>>;
109
104
110
105
// Sign-extend a 16-bit number:
111
106
// slliw r1, r0, 16
112
107
// sraiw r1, r1, 16
113
108
def SExtHFusion
114
- : SimpleFusion <"sign-extend-16bits-fusion","HasSExtHFusion",
109
+ : SingleFusion <"sign-extend-16bits-fusion","HasSExtHFusion",
115
110
"Enable SLLIW+SRAIW to be fused to sign-extend a 16-bit number",
116
- CheckAll<[
117
- CheckOpcode<[SLLIW]>,
118
- CheckImmOperand<2, 16>
119
- ]>,
120
- CheckAll<[
121
- CheckOpcode<[SRAIW]>,
122
- CheckImmOperand<2, 16>
123
- ]>>;
111
+ SLLIW, SRAIW,
112
+ CheckImmOperand<2, 16>,
113
+ CheckImmOperand<2, 16>>;
124
114
125
115
// These should be covered by Zba extension.
126
116
// * shift left by one and add:
@@ -132,17 +122,13 @@ def SExtHFusion
132
122
// * shift left by three and add:
133
123
// slli r1, r0, 3
134
124
// add r1, r1, r2
135
- let IsCommutable = 1 in
136
125
def ShiftNAddFusion
137
- : SimpleFusion <"shift-n-add-fusion", "HasShiftNAddFusion",
126
+ : SingleFusion <"shift-n-add-fusion", "HasShiftNAddFusion",
138
127
"Enable SLLI+ADD to be fused to shift left by 1/2/3 and add",
139
- CheckAll<[
140
- CheckOpcode<[SLLI]>,
141
- CheckAny<[CheckImmOperand<2, 1>,
142
- CheckImmOperand<2, 2>,
143
- CheckImmOperand<2, 3>]>
144
- ]>,
145
- CheckOpcode<[ADD]>>;
128
+ SLLI, ADD,
129
+ CheckAny<[CheckImmOperand<2, 1>,
130
+ CheckImmOperand<2, 2>,
131
+ CheckImmOperand<2, 3>]>>;
146
132
147
133
// * Shift zero-extended word left by 1:
148
134
// slli r1, r0, 32
@@ -154,46 +140,32 @@ def ShiftNAddFusion
154
140
// slli r1, r0, 32
155
141
// srli r1, r0, 29
156
142
def ShiftZExtByNFusion
157
- : SimpleFusion <"shift-zext-by-n-fusion", "HasShiftZExtByNFusion",
143
+ : SingleFusion <"shift-zext-by-n-fusion", "HasShiftZExtByNFusion",
158
144
"Enable SLLI+SRLI to be fused to shift zero-extended word left by 1/2/3",
159
- CheckAll<[
160
- CheckOpcode<[SLLI]>,
161
- CheckImmOperand<2, 32>
162
- ]>,
163
- CheckAll<[
164
- CheckOpcode<[SRLI]>,
165
- CheckAny<[CheckImmOperand<2, 29>,
166
- CheckImmOperand<2, 30>,
167
- CheckImmOperand<2, 31>]>
168
- ]>>;
145
+ SLLI, SRLI,
146
+ CheckImmOperand<2, 32>,
147
+ CheckAny<[CheckImmOperand<2, 29>,
148
+ CheckImmOperand<2, 30>,
149
+ CheckImmOperand<2, 31>]>>;
169
150
170
151
// Get the second byte:
171
152
// srli r1, r0, 8
172
153
// andi r1, r1, 255
173
154
def GetSecondByteFusion
174
- : SimpleFusion <"get-second-byte-fusion", "HasGetSecondByteFusion",
155
+ : SingleFusion <"get-second-byte-fusion", "HasGetSecondByteFusion",
175
156
"Enable SRLI+ANDI to be fused to get the second byte",
176
- CheckAll<[
177
- CheckOpcode<[SRLI]>,
178
- CheckImmOperand<2, 8>
179
- ]>,
180
- CheckAll<[
181
- CheckOpcode<[ANDI]>,
182
- CheckImmOperand<2, 255>
183
- ]>>;
157
+ SRLI, ANDI,
158
+ CheckImmOperand<2, 8>,
159
+ CheckImmOperand<2, 255>>;
184
160
185
161
// Shift left by four and add:
186
162
// slli r1, r0, 4
187
163
// add r1, r1, r2
188
- let IsCommutable = 1 in
189
164
def ShiftLeft4AddFusion
190
- : SimpleFusion <"shift-left-four-add-fusion", "HasShiftLeft4AddFusion",
165
+ : SingleFusion <"shift-left-four-add-fusion", "HasShiftLeft4AddFusion",
191
166
"Enable SLLI+ADD to be fused to shift left by four and add",
192
- CheckAll<[
193
- CheckOpcode<[SLLI]>,
194
- CheckImmOperand<2, 4>
195
- ]>,
196
- CheckOpcode<[ADD]>>;
167
+ SLLI, ADD,
168
+ CheckImmOperand<2, 4>>;
197
169
198
170
// * Shift right by 29 and add:
199
171
// srli r1, r0, 29
@@ -207,18 +179,14 @@ def ShiftLeft4AddFusion
207
179
// * Shift right by 32 and add:
208
180
// srli r1, r0, 32
209
181
// add r1, r1, r2
210
- let IsCommutable = 1 in
211
182
def ShiftRightNAddFusion
212
- : SimpleFusion <"shift-right-n-add-fusion", "HasShiftRightNAddFusion",
183
+ : SingleFusion <"shift-right-n-add-fusion", "HasShiftRightNAddFusion",
213
184
"Enable SRLI+add to be fused to shift right by 29/30/31/32 and add",
214
- CheckAll<[
215
- CheckOpcode<[SRLI]>,
216
- CheckAny<[CheckImmOperand<2, 29>,
217
- CheckImmOperand<2, 30>,
218
- CheckImmOperand<2, 31>,
219
- CheckImmOperand<2, 32>]>
220
- ]>,
221
- CheckOpcode<[ADD]>>;
185
+ SRLI, ADD,
186
+ CheckAny<[CheckImmOperand<2, 29>,
187
+ CheckImmOperand<2, 30>,
188
+ CheckImmOperand<2, 31>,
189
+ CheckImmOperand<2, 32>]>>;
222
190
223
191
// Add one if odd, otherwise unchanged:
224
192
// andi r1, r0, 1
@@ -243,14 +211,11 @@ def AddOneIfOddFusion
243
211
// andw r1, r1, r0
244
212
// andi r1, r1, 255
245
213
def AddAndExtractNBitsFusion
246
- : SimpleFusion <"add-and-extract-n-bits-fusion", "HasAddAndExtractNBitsFusion",
214
+ : SingleFusion <"add-and-extract-n-bits-fusion", "HasAddAndExtractNBitsFusion",
247
215
"Enable ADDW+ANDI to be fused to get lower 16 bits",
248
- CheckOpcode<[ADDW]>,
249
- CheckAll<[
250
- CheckOpcode<[ANDI]>,
251
- CheckAny<[CheckImmOperand<2, 1>,
252
- CheckImmOperand<2, 255>]>
253
- ]>>;
216
+ ADDW, ANDI,
217
+ secondInstPred = CheckAny<[CheckImmOperand<2, 1>,
218
+ CheckImmOperand<2, 255>]>>;
254
219
255
220
// * Add word and zext.h:
256
221
// andw r1, r1, r0
@@ -288,25 +253,17 @@ def LogicOpAndExtractLow16BitsFusion
288
253
// OR(Cat(src1(63, 8), 0.U(8.W)), src2):
289
254
// andi r1, r0, -256
290
255
// or r1, r1, r2
291
- let IsCommutable = 1 in
292
256
def OrCatFusion
293
- : SimpleFusion <"or-cat-fusion", "HasOrCatFusion",
257
+ : SingleFusion <"or-cat-fusion", "HasOrCatFusion",
294
258
"Enable SLLIW+SRLIW to be fused to get lower 16 bits",
295
- CheckAll<[
296
- CheckOpcode<[ANDI]>,
297
- CheckImmOperand<2, -256>
298
- ]>,
299
- CheckOpcode<[OR]>>;
259
+ ANDI, OR,
260
+ CheckImmOperand<2, -256>>;
300
261
301
262
// Multiply 7-bit data with 32-bit data:
302
263
// andi r1, r0, 127
303
264
// mulw r1, r1, r2
304
- let IsCommutable = 1 in
305
265
def Mul7BitsWith32BitsFusion
306
- : SimpleFusion <"mul-7bits-with-32bit-fusion", "HasMul7BitsWith32BitsFusion",
266
+ : SingleFusion <"mul-7bits-with-32bit-fusion", "HasMul7BitsWith32BitsFusion",
307
267
"Enable ANDI+MULW to be fused to multiply 7-bit data with 32-bit data",
308
- CheckAll<[
309
- CheckOpcode<[ANDI]>,
310
- CheckImmOperand<2, 127>
311
- ]>,
312
- CheckOpcode<[MULW]>>;
268
+ ANDI, MULW,
269
+ CheckImmOperand<2, 127>>;
0 commit comments