xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZOperators.td (revision e92ffd9b626833ebdbf2742c8ffddc6cd94b963e)
1//===-- SystemZOperators.td - SystemZ-specific operators ------*- tblgen-*-===//
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//===----------------------------------------------------------------------===//
10// Type profiles
11//===----------------------------------------------------------------------===//
12def SDT_CallSeqStart        : SDCallSeqStart<[SDTCisVT<0, i64>,
13                                              SDTCisVT<1, i64>]>;
14def SDT_CallSeqEnd          : SDCallSeqEnd<[SDTCisVT<0, i64>,
15                                            SDTCisVT<1, i64>]>;
16def SDT_ZCall               : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
17def SDT_ZCmp                : SDTypeProfile<1, 2,
18                                            [SDTCisVT<0, i32>,
19                                             SDTCisSameAs<1, 2>]>;
20def SDT_ZICmp               : SDTypeProfile<1, 3,
21                                            [SDTCisVT<0, i32>,
22                                             SDTCisSameAs<1, 2>,
23                                             SDTCisVT<3, i32>]>;
24def SDT_ZBRCCMask           : SDTypeProfile<0, 4,
25                                            [SDTCisVT<0, i32>,
26                                             SDTCisVT<1, i32>,
27                                             SDTCisVT<2, OtherVT>,
28                                             SDTCisVT<3, i32>]>;
29def SDT_ZSelectCCMask       : SDTypeProfile<1, 5,
30                                            [SDTCisSameAs<0, 1>,
31                                             SDTCisSameAs<1, 2>,
32                                             SDTCisVT<3, i32>,
33                                             SDTCisVT<4, i32>,
34                                             SDTCisVT<5, i32>]>;
35def SDT_ZWrapPtr            : SDTypeProfile<1, 1,
36                                            [SDTCisSameAs<0, 1>,
37                                             SDTCisPtrTy<0>]>;
38def SDT_ZWrapOffset         : SDTypeProfile<1, 2,
39                                            [SDTCisSameAs<0, 1>,
40                                             SDTCisSameAs<0, 2>,
41                                             SDTCisPtrTy<0>]>;
42def SDT_ZAdjDynAlloc        : SDTypeProfile<1, 0, [SDTCisVT<0, i64>]>;
43def SDT_ZProbedAlloca       : SDTypeProfile<1, 2,
44                                            [SDTCisSameAs<0, 1>,
45                                             SDTCisSameAs<0, 2>,
46                                             SDTCisPtrTy<0>]>;
47def SDT_ZGR128Binary        : SDTypeProfile<1, 2,
48                                            [SDTCisVT<0, untyped>,
49                                             SDTCisInt<1>,
50                                             SDTCisInt<2>]>;
51def SDT_ZBinaryWithFlags    : SDTypeProfile<2, 2,
52                                            [SDTCisInt<0>,
53                                             SDTCisVT<1, i32>,
54                                             SDTCisSameAs<0, 2>,
55                                             SDTCisSameAs<0, 3>]>;
56def SDT_ZBinaryWithCarry    : SDTypeProfile<2, 3,
57                                            [SDTCisInt<0>,
58                                             SDTCisVT<1, i32>,
59                                             SDTCisSameAs<0, 2>,
60                                             SDTCisSameAs<0, 3>,
61                                             SDTCisVT<1, i32>]>;
62def SDT_ZAtomicLoadBinaryW  : SDTypeProfile<1, 5,
63                                            [SDTCisVT<0, i32>,
64                                             SDTCisPtrTy<1>,
65                                             SDTCisVT<2, i32>,
66                                             SDTCisVT<3, i32>,
67                                             SDTCisVT<4, i32>,
68                                             SDTCisVT<5, i32>]>;
69def SDT_ZAtomicCmpSwapW     : SDTypeProfile<2, 6,
70                                            [SDTCisVT<0, i32>,
71                                             SDTCisVT<1, i32>,
72                                             SDTCisPtrTy<2>,
73                                             SDTCisVT<3, i32>,
74                                             SDTCisVT<4, i32>,
75                                             SDTCisVT<5, i32>,
76                                             SDTCisVT<6, i32>,
77                                             SDTCisVT<7, i32>]>;
78def SDT_ZAtomicCmpSwap      : SDTypeProfile<2, 3,
79                                            [SDTCisInt<0>,
80                                             SDTCisVT<1, i32>,
81                                             SDTCisPtrTy<2>,
82                                             SDTCisSameAs<0, 3>,
83                                             SDTCisSameAs<0, 4>]>;
84def SDT_ZAtomicLoad128      : SDTypeProfile<1, 1,
85                                            [SDTCisVT<0, untyped>,
86                                             SDTCisPtrTy<1>]>;
87def SDT_ZAtomicStore128     : SDTypeProfile<0, 2,
88                                            [SDTCisVT<0, untyped>,
89                                             SDTCisPtrTy<1>]>;
90def SDT_ZAtomicCmpSwap128   : SDTypeProfile<2, 3,
91                                            [SDTCisVT<0, untyped>,
92                                             SDTCisVT<1, i32>,
93                                             SDTCisPtrTy<2>,
94                                             SDTCisVT<3, untyped>,
95                                             SDTCisVT<4, untyped>]>;
96def SDT_ZMemMemLength       : SDTypeProfile<0, 3,
97                                            [SDTCisPtrTy<0>,
98                                             SDTCisPtrTy<1>,
99                                             SDTCisVT<2, i64>]>;
100def SDT_ZMemMemLengthCC     : SDTypeProfile<1, 3,
101                                            [SDTCisVT<0, i32>,
102                                             SDTCisPtrTy<1>,
103                                             SDTCisPtrTy<2>,
104                                             SDTCisVT<3, i64>]>;
105def SDT_ZMemMemLoop         : SDTypeProfile<0, 4,
106                                            [SDTCisPtrTy<0>,
107                                             SDTCisPtrTy<1>,
108                                             SDTCisVT<2, i64>,
109                                             SDTCisVT<3, i64>]>;
110def SDT_ZMemMemLoopCC       : SDTypeProfile<1, 4,
111                                            [SDTCisVT<0, i32>,
112                                             SDTCisPtrTy<1>,
113                                             SDTCisPtrTy<2>,
114                                             SDTCisVT<3, i64>,
115                                             SDTCisVT<4, i64>]>;
116def SDT_ZString             : SDTypeProfile<1, 3,
117                                            [SDTCisPtrTy<0>,
118                                             SDTCisPtrTy<1>,
119                                             SDTCisPtrTy<2>,
120                                             SDTCisVT<3, i32>]>;
121def SDT_ZStringCC           : SDTypeProfile<2, 3,
122                                            [SDTCisPtrTy<0>,
123                                             SDTCisVT<1, i32>,
124                                             SDTCisPtrTy<2>,
125                                             SDTCisPtrTy<3>,
126                                             SDTCisVT<4, i32>]>;
127def SDT_ZIPM                : SDTypeProfile<1, 1,
128                                            [SDTCisVT<0, i32>,
129                                             SDTCisVT<1, i32>]>;
130def SDT_ZPrefetch           : SDTypeProfile<0, 2,
131                                            [SDTCisVT<0, i32>,
132                                             SDTCisPtrTy<1>]>;
133def SDT_ZTBegin             : SDTypeProfile<1, 2,
134                                            [SDTCisVT<0, i32>,
135                                             SDTCisPtrTy<1>,
136                                             SDTCisVT<2, i32>]>;
137def SDT_ZTEnd               : SDTypeProfile<1, 0,
138                                            [SDTCisVT<0, i32>]>;
139def SDT_ZInsertVectorElt    : SDTypeProfile<1, 3,
140                                            [SDTCisVec<0>,
141                                             SDTCisSameAs<0, 1>,
142                                             SDTCisVT<3, i32>]>;
143def SDT_ZExtractVectorElt   : SDTypeProfile<1, 2,
144                                            [SDTCisVec<1>,
145                                             SDTCisVT<2, i32>]>;
146def SDT_ZReplicate          : SDTypeProfile<1, 1,
147                                            [SDTCisVec<0>]>;
148def SDT_ZVecUnaryConv       : SDTypeProfile<1, 1,
149                                            [SDTCisVec<0>,
150                                             SDTCisVec<1>]>;
151def SDT_ZVecUnary           : SDTypeProfile<1, 1,
152                                            [SDTCisVec<0>,
153                                             SDTCisSameAs<0, 1>]>;
154def SDT_ZVecUnaryCC         : SDTypeProfile<2, 1,
155                                            [SDTCisVec<0>,
156                                             SDTCisVT<1, i32>,
157                                             SDTCisSameAs<0, 2>]>;
158def SDT_ZVecBinary          : SDTypeProfile<1, 2,
159                                            [SDTCisVec<0>,
160                                             SDTCisSameAs<0, 1>,
161                                             SDTCisSameAs<0, 2>]>;
162def SDT_ZVecBinaryCC        : SDTypeProfile<2, 2,
163                                            [SDTCisVec<0>,
164                                             SDTCisVT<1, i32>,
165                                             SDTCisSameAs<0, 2>,
166                                             SDTCisSameAs<0, 2>]>;
167def SDT_ZVecBinaryInt       : SDTypeProfile<1, 2,
168                                            [SDTCisVec<0>,
169                                             SDTCisSameAs<0, 1>,
170                                             SDTCisVT<2, i32>]>;
171def SDT_ZVecBinaryConv      : SDTypeProfile<1, 2,
172                                            [SDTCisVec<0>,
173                                             SDTCisVec<1>,
174                                             SDTCisSameAs<1, 2>]>;
175def SDT_ZVecBinaryConvCC    : SDTypeProfile<2, 2,
176                                            [SDTCisVec<0>,
177                                             SDTCisVT<1, i32>,
178                                             SDTCisVec<2>,
179                                             SDTCisSameAs<2, 3>]>;
180def SDT_ZVecBinaryConvIntCC : SDTypeProfile<2, 2,
181                                            [SDTCisVec<0>,
182                                             SDTCisVT<1, i32>,
183                                             SDTCisVec<2>,
184                                             SDTCisVT<3, i32>]>;
185def SDT_ZRotateMask         : SDTypeProfile<1, 2,
186                                            [SDTCisVec<0>,
187                                             SDTCisVT<1, i32>,
188                                             SDTCisVT<2, i32>]>;
189def SDT_ZJoinDwords         : SDTypeProfile<1, 2,
190                                            [SDTCisVT<0, v2i64>,
191                                             SDTCisVT<1, i64>,
192                                             SDTCisVT<2, i64>]>;
193def SDT_ZVecTernary         : SDTypeProfile<1, 3,
194                                            [SDTCisVec<0>,
195                                             SDTCisSameAs<0, 1>,
196                                             SDTCisSameAs<0, 2>,
197                                             SDTCisSameAs<0, 3>]>;
198def SDT_ZVecTernaryConvCC   : SDTypeProfile<2, 3,
199                                            [SDTCisVec<0>,
200                                             SDTCisVT<1, i32>,
201                                             SDTCisVec<2>,
202                                             SDTCisSameAs<2, 3>,
203                                             SDTCisSameAs<0, 4>]>;
204def SDT_ZVecTernaryInt      : SDTypeProfile<1, 3,
205                                            [SDTCisVec<0>,
206                                             SDTCisSameAs<0, 1>,
207                                             SDTCisSameAs<0, 2>,
208                                             SDTCisVT<3, i32>]>;
209def SDT_ZVecTernaryIntCC    : SDTypeProfile<2, 3,
210                                            [SDTCisVec<0>,
211                                             SDTCisVT<1, i32>,
212                                             SDTCisSameAs<0, 2>,
213                                             SDTCisSameAs<0, 3>,
214                                             SDTCisVT<4, i32>]>;
215def SDT_ZVecQuaternaryInt   : SDTypeProfile<1, 4,
216                                            [SDTCisVec<0>,
217                                             SDTCisSameAs<0, 1>,
218                                             SDTCisSameAs<0, 2>,
219                                             SDTCisSameAs<0, 3>,
220                                             SDTCisVT<4, i32>]>;
221def SDT_ZVecQuaternaryIntCC : SDTypeProfile<2, 4,
222                                            [SDTCisVec<0>,
223                                             SDTCisVT<1, i32>,
224                                             SDTCisSameAs<0, 2>,
225                                             SDTCisSameAs<0, 3>,
226                                             SDTCisSameAs<0, 4>,
227                                             SDTCisVT<5, i32>]>;
228def SDT_ZTest               : SDTypeProfile<1, 2,
229                                            [SDTCisVT<0, i32>,
230                                             SDTCisVT<2, i64>]>;
231
232//===----------------------------------------------------------------------===//
233// Node definitions
234//===----------------------------------------------------------------------===//
235
236// These are target-independent nodes, but have target-specific formats.
237def callseq_start       : SDNode<"ISD::CALLSEQ_START", SDT_CallSeqStart,
238                                 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
239def callseq_end         : SDNode<"ISD::CALLSEQ_END",   SDT_CallSeqEnd,
240                                 [SDNPHasChain, SDNPSideEffect, SDNPOptInGlue,
241                                  SDNPOutGlue]>;
242def global_offset_table : SDNode<"ISD::GLOBAL_OFFSET_TABLE", SDTPtrLeaf>;
243
244// Nodes for SystemZISD::*.  See SystemZISelLowering.h for more details.
245def z_retflag           : SDNode<"SystemZISD::RET_FLAG", SDTNone,
246                                 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
247def z_call              : SDNode<"SystemZISD::CALL", SDT_ZCall,
248                                 [SDNPHasChain, SDNPOutGlue, SDNPOptInGlue,
249                                  SDNPVariadic]>;
250def z_sibcall           : SDNode<"SystemZISD::SIBCALL", SDT_ZCall,
251                                 [SDNPHasChain, SDNPOutGlue, SDNPOptInGlue,
252                                  SDNPVariadic]>;
253def z_tls_gdcall        : SDNode<"SystemZISD::TLS_GDCALL", SDT_ZCall,
254                                 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
255                                  SDNPVariadic]>;
256def z_tls_ldcall        : SDNode<"SystemZISD::TLS_LDCALL", SDT_ZCall,
257                                 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
258                                  SDNPVariadic]>;
259def z_pcrel_wrapper     : SDNode<"SystemZISD::PCREL_WRAPPER", SDT_ZWrapPtr, []>;
260def z_pcrel_offset      : SDNode<"SystemZISD::PCREL_OFFSET",
261                                 SDT_ZWrapOffset, []>;
262def z_icmp              : SDNode<"SystemZISD::ICMP", SDT_ZICmp>;
263def z_fcmp              : SDNode<"SystemZISD::FCMP", SDT_ZCmp>;
264def z_strict_fcmp       : SDNode<"SystemZISD::STRICT_FCMP", SDT_ZCmp,
265                                 [SDNPHasChain]>;
266def z_strict_fcmps      : SDNode<"SystemZISD::STRICT_FCMPS", SDT_ZCmp,
267                                 [SDNPHasChain]>;
268def z_tm                : SDNode<"SystemZISD::TM", SDT_ZICmp>;
269def z_br_ccmask_1       : SDNode<"SystemZISD::BR_CCMASK", SDT_ZBRCCMask,
270                                 [SDNPHasChain]>;
271def z_select_ccmask_1   : SDNode<"SystemZISD::SELECT_CCMASK",
272                                 SDT_ZSelectCCMask>;
273def z_ipm_1             : SDNode<"SystemZISD::IPM", SDT_ZIPM>;
274def z_adjdynalloc       : SDNode<"SystemZISD::ADJDYNALLOC", SDT_ZAdjDynAlloc>;
275def z_probed_alloca     : SDNode<"SystemZISD::PROBED_ALLOCA", SDT_ZProbedAlloca,
276                                 [SDNPHasChain]>;
277def z_popcnt            : SDNode<"SystemZISD::POPCNT", SDTIntUnaryOp>;
278def z_smul_lohi         : SDNode<"SystemZISD::SMUL_LOHI", SDT_ZGR128Binary>;
279def z_umul_lohi         : SDNode<"SystemZISD::UMUL_LOHI", SDT_ZGR128Binary>;
280def z_sdivrem           : SDNode<"SystemZISD::SDIVREM", SDT_ZGR128Binary>;
281def z_udivrem           : SDNode<"SystemZISD::UDIVREM", SDT_ZGR128Binary>;
282def z_saddo             : SDNode<"SystemZISD::SADDO", SDT_ZBinaryWithFlags>;
283def z_ssubo             : SDNode<"SystemZISD::SSUBO", SDT_ZBinaryWithFlags>;
284def z_uaddo             : SDNode<"SystemZISD::UADDO", SDT_ZBinaryWithFlags>;
285def z_usubo             : SDNode<"SystemZISD::USUBO", SDT_ZBinaryWithFlags>;
286def z_addcarry_1        : SDNode<"SystemZISD::ADDCARRY", SDT_ZBinaryWithCarry>;
287def z_subcarry_1        : SDNode<"SystemZISD::SUBCARRY", SDT_ZBinaryWithCarry>;
288
289def z_membarrier        : SDNode<"SystemZISD::MEMBARRIER", SDTNone,
290                                 [SDNPHasChain, SDNPSideEffect]>;
291
292def z_loadbswap        : SDNode<"SystemZISD::LRV", SDTLoad,
293                                 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
294def z_storebswap       : SDNode<"SystemZISD::STRV", SDTStore,
295                                 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
296def z_loadeswap        : SDNode<"SystemZISD::VLER", SDTLoad,
297                                 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
298def z_storeeswap       : SDNode<"SystemZISD::VSTER", SDTStore,
299                                 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
300
301def z_tdc               : SDNode<"SystemZISD::TDC", SDT_ZTest>;
302
303// Defined because the index is an i32 rather than a pointer.
304def z_vector_insert     : SDNode<"ISD::INSERT_VECTOR_ELT",
305                                 SDT_ZInsertVectorElt>;
306def z_vector_extract    : SDNode<"ISD::EXTRACT_VECTOR_ELT",
307                                 SDT_ZExtractVectorElt>;
308def z_byte_mask         : SDNode<"SystemZISD::BYTE_MASK", SDT_ZReplicate>;
309def z_rotate_mask       : SDNode<"SystemZISD::ROTATE_MASK", SDT_ZRotateMask>;
310def z_replicate         : SDNode<"SystemZISD::REPLICATE", SDT_ZReplicate>;
311def z_join_dwords       : SDNode<"SystemZISD::JOIN_DWORDS", SDT_ZJoinDwords>;
312def z_splat             : SDNode<"SystemZISD::SPLAT", SDT_ZVecBinaryInt>;
313def z_merge_high        : SDNode<"SystemZISD::MERGE_HIGH", SDT_ZVecBinary>;
314def z_merge_low         : SDNode<"SystemZISD::MERGE_LOW", SDT_ZVecBinary>;
315def z_shl_double        : SDNode<"SystemZISD::SHL_DOUBLE", SDT_ZVecTernaryInt>;
316def z_permute_dwords    : SDNode<"SystemZISD::PERMUTE_DWORDS",
317                                 SDT_ZVecTernaryInt>;
318def z_permute           : SDNode<"SystemZISD::PERMUTE", SDT_ZVecTernary>;
319def z_pack              : SDNode<"SystemZISD::PACK", SDT_ZVecBinaryConv>;
320def z_packs_cc          : SDNode<"SystemZISD::PACKS_CC", SDT_ZVecBinaryConvCC>;
321def z_packls_cc         : SDNode<"SystemZISD::PACKLS_CC", SDT_ZVecBinaryConvCC>;
322def z_unpack_high       : SDNode<"SystemZISD::UNPACK_HIGH", SDT_ZVecUnaryConv>;
323def z_unpackl_high      : SDNode<"SystemZISD::UNPACKL_HIGH", SDT_ZVecUnaryConv>;
324def z_unpack_low        : SDNode<"SystemZISD::UNPACK_LOW", SDT_ZVecUnaryConv>;
325def z_unpackl_low       : SDNode<"SystemZISD::UNPACKL_LOW", SDT_ZVecUnaryConv>;
326def z_vshl_by_scalar    : SDNode<"SystemZISD::VSHL_BY_SCALAR",
327                                 SDT_ZVecBinaryInt>;
328def z_vsrl_by_scalar    : SDNode<"SystemZISD::VSRL_BY_SCALAR",
329                                 SDT_ZVecBinaryInt>;
330def z_vsra_by_scalar    : SDNode<"SystemZISD::VSRA_BY_SCALAR",
331                                 SDT_ZVecBinaryInt>;
332def z_vsum              : SDNode<"SystemZISD::VSUM", SDT_ZVecBinaryConv>;
333def z_vicmpe            : SDNode<"SystemZISD::VICMPE", SDT_ZVecBinary>;
334def z_vicmph            : SDNode<"SystemZISD::VICMPH", SDT_ZVecBinary>;
335def z_vicmphl           : SDNode<"SystemZISD::VICMPHL", SDT_ZVecBinary>;
336def z_vicmpes           : SDNode<"SystemZISD::VICMPES", SDT_ZVecBinaryCC>;
337def z_vicmphs           : SDNode<"SystemZISD::VICMPHS", SDT_ZVecBinaryCC>;
338def z_vicmphls          : SDNode<"SystemZISD::VICMPHLS", SDT_ZVecBinaryCC>;
339def z_vfcmpe            : SDNode<"SystemZISD::VFCMPE", SDT_ZVecBinaryConv>;
340def z_strict_vfcmpe     : SDNode<"SystemZISD::STRICT_VFCMPE",
341                                 SDT_ZVecBinaryConv, [SDNPHasChain]>;
342def z_strict_vfcmpes    : SDNode<"SystemZISD::STRICT_VFCMPES",
343                                 SDT_ZVecBinaryConv, [SDNPHasChain]>;
344def z_vfcmph            : SDNode<"SystemZISD::VFCMPH", SDT_ZVecBinaryConv>;
345def z_strict_vfcmph     : SDNode<"SystemZISD::STRICT_VFCMPH",
346                                 SDT_ZVecBinaryConv, [SDNPHasChain]>;
347def z_strict_vfcmphs    : SDNode<"SystemZISD::STRICT_VFCMPHS",
348                                 SDT_ZVecBinaryConv, [SDNPHasChain]>;
349def z_vfcmphe           : SDNode<"SystemZISD::VFCMPHE", SDT_ZVecBinaryConv>;
350def z_strict_vfcmphe    : SDNode<"SystemZISD::STRICT_VFCMPHE",
351                                 SDT_ZVecBinaryConv, [SDNPHasChain]>;
352def z_strict_vfcmphes   : SDNode<"SystemZISD::STRICT_VFCMPHES",
353                                 SDT_ZVecBinaryConv, [SDNPHasChain]>;
354def z_vfcmpes           : SDNode<"SystemZISD::VFCMPES", SDT_ZVecBinaryConvCC>;
355def z_vfcmphs           : SDNode<"SystemZISD::VFCMPHS", SDT_ZVecBinaryConvCC>;
356def z_vfcmphes          : SDNode<"SystemZISD::VFCMPHES", SDT_ZVecBinaryConvCC>;
357def z_vextend           : SDNode<"SystemZISD::VEXTEND", SDT_ZVecUnaryConv>;
358def z_strict_vextend    : SDNode<"SystemZISD::STRICT_VEXTEND",
359                                 SDT_ZVecUnaryConv, [SDNPHasChain]>;
360def z_vround            : SDNode<"SystemZISD::VROUND", SDT_ZVecUnaryConv>;
361def z_strict_vround     : SDNode<"SystemZISD::STRICT_VROUND",
362                                 SDT_ZVecUnaryConv, [SDNPHasChain]>;
363def z_vtm               : SDNode<"SystemZISD::VTM", SDT_ZCmp>;
364def z_vfae_cc           : SDNode<"SystemZISD::VFAE_CC", SDT_ZVecTernaryIntCC>;
365def z_vfaez_cc          : SDNode<"SystemZISD::VFAEZ_CC", SDT_ZVecTernaryIntCC>;
366def z_vfee_cc           : SDNode<"SystemZISD::VFEE_CC", SDT_ZVecBinaryCC>;
367def z_vfeez_cc          : SDNode<"SystemZISD::VFEEZ_CC", SDT_ZVecBinaryCC>;
368def z_vfene_cc          : SDNode<"SystemZISD::VFENE_CC", SDT_ZVecBinaryCC>;
369def z_vfenez_cc         : SDNode<"SystemZISD::VFENEZ_CC", SDT_ZVecBinaryCC>;
370def z_vistr_cc          : SDNode<"SystemZISD::VISTR_CC", SDT_ZVecUnaryCC>;
371def z_vstrc_cc          : SDNode<"SystemZISD::VSTRC_CC",
372                                 SDT_ZVecQuaternaryIntCC>;
373def z_vstrcz_cc         : SDNode<"SystemZISD::VSTRCZ_CC",
374                                 SDT_ZVecQuaternaryIntCC>;
375def z_vstrs_cc          : SDNode<"SystemZISD::VSTRS_CC",
376                                 SDT_ZVecTernaryConvCC>;
377def z_vstrsz_cc         : SDNode<"SystemZISD::VSTRSZ_CC",
378                                 SDT_ZVecTernaryConvCC>;
379def z_vftci             : SDNode<"SystemZISD::VFTCI", SDT_ZVecBinaryConvIntCC>;
380
381class AtomicWOp<string name, SDTypeProfile profile = SDT_ZAtomicLoadBinaryW>
382  : SDNode<"SystemZISD::"#name, profile,
383           [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
384
385def z_atomic_swapw      : AtomicWOp<"ATOMIC_SWAPW">;
386def z_atomic_loadw_add  : AtomicWOp<"ATOMIC_LOADW_ADD">;
387def z_atomic_loadw_sub  : AtomicWOp<"ATOMIC_LOADW_SUB">;
388def z_atomic_loadw_and  : AtomicWOp<"ATOMIC_LOADW_AND">;
389def z_atomic_loadw_or   : AtomicWOp<"ATOMIC_LOADW_OR">;
390def z_atomic_loadw_xor  : AtomicWOp<"ATOMIC_LOADW_XOR">;
391def z_atomic_loadw_nand : AtomicWOp<"ATOMIC_LOADW_NAND">;
392def z_atomic_loadw_min  : AtomicWOp<"ATOMIC_LOADW_MIN">;
393def z_atomic_loadw_max  : AtomicWOp<"ATOMIC_LOADW_MAX">;
394def z_atomic_loadw_umin : AtomicWOp<"ATOMIC_LOADW_UMIN">;
395def z_atomic_loadw_umax : AtomicWOp<"ATOMIC_LOADW_UMAX">;
396
397def z_atomic_cmp_swap   : SDNode<"SystemZISD::ATOMIC_CMP_SWAP",
398                                 SDT_ZAtomicCmpSwap,
399                                 [SDNPHasChain, SDNPMayStore, SDNPMayLoad,
400                                  SDNPMemOperand]>;
401def z_atomic_cmp_swapw  : SDNode<"SystemZISD::ATOMIC_CMP_SWAPW",
402                                 SDT_ZAtomicCmpSwapW,
403                                 [SDNPHasChain, SDNPMayStore, SDNPMayLoad,
404                                  SDNPMemOperand]>;
405
406def z_atomic_load_128   : SDNode<"SystemZISD::ATOMIC_LOAD_128",
407                                 SDT_ZAtomicLoad128,
408                                 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
409def z_atomic_store_128  : SDNode<"SystemZISD::ATOMIC_STORE_128",
410                                 SDT_ZAtomicStore128,
411                                 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
412def z_atomic_cmp_swap_128 : SDNode<"SystemZISD::ATOMIC_CMP_SWAP_128",
413                                   SDT_ZAtomicCmpSwap128,
414                                   [SDNPHasChain, SDNPMayStore, SDNPMayLoad,
415                                    SDNPMemOperand]>;
416
417def z_mvc               : SDNode<"SystemZISD::MVC", SDT_ZMemMemLength,
418                                 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
419def z_mvc_loop          : SDNode<"SystemZISD::MVC_LOOP", SDT_ZMemMemLoop,
420                                 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
421def z_nc                : SDNode<"SystemZISD::NC", SDT_ZMemMemLength,
422                                  [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
423def z_nc_loop           : SDNode<"SystemZISD::NC_LOOP", SDT_ZMemMemLoop,
424                                  [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
425def z_oc                : SDNode<"SystemZISD::OC", SDT_ZMemMemLength,
426                                  [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
427def z_oc_loop           : SDNode<"SystemZISD::OC_LOOP", SDT_ZMemMemLoop,
428                                  [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
429def z_xc                : SDNode<"SystemZISD::XC", SDT_ZMemMemLength,
430                                  [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
431def z_xc_loop           : SDNode<"SystemZISD::XC_LOOP", SDT_ZMemMemLoop,
432                                  [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
433def z_clc               : SDNode<"SystemZISD::CLC", SDT_ZMemMemLengthCC,
434                                 [SDNPHasChain, SDNPMayLoad]>;
435def z_clc_loop          : SDNode<"SystemZISD::CLC_LOOP", SDT_ZMemMemLoopCC,
436                                 [SDNPHasChain, SDNPMayLoad]>;
437def z_strcmp            : SDNode<"SystemZISD::STRCMP", SDT_ZStringCC,
438                                 [SDNPHasChain, SDNPMayLoad]>;
439def z_stpcpy            : SDNode<"SystemZISD::STPCPY", SDT_ZString,
440                                 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
441def z_search_string     : SDNode<"SystemZISD::SEARCH_STRING", SDT_ZStringCC,
442                                 [SDNPHasChain, SDNPMayLoad]>;
443def z_prefetch          : SDNode<"SystemZISD::PREFETCH", SDT_ZPrefetch,
444                                 [SDNPHasChain, SDNPMayLoad, SDNPMayStore,
445                                  SDNPMemOperand]>;
446
447def z_tbegin            : SDNode<"SystemZISD::TBEGIN", SDT_ZTBegin,
448                                 [SDNPHasChain, SDNPMayStore, SDNPSideEffect]>;
449def z_tbegin_nofloat    : SDNode<"SystemZISD::TBEGIN_NOFLOAT", SDT_ZTBegin,
450                                 [SDNPHasChain, SDNPMayStore, SDNPSideEffect]>;
451def z_tend              : SDNode<"SystemZISD::TEND", SDT_ZTEnd,
452                                 [SDNPHasChain, SDNPSideEffect]>;
453
454def z_vshl              : SDNode<"ISD::SHL", SDT_ZVecBinary>;
455def z_vsra              : SDNode<"ISD::SRA", SDT_ZVecBinary>;
456def z_vsrl              : SDNode<"ISD::SRL", SDT_ZVecBinary>;
457
458//===----------------------------------------------------------------------===//
459// Pattern fragments
460//===----------------------------------------------------------------------===//
461
462def z_loadbswap16 : PatFrag<(ops node:$addr), (z_loadbswap node:$addr), [{
463  return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
464}]>;
465def z_loadbswap32 : PatFrag<(ops node:$addr), (z_loadbswap node:$addr), [{
466  return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
467}]>;
468def z_loadbswap64 : PatFrag<(ops node:$addr), (z_loadbswap node:$addr), [{
469  return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
470}]>;
471
472def z_storebswap16 : PatFrag<(ops node:$src, node:$addr),
473                             (z_storebswap node:$src, node:$addr), [{
474  return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
475}]>;
476def z_storebswap32 : PatFrag<(ops node:$src, node:$addr),
477                             (z_storebswap node:$src, node:$addr), [{
478  return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
479}]>;
480def z_storebswap64 : PatFrag<(ops node:$src, node:$addr),
481                             (z_storebswap node:$src, node:$addr), [{
482  return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
483}]>;
484
485// Fragments including CC as an implicit source.
486def z_br_ccmask
487  : PatFrag<(ops node:$valid, node:$mask, node:$bb),
488            (z_br_ccmask_1 node:$valid, node:$mask, node:$bb, CC)>;
489def z_select_ccmask
490  : PatFrag<(ops node:$true, node:$false, node:$valid, node:$mask),
491            (z_select_ccmask_1 node:$true, node:$false,
492                               node:$valid, node:$mask, CC)>;
493def z_ipm : PatFrag<(ops), (z_ipm_1 CC)>;
494def z_addcarry : PatFrag<(ops node:$lhs, node:$rhs),
495                              (z_addcarry_1 node:$lhs, node:$rhs, CC)>;
496def z_subcarry : PatFrag<(ops node:$lhs, node:$rhs),
497                              (z_subcarry_1 node:$lhs, node:$rhs, CC)>;
498
499// Signed and unsigned comparisons.
500def z_scmp : PatFrag<(ops node:$a, node:$b), (z_icmp node:$a, node:$b, timm), [{
501  unsigned Type = cast<ConstantSDNode>(N->getOperand(2))->getZExtValue();
502  return Type != SystemZICMP::UnsignedOnly;
503}]>;
504def z_ucmp : PatFrag<(ops node:$a, node:$b), (z_icmp node:$a, node:$b, timm), [{
505  unsigned Type = cast<ConstantSDNode>(N->getOperand(2))->getZExtValue();
506  return Type != SystemZICMP::SignedOnly;
507}]>;
508
509// Register- and memory-based TEST UNDER MASK.
510def z_tm_reg : PatFrag<(ops node:$a, node:$b), (z_tm node:$a, node:$b, timm)>;
511def z_tm_mem : PatFrag<(ops node:$a, node:$b), (z_tm node:$a, node:$b, 0)>;
512
513// Register sign-extend operations.  Sub-32-bit values are represented as i32s.
514def sext8  : PatFrag<(ops node:$src), (sext_inreg node:$src, i8)>;
515def sext16 : PatFrag<(ops node:$src), (sext_inreg node:$src, i16)>;
516def sext32 : PatFrag<(ops node:$src), (sext (i32 node:$src))>;
517
518// Match extensions of an i32 to an i64, followed by an in-register sign
519// extension from a sub-i32 value.
520def sext8dbl : PatFrag<(ops node:$src), (sext8 (anyext node:$src))>;
521def sext16dbl : PatFrag<(ops node:$src), (sext16 (anyext node:$src))>;
522
523// Register zero-extend operations.  Sub-32-bit values are represented as i32s.
524def zext8  : PatFrag<(ops node:$src), (and node:$src, 0xff)>;
525def zext16 : PatFrag<(ops node:$src), (and node:$src, 0xffff)>;
526def zext32 : PatFrag<(ops node:$src), (zext (i32 node:$src))>;
527
528// Extending loads in which the extension type can be signed.
529def asextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
530  unsigned Type = cast<LoadSDNode>(N)->getExtensionType();
531  return Type == ISD::EXTLOAD || Type == ISD::SEXTLOAD;
532}]>;
533def asextloadi8 : PatFrag<(ops node:$ptr), (asextload node:$ptr), [{
534  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
535}]>;
536def asextloadi16 : PatFrag<(ops node:$ptr), (asextload node:$ptr), [{
537  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
538}]>;
539def asextloadi32 : PatFrag<(ops node:$ptr), (asextload node:$ptr), [{
540  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
541}]>;
542
543// Extending loads in which the extension type can be unsigned.
544def azextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
545  unsigned Type = cast<LoadSDNode>(N)->getExtensionType();
546  return Type == ISD::EXTLOAD || Type == ISD::ZEXTLOAD;
547}]>;
548def azextloadi8 : PatFrag<(ops node:$ptr), (azextload node:$ptr), [{
549  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
550}]>;
551def azextloadi16 : PatFrag<(ops node:$ptr), (azextload node:$ptr), [{
552  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
553}]>;
554def azextloadi32 : PatFrag<(ops node:$ptr), (azextload node:$ptr), [{
555  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
556}]>;
557
558// Extending loads in which the extension type doesn't matter.
559def anyextload : PatFrag<(ops node:$ptr), (unindexedload node:$ptr), [{
560  return cast<LoadSDNode>(N)->getExtensionType() != ISD::NON_EXTLOAD;
561}]>;
562def anyextloadi8 : PatFrag<(ops node:$ptr), (anyextload node:$ptr), [{
563  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
564}]>;
565def anyextloadi16 : PatFrag<(ops node:$ptr), (anyextload node:$ptr), [{
566  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
567}]>;
568def anyextloadi32 : PatFrag<(ops node:$ptr), (anyextload node:$ptr), [{
569  return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i32;
570}]>;
571
572// Aligned loads.
573class AlignedLoad<SDPatternOperator load>
574  : PatFrag<(ops node:$addr), (load node:$addr),
575  [{ return storeLoadIsAligned(N); }]>;
576def aligned_load         : AlignedLoad<load>;
577def aligned_asextloadi16 : AlignedLoad<asextloadi16>;
578def aligned_asextloadi32 : AlignedLoad<asextloadi32>;
579def aligned_azextloadi16 : AlignedLoad<azextloadi16>;
580def aligned_azextloadi32 : AlignedLoad<azextloadi32>;
581
582// Aligned stores.
583class AlignedStore<SDPatternOperator store>
584  : PatFrag<(ops node:$src, node:$addr), (store node:$src, node:$addr),
585  [{ return storeLoadIsAligned(N); }]>;
586def aligned_store         : AlignedStore<store>;
587def aligned_truncstorei16 : AlignedStore<truncstorei16>;
588def aligned_truncstorei32 : AlignedStore<truncstorei32>;
589
590// Non-volatile loads.  Used for instructions that might access the storage
591// location multiple times.
592class NonvolatileLoad<SDPatternOperator load>
593  : PatFrag<(ops node:$addr), (load node:$addr), [{
594  auto *Load = cast<LoadSDNode>(N);
595  return !Load->isVolatile();
596}]>;
597def nonvolatile_anyextloadi8  : NonvolatileLoad<anyextloadi8>;
598def nonvolatile_anyextloadi16 : NonvolatileLoad<anyextloadi16>;
599def nonvolatile_anyextloadi32 : NonvolatileLoad<anyextloadi32>;
600
601// Non-volatile stores.
602class NonvolatileStore<SDPatternOperator store>
603  : PatFrag<(ops node:$src, node:$addr), (store node:$src, node:$addr), [{
604  auto *Store = cast<StoreSDNode>(N);
605  return !Store->isVolatile();
606}]>;
607def nonvolatile_truncstorei8  : NonvolatileStore<truncstorei8>;
608def nonvolatile_truncstorei16 : NonvolatileStore<truncstorei16>;
609def nonvolatile_truncstorei32 : NonvolatileStore<truncstorei32>;
610
611// A store of a load that can be implemented using MVC.
612def mvc_store : PatFrag<(ops node:$value, node:$addr),
613                        (unindexedstore node:$value, node:$addr),
614                        [{ return storeLoadCanUseMVC(N); }]>;
615
616// Binary read-modify-write operations on memory in which the other
617// operand is also memory and for which block operations like NC can
618// be used.  There are two patterns for each operator, depending on
619// which operand contains the "other" load.
620multiclass block_op<SDPatternOperator operator> {
621  def "1" : PatFrag<(ops node:$value, node:$addr),
622                    (unindexedstore (operator node:$value,
623                                              (unindexedload node:$addr)),
624                                    node:$addr),
625                    [{ return storeLoadCanUseBlockBinary(N, 0); }]>;
626  def "2" : PatFrag<(ops node:$value, node:$addr),
627                    (unindexedstore (operator (unindexedload node:$addr),
628                                              node:$value),
629                                    node:$addr),
630                    [{ return storeLoadCanUseBlockBinary(N, 1); }]>;
631}
632defm block_and : block_op<and>;
633defm block_or  : block_op<or>;
634defm block_xor : block_op<xor>;
635
636// Insertions.
637def inserti8 : PatFrag<(ops node:$src1, node:$src2),
638                       (or (and node:$src1, -256), node:$src2)>;
639def insertll : PatFrag<(ops node:$src1, node:$src2),
640                       (or (and node:$src1, 0xffffffffffff0000), node:$src2)>;
641def insertlh : PatFrag<(ops node:$src1, node:$src2),
642                       (or (and node:$src1, 0xffffffff0000ffff), node:$src2)>;
643def inserthl : PatFrag<(ops node:$src1, node:$src2),
644                       (or (and node:$src1, 0xffff0000ffffffff), node:$src2)>;
645def inserthh : PatFrag<(ops node:$src1, node:$src2),
646                       (or (and node:$src1, 0x0000ffffffffffff), node:$src2)>;
647def insertlf : PatFrag<(ops node:$src1, node:$src2),
648                       (or (and node:$src1, 0xffffffff00000000), node:$src2)>;
649def inserthf : PatFrag<(ops node:$src1, node:$src2),
650                       (or (and node:$src1, 0x00000000ffffffff), node:$src2)>;
651
652// ORs that can be treated as insertions.
653def or_as_inserti8 : PatFrag<(ops node:$src1, node:$src2),
654                             (or node:$src1, node:$src2), [{
655  unsigned BitWidth = N->getValueType(0).getScalarSizeInBits();
656  return CurDAG->MaskedValueIsZero(N->getOperand(0),
657                                   APInt::getLowBitsSet(BitWidth, 8));
658}]>;
659
660// ORs that can be treated as reversed insertions.
661def or_as_revinserti8 : PatFrag<(ops node:$src1, node:$src2),
662                                (or node:$src1, node:$src2), [{
663  unsigned BitWidth = N->getValueType(0).getScalarSizeInBits();
664  return CurDAG->MaskedValueIsZero(N->getOperand(1),
665                                   APInt::getLowBitsSet(BitWidth, 8));
666}]>;
667
668// Negative integer absolute.
669def z_inegabs : PatFrag<(ops node:$src), (ineg (abs node:$src))>;
670
671// Integer multiply-and-add
672def z_muladd : PatFrag<(ops node:$src1, node:$src2, node:$src3),
673                       (add (mul node:$src1, node:$src2), node:$src3)>;
674
675// Alternatives to match operations with or without an overflow CC result.
676def z_sadd : PatFrags<(ops node:$src1, node:$src2),
677                      [(z_saddo node:$src1, node:$src2),
678                       (add node:$src1, node:$src2)]>;
679def z_uadd : PatFrags<(ops node:$src1, node:$src2),
680                      [(z_uaddo node:$src1, node:$src2),
681                       (add node:$src1, node:$src2)]>;
682def z_ssub : PatFrags<(ops node:$src1, node:$src2),
683                      [(z_ssubo node:$src1, node:$src2),
684                       (sub node:$src1, node:$src2)]>;
685def z_usub : PatFrags<(ops node:$src1, node:$src2),
686                      [(z_usubo node:$src1, node:$src2),
687                       (sub node:$src1, node:$src2)]>;
688
689// Combined logical operations.
690def andc : PatFrag<(ops node:$src1, node:$src2),
691                   (and node:$src1, (not node:$src2))>;
692def orc  : PatFrag<(ops node:$src1, node:$src2),
693                   (or node:$src1, (not node:$src2))>;
694def nand : PatFrag<(ops node:$src1, node:$src2),
695                   (not (and node:$src1, node:$src2))>;
696def nor  : PatFrag<(ops node:$src1, node:$src2),
697                   (not (or node:$src1, node:$src2))>;
698def nxor : PatFrag<(ops node:$src1, node:$src2),
699                   (not (xor node:$src1, node:$src2))>;
700
701// Fused multiply-subtract, using the natural operand order.
702def any_fms : PatFrag<(ops node:$src1, node:$src2, node:$src3),
703                      (any_fma node:$src1, node:$src2, (fneg node:$src3))>;
704
705// Fused multiply-add and multiply-subtract, but with the order of the
706// operands matching SystemZ's MA and MS instructions.
707def z_any_fma : PatFrag<(ops node:$src1, node:$src2, node:$src3),
708                        (any_fma node:$src2, node:$src3, node:$src1)>;
709def z_any_fms : PatFrag<(ops node:$src1, node:$src2, node:$src3),
710                        (any_fma node:$src2, node:$src3, (fneg node:$src1))>;
711
712// Negative fused multiply-add and multiply-subtract.
713def any_fnma : PatFrag<(ops node:$src1, node:$src2, node:$src3),
714                       (fneg (any_fma node:$src1, node:$src2, node:$src3))>;
715def any_fnms : PatFrag<(ops node:$src1, node:$src2, node:$src3),
716                       (fneg (any_fms node:$src1, node:$src2, node:$src3))>;
717
718// Floating-point negative absolute.
719def fnabs : PatFrag<(ops node:$ptr), (fneg (fabs node:$ptr))>;
720
721// Strict floating-point fragments.
722def z_any_fcmp    : PatFrags<(ops node:$lhs, node:$rhs),
723                             [(z_strict_fcmp node:$lhs, node:$rhs),
724                              (z_fcmp node:$lhs, node:$rhs)]>;
725def z_any_vfcmpe  : PatFrags<(ops node:$lhs, node:$rhs),
726                             [(z_strict_vfcmpe node:$lhs, node:$rhs),
727                              (z_vfcmpe node:$lhs, node:$rhs)]>;
728def z_any_vfcmph  : PatFrags<(ops node:$lhs, node:$rhs),
729                             [(z_strict_vfcmph node:$lhs, node:$rhs),
730                              (z_vfcmph node:$lhs, node:$rhs)]>;
731def z_any_vfcmphe : PatFrags<(ops node:$lhs, node:$rhs),
732                             [(z_strict_vfcmphe node:$lhs, node:$rhs),
733                              (z_vfcmphe node:$lhs, node:$rhs)]>;
734def z_any_vextend : PatFrags<(ops node:$src),
735                             [(z_strict_vextend node:$src),
736                              (z_vextend node:$src)]>;
737def z_any_vround  : PatFrags<(ops node:$src),
738                             [(z_strict_vround node:$src),
739                              (z_vround node:$src)]>;
740
741// Create a unary operator that loads from memory and then performs
742// the given operation on it.
743class loadu<SDPatternOperator operator, SDPatternOperator load = load>
744  : PatFrag<(ops node:$addr), (operator (load node:$addr))>;
745
746// Create a store operator that performs the given unary operation
747// on the value before storing it.
748class storeu<SDPatternOperator operator, SDPatternOperator store = store>
749  : PatFrag<(ops node:$value, node:$addr),
750            (store (operator node:$value), node:$addr)>;
751
752// Create a store operator that performs the given inherent operation
753// and stores the resulting value.
754class storei<SDPatternOperator operator, SDPatternOperator store = store>
755  : PatFrag<(ops node:$addr),
756            (store (operator), node:$addr)>;
757
758// Create a shift operator that optionally ignores an AND of the
759// shift count with an immediate if the bottom 6 bits are all set.
760def imm32bottom6set : PatLeaf<(i32 imm), [{
761  return (N->getZExtValue() & 0x3f) == 0x3f;
762}]>;
763class shiftop<SDPatternOperator operator>
764  : PatFrags<(ops node:$val, node:$count),
765             [(operator node:$val, node:$count),
766              (operator node:$val, (and node:$count, imm32bottom6set))]>;
767
768def imm32mod64  : PatLeaf<(i32 imm), [{
769  return (N->getZExtValue() % 64 == 0);
770}]>;
771
772// Load a scalar and replicate it in all elements of a vector.
773class z_replicate_load<ValueType scalartype, SDPatternOperator load>
774  : PatFrag<(ops node:$addr),
775            (z_replicate (scalartype (load node:$addr)))>;
776def z_replicate_loadi8  : z_replicate_load<i32, anyextloadi8>;
777def z_replicate_loadi16 : z_replicate_load<i32, anyextloadi16>;
778def z_replicate_loadi32 : z_replicate_load<i32, load>;
779def z_replicate_loadi64 : z_replicate_load<i64, load>;
780def z_replicate_loadf32 : z_replicate_load<f32, load>;
781def z_replicate_loadf64 : z_replicate_load<f64, load>;
782// Byte-swapped replicated vector element loads.
783def z_replicate_loadbswapi16 : z_replicate_load<i32, z_loadbswap16>;
784def z_replicate_loadbswapi32 : z_replicate_load<i32, z_loadbswap32>;
785def z_replicate_loadbswapi64 : z_replicate_load<i64, z_loadbswap64>;
786
787// Load a scalar and insert it into a single element of a vector.
788class z_vle<ValueType scalartype, SDPatternOperator load>
789  : PatFrag<(ops node:$vec, node:$addr, node:$index),
790            (z_vector_insert node:$vec, (scalartype (load node:$addr)),
791                             node:$index)>;
792def z_vlei8  : z_vle<i32, anyextloadi8>;
793def z_vlei16 : z_vle<i32, anyextloadi16>;
794def z_vlei32 : z_vle<i32, load>;
795def z_vlei64 : z_vle<i64, load>;
796def z_vlef32 : z_vle<f32, load>;
797def z_vlef64 : z_vle<f64, load>;
798// Byte-swapped vector element loads.
799def z_vlebri16 : z_vle<i32, z_loadbswap16>;
800def z_vlebri32 : z_vle<i32, z_loadbswap32>;
801def z_vlebri64 : z_vle<i64, z_loadbswap64>;
802
803// Load a scalar and insert it into the low element of the high i64 of a
804// zeroed vector.
805class z_vllez<ValueType scalartype, SDPatternOperator load, int index>
806  : PatFrag<(ops node:$addr),
807            (z_vector_insert immAllZerosV,
808                             (scalartype (load node:$addr)), (i32 index))>;
809def z_vllezi8  : z_vllez<i32, anyextloadi8, 7>;
810def z_vllezi16 : z_vllez<i32, anyextloadi16, 3>;
811def z_vllezi32 : z_vllez<i32, load, 1>;
812def z_vllezi64 : PatFrags<(ops node:$addr),
813                          [(z_vector_insert immAllZerosV,
814                                            (i64 (load node:$addr)), (i32 0)),
815                           (z_join_dwords (i64 (load node:$addr)), (i64 0))]>;
816// We use high merges to form a v4f32 from four f32s.  Propagating zero
817// into all elements but index 1 gives this expression.
818def z_vllezf32 : PatFrag<(ops node:$addr),
819                         (z_merge_high
820                          (v2i64
821                           (z_unpackl_high
822                            (v4i32
823                             (bitconvert
824                              (v4f32 (scalar_to_vector
825                                      (f32 (load node:$addr)))))))),
826                          (v2i64
827                           (bitconvert (v4f32 immAllZerosV))))>;
828def z_vllezf64 : PatFrag<(ops node:$addr),
829                         (z_merge_high
830                          (v2f64 (scalar_to_vector (f64 (load node:$addr)))),
831                          immAllZerosV)>;
832
833// Similarly for the high element of a zeroed vector.
834def z_vllezli32 : z_vllez<i32, load, 0>;
835def z_vllezlf32 : PatFrag<(ops node:$addr),
836                          (z_merge_high
837                           (v2i64
838                            (bitconvert
839                             (z_merge_high
840                              (v4f32 (scalar_to_vector
841                                      (f32 (load node:$addr)))),
842                              (v4f32 immAllZerosV)))),
843                           (v2i64
844                            (bitconvert (v4f32 immAllZerosV))))>;
845
846// Byte-swapped variants.
847def z_vllebrzi16  : z_vllez<i32, z_loadbswap16, 3>;
848def z_vllebrzi32  : z_vllez<i32, z_loadbswap32, 1>;
849def z_vllebrzli32 : z_vllez<i32, z_loadbswap32, 0>;
850def z_vllebrzi64  : PatFrags<(ops node:$addr),
851                             [(z_vector_insert immAllZerosV,
852                                               (i64 (z_loadbswap64 node:$addr)),
853                                               (i32 0)),
854                              (z_join_dwords (i64 (z_loadbswap64 node:$addr)),
855                                             (i64 0))]>;
856
857
858// Store one element of a vector.
859class z_vste<ValueType scalartype, SDPatternOperator store>
860  : PatFrag<(ops node:$vec, node:$addr, node:$index),
861            (store (scalartype (z_vector_extract node:$vec, node:$index)),
862                   node:$addr)>;
863def z_vstei8  : z_vste<i32, truncstorei8>;
864def z_vstei16 : z_vste<i32, truncstorei16>;
865def z_vstei32 : z_vste<i32, store>;
866def z_vstei64 : z_vste<i64, store>;
867def z_vstef32 : z_vste<f32, store>;
868def z_vstef64 : z_vste<f64, store>;
869// Byte-swapped vector element stores.
870def z_vstebri16 : z_vste<i32, z_storebswap16>;
871def z_vstebri32 : z_vste<i32, z_storebswap32>;
872def z_vstebri64 : z_vste<i64, z_storebswap64>;
873
874// Arithmetic negation on vectors.
875def z_vneg : PatFrag<(ops node:$x), (sub immAllZerosV, node:$x)>;
876
877// Bitwise negation on vectors.
878def z_vnot : PatFrag<(ops node:$x), (xor node:$x, immAllOnesV)>;
879
880// Signed "integer greater than zero" on vectors.
881def z_vicmph_zero : PatFrag<(ops node:$x), (z_vicmph node:$x, immAllZerosV)>;
882
883// Signed "integer less than zero" on vectors.
884def z_vicmpl_zero : PatFrag<(ops node:$x), (z_vicmph immAllZerosV, node:$x)>;
885
886// Sign-extend the i64 elements of a vector.
887class z_vse<int shift>
888  : PatFrag<(ops node:$src),
889            (z_vsra_by_scalar (z_vshl_by_scalar node:$src, shift), shift)>;
890def z_vsei8  : z_vse<56>;
891def z_vsei16 : z_vse<48>;
892def z_vsei32 : z_vse<32>;
893
894// ...and again with the extensions being done on individual i64 scalars.
895class z_vse_by_parts<SDPatternOperator operator, int index1, int index2>
896  : PatFrag<(ops node:$src),
897            (z_join_dwords
898             (operator (z_vector_extract node:$src, index1)),
899             (operator (z_vector_extract node:$src, index2)))>;
900def z_vsei8_by_parts  : z_vse_by_parts<sext8dbl, 7, 15>;
901def z_vsei16_by_parts : z_vse_by_parts<sext16dbl, 3, 7>;
902def z_vsei32_by_parts : z_vse_by_parts<sext32, 1, 3>;
903