1 //===- IntrinsicsSystemZ.td - Defines SystemZ intrinsics ---*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines all of the SystemZ-specific intrinsics.
11 //===----------------------------------------------------------------------===//
13 class SystemZUnaryConv<string name, LLVMType result, LLVMType arg>
14 : GCCBuiltin<"__builtin_s390_" ## name>,
15 Intrinsic<[result], [arg], [IntrNoMem]>;
17 class SystemZUnary<string name, LLVMType type>
18 : SystemZUnaryConv<name, type, type>;
20 class SystemZUnaryConvCC<LLVMType result, LLVMType arg>
21 : Intrinsic<[result, llvm_i32_ty], [arg], [IntrNoMem]>;
23 class SystemZUnaryCC<LLVMType type>
24 : SystemZUnaryConvCC<type, type>;
26 class SystemZBinaryConv<string name, LLVMType result, LLVMType arg>
27 : GCCBuiltin<"__builtin_s390_" ## name>,
28 Intrinsic<[result], [arg, arg], [IntrNoMem]>;
30 class SystemZBinary<string name, LLVMType type>
31 : SystemZBinaryConv<name, type, type>;
33 class SystemZBinaryInt<string name, LLVMType type>
34 : GCCBuiltin<"__builtin_s390_" ## name>,
35 Intrinsic<[type], [type, llvm_i32_ty], [IntrNoMem]>;
37 class SystemZBinaryConvCC<LLVMType result, LLVMType arg>
38 : Intrinsic<[result, llvm_i32_ty], [arg, arg], [IntrNoMem]>;
40 class SystemZBinaryConvIntCC<LLVMType result, LLVMType arg>
41 : Intrinsic<[result, llvm_i32_ty], [arg, llvm_i32_ty], [IntrNoMem]>;
43 class SystemZBinaryCC<LLVMType type>
44 : SystemZBinaryConvCC<type, type>;
46 class SystemZTernaryConv<string name, LLVMType result, LLVMType arg>
47 : GCCBuiltin<"__builtin_s390_" ## name>,
48 Intrinsic<[result], [arg, arg, result], [IntrNoMem]>;
50 class SystemZTernary<string name, LLVMType type>
51 : SystemZTernaryConv<name, type, type>;
53 class SystemZTernaryInt<string name, LLVMType type>
54 : GCCBuiltin<"__builtin_s390_" ## name>,
55 Intrinsic<[type], [type, type, llvm_i32_ty], [IntrNoMem]>;
57 class SystemZTernaryIntCC<LLVMType type>
58 : Intrinsic<[type, llvm_i32_ty], [type, type, llvm_i32_ty], [IntrNoMem]>;
60 class SystemZQuaternaryInt<string name, LLVMType type>
61 : GCCBuiltin<"__builtin_s390_" ## name>,
62 Intrinsic<[type], [type, type, type, llvm_i32_ty], [IntrNoMem]>;
64 class SystemZQuaternaryIntCC<LLVMType type>
65 : Intrinsic<[type, llvm_i32_ty], [type, type, type, llvm_i32_ty],
68 multiclass SystemZUnaryExtBHF<string name> {
69 def b : SystemZUnaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
70 def h : SystemZUnaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
71 def f : SystemZUnaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
74 multiclass SystemZUnaryExtBHWF<string name> {
75 def b : SystemZUnaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
76 def hw : SystemZUnaryConv<name##"hw", llvm_v4i32_ty, llvm_v8i16_ty>;
77 def f : SystemZUnaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
80 multiclass SystemZUnaryBHF<string name> {
81 def b : SystemZUnary<name##"b", llvm_v16i8_ty>;
82 def h : SystemZUnary<name##"h", llvm_v8i16_ty>;
83 def f : SystemZUnary<name##"f", llvm_v4i32_ty>;
86 multiclass SystemZUnaryBHFG<string name> : SystemZUnaryBHF<name> {
87 def g : SystemZUnary<name##"g", llvm_v2i64_ty>;
90 multiclass SystemZUnaryCCBHF {
91 def bs : SystemZUnaryCC<llvm_v16i8_ty>;
92 def hs : SystemZUnaryCC<llvm_v8i16_ty>;
93 def fs : SystemZUnaryCC<llvm_v4i32_ty>;
96 multiclass SystemZBinaryTruncHFG<string name> {
97 def h : SystemZBinaryConv<name##"h", llvm_v16i8_ty, llvm_v8i16_ty>;
98 def f : SystemZBinaryConv<name##"f", llvm_v8i16_ty, llvm_v4i32_ty>;
99 def g : SystemZBinaryConv<name##"g", llvm_v4i32_ty, llvm_v2i64_ty>;
102 multiclass SystemZBinaryTruncCCHFG {
103 def hs : SystemZBinaryConvCC<llvm_v16i8_ty, llvm_v8i16_ty>;
104 def fs : SystemZBinaryConvCC<llvm_v8i16_ty, llvm_v4i32_ty>;
105 def gs : SystemZBinaryConvCC<llvm_v4i32_ty, llvm_v2i64_ty>;
108 multiclass SystemZBinaryExtBHF<string name> {
109 def b : SystemZBinaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
110 def h : SystemZBinaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
111 def f : SystemZBinaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
114 multiclass SystemZBinaryExtBHFG<string name> : SystemZBinaryExtBHF<name> {
115 def g : SystemZBinaryConv<name##"g", llvm_v16i8_ty, llvm_v2i64_ty>;
118 multiclass SystemZBinaryBHF<string name> {
119 def b : SystemZBinary<name##"b", llvm_v16i8_ty>;
120 def h : SystemZBinary<name##"h", llvm_v8i16_ty>;
121 def f : SystemZBinary<name##"f", llvm_v4i32_ty>;
124 multiclass SystemZBinaryBHFG<string name> : SystemZBinaryBHF<name> {
125 def g : SystemZBinary<name##"g", llvm_v2i64_ty>;
128 multiclass SystemZBinaryIntBHFG<string name> {
129 def b : SystemZBinaryInt<name##"b", llvm_v16i8_ty>;
130 def h : SystemZBinaryInt<name##"h", llvm_v8i16_ty>;
131 def f : SystemZBinaryInt<name##"f", llvm_v4i32_ty>;
132 def g : SystemZBinaryInt<name##"g", llvm_v2i64_ty>;
135 multiclass SystemZBinaryCCBHF {
136 def bs : SystemZBinaryCC<llvm_v16i8_ty>;
137 def hs : SystemZBinaryCC<llvm_v8i16_ty>;
138 def fs : SystemZBinaryCC<llvm_v4i32_ty>;
141 multiclass SystemZCompareBHFG<string name> {
142 def bs : SystemZBinaryCC<llvm_v16i8_ty>;
143 def hs : SystemZBinaryCC<llvm_v8i16_ty>;
144 def fs : SystemZBinaryCC<llvm_v4i32_ty>;
145 def gs : SystemZBinaryCC<llvm_v2i64_ty>;
148 multiclass SystemZTernaryExtBHF<string name> {
149 def b : SystemZTernaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
150 def h : SystemZTernaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
151 def f : SystemZTernaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
154 multiclass SystemZTernaryExtBHFG<string name> : SystemZTernaryExtBHF<name> {
155 def g : SystemZTernaryConv<name##"g", llvm_v16i8_ty, llvm_v2i64_ty>;
158 multiclass SystemZTernaryBHF<string name> {
159 def b : SystemZTernary<name##"b", llvm_v16i8_ty>;
160 def h : SystemZTernary<name##"h", llvm_v8i16_ty>;
161 def f : SystemZTernary<name##"f", llvm_v4i32_ty>;
164 multiclass SystemZTernaryIntBHF<string name> {
165 def b : SystemZTernaryInt<name##"b", llvm_v16i8_ty>;
166 def h : SystemZTernaryInt<name##"h", llvm_v8i16_ty>;
167 def f : SystemZTernaryInt<name##"f", llvm_v4i32_ty>;
170 multiclass SystemZTernaryIntCCBHF {
171 def bs : SystemZTernaryIntCC<llvm_v16i8_ty>;
172 def hs : SystemZTernaryIntCC<llvm_v8i16_ty>;
173 def fs : SystemZTernaryIntCC<llvm_v4i32_ty>;
176 multiclass SystemZQuaternaryIntBHF<string name> {
177 def b : SystemZQuaternaryInt<name##"b", llvm_v16i8_ty>;
178 def h : SystemZQuaternaryInt<name##"h", llvm_v8i16_ty>;
179 def f : SystemZQuaternaryInt<name##"f", llvm_v4i32_ty>;
182 multiclass SystemZQuaternaryIntBHFG<string name> : SystemZQuaternaryIntBHF<name> {
183 def g : SystemZQuaternaryInt<name##"g", llvm_v2i64_ty>;
186 multiclass SystemZQuaternaryIntCCBHF {
187 def bs : SystemZQuaternaryIntCC<llvm_v16i8_ty>;
188 def hs : SystemZQuaternaryIntCC<llvm_v8i16_ty>;
189 def fs : SystemZQuaternaryIntCC<llvm_v4i32_ty>;
192 //===----------------------------------------------------------------------===//
194 // Transactional-execution intrinsics
196 //===----------------------------------------------------------------------===//
198 let TargetPrefix = "s390" in {
199 def int_s390_tbegin : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
200 [IntrNoDuplicate, IntrWriteMem]>;
202 def int_s390_tbegin_nofloat : Intrinsic<[llvm_i32_ty],
203 [llvm_ptr_ty, llvm_i32_ty],
204 [IntrNoDuplicate, IntrWriteMem]>;
206 def int_s390_tbeginc : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
207 [IntrNoDuplicate, IntrWriteMem]>;
209 def int_s390_tabort : Intrinsic<[], [llvm_i64_ty],
210 [IntrNoReturn, Throws, IntrWriteMem]>;
212 def int_s390_tend : GCCBuiltin<"__builtin_tend">,
213 Intrinsic<[llvm_i32_ty], []>;
215 def int_s390_etnd : GCCBuiltin<"__builtin_tx_nesting_depth">,
216 Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>;
218 def int_s390_ntstg : Intrinsic<[], [llvm_i64_ty, llvm_ptr64_ty],
219 [IntrArgMemOnly, IntrWriteMem]>;
221 def int_s390_ppa_txassist : GCCBuiltin<"__builtin_tx_assist">,
222 Intrinsic<[], [llvm_i32_ty]>;
225 //===----------------------------------------------------------------------===//
229 //===----------------------------------------------------------------------===//
231 let TargetPrefix = "s390" in {
232 def int_s390_lcbb : GCCBuiltin<"__builtin_s390_lcbb">,
233 Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
236 def int_s390_vlbb : GCCBuiltin<"__builtin_s390_vlbb">,
237 Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty],
238 [IntrReadMem, IntrArgMemOnly]>;
240 def int_s390_vll : GCCBuiltin<"__builtin_s390_vll">,
241 Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty, llvm_ptr_ty],
242 [IntrReadMem, IntrArgMemOnly]>;
244 def int_s390_vpdi : GCCBuiltin<"__builtin_s390_vpdi">,
245 Intrinsic<[llvm_v2i64_ty],
246 [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty],
249 def int_s390_vperm : GCCBuiltin<"__builtin_s390_vperm">,
250 Intrinsic<[llvm_v16i8_ty],
251 [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
254 defm int_s390_vpks : SystemZBinaryTruncHFG<"vpks">;
255 defm int_s390_vpks : SystemZBinaryTruncCCHFG;
257 defm int_s390_vpkls : SystemZBinaryTruncHFG<"vpkls">;
258 defm int_s390_vpkls : SystemZBinaryTruncCCHFG;
260 def int_s390_vstl : GCCBuiltin<"__builtin_s390_vstl">,
261 Intrinsic<[], [llvm_v16i8_ty, llvm_i32_ty, llvm_ptr_ty],
262 [IntrArgMemOnly, IntrWriteMem]>;
264 defm int_s390_vupl : SystemZUnaryExtBHWF<"vupl">;
265 defm int_s390_vupll : SystemZUnaryExtBHF<"vupll">;
267 defm int_s390_vuph : SystemZUnaryExtBHF<"vuph">;
268 defm int_s390_vuplh : SystemZUnaryExtBHF<"vuplh">;
270 defm int_s390_vacc : SystemZBinaryBHFG<"vacc">;
272 def int_s390_vaq : SystemZBinary<"vaq", llvm_v16i8_ty>;
273 def int_s390_vacq : SystemZTernary<"vacq", llvm_v16i8_ty>;
274 def int_s390_vaccq : SystemZBinary<"vaccq", llvm_v16i8_ty>;
275 def int_s390_vacccq : SystemZTernary<"vacccq", llvm_v16i8_ty>;
277 defm int_s390_vavg : SystemZBinaryBHFG<"vavg">;
278 defm int_s390_vavgl : SystemZBinaryBHFG<"vavgl">;
280 def int_s390_vcksm : SystemZBinary<"vcksm", llvm_v4i32_ty>;
282 defm int_s390_vgfm : SystemZBinaryExtBHFG<"vgfm">;
283 defm int_s390_vgfma : SystemZTernaryExtBHFG<"vgfma">;
285 defm int_s390_vmah : SystemZTernaryBHF<"vmah">;
286 defm int_s390_vmalh : SystemZTernaryBHF<"vmalh">;
287 defm int_s390_vmae : SystemZTernaryExtBHF<"vmae">;
288 defm int_s390_vmale : SystemZTernaryExtBHF<"vmale">;
289 defm int_s390_vmao : SystemZTernaryExtBHF<"vmao">;
290 defm int_s390_vmalo : SystemZTernaryExtBHF<"vmalo">;
292 defm int_s390_vmh : SystemZBinaryBHF<"vmh">;
293 defm int_s390_vmlh : SystemZBinaryBHF<"vmlh">;
294 defm int_s390_vme : SystemZBinaryExtBHF<"vme">;
295 defm int_s390_vmle : SystemZBinaryExtBHF<"vmle">;
296 defm int_s390_vmo : SystemZBinaryExtBHF<"vmo">;
297 defm int_s390_vmlo : SystemZBinaryExtBHF<"vmlo">;
299 defm int_s390_verllv : SystemZBinaryBHFG<"verllv">;
300 defm int_s390_verll : SystemZBinaryIntBHFG<"verll">;
301 defm int_s390_verim : SystemZQuaternaryIntBHFG<"verim">;
303 def int_s390_vsl : SystemZBinary<"vsl", llvm_v16i8_ty>;
304 def int_s390_vslb : SystemZBinary<"vslb", llvm_v16i8_ty>;
305 def int_s390_vsra : SystemZBinary<"vsra", llvm_v16i8_ty>;
306 def int_s390_vsrab : SystemZBinary<"vsrab", llvm_v16i8_ty>;
307 def int_s390_vsrl : SystemZBinary<"vsrl", llvm_v16i8_ty>;
308 def int_s390_vsrlb : SystemZBinary<"vsrlb", llvm_v16i8_ty>;
310 def int_s390_vsldb : GCCBuiltin<"__builtin_s390_vsldb">,
311 Intrinsic<[llvm_v16i8_ty],
312 [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty],
315 defm int_s390_vscbi : SystemZBinaryBHFG<"vscbi">;
317 def int_s390_vsq : SystemZBinary<"vsq", llvm_v16i8_ty>;
318 def int_s390_vsbiq : SystemZTernary<"vsbiq", llvm_v16i8_ty>;
319 def int_s390_vscbiq : SystemZBinary<"vscbiq", llvm_v16i8_ty>;
320 def int_s390_vsbcbiq : SystemZTernary<"vsbcbiq", llvm_v16i8_ty>;
322 def int_s390_vsumb : SystemZBinaryConv<"vsumb", llvm_v4i32_ty, llvm_v16i8_ty>;
323 def int_s390_vsumh : SystemZBinaryConv<"vsumh", llvm_v4i32_ty, llvm_v8i16_ty>;
325 def int_s390_vsumgh : SystemZBinaryConv<"vsumgh", llvm_v2i64_ty,
327 def int_s390_vsumgf : SystemZBinaryConv<"vsumgf", llvm_v2i64_ty,
330 def int_s390_vsumqf : SystemZBinaryConv<"vsumqf", llvm_v16i8_ty,
332 def int_s390_vsumqg : SystemZBinaryConv<"vsumqg", llvm_v16i8_ty,
335 def int_s390_vtm : SystemZBinaryConv<"vtm", llvm_i32_ty, llvm_v16i8_ty>;
337 defm int_s390_vceq : SystemZCompareBHFG<"vceq">;
338 defm int_s390_vch : SystemZCompareBHFG<"vch">;
339 defm int_s390_vchl : SystemZCompareBHFG<"vchl">;
341 defm int_s390_vfae : SystemZTernaryIntBHF<"vfae">;
342 defm int_s390_vfae : SystemZTernaryIntCCBHF;
343 defm int_s390_vfaez : SystemZTernaryIntBHF<"vfaez">;
344 defm int_s390_vfaez : SystemZTernaryIntCCBHF;
346 defm int_s390_vfee : SystemZBinaryBHF<"vfee">;
347 defm int_s390_vfee : SystemZBinaryCCBHF;
348 defm int_s390_vfeez : SystemZBinaryBHF<"vfeez">;
349 defm int_s390_vfeez : SystemZBinaryCCBHF;
351 defm int_s390_vfene : SystemZBinaryBHF<"vfene">;
352 defm int_s390_vfene : SystemZBinaryCCBHF;
353 defm int_s390_vfenez : SystemZBinaryBHF<"vfenez">;
354 defm int_s390_vfenez : SystemZBinaryCCBHF;
356 defm int_s390_vistr : SystemZUnaryBHF<"vistr">;
357 defm int_s390_vistr : SystemZUnaryCCBHF;
359 defm int_s390_vstrc : SystemZQuaternaryIntBHF<"vstrc">;
360 defm int_s390_vstrc : SystemZQuaternaryIntCCBHF;
361 defm int_s390_vstrcz : SystemZQuaternaryIntBHF<"vstrcz">;
362 defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
364 def int_s390_vfcedbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
365 def int_s390_vfchdbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
366 def int_s390_vfchedbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
368 def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
370 def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
371 [llvm_v2f64_ty, llvm_i32_ty, llvm_i32_ty],
374 // Instructions from the Vector Enhancements Facility 1
375 def int_s390_vbperm : SystemZBinaryConv<"vbperm", llvm_v2i64_ty,
378 def int_s390_vmslg : GCCBuiltin<"__builtin_s390_vmslg">,
379 Intrinsic<[llvm_v16i8_ty],
380 [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v16i8_ty,
381 llvm_i32_ty], [IntrNoMem]>;
383 def int_s390_vfmaxdb : Intrinsic<[llvm_v2f64_ty],
384 [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty],
386 def int_s390_vfmindb : Intrinsic<[llvm_v2f64_ty],
387 [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty],
389 def int_s390_vfmaxsb : Intrinsic<[llvm_v4f32_ty],
390 [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
392 def int_s390_vfminsb : Intrinsic<[llvm_v4f32_ty],
393 [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
396 def int_s390_vfcesbs : SystemZBinaryConvCC<llvm_v4i32_ty, llvm_v4f32_ty>;
397 def int_s390_vfchsbs : SystemZBinaryConvCC<llvm_v4i32_ty, llvm_v4f32_ty>;
398 def int_s390_vfchesbs : SystemZBinaryConvCC<llvm_v4i32_ty, llvm_v4f32_ty>;
400 def int_s390_vftcisb : SystemZBinaryConvIntCC<llvm_v4i32_ty, llvm_v4f32_ty>;
402 def int_s390_vfisb : Intrinsic<[llvm_v4f32_ty],
403 [llvm_v4f32_ty, llvm_i32_ty, llvm_i32_ty],
406 // Instructions from the Vector Packed Decimal Facility
407 def int_s390_vlrl : GCCBuiltin<"__builtin_s390_vlrl">,
408 Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty, llvm_ptr_ty],
409 [IntrReadMem, IntrArgMemOnly]>;
411 def int_s390_vstrl : GCCBuiltin<"__builtin_s390_vstrl">,
412 Intrinsic<[], [llvm_v16i8_ty, llvm_i32_ty, llvm_ptr_ty],
413 [IntrArgMemOnly, IntrWriteMem]>;
416 //===----------------------------------------------------------------------===//
420 //===----------------------------------------------------------------------===//
422 let TargetPrefix = "s390" in {
423 def int_s390_sfpc : GCCBuiltin<"__builtin_s390_sfpc">,
424 Intrinsic<[], [llvm_i32_ty], []>;
425 def int_s390_efpc : GCCBuiltin<"__builtin_s390_efpc">,
426 Intrinsic<[llvm_i32_ty], [], []>;
428 def int_s390_tdc : Intrinsic<[llvm_i32_ty], [llvm_anyfloat_ty, llvm_i64_ty],