Skip to content

Commit e59fd14

Browse files
committed
Use SingleFusion
1 parent 466d10d commit e59fd14

File tree

1 file changed

+42
-85
lines changed

1 file changed

+42
-85
lines changed

llvm/lib/Target/RISCV/RISCVMacroFusion.td

+42-85
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,21 @@ def TuneLDADDFusion
9696
// slliw r1, r0, 16
9797
// srliw r1, r1, 16
9898
def GetLower16BitsFusion
99-
: SimpleFusion<"get-lower-16bits-fusion", "HasGetLower16BitsFusion",
99+
: SingleFusion<"get-lower-16bits-fusion", "HasGetLower16BitsFusion",
100100
"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>>;
109104

110105
// Sign-extend a 16-bit number:
111106
// slliw r1, r0, 16
112107
// sraiw r1, r1, 16
113108
def SExtHFusion
114-
: SimpleFusion<"sign-extend-16bits-fusion","HasSExtHFusion",
109+
: SingleFusion<"sign-extend-16bits-fusion","HasSExtHFusion",
115110
"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>>;
124114

125115
// These should be covered by Zba extension.
126116
// * shift left by one and add:
@@ -132,17 +122,13 @@ def SExtHFusion
132122
// * shift left by three and add:
133123
// slli r1, r0, 3
134124
// add r1, r1, r2
135-
let IsCommutable = 1 in
136125
def ShiftNAddFusion
137-
: SimpleFusion<"shift-n-add-fusion", "HasShiftNAddFusion",
126+
: SingleFusion<"shift-n-add-fusion", "HasShiftNAddFusion",
138127
"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>]>>;
146132

147133
// * Shift zero-extended word left by 1:
148134
// slli r1, r0, 32
@@ -154,46 +140,32 @@ def ShiftNAddFusion
154140
// slli r1, r0, 32
155141
// srli r1, r0, 29
156142
def ShiftZExtByNFusion
157-
: SimpleFusion<"shift-zext-by-n-fusion", "HasShiftZExtByNFusion",
143+
: SingleFusion<"shift-zext-by-n-fusion", "HasShiftZExtByNFusion",
158144
"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>]>>;
169150

170151
// Get the second byte:
171152
// srli r1, r0, 8
172153
// andi r1, r1, 255
173154
def GetSecondByteFusion
174-
: SimpleFusion<"get-second-byte-fusion", "HasGetSecondByteFusion",
155+
: SingleFusion<"get-second-byte-fusion", "HasGetSecondByteFusion",
175156
"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>>;
184160

185161
// Shift left by four and add:
186162
// slli r1, r0, 4
187163
// add r1, r1, r2
188-
let IsCommutable = 1 in
189164
def ShiftLeft4AddFusion
190-
: SimpleFusion<"shift-left-four-add-fusion", "HasShiftLeft4AddFusion",
165+
: SingleFusion<"shift-left-four-add-fusion", "HasShiftLeft4AddFusion",
191166
"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>>;
197169

198170
// * Shift right by 29 and add:
199171
// srli r1, r0, 29
@@ -207,18 +179,14 @@ def ShiftLeft4AddFusion
207179
// * Shift right by 32 and add:
208180
// srli r1, r0, 32
209181
// add r1, r1, r2
210-
let IsCommutable = 1 in
211182
def ShiftRightNAddFusion
212-
: SimpleFusion<"shift-right-n-add-fusion", "HasShiftRightNAddFusion",
183+
: SingleFusion<"shift-right-n-add-fusion", "HasShiftRightNAddFusion",
213184
"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>]>>;
222190

223191
// Add one if odd, otherwise unchanged:
224192
// andi r1, r0, 1
@@ -243,14 +211,11 @@ def AddOneIfOddFusion
243211
// andw r1, r1, r0
244212
// andi r1, r1, 255
245213
def AddAndExtractNBitsFusion
246-
: SimpleFusion<"add-and-extract-n-bits-fusion", "HasAddAndExtractNBitsFusion",
214+
: SingleFusion<"add-and-extract-n-bits-fusion", "HasAddAndExtractNBitsFusion",
247215
"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>]>>;
254219

255220
// * Add word and zext.h:
256221
// andw r1, r1, r0
@@ -288,25 +253,17 @@ def LogicOpAndExtractLow16BitsFusion
288253
// OR(Cat(src1(63, 8), 0.U(8.W)), src2):
289254
// andi r1, r0, -256
290255
// or r1, r1, r2
291-
let IsCommutable = 1 in
292256
def OrCatFusion
293-
: SimpleFusion<"or-cat-fusion", "HasOrCatFusion",
257+
: SingleFusion<"or-cat-fusion", "HasOrCatFusion",
294258
"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>>;
300261

301262
// Multiply 7-bit data with 32-bit data:
302263
// andi r1, r0, 127
303264
// mulw r1, r1, r2
304-
let IsCommutable = 1 in
305265
def Mul7BitsWith32BitsFusion
306-
: SimpleFusion<"mul-7bits-with-32bit-fusion", "HasMul7BitsWith32BitsFusion",
266+
: SingleFusion<"mul-7bits-with-32bit-fusion", "HasMul7BitsWith32BitsFusion",
307267
"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

Comments
 (0)