blob: d4c473e2a68f194c88a9a96ebbd652d266df7fbe [file] [log] [blame]
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001//==--- OpenCLBuiltins.td - OpenCL builtin declarations -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9//===----------------------------------------------------------------------===//
10//
11// This file contains TableGen definitions for OpenCL builtin function
12// declarations. In case of an unresolved function name in OpenCL, Clang will
13// check for a function described in this file when -fdeclare-opencl-builtins
14// is specified.
15//
16//===----------------------------------------------------------------------===//
17
18//===----------------------------------------------------------------------===//
19// Definitions of miscellaneous basic entities.
20//===----------------------------------------------------------------------===//
21// Versions of OpenCL
22class Version<int _Version> {
Sven van Haastregted69faa2019-09-19 13:41:51 +000023 int ID = _Version;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000024}
Sven van Haastregted69faa2019-09-19 13:41:51 +000025def CLAll : Version< 0>;
26def CL10 : Version<100>;
27def CL11 : Version<110>;
28def CL12 : Version<120>;
29def CL20 : Version<200>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000030
31// Address spaces
32// Pointer types need to be assigned an address space.
33class AddressSpace<string _AS> {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +000034 string Name = _AS;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000035}
Sven van Haastregt89fb9e82019-07-29 14:55:29 +000036def DefaultAS : AddressSpace<"clang::LangAS::Default">;
37def PrivateAS : AddressSpace<"clang::LangAS::opencl_private">;
38def GlobalAS : AddressSpace<"clang::LangAS::opencl_global">;
39def ConstantAS : AddressSpace<"clang::LangAS::opencl_constant">;
40def LocalAS : AddressSpace<"clang::LangAS::opencl_local">;
41def GenericAS : AddressSpace<"clang::LangAS::opencl_generic">;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000042
Sven van Haastregt308b8b72019-12-18 10:13:51 +000043// OpenCL language extension.
44class AbstractExtension<string _Ext> {
45 // One or more OpenCL extensions, space separated. Each extension must be
46 // a valid extension name for the opencl extension pragma.
47 string ExtName = _Ext;
48}
49
50// Extension associated to a builtin function.
51class FunctionExtension<string _Ext> : AbstractExtension<_Ext>;
52
53// FunctionExtension definitions.
54def FuncExtNone : FunctionExtension<"">;
55def FuncExtKhrSubgroups : FunctionExtension<"cl_khr_subgroups">;
56def FuncExtKhrGlobalInt32BaseAtomics : FunctionExtension<"cl_khr_global_int32_base_atomics">;
57def FuncExtKhrGlobalInt32ExtendedAtomics : FunctionExtension<"cl_khr_global_int32_extended_atomics">;
Sven van Haastregtb7145832019-12-23 12:29:01 +000058def FuncExtKhrLocalInt32BaseAtomics : FunctionExtension<"cl_khr_local_int32_base_atomics">;
59def FuncExtKhrLocalInt32ExtendedAtomics : FunctionExtension<"cl_khr_local_int32_extended_atomics">;
60def FuncExtKhrInt64BaseAtomics : FunctionExtension<"cl_khr_int64_base_atomics">;
61def FuncExtKhrInt64ExtendedAtomics : FunctionExtension<"cl_khr_int64_extended_atomics">;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +000062def FuncExtKhrMipmapImage : FunctionExtension<"cl_khr_mipmap_image">;
63
64// Multiple extensions
65def FuncExtKhrMipmapAndWrite3d : FunctionExtension<"cl_khr_mipmap_image cl_khr_3d_image_writes">;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000066
Sven van Haastregtb21a3652019-08-19 11:56:03 +000067// Qualified Type. These map to ASTContext::QualType.
68class QualType<string _Name, bit _IsAbstract=0> {
Sven van Haastregt79a222f2019-06-03 09:39:11 +000069 // Name of the field or function in a clang::ASTContext
70 // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
71 string Name = _Name;
Sven van Haastregtb21a3652019-08-19 11:56:03 +000072 // Some QualTypes in this file represent an abstract type for which there is
73 // no corresponding AST QualType, e.g. a GenType or an `image2d_t` type
74 // without access qualifiers.
75 bit IsAbstract = _IsAbstract;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000076}
77
Sven van Haastregtb21a3652019-08-19 11:56:03 +000078// List of integers.
79class IntList<string _Name, list<int> _List> {
80 string Name = _Name;
81 list<int> List = _List;
82}
83
Sven van Haastregt79a222f2019-06-03 09:39:11 +000084//===----------------------------------------------------------------------===//
85// OpenCL C classes for types
86//===----------------------------------------------------------------------===//
Sven van Haastregtb21a3652019-08-19 11:56:03 +000087// OpenCL C basic data types (int, float, image2d_t, ...).
Sven van Haastregt47e95ff2019-09-17 13:32:56 +000088// Its child classes can represent concrete types (e.g. VectorType) or
89// abstract types (e.g. GenType).
Sven van Haastregt79a222f2019-06-03 09:39:11 +000090class Type<string _Name, QualType _QTName> {
Sven van Haastregtb21a3652019-08-19 11:56:03 +000091 // Name of the Type.
Sven van Haastregt79a222f2019-06-03 09:39:11 +000092 string Name = _Name;
Sven van Haastregtb21a3652019-08-19 11:56:03 +000093 // QualType associated with this type.
Sven van Haastregt79a222f2019-06-03 09:39:11 +000094 QualType QTName = _QTName;
Sven van Haastregtb21a3652019-08-19 11:56:03 +000095 // Size of the vector (if applicable).
96 int VecWidth = 1;
97 // Is a pointer.
Sven van Haastregt79a222f2019-06-03 09:39:11 +000098 bit IsPointer = 0;
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000099 // "const" qualifier.
100 bit IsConst = 0;
101 // "volatile" qualifier.
102 bit IsVolatile = 0;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000103 // Access qualifier. Must be one of ("RO", "WO", "RW").
104 string AccessQualifier = "";
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000105 // Address space.
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000106 string AddrSpace = DefaultAS.Name;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000107}
108
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000109// OpenCL vector types (e.g. int2, int3, int16, float8, ...).
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000110class VectorType<Type _Ty, int _VecWidth> : Type<_Ty.Name, _Ty.QTName> {
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000111 let VecWidth = _VecWidth;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000112 let AccessQualifier = "";
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000113 // Inherited fields
114 let IsPointer = _Ty.IsPointer;
115 let IsConst = _Ty.IsConst;
116 let IsVolatile = _Ty.IsVolatile;
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000117 let AddrSpace = _Ty.AddrSpace;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000118}
119
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000120// OpenCL pointer types (e.g. int*, float*, ...).
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000121class PointerType<Type _Ty, AddressSpace _AS = DefaultAS> :
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000122 Type<_Ty.Name, _Ty.QTName> {
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000123 let AddrSpace = _AS.Name;
124 // Inherited fields
125 let VecWidth = _Ty.VecWidth;
126 let IsPointer = 1;
127 let IsConst = _Ty.IsConst;
128 let IsVolatile = _Ty.IsVolatile;
129 let AccessQualifier = _Ty.AccessQualifier;
130}
131
132// OpenCL const types (e.g. const int).
133class ConstType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> {
134 let IsConst = 1;
135 // Inherited fields
136 let VecWidth = _Ty.VecWidth;
137 let IsPointer = _Ty.IsPointer;
138 let IsVolatile = _Ty.IsVolatile;
139 let AccessQualifier = _Ty.AccessQualifier;
140 let AddrSpace = _Ty.AddrSpace;
141}
142
143// OpenCL volatile types (e.g. volatile int).
144class VolatileType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> {
145 let IsVolatile = 1;
146 // Inherited fields
147 let VecWidth = _Ty.VecWidth;
148 let IsPointer = _Ty.IsPointer;
149 let IsConst = _Ty.IsConst;
150 let AccessQualifier = _Ty.AccessQualifier;
151 let AddrSpace = _Ty.AddrSpace;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000152}
153
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000154// OpenCL image types (e.g. image2d).
155class ImageType<Type _Ty, string _AccessQualifier> :
156 Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
157 let VecWidth = 0;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000158 let AccessQualifier = _AccessQualifier;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000159 // Inherited fields
160 let IsPointer = _Ty.IsPointer;
161 let IsConst = _Ty.IsConst;
162 let IsVolatile = _Ty.IsVolatile;
163 let AddrSpace = _Ty.AddrSpace;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000164}
165
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000166// List of Types.
167class TypeList<string _Name, list<Type> _Type> {
168 string Name = _Name;
169 list<Type> List = _Type;
170}
171
172// A GenericType is an abstract type that defines a set of types as a
173// combination of Types and vector sizes.
174//
Sven van Haastregt47e95ff2019-09-17 13:32:56 +0000175// For example, if TypeList = <int, float> and VectorList = <1, 2, 4>, then it
176// represents <int, int2, int4, float, float2, float4>.
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000177//
178// Some rules apply when using multiple GenericType arguments in a declaration:
179// 1. The number of vector sizes must be equal or 1 for all gentypes in a
180// declaration.
181// 2. The number of Types must be equal or 1 for all gentypes in a
182// declaration.
183// 3. Generic types are combined by iterating over all generic types at once.
184// For example, for the following GenericTypes
185// GenT1 = GenericType<half, [1, 2]> and
186// GenT2 = GenericType<float, int, [1, 2]>
187// A declaration f(GenT1, GenT2) results in the combinations
188// f(half, float), f(half2, float2), f(half, int), f(half2, int2) .
189// 4. "sgentype" from the OpenCL specification is supported by specifying
190// a single vector size.
191// For example, for the following GenericTypes
192// GenT = GenericType<half, int, [1, 2]> and
193// SGenT = GenericType<half, int, [1]>
194// A declaration f(GenT, SGenT) results in the combinations
195// f(half, half), f(half2, half), f(int, int), f(int2, int) .
196class GenericType<string _Ty, TypeList _TypeList, IntList _VectorList> :
197 Type<_Ty, QualType<"null", 1>> {
198 // Possible element types of the generic type.
199 TypeList TypeList = _TypeList;
200 // Possible vector sizes of the types in the TypeList.
201 IntList VectorList = _VectorList;
202 // The VecWidth field is ignored for GenericTypes. Use VectorList instead.
203 let VecWidth = 0;
204}
205
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000206// Builtin function attributes.
207def Attr {
208 list<bit> None = [0, 0, 0];
209 list<bit> Pure = [1, 0, 0];
210 list<bit> Const = [0, 1, 0];
211 list<bit> Convergent = [0, 0, 1];
212}
213
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000214//===----------------------------------------------------------------------===//
215// OpenCL C class for builtin functions
216//===----------------------------------------------------------------------===//
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000217class Builtin<string _Name, list<Type> _Signature, list<bit> _Attributes = Attr.None> {
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000218 // Name of the builtin function
219 string Name = _Name;
220 // List of types used by the function. The first one is the return type and
221 // the following are the arguments. The list must have at least one element
222 // (the return type).
223 list<Type> Signature = _Signature;
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000224 // Function attribute __attribute__((pure))
225 bit IsPure = _Attributes[0];
226 // Function attribute __attribute__((const))
227 bit IsConst = _Attributes[1];
228 // Function attribute __attribute__((convergent))
229 bit IsConv = _Attributes[2];
Sven van Haastregt308b8b72019-12-18 10:13:51 +0000230 // OpenCL extensions to which the function belongs.
231 FunctionExtension Extension = FuncExtNone;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000232 // Version of OpenCL from which the function is available (e.g.: CL10).
233 // MinVersion is inclusive.
234 Version MinVersion = CL10;
235 // Version of OpenCL from which the function is not supported anymore.
236 // MaxVersion is exclusive.
237 // CLAll makes the function available for all versions.
238 Version MaxVersion = CLAll;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000239}
240
241//===----------------------------------------------------------------------===//
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000242// Definitions of OpenCL C types
243//===----------------------------------------------------------------------===//
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000244
245// OpenCL v1.0/1.2/2.0 s6.1.1: Built-in Scalar Data Types.
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000246def Bool : Type<"bool", QualType<"BoolTy">>;
247def Char : Type<"char", QualType<"CharTy">>;
248def UChar : Type<"uchar", QualType<"UnsignedCharTy">>;
249def Short : Type<"short", QualType<"ShortTy">>;
250def UShort : Type<"ushort", QualType<"UnsignedShortTy">>;
251def Int : Type<"int", QualType<"IntTy">>;
252def UInt : Type<"uint", QualType<"UnsignedIntTy">>;
253def Long : Type<"long", QualType<"LongTy">>;
254def ULong : Type<"ulong", QualType<"UnsignedLongTy">>;
255def Float : Type<"float", QualType<"FloatTy">>;
256def Double : Type<"double", QualType<"DoubleTy">>;
257def Half : Type<"half", QualType<"HalfTy">>;
258def Size : Type<"size_t", QualType<"getSizeType()">>;
259def PtrDiff : Type<"ptrdiff_t", QualType<"getPointerDiffType()">>;
260def IntPtr : Type<"intptr_t", QualType<"getIntPtrType()">>;
261def UIntPtr : Type<"uintPtr_t", QualType<"getUIntPtrType()">>;
262def Void : Type<"void_t", QualType<"VoidTy">>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000263
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000264// OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
265// Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000266
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000267// OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types.
268// The image definitions are "abstract". They should not be used without
269// specifying an access qualifier (RO/WO/RW).
270def Image1d : Type<"Image1d", QualType<"OCLImage1d", 1>>;
271def Image2d : Type<"Image2d", QualType<"OCLImage2d", 1>>;
272def Image3d : Type<"Image3d", QualType<"OCLImage3d", 1>>;
273def Image1dArray : Type<"Image1dArray", QualType<"OCLImage1dArray", 1>>;
274def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 1>>;
275def Image2dArray : Type<"Image2dArray", QualType<"OCLImage2dArray", 1>>;
276def Image2dDepth : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 1>>;
277def Image2dArrayDepth : Type<"Image2dArrayDepth", QualType<"OCLImage2dArrayDepth", 1>>;
278def Image2dMsaa : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>;
279def Image2dArrayMsaa : Type<"Image2dArrayMsaa", QualType<"OCLImage2dArrayMSAA", 1>>;
280def Image2dMsaaDepth : Type<"Image2dMsaaDepth", QualType<"OCLImage2dMSAADepth", 1>>;
281def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", QualType<"OCLImage2dArrayMSAADepth", 1>>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000282
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000283def Sampler : Type<"Sampler", QualType<"OCLSamplerTy">>;
284def Event : Type<"Event", QualType<"OCLEventTy">>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000285
286//===----------------------------------------------------------------------===//
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000287// Definitions of OpenCL gentype variants
288//===----------------------------------------------------------------------===//
289// The OpenCL specification often uses "gentype" in builtin function
290// declarations to indicate that a builtin function is available with various
291// argument and return types. The types represented by "gentype" vary between
292// different parts of the specification. The following definitions capture
293// the different type lists for gentypes in different parts of the
294// specification.
295
296// Vector width lists.
297def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>;
298def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>;
299def Vec1 : IntList<"Vec1", [1]>;
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000300def Vec2 : IntList<"Vec2", [2]>;
301def Vec4 : IntList<"Vec4", [4]>;
302def Vec8 : IntList<"Vec8", [8]>;
303def Vec16 : IntList<"Vec16", [16]>;
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000304def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000305
306// Type lists.
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000307def TLAll : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
308def TLAllUnsigned : TypeList<"TLAllUnsigned", [UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong, UInt, ULong, UShort]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000309def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>;
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000310def TLSignedInts : TypeList<"TLSignedInts", [Char, Short, Int, Long]>;
311def TLUnsignedInts : TypeList<"TLUnsignedInts", [UChar, UShort, UInt, ULong]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000312
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000313def TLIntLongFloats : TypeList<"TLIntLongFloats", [Int, UInt, Long, ULong, Float, Double, Half]>;
314
Sven van Haastregt0e70c352019-11-06 11:53:19 +0000315// All unsigned integer types twice, to facilitate unsigned return types for e.g.
316// uchar abs(char) and
317// uchar abs(uchar).
318def TLAllUIntsTwice : TypeList<"TLAllUIntsTwice", [UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong]>;
319
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000320def TLAllInts : TypeList<"TLAllInts", [Char, UChar, Short, UShort, Int, UInt, Long, ULong]>;
321
322// GenType definitions for multiple base types (e.g. all floating point types,
323// or all integer types).
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000324// All types
325def AGenTypeN : GenericType<"AGenTypeN", TLAll, VecAndScalar>;
326def AGenTypeNNoScalar : GenericType<"AGenTypeNNoScalar", TLAll, VecNoScalar>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000327// All integer
328def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>;
329def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>;
330def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>;
Sven van Haastregt0e70c352019-11-06 11:53:19 +0000331// All integer to unsigned
332def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>;
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000333// Signed integer
334def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar>;
335// Unsigned integer
336def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000337// Float
338def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>;
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000339// (u)int, (u)long, and all floats
340def IntLongFloatGenType1 : GenericType<"IntLongFloatGenType1", TLIntLongFloats, Vec1>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000341
342// GenType definitions for every single base type (e.g. fp32 only).
343// Names are like: GenTypeFloatVecAndScalar.
344foreach Type = [Char, UChar, Short, UShort,
345 Int, UInt, Long, ULong,
346 Float, Double, Half] in {
347 foreach VecSizes = [VecAndScalar, VecNoScalar] in {
348 def "GenType" # Type # VecSizes :
349 GenericType<"GenType" # Type # VecSizes,
350 TypeList<"GL" # Type.Name, [Type]>,
351 VecSizes>;
352 }
353}
354
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000355// GenType definitions for vec1234.
356foreach Type = [Float, Double, Half] in {
357 def "GenType" # Type # Vec1234 :
358 GenericType<"GenType" # Type # Vec1234,
359 TypeList<"GL" # Type.Name, [Type]>,
360 Vec1234>;
361}
362
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000363
364//===----------------------------------------------------------------------===//
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000365// Definitions of OpenCL builtin functions
366//===----------------------------------------------------------------------===//
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000367//--------------------------------------------------------------------
368// OpenCL v1.1/1.2/2.0 s6.2.3 - Explicit conversions.
369// OpenCL v2.0 Extensions s5.1.1 and s6.1.1 - Conversions.
370
371// Generate the convert_* builtins functions.
372foreach RType = [Float, Double, Half, Char, UChar, Short,
373 UShort, Int, UInt, Long, ULong] in {
374 foreach IType = [Float, Double, Half, Char, UChar, Short,
375 UShort, Int, UInt, Long, ULong] in {
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000376 foreach sat = ["", "_sat"] in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000377 foreach rnd = ["", "_rte", "_rtn", "_rtp", "_rtz"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000378 def : Builtin<"convert_" # RType.Name # sat # rnd, [RType, IType],
379 Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000380 foreach v = [2, 3, 4, 8, 16] in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000381 def : Builtin<"convert_" # RType.Name # v # sat # rnd,
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000382 [VectorType<RType, v>, VectorType<IType, v>],
383 Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000384 }
385 }
386 }
387 }
388}
389
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000390//--------------------------------------------------------------------
Sven van Haastregted69faa2019-09-19 13:41:51 +0000391// OpenCL v1.1 s6.11.1, v1.2 s6.12.1, v2.0 s6.13.1 - Work-item Functions
392// --- Table 7 ---
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000393def : Builtin<"get_work_dim", [UInt], Attr.Const>;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000394foreach name = ["get_global_size", "get_global_id", "get_local_size",
395 "get_local_id", "get_num_groups", "get_group_id",
396 "get_global_offset"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000397 def : Builtin<name, [Size, UInt], Attr.Const>;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000398}
399
400let MinVersion = CL20 in {
401 def : Builtin<"get_enqueued_local_size", [Size, UInt]>;
402 foreach name = ["get_global_linear_id", "get_local_linear_id"] in {
403 def : Builtin<name, [Size]>;
404 }
405}
406
Sven van Haastregt6fc73f62019-11-05 19:47:21 +0000407
Sven van Haastregted69faa2019-09-19 13:41:51 +0000408//--------------------------------------------------------------------
Sven van Haastregt6fc73f62019-11-05 19:47:21 +0000409// OpenCL v1.1 s6.11.2, v1.2 s6.12.2, v2.0 s6.13.2 - Math functions
410// OpenCL Extension v2.0 s5.1.2 and s6.1.2 - Math Functions
411// --- Table 8 ---
412// --- 1 argument ---
413foreach name = ["acos", "acosh", "acospi",
414 "asin", "asinh", "asinpi",
415 "atan", "atanh", "atanpi",
416 "cbrt", "ceil",
417 "cos", "cosh", "cospi",
418 "erfc", "erf",
419 "exp", "exp2", "exp10", "expm1",
420 "fabs", "floor",
421 "log", "log2", "log10", "log1p", "logb",
422 "rint", "round", "rsqrt",
423 "sin", "sinh", "sinpi",
424 "sqrt",
425 "tan", "tanh", "tanpi",
426 "tgamma", "trunc",
427 "lgamma"] in {
428 def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>;
429}
430foreach name = ["nan"] in {
431 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
432 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>;
433 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
434}
435
436// --- 2 arguments ---
437foreach name = ["atan2", "atan2pi", "copysign", "fdim", "fmod", "hypot",
438 "maxmag", "minmag", "nextafter", "pow", "powr",
439 "remainder"] in {
440 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
441}
442foreach name = ["fmax", "fmin"] in {
443 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
444 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>;
445 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>;
446 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>;
447}
448foreach name = ["ilogb"] in {
449 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
450 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeDoubleVecAndScalar], Attr.Const>;
451 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeHalfVecAndScalar], Attr.Const>;
452}
453foreach name = ["ldexp"] in {
454 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
455 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Int], Attr.Const>;
456 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
457 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Int], Attr.Const>;
458 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
459 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Int], Attr.Const>;
460}
461foreach name = ["pown", "rootn"] in {
462 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
463 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
464 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
465}
466
467// --- 3 arguments ---
468foreach name = ["fma", "mad"] in {
469 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
470}
471
472// --- Version dependent ---
473let MaxVersion = CL20 in {
474 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
475 foreach name = ["fract", "modf", "sincos"] in {
476 def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, AS>]>;
477 }
478 foreach name = ["frexp", "lgamma_r"] in {
479 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
480 def : Builtin<name, [Type, Type, PointerType<GenTypeIntVecAndScalar, AS>]>;
481 }
482 }
483 foreach name = ["remquo"] in {
484 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
485 def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, AS>]>;
486 }
487 }
488 }
489}
490let MinVersion = CL20 in {
491 foreach name = ["fract", "modf", "sincos"] in {
492 def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, GenericAS>]>;
493 }
494 foreach name = ["frexp", "lgamma_r"] in {
495 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
496 def : Builtin<name, [Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>;
497 } }
498 foreach name = ["remquo"] in {
499 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
500 def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>;
501 }
502 }
503}
504
505// --- Table 9 ---
506foreach name = ["half_cos",
507 "half_exp", "half_exp2", "half_exp10",
508 "half_log", "half_log2", "half_log10",
509 "half_recip", "half_rsqrt",
510 "half_sin", "half_sqrt", "half_tan",
511 "native_cos",
512 "native_exp", "native_exp2", "native_exp10",
513 "native_log", "native_log2", "native_log10",
514 "native_recip", "native_rsqrt",
515 "native_sin", "native_sqrt", "native_tan"] in {
516 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
517}
518foreach name = ["half_divide", "half_powr",
519 "native_divide", "native_powr"] in {
520 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
521}
522
523//--------------------------------------------------------------------
Sven van Haastregt0e70c352019-11-06 11:53:19 +0000524// OpenCL v1.1 s6.11.3, v1.2 s6.12.3, v2.0 s6.13.3 - Integer Functions
525// --- Table 10 ---
526// --- 1 argument ---
527foreach name = ["abs"] in {
528 def : Builtin<name, [AI2UGenTypeN, AIGenTypeN], Attr.Const>;
529}
530foreach name = ["clz", "popcount"] in {
531 def : Builtin<name, [AIGenTypeN, AIGenTypeN], Attr.Const>;
532}
533let MinVersion = CL20 in {
534 foreach name = ["ctz"] in {
535 def : Builtin<name, [AIGenTypeN, AIGenTypeN]>;
536 }
537}
538
539// --- 2 arguments ---
540foreach name = ["abs_diff"] in {
541 def : Builtin<name, [AI2UGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
542}
543foreach name = ["add_sat", "hadd", "rhadd", "mul_hi", "rotate", "sub_sat"] in {
544 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
545}
546foreach name = ["max", "min"] in {
547 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
548 def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1], Attr.Const>;
549}
550foreach name = ["upsample"] in {
551 def : Builtin<name, [GenTypeShortVecAndScalar, GenTypeCharVecAndScalar, GenTypeUCharVecAndScalar], Attr.Const>;
552 def : Builtin<name, [GenTypeUShortVecAndScalar, GenTypeUCharVecAndScalar, GenTypeUCharVecAndScalar], Attr.Const>;
553 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeShortVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
554 def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUShortVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
555 def : Builtin<name, [GenTypeLongVecAndScalar, GenTypeIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
556 def : Builtin<name, [GenTypeULongVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
557}
558
559// --- 3 arguments ---
560foreach name = ["clamp"] in {
561 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
562 def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1, AIGenType1], Attr.Const>;
563}
564foreach name = ["mad_hi", "mad_sat"] in {
565 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
566}
567
568// --- Table 11 ---
569foreach name = ["mad24"] in {
570 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
571 def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
572}
573foreach name = ["mul24"] in {
574 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
575 def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
576}
577
578//--------------------------------------------------------------------
Sven van Haastregt6fc73f62019-11-05 19:47:21 +0000579// OpenCL v1.1 s6.11.4, v1.2 s6.12.4, v2.0 s6.13.4 - Common Functions
580// OpenCL Extension v2.0 s5.1.3 and s6.1.3 - Common Functions
581// --- Table 12 ---
582// --- 1 argument ---
583foreach name = ["degrees", "radians", "sign"] in {
584 def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>;
585}
586
587// --- 2 arguments ---
588foreach name = ["max", "min"] in {
589 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
590 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>;
591 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>;
592 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>;
593}
594foreach name = ["step"] in {
595 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
596 def : Builtin<name, [GenTypeFloatVecNoScalar, Float, GenTypeFloatVecNoScalar], Attr.Const>;
597 def : Builtin<name, [GenTypeDoubleVecNoScalar, Double, GenTypeDoubleVecNoScalar], Attr.Const>;
598 def : Builtin<name, [GenTypeHalfVecNoScalar, Half, GenTypeHalfVecNoScalar], Attr.Const>;
599}
600
601// --- 3 arguments ---
602foreach name = ["clamp", "mix"] in {
603 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
604 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float, Float], Attr.Const>;
605 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double, Double], Attr.Const>;
606 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half, Half], Attr.Const>;
607}
608foreach name = ["smoothstep"] in {
609 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
610 def : Builtin<name, [GenTypeFloatVecNoScalar, Float, Float, GenTypeFloatVecNoScalar], Attr.Const>;
611 def : Builtin<name, [GenTypeDoubleVecNoScalar, Double, Double, GenTypeDoubleVecNoScalar], Attr.Const>;
612 def : Builtin<name, [GenTypeHalfVecNoScalar, Half, Half, GenTypeHalfVecNoScalar], Attr.Const>;
613}
614
615
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000616//--------------------------------------------------------------------
617// OpenCL v1.1 s6.11.5, v1.2 s6.12.5, v2.0 s6.13.5 - Geometric Functions
618// OpenCL Extension v2.0 s5.1.4 and s6.1.4 - Geometric Functions
619// --- Table 13 ---
620// --- 1 argument ---
621foreach name = ["length"] in {
622 def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>;
623 def : Builtin<name, [Double, GenTypeDoubleVec1234], Attr.Const>;
624 def : Builtin<name, [Half, GenTypeHalfVec1234], Attr.Const>;
625}
626foreach name = ["normalize"] in {
627 def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
628 def : Builtin<name, [GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>;
629 def : Builtin<name, [GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>;
630}
631foreach name = ["fast_length"] in {
632 def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>;
633}
634foreach name = ["fast_normalize"] in {
635 def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
636}
637
638// --- 2 arguments ---
639foreach name = ["cross"] in {
640 foreach VSize = [3, 4] in {
641 def : Builtin<name, [VectorType<Float, VSize>, VectorType<Float, VSize>, VectorType<Float, VSize>], Attr.Const>;
642 def : Builtin<name, [VectorType<Double, VSize>, VectorType<Double, VSize>, VectorType<Double, VSize>], Attr.Const>;
643 def : Builtin<name, [VectorType<Half, VSize>, VectorType<Half, VSize>, VectorType<Half, VSize>], Attr.Const>;
644 }
645}
646foreach name = ["dot", "distance"] in {
647 def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
648 def : Builtin<name, [Double, GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>;
649 def : Builtin<name, [Half, GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>;
650}
651foreach name = ["fast_distance"] in {
652 def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
653}
654
655
656//--------------------------------------------------------------------
657// OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
658// OpenCL Extension v2.0 s5.1.5 and s6.1.5 - Relational Functions
659// --- Table 14 ---
660// --- 1 argument ---
661foreach name = ["isfinite", "isinf", "isnan", "isnormal", "signbit"] in {
662 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
663 def : Builtin<name, [Int, Double], Attr.Const>;
664 def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
665 def : Builtin<name, [Int, Half], Attr.Const>;
666 def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
667}
668foreach name = ["any", "all"] in {
669 def : Builtin<name, [Int, AIGenTypeN], Attr.Const>;
670}
671
672// --- 2 arguments ---
673foreach name = ["isequal", "isnotequal", "isgreater", "isgreaterequal",
674 "isless", "islessequal", "islessgreater", "isordered",
675 "isunordered"] in {
676 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
677 def : Builtin<name, [Int, Double, Double], Attr.Const>;
678 def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
679 def : Builtin<name, [Int, Half, Half], Attr.Const>;
680 def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
681}
682
683// --- 3 arguments ---
684foreach name = ["bitselect"] in {
685 def : Builtin<name, [AGenTypeN, AGenTypeN, AGenTypeN, AGenTypeN], Attr.Const>;
686}
687foreach name = ["select"] in {
688 def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, SGenTypeN], Attr.Const>;
689 def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UGenTypeN], Attr.Const>;
690 def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, UGenTypeN], Attr.Const>;
691 def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, SGenTypeN], Attr.Const>;
692 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
693 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
694 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeLongVecAndScalar], Attr.Const>;
695 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>;
696 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeShortVecAndScalar], Attr.Const>;
697 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
698}
699
700
Sven van Haastregt2fe674b2019-11-13 10:16:33 +0000701//--------------------------------------------------------------------
Sven van Haastregted69faa2019-09-19 13:41:51 +0000702// OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions
Sven van Haastregt2fe674b2019-11-13 10:16:33 +0000703// OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s5.1.6 and s6.1.6 - Vector Data Load and Store Functions
Sven van Haastregted69faa2019-09-19 13:41:51 +0000704// --- Table 15 ---
705// Variants for OpenCL versions below 2.0, using pointers to the global, local
706// and private address spaces.
707let MaxVersion = CL20 in {
708 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
709 foreach VSize = [2, 3, 4, 8, 16] in {
710 foreach name = ["vload" # VSize] in {
711 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>;
712 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>;
713 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>;
714 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>;
715 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>;
716 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>;
717 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>;
718 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>;
719 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>;
720 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>;
721 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
722 }
723 foreach name = ["vstore" # VSize] in {
724 def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>;
725 def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>;
726 def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>;
727 def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>;
728 def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>;
729 def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>;
730 def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>;
731 def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>;
732 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>;
733 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>;
734 def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
735 }
736 foreach name = ["vloada_half" # VSize] in {
737 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
738 }
739 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
740 foreach name = ["vstorea_half" # VSize # rnd] in {
741 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
742 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
743 }
744 }
745 }
746 }
747}
748// Variants for OpenCL versions above 2.0, using pointers to the generic
749// address space.
750let MinVersion = CL20 in {
751 foreach VSize = [2, 3, 4, 8, 16] in {
752 foreach name = ["vload" # VSize] in {
753 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
754 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>;
755 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>;
756 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>;
757 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>;
758 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>;
759 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>;
760 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>;
761 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>;
762 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>;
763 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
764 }
765 foreach name = ["vstore" # VSize] in {
766 def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
767 def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>;
768 def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>;
769 def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>;
770 def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>;
771 def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>;
772 def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>;
773 def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>;
774 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>;
775 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>;
776 def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
777 }
778 foreach name = ["vloada_half" # VSize] in {
779 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
780 }
781 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
782 foreach name = ["vstorea_half" # VSize # rnd] in {
783 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, GenericAS>]>;
784 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, GenericAS>]>;
785 }
786 }
787 }
788}
789// Variants using pointers to the constant address space.
790foreach VSize = [2, 3, 4, 8, 16] in {
791 foreach name = ["vload" # VSize] in {
792 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, ConstantAS>]>;
793 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, ConstantAS>]>;
794 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, ConstantAS>]>;
795 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, ConstantAS>]>;
796 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, ConstantAS>]>;
797 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, ConstantAS>]>;
798 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, ConstantAS>]>;
799 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, ConstantAS>]>;
800 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, ConstantAS>]>;
801 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, ConstantAS>]>;
802 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
803 }
804 foreach name = ["vloada_half" # VSize] in {
805 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
806 }
807 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
808 foreach name = ["vstorea_half" # VSize # rnd] in {
809 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, ConstantAS>]>;
810 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, ConstantAS>]>;
811 }
812 }
813}
Sven van Haastregt2fe674b2019-11-13 10:16:33 +0000814let MaxVersion = CL20 in {
815 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
816 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
817 foreach VSize = [2, 3, 4, 8, 16] in {
818 foreach name = ["vload_half" # VSize] in {
819 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
820 }
821 }
822 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
823 def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType<Half, AS>]>;
824 def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType<Half, AS>]>;
825 foreach VSize = [2, 3, 4, 8, 16] in {
826 foreach name = ["vstore_half" # VSize # rnd] in {
827 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
828 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
829 }
830 }
831 }
832 }
833}
834let MinVersion = CL20 in {
835 foreach AS = [GenericAS] in {
836 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
837 foreach VSize = [2, 3, 4, 8, 16] in {
838 foreach name = ["vload_half" # VSize] in {
839 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
840 }
841 }
842 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
843 def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType<Half, AS>]>;
844 def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType<Half, AS>]>;
845 foreach VSize = [2, 3, 4, 8, 16] in {
846 foreach name = ["vstore_half" # VSize # rnd] in {
847 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
848 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
849 }
850 }
851 }
852 }
853}
854
855foreach AS = [ConstantAS] in {
856 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
857 foreach VSize = [2, 3, 4, 8, 16] in {
858 foreach name = ["vload_half" # VSize] in {
859 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
860 }
861 }
862}
Sven van Haastregted69faa2019-09-19 13:41:51 +0000863
864//--------------------------------------------------------------------
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000865// OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
866// OpenCL Extension v2.0 s5.1.7 and s6.1.7: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
867// --- Table 18 ---
868foreach name = ["async_work_group_copy"] in {
869 def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Event]>;
870 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Event]>;
871}
872foreach name = ["async_work_group_strided_copy"] in {
873 def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Size, Event]>;
874 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Size, Event]>;
875}
876foreach name = ["wait_group_events"] in {
877 def : Builtin<name, [Void, Int, PointerType<Event, GenericAS>]>;
878}
879foreach name = ["prefetch"] in {
880 def : Builtin<name, [Void, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size]>;
881}
882
883//--------------------------------------------------------------------
884// OpenCL v2.0 s6.13.11 - Atomics Functions.
885// Functions that use memory_order and cl_mem_fence_flags enums are not
886// declared here as the TableGen backend does not handle enums.
887
Sven van Haastregt308b8b72019-12-18 10:13:51 +0000888// OpenCL v1.0 s9.5, s9.6, s9.7 - Atomic Functions for 32-bit integers
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000889// --- Table 9.1 ---
Sven van Haastregt308b8b72019-12-18 10:13:51 +0000890let Extension = FuncExtKhrGlobalInt32BaseAtomics in {
891 foreach Type = [Int, UInt] in {
892 foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
893 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type]>;
894 }
895 foreach name = ["atom_inc", "atom_dec"] in {
896 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>]>;
897 }
898 foreach name = ["atom_cmpxchg"] in {
899 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type, Type]>;
900 }
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000901 }
902}
Sven van Haastregtb7145832019-12-23 12:29:01 +0000903// --- Table 9.3 ---
904let Extension = FuncExtKhrLocalInt32BaseAtomics in {
905 foreach Type = [Int, UInt] in {
906 foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
907 def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>, Type]>;
908 }
909 foreach name = ["atom_inc", "atom_dec"] in {
910 def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>]>;
911 }
912 foreach name = ["atom_cmpxchg"] in {
913 def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>, Type, Type]>;
914 }
915 }
916}
917// --- Table 9.5 ---
918let Extension = FuncExtKhrInt64BaseAtomics in {
919 foreach AS = [GlobalAS, LocalAS] in {
920 foreach Type = [Long, ULong] in {
921 foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
922 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type]>;
923 }
924 foreach name = ["atom_inc", "atom_dec"] in {
925 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>]>;
926 }
927 foreach name = ["atom_cmpxchg"] in {
928 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type, Type]>;
929 }
930 }
931 }
932}
933// --- Table 9.2 ---
934let Extension = FuncExtKhrGlobalInt32ExtendedAtomics in {
935 foreach Type = [Int, UInt] in {
936 foreach name = ["atom_min", "atom_max", "atom_and",
937 "atom_or", "atom_xor"] in {
938 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type]>;
939 }
940 }
941}
942// --- Table 9.4 ---
943let Extension = FuncExtKhrLocalInt32ExtendedAtomics in {
944 foreach Type = [Int, UInt] in {
945 foreach name = ["atom_min", "atom_max", "atom_and",
946 "atom_or", "atom_xor"] in {
947 def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>, Type]>;
948 }
949 }
950}
951// --- Table 9.6 ---
952let Extension = FuncExtKhrInt64ExtendedAtomics in {
953 foreach AS = [GlobalAS, LocalAS] in {
954 foreach Type = [Long, ULong] in {
955 foreach name = ["atom_min", "atom_max", "atom_and",
956 "atom_or", "atom_xor"] in {
957 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type]>;
958 }
959 }
960 }
961}
962// OpenCL v1.1 s6.11.1, v1.2 s6.12.11 - Atomic Functions
963foreach AS = [GlobalAS, LocalAS] in {
964 foreach Type = [Int, UInt] in {
965 foreach name = ["atomic_add", "atomic_sub", "atomic_xchg",
966 "atomic_min", "atomic_max", "atomic_and",
967 "atomic_or", "atomic_xor"] in {
968 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type]>;
969 }
970 foreach name = ["atomic_inc", "atomic_dec"] in {
971 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>]>;
972 }
973 foreach name = ["atomic_cmpxchg"] in {
974 def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type, Type]>;
975 }
976 }
977}
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000978
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000979//--------------------------------------------------------------------
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000980// OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector Functions
981// --- Table 19 ---
Sven van Haastregtff429c52019-12-31 15:30:02 +0000982foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
983 foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
984 def : Builtin<"shuffle", [GenericType<"TLAll" # VSize1.Name, TLAll, VSize1>,
985 GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
986 GenericType<"TLAllUnsigned" # VSize1.Name, TLAllUnsigned, VSize1>],
987 Attr.Const>;
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000988 }
989}
Sven van Haastregtff429c52019-12-31 15:30:02 +0000990foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
991 foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
992 def : Builtin<"shuffle2", [GenericType<"TLAll" # VSize1.Name, TLAll, VSize1>,
993 GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
994 GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
995 GenericType<"TLAllUnsigned" # VSize1.Name, TLAllUnsigned, VSize1>],
996 Attr.Const>;
Sven van Haastregte54c83e2019-11-26 10:44:49 +0000997 }
998}
999
1000//--------------------------------------------------------------------
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001001// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14: Image Read and Write Functions
1002// OpenCL Extension v2.0 s5.1.8 and s6.1.8: Image Read and Write Functions
1003// --- Table 22: Image Read Functions with Samplers ---
1004foreach imgTy = [Image1d] in {
1005 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001006 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
1007 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
1008 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001009 }
1010}
1011foreach imgTy = [Image2d, Image1dArray] in {
1012 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001013 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
1014 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
1015 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001016 }
1017}
1018foreach imgTy = [Image3d, Image2dArray] in {
1019 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001020 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
1021 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
1022 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001023 }
1024}
1025foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001026 def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
1027 def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001028}
1029
1030// --- Table 23: Sampler-less Read Functions ---
1031foreach aQual = ["RO", "RW"] in {
1032 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001033 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
1034 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
1035 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001036 }
1037 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001038 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
1039 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
1040 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001041 }
1042 foreach imgTy = [Image1d, Image1dBuffer] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001043 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
1044 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
1045 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001046 }
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001047 def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>], Attr.Pure>;
1048 def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001049}
1050
1051// --- Table 24: Image Write Functions ---
1052foreach aQual = ["WO", "RW"] in {
1053 foreach imgTy = [Image2d] in {
1054 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
1055 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
1056 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
1057 }
1058 foreach imgTy = [Image2dArray] in {
1059 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
1060 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
1061 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
1062 }
1063 foreach imgTy = [Image1d, Image1dBuffer] in {
1064 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, Int, VectorType<Float, 4>]>;
1065 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, Int, VectorType<Int, 4>]>;
1066 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, Int, VectorType<UInt, 4>]>;
1067 }
1068 foreach imgTy = [Image1dArray] in {
1069 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
1070 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
1071 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
1072 }
1073 foreach imgTy = [Image3d] in {
1074 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
1075 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
1076 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
1077 }
1078 def : Builtin<"write_imagef", [Void, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>, Float]>;
1079 def : Builtin<"write_imagef", [Void, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>, Float]>;
1080}
1081
Sven van Haastregt2a69ed02019-09-25 09:12:59 +00001082// --- Table 25: Image Query Functions ---
1083foreach aQual = ["RO", "WO", "RW"] in {
1084 foreach imgTy = [Image1d, Image1dBuffer, Image2d, Image3d,
1085 Image1dArray, Image2dArray, Image2dDepth,
1086 Image2dArrayDepth] in {
1087 foreach name = ["get_image_width", "get_image_channel_data_type",
1088 "get_image_channel_order"] in {
1089 def : Builtin<name, [Int, ImageType<imgTy, aQual>]>;
1090 }
1091 }
1092 foreach imgTy = [Image2d, Image3d, Image2dArray, Image2dDepth,
1093 Image2dArrayDepth] in {
1094 def : Builtin<"get_image_height", [Int, ImageType<imgTy, aQual>]>;
1095 }
1096 def : Builtin<"get_image_depth", [Int, ImageType<Image3d, aQual>]>;
1097 foreach imgTy = [Image2d, Image2dArray, Image2dDepth,
1098 Image2dArrayDepth] in {
1099 def : Builtin<"get_image_dim", [VectorType<Int, 2>, ImageType<imgTy, aQual>]>;
1100 }
1101 def : Builtin<"get_image_dim", [VectorType<Int, 4>, ImageType<Image3d, aQual>]>;
1102 foreach imgTy = [Image1dArray, Image2dArray, Image2dArrayDepth] in {
1103 def : Builtin<"get_image_array_size", [Size, ImageType<imgTy, aQual>]>;
1104 }
1105}
1106
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001107// OpenCL extension v2.0 s5.1.9: Built-in Image Read Functions
1108// --- Table 8 ---
1109foreach aQual = ["RO"] in {
1110 foreach name = ["read_imageh"] in {
1111 foreach coordTy = [Int, Float] in {
1112 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001113 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001114 }
1115 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001116 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001117 }
1118 foreach imgTy = [Image1d] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001119 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, coordTy], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001120 }
1121 }
1122 }
1123}
1124// OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
1125// --- Table 9 ---
1126foreach aQual = ["RO", "RW"] in {
1127 foreach name = ["read_imageh"] in {
1128 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001129 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001130 }
1131 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001132 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001133 }
1134 foreach imgTy = [Image1d, Image1dBuffer] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001135 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001136 }
1137 }
1138}
1139// OpenCL extension v2.0 s5.1.11: Built-in Image Write Functions
1140// --- Table 10 ---
1141foreach aQual = ["WO", "RW"] in {
1142 foreach name = ["write_imageh"] in {
1143 def : Builtin<name, [Void, ImageType<Image2d, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
1144 def : Builtin<name, [Void, ImageType<Image2dArray, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
1145 def : Builtin<name, [Void, ImageType<Image1d, aQual>, Int, VectorType<Half, 4>]>;
1146 def : Builtin<name, [Void, ImageType<Image1dBuffer, aQual>, Int, VectorType<Half, 4>]>;
1147 def : Builtin<name, [Void, ImageType<Image1dArray, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
1148 def : Builtin<name, [Void, ImageType<Image3d, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
1149 }
1150}
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001151
1152
Sven van Haastregte54c83e2019-11-26 10:44:49 +00001153//--------------------------------------------------------------------
1154// OpenCL v2.0 s6.13.15 - Work-group Functions
1155// --- Table 26 ---
1156let MinVersion = CL20 in {
1157 foreach name = ["work_group_all", "work_group_any"] in {
1158 def : Builtin<name, [Int, Int], Attr.Convergent>;
1159 }
1160 foreach name = ["work_group_broadcast"] in {
1161 def : Builtin<name, [IntLongFloatGenType1, IntLongFloatGenType1, Size], Attr.Convergent>;
1162 def : Builtin<name, [IntLongFloatGenType1, IntLongFloatGenType1, Size, Size], Attr.Convergent>;
1163 def : Builtin<name, [IntLongFloatGenType1, IntLongFloatGenType1, Size, Size, Size], Attr.Convergent>;
1164 }
1165 foreach op = ["add", "min", "max"] in {
1166 foreach name = ["work_group_reduce_", "work_group_scan_exclusive_",
1167 "work_group_scan_inclusive_"] in {
1168 def : Builtin<name # op, [IntLongFloatGenType1, IntLongFloatGenType1], Attr.Convergent>;
1169 }
1170 }
1171}
1172
1173
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001174// OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions
Sven van Haastregted69faa2019-09-19 13:41:51 +00001175let MinVersion = CL20 in {
Sven van Haastregt308b8b72019-12-18 10:13:51 +00001176 let Extension = FuncExtKhrSubgroups in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +00001177 def get_sub_group_size : Builtin<"get_sub_group_size", [UInt]>;
1178 def get_max_sub_group_size : Builtin<"get_max_sub_group_size", [UInt]>;
1179 def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001180 }
1181}
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001182
1183//--------------------------------------------------------------------
1184// End of the builtin functions defined in the OpenCL C specification.
1185// Builtin functions defined in the OpenCL C Extension are below.
1186//--------------------------------------------------------------------
1187
1188
1189// OpenCL Extension v2.0 s9.18 - Mipmaps
1190let Extension = FuncExtKhrMipmapImage in {
1191 // Added to section 6.13.14.2.
1192 foreach aQual = ["RO"] in {
1193 foreach imgTy = [Image2d] in {
1194 foreach name = ["read_imagef"] in {
1195 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1196 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1197 }
1198 foreach name = ["read_imagei"] in {
1199 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1200 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1201 }
1202 foreach name = ["read_imageui"] in {
1203 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1204 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1205 }
1206 }
1207 foreach imgTy = [Image2dDepth] in {
1208 foreach name = ["read_imagef"] in {
1209 def : Builtin<name, [Float, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1210 def : Builtin<name, [Float, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1211 }
1212 }
1213 foreach imgTy = [Image1d] in {
1214 foreach name = ["read_imagef"] in {
1215 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float], Attr.Pure>;
1216 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float, Float], Attr.Pure>;
1217 }
1218 foreach name = ["read_imagei"] in {
1219 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float], Attr.Pure>;
1220 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float, Float], Attr.Pure>;
1221 }
1222 foreach name = ["read_imageui"] in {
1223 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float], Attr.Pure>;
1224 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float, Float], Attr.Pure>;
1225 }
1226 }
1227 foreach imgTy = [Image3d] in {
1228 foreach name = ["read_imagef"] in {
1229 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 4>, VectorType<Float, 4>], Attr.Pure>;
1230 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1231 }
1232 foreach name = ["read_imagei"] in {
1233 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 4>, VectorType<Float, 4>], Attr.Pure>;
1234 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1235 }
1236 foreach name = ["read_imageui"] in {
1237 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 4>, VectorType<Float, 4>], Attr.Pure>;
1238 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1239 }
1240 }
1241 foreach imgTy = [Image1dArray] in {
1242 foreach name = ["read_imagef"] in {
1243 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1244 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float, Float], Attr.Pure>;
1245 }
1246 foreach name = ["read_imagei"] in {
1247 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1248 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float, Float], Attr.Pure>;
1249 }
1250 foreach name = ["read_imageui"] in {
1251 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>;
1252 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float, Float], Attr.Pure>;
1253 }
1254 }
1255 foreach imgTy = [Image2dArray] in {
1256 foreach name = ["read_imagef"] in {
1257 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1258 def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1259 }
1260 foreach name = ["read_imagei"] in {
1261 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1262 def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1263 }
1264 foreach name = ["read_imageui"] in {
1265 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1266 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1267 }
1268 }
1269 foreach imgTy = [Image2dArrayDepth] in {
1270 foreach name = ["read_imagef"] in {
1271 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>;
1272 def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>;
1273 }
1274 }
1275 }
1276 // Added to section 6.13.14.4.
1277 foreach aQual = ["WO"] in {
1278 foreach imgTy = [Image2d] in {
Sven van Haastregtff429c52019-12-31 15:30:02 +00001279 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Float, 4>]>;
1280 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Int, 4>]>;
1281 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<UInt, 4>]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001282 }
Sven van Haastregtff429c52019-12-31 15:30:02 +00001283 def : Builtin<"write_imagef", [Void, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>, Int, Float]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001284 foreach imgTy = [Image1d] in {
Sven van Haastregtff429c52019-12-31 15:30:02 +00001285 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, Int, Int, VectorType<Float, 4>]>;
1286 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, Int, Int, VectorType<Int, 4>]>;
1287 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, Int, Int, VectorType<UInt, 4>]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001288 }
1289 foreach imgTy = [Image1dArray] in {
Sven van Haastregtff429c52019-12-31 15:30:02 +00001290 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Float, 4>]>;
1291 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Int, 4>]>;
1292 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<UInt, 4>]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001293 }
1294 foreach imgTy = [Image2dArray] in {
Sven van Haastregtff429c52019-12-31 15:30:02 +00001295 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Float, 4>]>;
1296 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Int, 4>]>;
1297 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<UInt, 4>]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001298 }
Sven van Haastregtff429c52019-12-31 15:30:02 +00001299 def : Builtin<"write_imagef", [Void, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>, Int, Float]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001300 let Extension = FuncExtKhrMipmapAndWrite3d in {
1301 foreach imgTy = [Image3d] in {
Sven van Haastregtff429c52019-12-31 15:30:02 +00001302 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Float, 4>]>;
1303 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Int, 4>]>;
1304 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<UInt, 4>]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001305 }
1306 }
1307 }
1308 // Added to section 6.13.14.5
1309 foreach aQual = ["RO", "WO", "RW"] in {
Sven van Haastregtff429c52019-12-31 15:30:02 +00001310 foreach imgTy = [Image1d, Image2d, Image3d, Image1dArray, Image2dArray, Image2dDepth, Image2dArrayDepth] in {
1311 def : Builtin<"get_image_num_mip_levels", [Int, ImageType<imgTy, aQual>]>;
Sven van Haastregt4a188fd2019-12-30 10:47:58 +00001312 }
1313 }
1314}