]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/Hexagon/HexagonIntrinsics.td
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / Hexagon / HexagonIntrinsics.td
1 //===-- HexagonIntrinsics.td - Instruction intrinsics ------*- tablegen -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // These intrinsic patterns are not auto-generated.
10
11 class T_R_pat <InstHexagon MI, Intrinsic IntID>
12   : Pat <(IntID I32:$Rs),
13          (MI I32:$Rs)>;
14
15 class T_RR_pat <InstHexagon MI, Intrinsic IntID>
16   : Pat <(IntID I32:$Rs, I32:$Rt),
17          (MI I32:$Rs, I32:$Rt)>;
18
19 class T_RP_pat <InstHexagon MI, Intrinsic IntID>
20   : Pat <(IntID I32:$Rs, I64:$Rt),
21          (MI I32:$Rs, I64:$Rt)>;
22
23 def: Pat<(int_hexagon_A2_add IntRegs:$Rs, IntRegs:$Rt),
24          (A2_add IntRegs:$Rs, IntRegs:$Rt)>;
25 def: Pat<(int_hexagon_A2_addi IntRegs:$Rs, imm:$s16),
26          (A2_addi IntRegs:$Rs, imm:$s16)>;
27 def: Pat<(int_hexagon_A2_addp DoubleRegs:$Rs, DoubleRegs:$Rt),
28          (A2_addp DoubleRegs:$Rs, DoubleRegs:$Rt)>;
29
30 def: Pat<(int_hexagon_A2_sub IntRegs:$Rs, IntRegs:$Rt),
31          (A2_sub IntRegs:$Rs, IntRegs:$Rt)>;
32 def: Pat<(int_hexagon_A2_subri imm:$s10, IntRegs:$Rs),
33          (A2_subri imm:$s10, IntRegs:$Rs)>;
34 def: Pat<(int_hexagon_A2_subp DoubleRegs:$Rs, DoubleRegs:$Rt),
35          (A2_subp DoubleRegs:$Rs, DoubleRegs:$Rt)>;
36
37 def: Pat<(int_hexagon_M2_mpyi IntRegs:$Rs, IntRegs:$Rt),
38          (M2_mpyi IntRegs:$Rs, IntRegs:$Rt)>;
39 def: Pat<(int_hexagon_M2_mpyui IntRegs:$Rs, IntRegs:$Rt), // Same as M2_mpyi
40          (M2_mpyi IntRegs:$Rs, IntRegs:$Rt)>;
41 def: Pat<(int_hexagon_M2_mpysmi IntRegs:$Rs, imm:$s9),
42          (M2_mpysmi IntRegs:$Rs, imm:$s9)>;
43 def: Pat<(int_hexagon_M2_dpmpyss_s0 IntRegs:$Rs, IntRegs:$Rt),
44          (M2_dpmpyss_s0 IntRegs:$Rs, IntRegs:$Rt)>;
45 def: Pat<(int_hexagon_M2_dpmpyuu_s0 IntRegs:$Rs, IntRegs:$Rt),
46          (M2_dpmpyuu_s0 IntRegs:$Rs, IntRegs:$Rt)>;
47
48 def: Pat<(int_hexagon_S2_asl_i_r IntRegs:$Rs, imm:$u5),
49          (S2_asl_i_r IntRegs:$Rs, imm:$u5)>;
50 def: Pat<(int_hexagon_S2_lsr_i_r IntRegs:$Rs, imm:$u5),
51          (S2_lsr_i_r IntRegs:$Rs, imm:$u5)>;
52 def: Pat<(int_hexagon_S2_asr_i_r IntRegs:$Rs, imm:$u5),
53          (S2_asr_i_r IntRegs:$Rs, imm:$u5)>;
54 def: Pat<(int_hexagon_S2_asl_i_p DoubleRegs:$Rs, imm:$u6),
55          (S2_asl_i_p DoubleRegs:$Rs, imm:$u6)>;
56 def: Pat<(int_hexagon_S2_lsr_i_p DoubleRegs:$Rs, imm:$u6),
57          (S2_lsr_i_p DoubleRegs:$Rs, imm:$u6)>;
58 def: Pat<(int_hexagon_S2_asr_i_p DoubleRegs:$Rs, imm:$u6),
59          (S2_asr_i_p DoubleRegs:$Rs, imm:$u6)>;
60
61 def: Pat<(int_hexagon_A2_and IntRegs:$Rs, IntRegs:$Rt),
62          (A2_and IntRegs:$Rs, IntRegs:$Rt)>;
63 def: Pat<(int_hexagon_A2_andir IntRegs:$Rs, imm:$s10),
64          (A2_andir IntRegs:$Rs, imm:$s10)>;
65 def: Pat<(int_hexagon_A2_or IntRegs:$Rs, IntRegs:$Rt),
66          (A2_or IntRegs:$Rs, IntRegs:$Rt)>;
67 def: Pat<(int_hexagon_A2_orir IntRegs:$Rs, imm:$s10),
68          (A2_orir IntRegs:$Rs, imm:$s10)>;
69 def: Pat<(int_hexagon_A2_xor IntRegs:$Rs, IntRegs:$Rt),
70          (A2_xor IntRegs:$Rs, IntRegs:$Rt)>;
71
72 def: Pat<(int_hexagon_A2_sxtb IntRegs:$Rs),
73          (A2_sxtb IntRegs:$Rs)>;
74 def: Pat<(int_hexagon_A2_sxth IntRegs:$Rs),
75          (A2_sxth IntRegs:$Rs)>;
76 def: Pat<(int_hexagon_A2_zxtb IntRegs:$Rs),
77          (A2_zxtb IntRegs:$Rs)>;
78 def: Pat<(int_hexagon_A2_zxth IntRegs:$Rs),
79          (A2_zxth IntRegs:$Rs)>;
80
81 // Assembler mapped from Rd32=not(Rs32) to Rd32=sub(#-1,Rs32)
82 def : Pat <(int_hexagon_A2_not I32:$Rs),
83            (A2_subri -1, I32:$Rs)>;
84
85 // Assembler mapped from Rd32=neg(Rs32) to Rd32=sub(#0,Rs32)
86 def : Pat <(int_hexagon_A2_neg I32:$Rs),
87            (A2_subri 0, I32:$Rs)>;
88
89 // Make sure the patterns with zero immediate value has higher complexity
90 // otherwise, we need to updated the predicates for immediates to exclude zero
91 let AddedComplexity = 200 in {
92 def : Pat <(int_hexagon_S2_asr_i_r_rnd_goodsyntax I32:$Rs, (i32 0)),
93            (A2_tfr I32:$Rs)>;
94 def : Pat <(int_hexagon_S2_asr_i_p_rnd_goodsyntax I64:$Rs, (i32 0)),
95            (A2_combinew (HiReg I64:$Rs), (LoReg I64:$Rs))>;
96 def : Pat <(int_hexagon_S5_vasrhrnd_goodsyntax I64:$Rs, (i32 0)),
97            (A2_combinew (HiReg I64:$Rs), (LoReg I64:$Rs))>;
98 def : Pat <(int_hexagon_S5_asrhub_rnd_sat_goodsyntax I64:$Rs, (i32 0)),
99            (S2_vsathub I64:$Rs)>;
100 }
101
102 def : Pat <(int_hexagon_S2_asr_i_r_rnd_goodsyntax I32:$Rs, u5_0ImmPred:$imm),
103            (S2_asr_i_r_rnd I32:$Rs, (UDEC1 u5_0ImmPred:$imm))>;
104 def : Pat <(int_hexagon_S2_asr_i_p_rnd_goodsyntax I64:$Rs, u6_0ImmPred:$imm),
105            (S2_asr_i_p_rnd I64:$Rs, (UDEC1 u6_0ImmPred:$imm))>;
106 def : Pat <(int_hexagon_S5_vasrhrnd_goodsyntax I64:$Rs, u4_0ImmPred:$imm),
107            (S5_vasrhrnd I64:$Rs, (UDEC1 u4_0ImmPred:$imm))>;
108 def : Pat <(int_hexagon_S5_asrhub_rnd_sat_goodsyntax I64:$Rs, u4_0ImmPred:$imm),
109            (S5_asrhub_rnd_sat I64:$Rs, (UDEC1 u4_0ImmPred:$imm))>;
110
111 def ImmExt64: SDNodeXForm<imm, [{
112   int64_t V = N->getSExtValue();
113   return CurDAG->getTargetConstant(V, SDLoc(N), MVT::i64);
114 }]>;
115
116 // A2_tfrpi has an operand of type i64. This is necessary, since it is
117 // generated from "(set I64:$Rd, imm)". That pattern would not appear
118 // in the DAG, if the immediate was not a 64-bit value.
119 // The builtin for A2_tfrpi, on the other hand, takes a 32-bit value,
120 // which makes it impossible to simply replace it with the instruction.
121 // To connect the builtin with the instruction, the builtin's operand
122 // needs to be extended to the right type.
123
124 def : Pat<(int_hexagon_A2_tfrpi imm:$Is),
125           (A2_tfrpi (ImmExt64 $Is))>;
126
127 def : Pat <(int_hexagon_C2_cmpgei I32:$src1, s32_0ImmPred:$src2),
128            (C2_tfrpr (C2_cmpgti I32:$src1, (SDEC1 s32_0ImmPred:$src2)))>;
129
130 def : Pat <(int_hexagon_C2_cmpgeui I32:$src1, u32_0ImmPred:$src2),
131            (C2_tfrpr (C2_cmpgtui I32:$src1, (UDEC1 u32_0ImmPred:$src2)))>;
132
133 def : Pat <(int_hexagon_C2_cmpgeui I32:$src, 0),
134            (C2_tfrpr (C2_cmpeq I32:$src, I32:$src))>;
135 def : Pat <(int_hexagon_C2_cmplt I32:$src1, I32:$src2),
136            (C2_tfrpr (C2_cmpgt I32:$src2, I32:$src1))>;
137 def : Pat <(int_hexagon_C2_cmpltu I32:$src1, I32:$src2),
138            (C2_tfrpr (C2_cmpgtu I32:$src2, I32:$src1))>;
139
140 //===----------------------------------------------------------------------===//
141 // Template 'def pat' to map tableidx[bhwd] intrinsics to :raw instructions.
142 //===----------------------------------------------------------------------===//
143 class S2op_tableidx_pat <Intrinsic IntID, InstHexagon OutputInst,
144                          SDNodeXForm XformImm>
145   : Pat <(IntID I32:$src1, I32:$src2, u4_0ImmPred:$src3, u5_0ImmPred:$src4),
146          (OutputInst I32:$src1, I32:$src2, u4_0ImmPred:$src3,
147                      (XformImm u5_0ImmPred:$src4))>;
148
149 def SDEC2 : SDNodeXForm<imm, [{
150   int32_t V = N->getSExtValue();
151   return CurDAG->getTargetConstant(V-2, SDLoc(N), MVT::i32);
152 }]>;
153
154 def SDEC3 : SDNodeXForm<imm, [{
155   int32_t V = N->getSExtValue();
156   return CurDAG->getTargetConstant(V-3, SDLoc(N), MVT::i32);
157 }]>;
158
159 // Table Index : Extract and insert bits.
160 // Map to the real hardware instructions after subtracting appropriate
161 // values from the 4th input operand. Please note that subtraction is not
162 // needed for int_hexagon_S2_tableidxb_goodsyntax.
163
164 def : S2op_tableidx_pat <int_hexagon_S2_tableidxb_goodsyntax, S2_tableidxb,
165                          IdImm>;
166 def : S2op_tableidx_pat <int_hexagon_S2_tableidxh_goodsyntax, S2_tableidxh,
167                          SDEC1>;
168 def : S2op_tableidx_pat <int_hexagon_S2_tableidxw_goodsyntax, S2_tableidxw,
169                          SDEC2>;
170 def : S2op_tableidx_pat <int_hexagon_S2_tableidxd_goodsyntax, S2_tableidxd,
171                          SDEC3>;
172
173 // Load/store locked.
174 def : T_R_pat<L2_loadw_locked, int_hexagon_L2_loadw_locked>;
175 def : T_R_pat<L4_loadd_locked, int_hexagon_L4_loadd_locked>;
176
177 def : Pat<(int_hexagon_S2_storew_locked I32:$Rs, I32:$Rt),
178           (C2_tfrpr (S2_storew_locked I32:$Rs, I32:$Rt))>;
179 def : Pat<(int_hexagon_S4_stored_locked I32:$Rs, I64:$Rt),
180           (C2_tfrpr (S4_stored_locked I32:$Rs, I64:$Rt))>;
181
182 //*******************************************************************
183 //           ST
184 //*******************************************************************
185
186 class T_stb_pat <InstHexagon MI, Intrinsic IntID, PatLeaf Val>
187   : Pat<(IntID I32:$Rs, Val:$Rt, I32:$Ru),
188         (MI I32:$Rs, I32:$Ru, Val:$Rt)>;
189
190 def : T_stb_pat <S2_storerh_pbr, int_hexagon_S2_storerh_pbr, I32>;
191 def : T_stb_pat <S2_storerb_pbr, int_hexagon_S2_storerb_pbr, I32>;
192 def : T_stb_pat <S2_storeri_pbr, int_hexagon_S2_storeri_pbr, I32>;
193 def : T_stb_pat <S2_storerf_pbr, int_hexagon_S2_storerf_pbr, I32>;
194 def : T_stb_pat <S2_storerd_pbr, int_hexagon_S2_storerd_pbr, I64>;
195
196 class T_stc_pat <InstHexagon MI, Intrinsic IntID, PatLeaf Imm, PatLeaf Val>
197   : Pat<(IntID I32:$Rs, Val:$Rt, I32:$Ru, Imm:$s),
198         (MI I32:$Rs, Imm:$s, I32:$Ru, Val:$Rt)>;
199
200 def: T_stc_pat<S2_storerb_pci, int_hexagon_circ_stb,   s4_0ImmPred, I32>;
201 def: T_stc_pat<S2_storerh_pci, int_hexagon_circ_sth,   s4_1ImmPred, I32>;
202 def: T_stc_pat<S2_storeri_pci, int_hexagon_circ_stw,   s4_2ImmPred, I32>;
203 def: T_stc_pat<S2_storerd_pci, int_hexagon_circ_std,   s4_3ImmPred, I64>;
204 def: T_stc_pat<S2_storerf_pci, int_hexagon_circ_sthhi, s4_1ImmPred, I32>;
205
206 multiclass MaskedStore <InstHexagon MI, Intrinsic IntID> {
207   def : Pat<(IntID HvxQR:$src1, IntRegs:$src2, HvxVR:$src3),
208             (MI HvxQR:$src1, IntRegs:$src2, #0, HvxVR:$src3)>,
209         Requires<[UseHVX]>;
210
211   def : Pat<(!cast<Intrinsic>(IntID#"_128B") HvxQR:$src1, IntRegs:$src2,
212                                              HvxVR:$src3),
213             (MI HvxQR:$src1, IntRegs:$src2, #0, HvxVR:$src3)>,
214         Requires<[UseHVX]>;
215 }
216
217 defm : MaskedStore <V6_vS32b_qpred_ai, int_hexagon_V6_vmaskedstoreq>;
218 defm : MaskedStore <V6_vS32b_nqpred_ai, int_hexagon_V6_vmaskedstorenq>;
219 defm : MaskedStore <V6_vS32b_nt_qpred_ai, int_hexagon_V6_vmaskedstorentq>;
220 defm : MaskedStore <V6_vS32b_nt_nqpred_ai, int_hexagon_V6_vmaskedstorentnq>;
221
222 defm : MaskedStore <V6_vS32b_qpred_ai, int_hexagon_V6_vS32b_qpred_ai>;
223 defm : MaskedStore <V6_vS32b_nqpred_ai, int_hexagon_V6_vS32b_nqpred_ai>;
224 defm : MaskedStore <V6_vS32b_nt_qpred_ai, int_hexagon_V6_vS32b_nt_qpred_ai>;
225 defm : MaskedStore <V6_vS32b_nt_nqpred_ai, int_hexagon_V6_vS32b_nt_nqpred_ai>;
226
227 //*******************************************************************
228 //           SYSTEM
229 //*******************************************************************
230
231 def: T_R_pat<Y2_dccleana,    int_hexagon_Y2_dccleana>;
232 def: T_R_pat<Y2_dccleaninva, int_hexagon_Y2_dccleaninva>;
233 def: T_R_pat<Y2_dcinva,      int_hexagon_Y2_dcinva>;
234 def: T_R_pat<Y2_dczeroa,     int_hexagon_Y2_dczeroa>;
235
236 def: T_RR_pat<Y4_l2fetch,    int_hexagon_Y4_l2fetch>;
237 def: T_RP_pat<Y5_l2fetch,    int_hexagon_Y5_l2fetch>;
238
239 //
240 // Patterns for optimizing code generations for HVX.
241
242 def u3_64_ImmPred  : PatLeaf<(i32 imm), [{
243   int64_t v = (int64_t)(64 - N->getSExtValue());
244   return isUInt<3>(v);
245 }]>;
246
247 def u3_128_ImmPred  : PatLeaf<(i32 imm), [{
248   int64_t v = (int64_t)(128 - N->getSExtValue());
249   return isUInt<3>(v);
250 }]>;
251
252 def SUB_64_VAL : SDNodeXForm<imm, [{
253    int32_t Imm = N->getSExtValue();
254    return CurDAG->getTargetConstant(64 - Imm, SDLoc(N), MVT::i32);
255 }]>;
256
257 def SUB_128_VAL : SDNodeXForm<imm, [{
258    int32_t Imm = N->getSExtValue();
259    return CurDAG->getTargetConstant(128 - Imm, SDLoc(N), MVT::i32);
260 }]>;
261
262 let AddedComplexity = 100 in {
263 def : Pat <(v16i32 (int_hexagon_V6_lo (v32i32 HvxWR:$src1))),
264            (v16i32 (EXTRACT_SUBREG (v32i32 HvxWR:$src1), vsub_lo))>,
265            Requires<[UseHVX]>;
266
267 def : Pat <(v16i32 (int_hexagon_V6_hi (v32i32 HvxWR:$src1))),
268            (v16i32 (EXTRACT_SUBREG (v32i32 HvxWR:$src1), vsub_hi))>,
269            Requires<[UseHVX]>;
270
271 def : Pat <(v32i32 (int_hexagon_V6_lo_128B (v64i32 HvxWR:$src1))),
272            (v32i32 (EXTRACT_SUBREG (v64i32 HvxWR:$src1), vsub_lo))>,
273            Requires<[UseHVX]>;
274
275 def : Pat <(v32i32 (int_hexagon_V6_hi_128B (v64i32 HvxWR:$src1))),
276            (v32i32 (EXTRACT_SUBREG (v64i32 HvxWR:$src1), vsub_hi))>,
277            Requires<[UseHVX]>;
278 }
279
280 def : Pat <(v512i1 (bitconvert (v16i32 HvxVR:$src1))),
281            (v512i1 (V6_vandvrt (v16i32 HvxVR:$src1), (A2_tfrsi 0x01010101)))>,
282            Requires<[UseHVX]>;
283
284 def : Pat <(v512i1 (bitconvert (v32i16 HvxVR:$src1))),
285            (v512i1 (V6_vandvrt (v32i16 HvxVR:$src1), (A2_tfrsi 0x01010101)))>,
286            Requires<[UseHVX]>;
287
288 def : Pat <(v512i1 (bitconvert (v64i8  HvxVR:$src1))),
289            (v512i1 (V6_vandvrt (v64i8  HvxVR:$src1), (A2_tfrsi 0x01010101)))>,
290            Requires<[UseHVX]>;
291
292 def : Pat <(v16i32 (bitconvert (v512i1 HvxQR:$src1))),
293            (v16i32 (V6_vandqrt (v512i1 HvxQR:$src1), (A2_tfrsi 0x01010101)))>,
294            Requires<[UseHVX]>;
295
296 def : Pat <(v32i16 (bitconvert (v512i1 HvxQR:$src1))),
297            (v32i16 (V6_vandqrt (v512i1 HvxQR:$src1), (A2_tfrsi 0x01010101)))>,
298            Requires<[UseHVX]>;
299
300 def : Pat <(v64i8  (bitconvert (v512i1 HvxQR:$src1))),
301            (v64i8  (V6_vandqrt (v512i1 HvxQR:$src1), (A2_tfrsi 0x01010101)))>,
302            Requires<[UseHVX]>;
303
304 def : Pat <(v1024i1 (bitconvert (v32i32 HvxVR:$src1))),
305            (v1024i1 (V6_vandvrt (v32i32 HvxVR:$src1), (A2_tfrsi 0x01010101)))>,
306            Requires<[UseHVX]>;
307
308 def : Pat <(v1024i1 (bitconvert (v64i16 HvxVR:$src1))),
309            (v1024i1 (V6_vandvrt (v64i16 HvxVR:$src1), (A2_tfrsi 0x01010101)))>,
310            Requires<[UseHVX]>;
311
312 def : Pat <(v1024i1 (bitconvert (v128i8 HvxVR:$src1))),
313            (v1024i1 (V6_vandvrt (v128i8 HvxVR:$src1), (A2_tfrsi 0x01010101)))>,
314            Requires<[UseHVX]>;
315
316 def : Pat <(v32i32 (bitconvert (v1024i1 HvxQR:$src1))),
317            (v32i32 (V6_vandqrt (v1024i1 HvxQR:$src1), (A2_tfrsi 0x01010101)))>,
318            Requires<[UseHVX]>;
319
320 def : Pat <(v64i16 (bitconvert (v1024i1 HvxQR:$src1))),
321            (v64i16 (V6_vandqrt (v1024i1 HvxQR:$src1), (A2_tfrsi 0x01010101)))>,
322            Requires<[UseHVX]>;
323
324 def : Pat <(v128i8 (bitconvert (v1024i1 HvxQR:$src1))),
325            (v128i8 (V6_vandqrt (v1024i1 HvxQR:$src1), (A2_tfrsi 0x01010101)))>,
326            Requires<[UseHVX]>;
327
328 let AddedComplexity = 140 in {
329 def : Pat <(store (v512i1 HvxQR:$src1), (i32 IntRegs:$addr)),
330            (V6_vS32b_ai IntRegs:$addr, 0,
331            (v16i32 (V6_vandqrt (v512i1 HvxQR:$src1), (A2_tfrsi 0x01010101))))>,
332            Requires<[UseHVX]>;
333
334 def : Pat <(v512i1 (load (i32 IntRegs:$addr))),
335            (v512i1 (V6_vandvrt
336            (v16i32 (V6_vL32b_ai IntRegs:$addr, 0)), (A2_tfrsi 0x01010101)))>,
337            Requires<[UseHVX]>;
338
339 def : Pat <(store (v1024i1 HvxQR:$src1), (i32 IntRegs:$addr)),
340            (V6_vS32b_ai IntRegs:$addr, 0,
341            (v32i32 (V6_vandqrt (v1024i1 HvxQR:$src1), (A2_tfrsi 0x01010101))))>,
342            Requires<[UseHVX]>;
343
344 def : Pat <(v1024i1 (load (i32 IntRegs:$addr))),
345            (v1024i1 (V6_vandvrt
346            (v32i32 (V6_vL32b_ai IntRegs:$addr, 0)), (A2_tfrsi 0x01010101)))>,
347            Requires<[UseHVX]>;
348 }
349
350 def: Pat<(v64i16 (trunc v64i32:$Vdd)),
351          (v64i16 (V6_vpackwh_sat
352                  (v32i32 (V6_hi HvxWR:$Vdd)),
353                  (v32i32 (V6_lo HvxWR:$Vdd))))>,
354      Requires<[UseHVX]>;
355
356 def: Pat<(int_hexagon_S2_asr_i_vh DoubleRegs:$src1, IntRegs:$src2),
357          (S2_asr_r_vh DoubleRegs:$src1, IntRegs:$src2)>, Requires<[HasV55]>;
358
359 multiclass T_VI_pat <InstHexagon MI, Intrinsic IntID> {
360   def: Pat<(IntID HvxVR:$src1, u3_0ImmPred:$src2),
361            (MI    HvxVR:$src1, HvxVR:$src1, u3_0ImmPred:$src2)>,
362        Requires<[UseHVX]>;
363
364   def: Pat<(!cast<Intrinsic>(IntID#"_128B") HvxVR:$src1, u3_0ImmPred:$src2),
365            (MI                 HvxVR:$src1, HvxVR:$src1, u3_0ImmPred:$src2)>,
366        Requires<[UseHVX]>;
367 }
368
369 multiclass T_VI_inv_pat <InstHexagon MI, Intrinsic IntID> {
370   def: Pat<(IntID HvxVR:$src1, u3_64_ImmPred:$src2),
371            (MI    HvxVR:$src1, HvxVR:$src1,
372                   (SUB_64_VAL u3_64_ImmPred:$src2))>,
373        Requires<[UseHVX]>;
374
375   def: Pat<(!cast<Intrinsic>(IntID#"_128B") HvxVR:$src1, u3_128_ImmPred:$src2),
376            (MI HvxVR:$src1, HvxVR:$src1, (SUB_128_VAL u3_128_ImmPred:$src2))>,
377        Requires<[UseHVX]>;
378 }
379
380 multiclass T_VVI_pat <InstHexagon MI, Intrinsic IntID> {
381   def: Pat<(IntID HvxVR:$src1, HvxVR:$src2, u3_0ImmPred:$src3),
382            (MI    HvxVR:$src1, HvxVR:$src2, u3_0ImmPred:$src3)>,
383        Requires<[UseHVX]>;
384
385   def: Pat<(!cast<Intrinsic>(IntID#"_128B") HvxVR:$src1, HvxVR:$src2,
386                                             u3_0ImmPred:$src3),
387            (MI                              HvxVR:$src1, HvxVR:$src2,
388                                             u3_0ImmPred:$src3)>,
389        Requires<[UseHVX]>;
390 }
391
392 multiclass T_VVI_inv_pat <InstHexagon MI, Intrinsic IntID> {
393   def: Pat<(IntID HvxVR:$src1, HvxVR:$src2, u3_64_ImmPred:$src3),
394            (MI    HvxVR:$src1, HvxVR:$src2,
395                                     (SUB_64_VAL u3_64_ImmPred:$src3))>,
396        Requires<[UseHVX]>;
397
398   def: Pat<(!cast<Intrinsic>(IntID#"_128B") HvxVR:$src1, HvxVR:$src2,
399                                             u3_128_ImmPred:$src3),
400            (MI                              HvxVR:$src1, HvxVR:$src2,
401                                           (SUB_128_VAL u3_128_ImmPred:$src3))>,
402        Requires<[UseHVX]>;
403 }
404
405 multiclass T_VVR_pat <InstHexagon MI, Intrinsic IntID> {
406   def: Pat<(IntID HvxVR:$src1, HvxVR:$src2, IntRegs:$src3),
407            (MI    HvxVR:$src1, HvxVR:$src2, IntRegs:$src3)>,
408        Requires<[UseHVX]>;
409
410   def: Pat<(!cast<Intrinsic>(IntID#"_128B") HvxVR:$src1, HvxVR:$src2,
411                                             IntRegs:$src3),
412            (MI                              HvxVR:$src1, HvxVR:$src2,
413                                             IntRegs:$src3)>,
414        Requires<[UseHVX]>;
415 }
416
417 defm : T_VI_pat <V6_valignbi, int_hexagon_V6_vror>;
418 defm : T_VI_inv_pat <V6_vlalignbi, int_hexagon_V6_vror>;
419
420 defm : T_VVI_pat <V6_valignbi, int_hexagon_V6_valignb>;
421 defm : T_VVI_inv_pat <V6_vlalignbi, int_hexagon_V6_valignbi>;
422 defm : T_VVI_inv_pat <V6_vlalignbi, int_hexagon_V6_valignb>;
423 defm : T_VVR_pat <V6_valignb, int_hexagon_V6_valignbi>;
424 defm : T_VVI_pat <V6_vlalignbi, int_hexagon_V6_vlalignb>;
425 defm : T_VVI_inv_pat <V6_valignbi, int_hexagon_V6_vlalignbi>;
426 defm : T_VVI_inv_pat <V6_valignbi, int_hexagon_V6_vlalignb>;
427 defm : T_VVR_pat <V6_vlalignb, int_hexagon_V6_vlalignbi>;
428
429 def: Pat<(int_hexagon_V6_vd0),
430          (V6_vd0)>, Requires<[HasV60, UseHVX64B]>;
431 def: Pat<(int_hexagon_V6_vd0_128B ),
432          (V6_vd0)>, Requires<[HasV60, UseHVX128B]>;
433
434 def: Pat<(int_hexagon_V6_vdd0),
435          (V6_vdd0)>, Requires<[HasV65, UseHVX64B]>;
436 def: Pat<(int_hexagon_V6_vdd0_128B),
437          (V6_vdd0)>, Requires<[HasV65, UseHVX128B]>;
438
439 def: Pat<(int_hexagon_V6_vscattermw IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
440          (V6_vscattermw IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
441 def: Pat<(int_hexagon_V6_vscattermh IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
442          (V6_vscattermh IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
443 def: Pat<(int_hexagon_V6_vscattermw_add IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
444          (V6_vscattermw_add IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
445 def: Pat<(int_hexagon_V6_vscattermh_add IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
446          (V6_vscattermh_add IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
447 def: Pat<(int_hexagon_V6_vscattermwq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5),
448          (V6_vscattermwq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5)>, Requires<[HasV65, UseHVX]>;
449 def: Pat<(int_hexagon_V6_vscattermhq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5),
450          (V6_vscattermhq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5)>, Requires<[HasV65, UseHVX]>;
451 def: Pat<(int_hexagon_V6_vscattermhw IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4),
452          (V6_vscattermhw IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
453 def: Pat<(int_hexagon_V6_vscattermhw_add IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4),
454          (V6_vscattermhw_add IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
455 def: Pat<(int_hexagon_V6_vscattermhwq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxWR:$src4, HvxVR:$src5),
456          (V6_vscattermhwq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxWR:$src4, HvxVR:$src5)>, Requires<[HasV65, UseHVX]>;
457 def: Pat<(int_hexagon_V6_vscattermw_128B IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
458          (V6_vscattermw IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
459 def: Pat<(int_hexagon_V6_vscattermh_128B IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
460          (V6_vscattermh IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
461 def: Pat<(int_hexagon_V6_vscattermw_add_128B IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
462          (V6_vscattermw_add IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
463 def: Pat<(int_hexagon_V6_vscattermh_add_128B IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4),
464          (V6_vscattermh_add IntRegs:$src1, ModRegs:$src2, HvxVR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
465 def: Pat<(int_hexagon_V6_vscattermwq_128B HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5),
466          (V6_vscattermwq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5)>, Requires<[HasV65, UseHVX]>;
467 def: Pat<(int_hexagon_V6_vscattermhq_128B HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5),
468          (V6_vscattermhq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxVR:$src4, HvxVR:$src5)>, Requires<[HasV65, UseHVX]>;
469 def: Pat<(int_hexagon_V6_vscattermhw_128B IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4),
470          (V6_vscattermhw IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
471 def: Pat<(int_hexagon_V6_vscattermhw_add_128B IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4),
472          (V6_vscattermhw_add IntRegs:$src1, ModRegs:$src2, HvxWR:$src3, HvxVR:$src4)>, Requires<[HasV65, UseHVX]>;
473 def: Pat<(int_hexagon_V6_vscattermhwq_128B HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxWR:$src4, HvxVR:$src5),
474          (V6_vscattermhwq HvxQR:$src1, IntRegs:$src2, ModRegs:$src3, HvxWR:$src4, HvxVR:$src5)>, Requires<[HasV65, UseHVX]>;
475
476 include "HexagonDepMapAsm2Intrin.td"