1 //===- IntrinsicsSystemZ.td - Defines SystemZ intrinsics ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines all of the SystemZ-specific intrinsics.
12 //===----------------------------------------------------------------------===//
14 class SystemZUnaryConv<string name, LLVMType result, LLVMType arg>
15 : GCCBuiltin<"__builtin_s390_" ## name>,
16 Intrinsic<[result], [arg], [IntrNoMem]>;
18 class SystemZUnary<string name, LLVMType type>
19 : SystemZUnaryConv<name, type, type>;
21 class SystemZUnaryConvCC<LLVMType result, LLVMType arg>
22 : Intrinsic<[result, llvm_i32_ty], [arg], [IntrNoMem]>;
24 class SystemZUnaryCC<LLVMType type>
25 : SystemZUnaryConvCC<type, type>;
27 class SystemZBinaryConv<string name, LLVMType result, LLVMType arg>
28 : GCCBuiltin<"__builtin_s390_" ## name>,
29 Intrinsic<[result], [arg, arg], [IntrNoMem]>;
31 class SystemZBinary<string name, LLVMType type>
32 : SystemZBinaryConv<name, type, type>;
34 class SystemZBinaryInt<string name, LLVMType type>
35 : GCCBuiltin<"__builtin_s390_" ## name>,
36 Intrinsic<[type], [type, llvm_i32_ty], [IntrNoMem]>;
38 class SystemZBinaryConvCC<LLVMType result, LLVMType arg>
39 : Intrinsic<[result, llvm_i32_ty], [arg, arg], [IntrNoMem]>;
41 class SystemZBinaryConvIntCC<LLVMType result, LLVMType arg>
42 : Intrinsic<[result, llvm_i32_ty], [arg, llvm_i32_ty], [IntrNoMem]>;
44 class SystemZBinaryCC<LLVMType type>
45 : SystemZBinaryConvCC<type, type>;
47 class SystemZTernaryConv<string name, LLVMType result, LLVMType arg>
48 : GCCBuiltin<"__builtin_s390_" ## name>,
49 Intrinsic<[result], [arg, arg, result], [IntrNoMem]>;
51 class SystemZTernary<string name, LLVMType type>
52 : SystemZTernaryConv<name, type, type>;
54 class SystemZTernaryInt<string name, LLVMType type>
55 : GCCBuiltin<"__builtin_s390_" ## name>,
56 Intrinsic<[type], [type, type, llvm_i32_ty], [IntrNoMem]>;
58 class SystemZTernaryIntCC<LLVMType type>
59 : Intrinsic<[type, llvm_i32_ty], [type, type, llvm_i32_ty], [IntrNoMem]>;
61 class SystemZQuaternaryInt<string name, LLVMType type>
62 : GCCBuiltin<"__builtin_s390_" ## name>,
63 Intrinsic<[type], [type, type, type, llvm_i32_ty], [IntrNoMem]>;
65 class SystemZQuaternaryIntCC<LLVMType type>
66 : Intrinsic<[type, llvm_i32_ty], [type, type, type, llvm_i32_ty],
69 multiclass SystemZUnaryExtBHF<string name> {
70 def b : SystemZUnaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
71 def h : SystemZUnaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
72 def f : SystemZUnaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
75 multiclass SystemZUnaryExtBHWF<string name> {
76 def b : SystemZUnaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
77 def hw : SystemZUnaryConv<name##"hw", llvm_v4i32_ty, llvm_v8i16_ty>;
78 def f : SystemZUnaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
81 multiclass SystemZUnaryBHF<string name> {
82 def b : SystemZUnary<name##"b", llvm_v16i8_ty>;
83 def h : SystemZUnary<name##"h", llvm_v8i16_ty>;
84 def f : SystemZUnary<name##"f", llvm_v4i32_ty>;
87 multiclass SystemZUnaryBHFG<string name> : SystemZUnaryBHF<name> {
88 def g : SystemZUnary<name##"g", llvm_v2i64_ty>;
91 multiclass SystemZUnaryCCBHF {
92 def bs : SystemZUnaryCC<llvm_v16i8_ty>;
93 def hs : SystemZUnaryCC<llvm_v8i16_ty>;
94 def fs : SystemZUnaryCC<llvm_v4i32_ty>;
97 multiclass SystemZBinaryTruncHFG<string name> {
98 def h : SystemZBinaryConv<name##"h", llvm_v16i8_ty, llvm_v8i16_ty>;
99 def f : SystemZBinaryConv<name##"f", llvm_v8i16_ty, llvm_v4i32_ty>;
100 def g : SystemZBinaryConv<name##"g", llvm_v4i32_ty, llvm_v2i64_ty>;
103 multiclass SystemZBinaryTruncCCHFG {
104 def hs : SystemZBinaryConvCC<llvm_v16i8_ty, llvm_v8i16_ty>;
105 def fs : SystemZBinaryConvCC<llvm_v8i16_ty, llvm_v4i32_ty>;
106 def gs : SystemZBinaryConvCC<llvm_v4i32_ty, llvm_v2i64_ty>;
109 multiclass SystemZBinaryExtBHF<string name> {
110 def b : SystemZBinaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
111 def h : SystemZBinaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
112 def f : SystemZBinaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
115 multiclass SystemZBinaryExtBHFG<string name> : SystemZBinaryExtBHF<name> {
116 def g : SystemZBinaryConv<name##"g", llvm_v16i8_ty, llvm_v2i64_ty>;
119 multiclass SystemZBinaryBHF<string name> {
120 def b : SystemZBinary<name##"b", llvm_v16i8_ty>;
121 def h : SystemZBinary<name##"h", llvm_v8i16_ty>;
122 def f : SystemZBinary<name##"f", llvm_v4i32_ty>;
125 multiclass SystemZBinaryBHFG<string name> : SystemZBinaryBHF<name> {
126 def g : SystemZBinary<name##"g", llvm_v2i64_ty>;
129 multiclass SystemZBinaryIntBHFG<string name> {
130 def b : SystemZBinaryInt<name##"b", llvm_v16i8_ty>;
131 def h : SystemZBinaryInt<name##"h", llvm_v8i16_ty>;
132 def f : SystemZBinaryInt<name##"f", llvm_v4i32_ty>;
133 def g : SystemZBinaryInt<name##"g", llvm_v2i64_ty>;
136 multiclass SystemZBinaryCCBHF {
137 def bs : SystemZBinaryCC<llvm_v16i8_ty>;
138 def hs : SystemZBinaryCC<llvm_v8i16_ty>;
139 def fs : SystemZBinaryCC<llvm_v4i32_ty>;
142 multiclass SystemZCompareBHFG<string name> {
143 def bs : SystemZBinaryCC<llvm_v16i8_ty>;
144 def hs : SystemZBinaryCC<llvm_v8i16_ty>;
145 def fs : SystemZBinaryCC<llvm_v4i32_ty>;
146 def gs : SystemZBinaryCC<llvm_v2i64_ty>;
149 multiclass SystemZTernaryExtBHF<string name> {
150 def b : SystemZTernaryConv<name##"b", llvm_v8i16_ty, llvm_v16i8_ty>;
151 def h : SystemZTernaryConv<name##"h", llvm_v4i32_ty, llvm_v8i16_ty>;
152 def f : SystemZTernaryConv<name##"f", llvm_v2i64_ty, llvm_v4i32_ty>;
155 multiclass SystemZTernaryExtBHFG<string name> : SystemZTernaryExtBHF<name> {
156 def g : SystemZTernaryConv<name##"g", llvm_v16i8_ty, llvm_v2i64_ty>;
159 multiclass SystemZTernaryBHF<string name> {
160 def b : SystemZTernary<name##"b", llvm_v16i8_ty>;
161 def h : SystemZTernary<name##"h", llvm_v8i16_ty>;
162 def f : SystemZTernary<name##"f", llvm_v4i32_ty>;
165 multiclass SystemZTernaryIntBHF<string name> {
166 def b : SystemZTernaryInt<name##"b", llvm_v16i8_ty>;
167 def h : SystemZTernaryInt<name##"h", llvm_v8i16_ty>;
168 def f : SystemZTernaryInt<name##"f", llvm_v4i32_ty>;
171 multiclass SystemZTernaryIntCCBHF {
172 def bs : SystemZTernaryIntCC<llvm_v16i8_ty>;
173 def hs : SystemZTernaryIntCC<llvm_v8i16_ty>;
174 def fs : SystemZTernaryIntCC<llvm_v4i32_ty>;
177 multiclass SystemZQuaternaryIntBHF<string name> {
178 def b : SystemZQuaternaryInt<name##"b", llvm_v16i8_ty>;
179 def h : SystemZQuaternaryInt<name##"h", llvm_v8i16_ty>;
180 def f : SystemZQuaternaryInt<name##"f", llvm_v4i32_ty>;
183 multiclass SystemZQuaternaryIntBHFG<string name> : SystemZQuaternaryIntBHF<name> {
184 def g : SystemZQuaternaryInt<name##"g", llvm_v2i64_ty>;
187 multiclass SystemZQuaternaryIntCCBHF {
188 def bs : SystemZQuaternaryIntCC<llvm_v16i8_ty>;
189 def hs : SystemZQuaternaryIntCC<llvm_v8i16_ty>;
190 def fs : SystemZQuaternaryIntCC<llvm_v4i32_ty>;
193 //===----------------------------------------------------------------------===//
195 // Transactional-execution intrinsics
197 //===----------------------------------------------------------------------===//
199 let TargetPrefix = "s390" in {
200 def int_s390_tbegin : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
203 def int_s390_tbegin_nofloat : Intrinsic<[llvm_i32_ty],
204 [llvm_ptr_ty, llvm_i32_ty],
207 def int_s390_tbeginc : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
210 def int_s390_tabort : Intrinsic<[], [llvm_i64_ty],
211 [IntrNoReturn, Throws]>;
213 def int_s390_tend : GCCBuiltin<"__builtin_tend">,
214 Intrinsic<[llvm_i32_ty], []>;
216 def int_s390_etnd : GCCBuiltin<"__builtin_tx_nesting_depth">,
217 Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>;
219 def int_s390_ntstg : Intrinsic<[], [llvm_i64_ty, llvm_ptr64_ty],
220 [IntrReadWriteArgMem]>;
222 def int_s390_ppa_txassist : GCCBuiltin<"__builtin_tx_assist">,
223 Intrinsic<[], [llvm_i32_ty]>;
226 //===----------------------------------------------------------------------===//
230 //===----------------------------------------------------------------------===//
232 let TargetPrefix = "s390" in {
233 def int_s390_lcbb : GCCBuiltin<"__builtin_s390_lcbb">,
234 Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_i32_ty],
237 def int_s390_vlbb : GCCBuiltin<"__builtin_s390_vlbb">,
238 Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty],
241 def int_s390_vll : GCCBuiltin<"__builtin_s390_vll">,
242 Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty, llvm_ptr_ty],
245 def int_s390_vpdi : GCCBuiltin<"__builtin_s390_vpdi">,
246 Intrinsic<[llvm_v2i64_ty],
247 [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty],
250 def int_s390_vperm : GCCBuiltin<"__builtin_s390_vperm">,
251 Intrinsic<[llvm_v16i8_ty],
252 [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
255 defm int_s390_vpks : SystemZBinaryTruncHFG<"vpks">;
256 defm int_s390_vpks : SystemZBinaryTruncCCHFG;
258 defm int_s390_vpkls : SystemZBinaryTruncHFG<"vpkls">;
259 defm int_s390_vpkls : SystemZBinaryTruncCCHFG;
261 def int_s390_vstl : GCCBuiltin<"__builtin_s390_vstl">,
262 Intrinsic<[], [llvm_v16i8_ty, llvm_i32_ty, llvm_ptr_ty],
263 // In fact write-only but there's no property
265 [IntrReadWriteArgMem]>;
267 defm int_s390_vupl : SystemZUnaryExtBHWF<"vupl">;
268 defm int_s390_vupll : SystemZUnaryExtBHF<"vupll">;
270 defm int_s390_vuph : SystemZUnaryExtBHF<"vuph">;
271 defm int_s390_vuplh : SystemZUnaryExtBHF<"vuplh">;
273 defm int_s390_vacc : SystemZBinaryBHFG<"vacc">;
275 def int_s390_vaq : SystemZBinary<"vaq", llvm_v16i8_ty>;
276 def int_s390_vacq : SystemZTernary<"vacq", llvm_v16i8_ty>;
277 def int_s390_vaccq : SystemZBinary<"vaccq", llvm_v16i8_ty>;
278 def int_s390_vacccq : SystemZTernary<"vacccq", llvm_v16i8_ty>;
280 defm int_s390_vavg : SystemZBinaryBHFG<"vavg">;
281 defm int_s390_vavgl : SystemZBinaryBHFG<"vavgl">;
283 def int_s390_vcksm : SystemZBinary<"vcksm", llvm_v4i32_ty>;
285 defm int_s390_vgfm : SystemZBinaryExtBHFG<"vgfm">;
286 defm int_s390_vgfma : SystemZTernaryExtBHFG<"vgfma">;
288 defm int_s390_vmah : SystemZTernaryBHF<"vmah">;
289 defm int_s390_vmalh : SystemZTernaryBHF<"vmalh">;
290 defm int_s390_vmae : SystemZTernaryExtBHF<"vmae">;
291 defm int_s390_vmale : SystemZTernaryExtBHF<"vmale">;
292 defm int_s390_vmao : SystemZTernaryExtBHF<"vmao">;
293 defm int_s390_vmalo : SystemZTernaryExtBHF<"vmalo">;
295 defm int_s390_vmh : SystemZBinaryBHF<"vmh">;
296 defm int_s390_vmlh : SystemZBinaryBHF<"vmlh">;
297 defm int_s390_vme : SystemZBinaryExtBHF<"vme">;
298 defm int_s390_vmle : SystemZBinaryExtBHF<"vmle">;
299 defm int_s390_vmo : SystemZBinaryExtBHF<"vmo">;
300 defm int_s390_vmlo : SystemZBinaryExtBHF<"vmlo">;
302 defm int_s390_verllv : SystemZBinaryBHFG<"verllv">;
303 defm int_s390_verll : SystemZBinaryIntBHFG<"verll">;
304 defm int_s390_verim : SystemZQuaternaryIntBHFG<"verim">;
306 def int_s390_vsl : SystemZBinary<"vsl", llvm_v16i8_ty>;
307 def int_s390_vslb : SystemZBinary<"vslb", llvm_v16i8_ty>;
308 def int_s390_vsra : SystemZBinary<"vsra", llvm_v16i8_ty>;
309 def int_s390_vsrab : SystemZBinary<"vsrab", llvm_v16i8_ty>;
310 def int_s390_vsrl : SystemZBinary<"vsrl", llvm_v16i8_ty>;
311 def int_s390_vsrlb : SystemZBinary<"vsrlb", llvm_v16i8_ty>;
313 def int_s390_vsldb : GCCBuiltin<"__builtin_s390_vsldb">,
314 Intrinsic<[llvm_v16i8_ty],
315 [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty],
318 defm int_s390_vscbi : SystemZBinaryBHFG<"vscbi">;
320 def int_s390_vsq : SystemZBinary<"vsq", llvm_v16i8_ty>;
321 def int_s390_vsbiq : SystemZTernary<"vsbiq", llvm_v16i8_ty>;
322 def int_s390_vscbiq : SystemZBinary<"vscbiq", llvm_v16i8_ty>;
323 def int_s390_vsbcbiq : SystemZTernary<"vsbcbiq", llvm_v16i8_ty>;
325 def int_s390_vsumb : SystemZBinaryConv<"vsumb", llvm_v4i32_ty, llvm_v16i8_ty>;
326 def int_s390_vsumh : SystemZBinaryConv<"vsumh", llvm_v4i32_ty, llvm_v8i16_ty>;
328 def int_s390_vsumgh : SystemZBinaryConv<"vsumgh", llvm_v2i64_ty,
330 def int_s390_vsumgf : SystemZBinaryConv<"vsumgf", llvm_v2i64_ty,
333 def int_s390_vsumqf : SystemZBinaryConv<"vsumqf", llvm_v16i8_ty,
335 def int_s390_vsumqg : SystemZBinaryConv<"vsumqg", llvm_v16i8_ty,
338 def int_s390_vtm : SystemZBinaryConv<"vtm", llvm_i32_ty, llvm_v16i8_ty>;
340 defm int_s390_vceq : SystemZCompareBHFG<"vceq">;
341 defm int_s390_vch : SystemZCompareBHFG<"vch">;
342 defm int_s390_vchl : SystemZCompareBHFG<"vchl">;
344 defm int_s390_vfae : SystemZTernaryIntBHF<"vfae">;
345 defm int_s390_vfae : SystemZTernaryIntCCBHF;
346 defm int_s390_vfaez : SystemZTernaryIntBHF<"vfaez">;
347 defm int_s390_vfaez : SystemZTernaryIntCCBHF;
349 defm int_s390_vfee : SystemZBinaryBHF<"vfee">;
350 defm int_s390_vfee : SystemZBinaryCCBHF;
351 defm int_s390_vfeez : SystemZBinaryBHF<"vfeez">;
352 defm int_s390_vfeez : SystemZBinaryCCBHF;
354 defm int_s390_vfene : SystemZBinaryBHF<"vfene">;
355 defm int_s390_vfene : SystemZBinaryCCBHF;
356 defm int_s390_vfenez : SystemZBinaryBHF<"vfenez">;
357 defm int_s390_vfenez : SystemZBinaryCCBHF;
359 defm int_s390_vistr : SystemZUnaryBHF<"vistr">;
360 defm int_s390_vistr : SystemZUnaryCCBHF;
362 defm int_s390_vstrc : SystemZQuaternaryIntBHF<"vstrc">;
363 defm int_s390_vstrc : SystemZQuaternaryIntCCBHF;
364 defm int_s390_vstrcz : SystemZQuaternaryIntBHF<"vstrcz">;
365 defm int_s390_vstrcz : SystemZQuaternaryIntCCBHF;
367 def int_s390_vfcedbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
368 def int_s390_vfchdbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
369 def int_s390_vfchedbs : SystemZBinaryConvCC<llvm_v2i64_ty, llvm_v2f64_ty>;
371 def int_s390_vftcidb : SystemZBinaryConvIntCC<llvm_v2i64_ty, llvm_v2f64_ty>;
373 def int_s390_vfidb : Intrinsic<[llvm_v2f64_ty],
374 [llvm_v2f64_ty, llvm_i32_ty, llvm_i32_ty],