blob: 0bd4c51a04c2a556d1b21792ed29729acf85f687 [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
43
Sven van Haastregtb21a3652019-08-19 11:56:03 +000044// Qualified Type. These map to ASTContext::QualType.
45class QualType<string _Name, bit _IsAbstract=0> {
Sven van Haastregt79a222f2019-06-03 09:39:11 +000046 // Name of the field or function in a clang::ASTContext
47 // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t
48 string Name = _Name;
Sven van Haastregtb21a3652019-08-19 11:56:03 +000049 // Some QualTypes in this file represent an abstract type for which there is
50 // no corresponding AST QualType, e.g. a GenType or an `image2d_t` type
51 // without access qualifiers.
52 bit IsAbstract = _IsAbstract;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000053}
54
Sven van Haastregtb21a3652019-08-19 11:56:03 +000055// List of integers.
56class IntList<string _Name, list<int> _List> {
57 string Name = _Name;
58 list<int> List = _List;
59}
60
Sven van Haastregt79a222f2019-06-03 09:39:11 +000061//===----------------------------------------------------------------------===//
62// OpenCL C classes for types
63//===----------------------------------------------------------------------===//
Sven van Haastregtb21a3652019-08-19 11:56:03 +000064// OpenCL C basic data types (int, float, image2d_t, ...).
Sven van Haastregt47e95ff2019-09-17 13:32:56 +000065// Its child classes can represent concrete types (e.g. VectorType) or
66// abstract types (e.g. GenType).
Sven van Haastregt79a222f2019-06-03 09:39:11 +000067class Type<string _Name, QualType _QTName> {
Sven van Haastregtb21a3652019-08-19 11:56:03 +000068 // Name of the Type.
Sven van Haastregt79a222f2019-06-03 09:39:11 +000069 string Name = _Name;
Sven van Haastregtb21a3652019-08-19 11:56:03 +000070 // QualType associated with this type.
Sven van Haastregt79a222f2019-06-03 09:39:11 +000071 QualType QTName = _QTName;
Sven van Haastregtb21a3652019-08-19 11:56:03 +000072 // Size of the vector (if applicable).
73 int VecWidth = 1;
74 // Is a pointer.
Sven van Haastregt79a222f2019-06-03 09:39:11 +000075 bit IsPointer = 0;
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000076 // "const" qualifier.
77 bit IsConst = 0;
78 // "volatile" qualifier.
79 bit IsVolatile = 0;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000080 // Access qualifier. Must be one of ("RO", "WO", "RW").
81 string AccessQualifier = "";
Sven van Haastregtb21a3652019-08-19 11:56:03 +000082 // Address space.
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000083 string AddrSpace = DefaultAS.Name;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000084}
85
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000086// OpenCL vector types (e.g. int2, int3, int16, float8, ...).
Sven van Haastregt79a222f2019-06-03 09:39:11 +000087class VectorType<Type _Ty, int _VecWidth> : Type<_Ty.Name, _Ty.QTName> {
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000088 let VecWidth = _VecWidth;
Sven van Haastregt988f1e32019-09-05 10:01:24 +000089 let AccessQualifier = "";
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000090 // Inherited fields
91 let IsPointer = _Ty.IsPointer;
92 let IsConst = _Ty.IsConst;
93 let IsVolatile = _Ty.IsVolatile;
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000094 let AddrSpace = _Ty.AddrSpace;
Sven van Haastregt79a222f2019-06-03 09:39:11 +000095}
96
Sven van Haastregtb21a3652019-08-19 11:56:03 +000097// OpenCL pointer types (e.g. int*, float*, ...).
Sven van Haastregtcc0ba282019-08-20 12:21:03 +000098class PointerType<Type _Ty, AddressSpace _AS = DefaultAS> :
Sven van Haastregt79a222f2019-06-03 09:39:11 +000099 Type<_Ty.Name, _Ty.QTName> {
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000100 let AddrSpace = _AS.Name;
101 // Inherited fields
102 let VecWidth = _Ty.VecWidth;
103 let IsPointer = 1;
104 let IsConst = _Ty.IsConst;
105 let IsVolatile = _Ty.IsVolatile;
106 let AccessQualifier = _Ty.AccessQualifier;
107}
108
109// OpenCL const types (e.g. const int).
110class ConstType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> {
111 let IsConst = 1;
112 // Inherited fields
113 let VecWidth = _Ty.VecWidth;
114 let IsPointer = _Ty.IsPointer;
115 let IsVolatile = _Ty.IsVolatile;
116 let AccessQualifier = _Ty.AccessQualifier;
117 let AddrSpace = _Ty.AddrSpace;
118}
119
120// OpenCL volatile types (e.g. volatile int).
121class VolatileType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> {
122 let IsVolatile = 1;
123 // Inherited fields
124 let VecWidth = _Ty.VecWidth;
125 let IsPointer = _Ty.IsPointer;
126 let IsConst = _Ty.IsConst;
127 let AccessQualifier = _Ty.AccessQualifier;
128 let AddrSpace = _Ty.AddrSpace;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000129}
130
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000131// OpenCL image types (e.g. image2d).
132class ImageType<Type _Ty, string _AccessQualifier> :
133 Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> {
134 let VecWidth = 0;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000135 let AccessQualifier = _AccessQualifier;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000136 // Inherited fields
137 let IsPointer = _Ty.IsPointer;
138 let IsConst = _Ty.IsConst;
139 let IsVolatile = _Ty.IsVolatile;
140 let AddrSpace = _Ty.AddrSpace;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000141}
142
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000143// List of Types.
144class TypeList<string _Name, list<Type> _Type> {
145 string Name = _Name;
146 list<Type> List = _Type;
147}
148
149// A GenericType is an abstract type that defines a set of types as a
150// combination of Types and vector sizes.
151//
Sven van Haastregt47e95ff2019-09-17 13:32:56 +0000152// For example, if TypeList = <int, float> and VectorList = <1, 2, 4>, then it
153// represents <int, int2, int4, float, float2, float4>.
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000154//
155// Some rules apply when using multiple GenericType arguments in a declaration:
156// 1. The number of vector sizes must be equal or 1 for all gentypes in a
157// declaration.
158// 2. The number of Types must be equal or 1 for all gentypes in a
159// declaration.
160// 3. Generic types are combined by iterating over all generic types at once.
161// For example, for the following GenericTypes
162// GenT1 = GenericType<half, [1, 2]> and
163// GenT2 = GenericType<float, int, [1, 2]>
164// A declaration f(GenT1, GenT2) results in the combinations
165// f(half, float), f(half2, float2), f(half, int), f(half2, int2) .
166// 4. "sgentype" from the OpenCL specification is supported by specifying
167// a single vector size.
168// For example, for the following GenericTypes
169// GenT = GenericType<half, int, [1, 2]> and
170// SGenT = GenericType<half, int, [1]>
171// A declaration f(GenT, SGenT) results in the combinations
172// f(half, half), f(half2, half), f(int, int), f(int2, int) .
173class GenericType<string _Ty, TypeList _TypeList, IntList _VectorList> :
174 Type<_Ty, QualType<"null", 1>> {
175 // Possible element types of the generic type.
176 TypeList TypeList = _TypeList;
177 // Possible vector sizes of the types in the TypeList.
178 IntList VectorList = _VectorList;
179 // The VecWidth field is ignored for GenericTypes. Use VectorList instead.
180 let VecWidth = 0;
181}
182
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000183// Builtin function attributes.
184def Attr {
185 list<bit> None = [0, 0, 0];
186 list<bit> Pure = [1, 0, 0];
187 list<bit> Const = [0, 1, 0];
188 list<bit> Convergent = [0, 0, 1];
189}
190
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000191//===----------------------------------------------------------------------===//
192// OpenCL C class for builtin functions
193//===----------------------------------------------------------------------===//
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000194class Builtin<string _Name, list<Type> _Signature, list<bit> _Attributes = Attr.None> {
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000195 // Name of the builtin function
196 string Name = _Name;
197 // List of types used by the function. The first one is the return type and
198 // the following are the arguments. The list must have at least one element
199 // (the return type).
200 list<Type> Signature = _Signature;
201 // OpenCL Extension to which the function belongs (cl_khr_subgroups, ...)
202 string Extension = "";
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000203 // Function attribute __attribute__((pure))
204 bit IsPure = _Attributes[0];
205 // Function attribute __attribute__((const))
206 bit IsConst = _Attributes[1];
207 // Function attribute __attribute__((convergent))
208 bit IsConv = _Attributes[2];
Sven van Haastregted69faa2019-09-19 13:41:51 +0000209 // Version of OpenCL from which the function is available (e.g.: CL10).
210 // MinVersion is inclusive.
211 Version MinVersion = CL10;
212 // Version of OpenCL from which the function is not supported anymore.
213 // MaxVersion is exclusive.
214 // CLAll makes the function available for all versions.
215 Version MaxVersion = CLAll;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000216}
217
218//===----------------------------------------------------------------------===//
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000219// Definitions of OpenCL C types
220//===----------------------------------------------------------------------===//
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000221
222// OpenCL v1.0/1.2/2.0 s6.1.1: Built-in Scalar Data Types.
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000223def Bool : Type<"bool", QualType<"BoolTy">>;
224def Char : Type<"char", QualType<"CharTy">>;
225def UChar : Type<"uchar", QualType<"UnsignedCharTy">>;
226def Short : Type<"short", QualType<"ShortTy">>;
227def UShort : Type<"ushort", QualType<"UnsignedShortTy">>;
228def Int : Type<"int", QualType<"IntTy">>;
229def UInt : Type<"uint", QualType<"UnsignedIntTy">>;
230def Long : Type<"long", QualType<"LongTy">>;
231def ULong : Type<"ulong", QualType<"UnsignedLongTy">>;
232def Float : Type<"float", QualType<"FloatTy">>;
233def Double : Type<"double", QualType<"DoubleTy">>;
234def Half : Type<"half", QualType<"HalfTy">>;
235def Size : Type<"size_t", QualType<"getSizeType()">>;
236def PtrDiff : Type<"ptrdiff_t", QualType<"getPointerDiffType()">>;
237def IntPtr : Type<"intptr_t", QualType<"getIntPtrType()">>;
238def UIntPtr : Type<"uintPtr_t", QualType<"getUIntPtrType()">>;
239def Void : Type<"void_t", QualType<"VoidTy">>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000240
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000241// OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types.
242// Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter.
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000243
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000244// OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types.
245// The image definitions are "abstract". They should not be used without
246// specifying an access qualifier (RO/WO/RW).
247def Image1d : Type<"Image1d", QualType<"OCLImage1d", 1>>;
248def Image2d : Type<"Image2d", QualType<"OCLImage2d", 1>>;
249def Image3d : Type<"Image3d", QualType<"OCLImage3d", 1>>;
250def Image1dArray : Type<"Image1dArray", QualType<"OCLImage1dArray", 1>>;
251def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 1>>;
252def Image2dArray : Type<"Image2dArray", QualType<"OCLImage2dArray", 1>>;
253def Image2dDepth : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 1>>;
254def Image2dArrayDepth : Type<"Image2dArrayDepth", QualType<"OCLImage2dArrayDepth", 1>>;
255def Image2dMsaa : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>;
256def Image2dArrayMsaa : Type<"Image2dArrayMsaa", QualType<"OCLImage2dArrayMSAA", 1>>;
257def Image2dMsaaDepth : Type<"Image2dMsaaDepth", QualType<"OCLImage2dMSAADepth", 1>>;
258def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", QualType<"OCLImage2dArrayMSAADepth", 1>>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000259
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000260def Sampler : Type<"Sampler", QualType<"OCLSamplerTy">>;
261def Event : Type<"Event", QualType<"OCLEventTy">>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000262
263//===----------------------------------------------------------------------===//
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000264// Definitions of OpenCL gentype variants
265//===----------------------------------------------------------------------===//
266// The OpenCL specification often uses "gentype" in builtin function
267// declarations to indicate that a builtin function is available with various
268// argument and return types. The types represented by "gentype" vary between
269// different parts of the specification. The following definitions capture
270// the different type lists for gentypes in different parts of the
271// specification.
272
273// Vector width lists.
274def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>;
275def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>;
276def Vec1 : IntList<"Vec1", [1]>;
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000277def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000278
279// Type lists.
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000280def TLAll : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000281def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>;
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000282def TLSignedInts : TypeList<"TLSignedInts", [Char, Short, Int, Long]>;
283def TLUnsignedInts : TypeList<"TLUnsignedInts", [UChar, UShort, UInt, ULong]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000284
Sven van Haastregt0e70c352019-11-06 11:53:19 +0000285// All unsigned integer types twice, to facilitate unsigned return types for e.g.
286// uchar abs(char) and
287// uchar abs(uchar).
288def TLAllUIntsTwice : TypeList<"TLAllUIntsTwice", [UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong]>;
289
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000290def TLAllInts : TypeList<"TLAllInts", [Char, UChar, Short, UShort, Int, UInt, Long, ULong]>;
291
292// GenType definitions for multiple base types (e.g. all floating point types,
293// or all integer types).
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000294// All types
295def AGenTypeN : GenericType<"AGenTypeN", TLAll, VecAndScalar>;
296def AGenTypeNNoScalar : GenericType<"AGenTypeNNoScalar", TLAll, VecNoScalar>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000297// All integer
298def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>;
299def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>;
300def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>;
Sven van Haastregt0e70c352019-11-06 11:53:19 +0000301// All integer to unsigned
302def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>;
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000303// Signed integer
304def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar>;
305// Unsigned integer
306def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000307// Float
308def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>;
309
310// GenType definitions for every single base type (e.g. fp32 only).
311// Names are like: GenTypeFloatVecAndScalar.
312foreach Type = [Char, UChar, Short, UShort,
313 Int, UInt, Long, ULong,
314 Float, Double, Half] in {
315 foreach VecSizes = [VecAndScalar, VecNoScalar] in {
316 def "GenType" # Type # VecSizes :
317 GenericType<"GenType" # Type # VecSizes,
318 TypeList<"GL" # Type.Name, [Type]>,
319 VecSizes>;
320 }
321}
322
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000323// GenType definitions for vec1234.
324foreach Type = [Float, Double, Half] in {
325 def "GenType" # Type # Vec1234 :
326 GenericType<"GenType" # Type # Vec1234,
327 TypeList<"GL" # Type.Name, [Type]>,
328 Vec1234>;
329}
330
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000331
332//===----------------------------------------------------------------------===//
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000333// Definitions of OpenCL builtin functions
334//===----------------------------------------------------------------------===//
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000335//--------------------------------------------------------------------
336// OpenCL v1.1/1.2/2.0 s6.2.3 - Explicit conversions.
337// OpenCL v2.0 Extensions s5.1.1 and s6.1.1 - Conversions.
338
339// Generate the convert_* builtins functions.
340foreach RType = [Float, Double, Half, Char, UChar, Short,
341 UShort, Int, UInt, Long, ULong] in {
342 foreach IType = [Float, Double, Half, Char, UChar, Short,
343 UShort, Int, UInt, Long, ULong] in {
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000344 foreach sat = ["", "_sat"] in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000345 foreach rnd = ["", "_rte", "_rtn", "_rtp", "_rtz"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000346 def : Builtin<"convert_" # RType.Name # sat # rnd, [RType, IType],
347 Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000348 foreach v = [2, 3, 4, 8, 16] in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000349 def : Builtin<"convert_" # RType.Name # v # sat # rnd,
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000350 [VectorType<RType, v>, VectorType<IType, v>],
351 Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000352 }
353 }
354 }
355 }
356}
357
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000358//--------------------------------------------------------------------
Sven van Haastregted69faa2019-09-19 13:41:51 +0000359// OpenCL v1.1 s6.11.1, v1.2 s6.12.1, v2.0 s6.13.1 - Work-item Functions
360// --- Table 7 ---
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000361def : Builtin<"get_work_dim", [UInt], Attr.Const>;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000362foreach name = ["get_global_size", "get_global_id", "get_local_size",
363 "get_local_id", "get_num_groups", "get_group_id",
364 "get_global_offset"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000365 def : Builtin<name, [Size, UInt], Attr.Const>;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000366}
367
368let MinVersion = CL20 in {
369 def : Builtin<"get_enqueued_local_size", [Size, UInt]>;
370 foreach name = ["get_global_linear_id", "get_local_linear_id"] in {
371 def : Builtin<name, [Size]>;
372 }
373}
374
Sven van Haastregt6fc73f62019-11-05 19:47:21 +0000375
Sven van Haastregted69faa2019-09-19 13:41:51 +0000376//--------------------------------------------------------------------
Sven van Haastregt6fc73f62019-11-05 19:47:21 +0000377// OpenCL v1.1 s6.11.2, v1.2 s6.12.2, v2.0 s6.13.2 - Math functions
378// OpenCL Extension v2.0 s5.1.2 and s6.1.2 - Math Functions
379// --- Table 8 ---
380// --- 1 argument ---
381foreach name = ["acos", "acosh", "acospi",
382 "asin", "asinh", "asinpi",
383 "atan", "atanh", "atanpi",
384 "cbrt", "ceil",
385 "cos", "cosh", "cospi",
386 "erfc", "erf",
387 "exp", "exp2", "exp10", "expm1",
388 "fabs", "floor",
389 "log", "log2", "log10", "log1p", "logb",
390 "rint", "round", "rsqrt",
391 "sin", "sinh", "sinpi",
392 "sqrt",
393 "tan", "tanh", "tanpi",
394 "tgamma", "trunc",
395 "lgamma"] in {
396 def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>;
397}
398foreach name = ["nan"] in {
399 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
400 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>;
401 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
402}
403
404// --- 2 arguments ---
405foreach name = ["atan2", "atan2pi", "copysign", "fdim", "fmod", "hypot",
406 "maxmag", "minmag", "nextafter", "pow", "powr",
407 "remainder"] in {
408 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
409}
410foreach name = ["fmax", "fmin"] in {
411 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
412 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>;
413 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>;
414 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>;
415}
416foreach name = ["ilogb"] in {
417 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
418 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeDoubleVecAndScalar], Attr.Const>;
419 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeHalfVecAndScalar], Attr.Const>;
420}
421foreach name = ["ldexp"] in {
422 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
423 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Int], Attr.Const>;
424 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
425 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Int], Attr.Const>;
426 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
427 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Int], Attr.Const>;
428}
429foreach name = ["pown", "rootn"] in {
430 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
431 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
432 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
433}
434
435// --- 3 arguments ---
436foreach name = ["fma", "mad"] in {
437 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
438}
439
440// --- Version dependent ---
441let MaxVersion = CL20 in {
442 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
443 foreach name = ["fract", "modf", "sincos"] in {
444 def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, AS>]>;
445 }
446 foreach name = ["frexp", "lgamma_r"] in {
447 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
448 def : Builtin<name, [Type, Type, PointerType<GenTypeIntVecAndScalar, AS>]>;
449 }
450 }
451 foreach name = ["remquo"] in {
452 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
453 def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, AS>]>;
454 }
455 }
456 }
457}
458let MinVersion = CL20 in {
459 foreach name = ["fract", "modf", "sincos"] in {
460 def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, GenericAS>]>;
461 }
462 foreach name = ["frexp", "lgamma_r"] in {
463 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
464 def : Builtin<name, [Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>;
465 } }
466 foreach name = ["remquo"] in {
467 foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
468 def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>;
469 }
470 }
471}
472
473// --- Table 9 ---
474foreach name = ["half_cos",
475 "half_exp", "half_exp2", "half_exp10",
476 "half_log", "half_log2", "half_log10",
477 "half_recip", "half_rsqrt",
478 "half_sin", "half_sqrt", "half_tan",
479 "native_cos",
480 "native_exp", "native_exp2", "native_exp10",
481 "native_log", "native_log2", "native_log10",
482 "native_recip", "native_rsqrt",
483 "native_sin", "native_sqrt", "native_tan"] in {
484 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
485}
486foreach name = ["half_divide", "half_powr",
487 "native_divide", "native_powr"] in {
488 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
489}
490
491//--------------------------------------------------------------------
Sven van Haastregt0e70c352019-11-06 11:53:19 +0000492// OpenCL v1.1 s6.11.3, v1.2 s6.12.3, v2.0 s6.13.3 - Integer Functions
493// --- Table 10 ---
494// --- 1 argument ---
495foreach name = ["abs"] in {
496 def : Builtin<name, [AI2UGenTypeN, AIGenTypeN], Attr.Const>;
497}
498foreach name = ["clz", "popcount"] in {
499 def : Builtin<name, [AIGenTypeN, AIGenTypeN], Attr.Const>;
500}
501let MinVersion = CL20 in {
502 foreach name = ["ctz"] in {
503 def : Builtin<name, [AIGenTypeN, AIGenTypeN]>;
504 }
505}
506
507// --- 2 arguments ---
508foreach name = ["abs_diff"] in {
509 def : Builtin<name, [AI2UGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
510}
511foreach name = ["add_sat", "hadd", "rhadd", "mul_hi", "rotate", "sub_sat"] in {
512 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
513}
514foreach name = ["max", "min"] in {
515 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
516 def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1], Attr.Const>;
517}
518foreach name = ["upsample"] in {
519 def : Builtin<name, [GenTypeShortVecAndScalar, GenTypeCharVecAndScalar, GenTypeUCharVecAndScalar], Attr.Const>;
520 def : Builtin<name, [GenTypeUShortVecAndScalar, GenTypeUCharVecAndScalar, GenTypeUCharVecAndScalar], Attr.Const>;
521 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeShortVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
522 def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUShortVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
523 def : Builtin<name, [GenTypeLongVecAndScalar, GenTypeIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
524 def : Builtin<name, [GenTypeULongVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
525}
526
527// --- 3 arguments ---
528foreach name = ["clamp"] in {
529 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
530 def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1, AIGenType1], Attr.Const>;
531}
532foreach name = ["mad_hi", "mad_sat"] in {
533 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
534}
535
536// --- Table 11 ---
537foreach name = ["mad24"] in {
538 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
539 def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
540}
541foreach name = ["mul24"] in {
542 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
543 def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
544}
545
546//--------------------------------------------------------------------
Sven van Haastregt6fc73f62019-11-05 19:47:21 +0000547// OpenCL v1.1 s6.11.4, v1.2 s6.12.4, v2.0 s6.13.4 - Common Functions
548// OpenCL Extension v2.0 s5.1.3 and s6.1.3 - Common Functions
549// --- Table 12 ---
550// --- 1 argument ---
551foreach name = ["degrees", "radians", "sign"] in {
552 def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>;
553}
554
555// --- 2 arguments ---
556foreach name = ["max", "min"] in {
557 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
558 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>;
559 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>;
560 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>;
561}
562foreach name = ["step"] in {
563 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
564 def : Builtin<name, [GenTypeFloatVecNoScalar, Float, GenTypeFloatVecNoScalar], Attr.Const>;
565 def : Builtin<name, [GenTypeDoubleVecNoScalar, Double, GenTypeDoubleVecNoScalar], Attr.Const>;
566 def : Builtin<name, [GenTypeHalfVecNoScalar, Half, GenTypeHalfVecNoScalar], Attr.Const>;
567}
568
569// --- 3 arguments ---
570foreach name = ["clamp", "mix"] in {
571 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
572 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float, Float], Attr.Const>;
573 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double, Double], Attr.Const>;
574 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half, Half], Attr.Const>;
575}
576foreach name = ["smoothstep"] in {
577 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>;
578 def : Builtin<name, [GenTypeFloatVecNoScalar, Float, Float, GenTypeFloatVecNoScalar], Attr.Const>;
579 def : Builtin<name, [GenTypeDoubleVecNoScalar, Double, Double, GenTypeDoubleVecNoScalar], Attr.Const>;
580 def : Builtin<name, [GenTypeHalfVecNoScalar, Half, Half, GenTypeHalfVecNoScalar], Attr.Const>;
581}
582
583
Sven van Haastregt3d30f2c2019-11-07 15:00:19 +0000584//--------------------------------------------------------------------
585// OpenCL v1.1 s6.11.5, v1.2 s6.12.5, v2.0 s6.13.5 - Geometric Functions
586// OpenCL Extension v2.0 s5.1.4 and s6.1.4 - Geometric Functions
587// --- Table 13 ---
588// --- 1 argument ---
589foreach name = ["length"] in {
590 def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>;
591 def : Builtin<name, [Double, GenTypeDoubleVec1234], Attr.Const>;
592 def : Builtin<name, [Half, GenTypeHalfVec1234], Attr.Const>;
593}
594foreach name = ["normalize"] in {
595 def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
596 def : Builtin<name, [GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>;
597 def : Builtin<name, [GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>;
598}
599foreach name = ["fast_length"] in {
600 def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>;
601}
602foreach name = ["fast_normalize"] in {
603 def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
604}
605
606// --- 2 arguments ---
607foreach name = ["cross"] in {
608 foreach VSize = [3, 4] in {
609 def : Builtin<name, [VectorType<Float, VSize>, VectorType<Float, VSize>, VectorType<Float, VSize>], Attr.Const>;
610 def : Builtin<name, [VectorType<Double, VSize>, VectorType<Double, VSize>, VectorType<Double, VSize>], Attr.Const>;
611 def : Builtin<name, [VectorType<Half, VSize>, VectorType<Half, VSize>, VectorType<Half, VSize>], Attr.Const>;
612 }
613}
614foreach name = ["dot", "distance"] in {
615 def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
616 def : Builtin<name, [Double, GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>;
617 def : Builtin<name, [Half, GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>;
618}
619foreach name = ["fast_distance"] in {
620 def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>;
621}
622
623
624//--------------------------------------------------------------------
625// OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions
626// OpenCL Extension v2.0 s5.1.5 and s6.1.5 - Relational Functions
627// --- Table 14 ---
628// --- 1 argument ---
629foreach name = ["isfinite", "isinf", "isnan", "isnormal", "signbit"] in {
630 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
631 def : Builtin<name, [Int, Double], Attr.Const>;
632 def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
633 def : Builtin<name, [Int, Half], Attr.Const>;
634 def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
635}
636foreach name = ["any", "all"] in {
637 def : Builtin<name, [Int, AIGenTypeN], Attr.Const>;
638}
639
640// --- 2 arguments ---
641foreach name = ["isequal", "isnotequal", "isgreater", "isgreaterequal",
642 "isless", "islessequal", "islessgreater", "isordered",
643 "isunordered"] in {
644 def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>;
645 def : Builtin<name, [Int, Double, Double], Attr.Const>;
646 def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>;
647 def : Builtin<name, [Int, Half, Half], Attr.Const>;
648 def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>;
649}
650
651// --- 3 arguments ---
652foreach name = ["bitselect"] in {
653 def : Builtin<name, [AGenTypeN, AGenTypeN, AGenTypeN, AGenTypeN], Attr.Const>;
654}
655foreach name = ["select"] in {
656 def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, SGenTypeN], Attr.Const>;
657 def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UGenTypeN], Attr.Const>;
658 def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, UGenTypeN], Attr.Const>;
659 def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, SGenTypeN], Attr.Const>;
660 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>;
661 def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>;
662 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeLongVecAndScalar], Attr.Const>;
663 def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>;
664 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeShortVecAndScalar], Attr.Const>;
665 def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>;
666}
667
668
Sven van Haastregt2fe674b2019-11-13 10:16:33 +0000669//--------------------------------------------------------------------
Sven van Haastregted69faa2019-09-19 13:41:51 +0000670// 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 +0000671// 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 +0000672// --- Table 15 ---
673// Variants for OpenCL versions below 2.0, using pointers to the global, local
674// and private address spaces.
675let MaxVersion = CL20 in {
676 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
677 foreach VSize = [2, 3, 4, 8, 16] in {
678 foreach name = ["vload" # VSize] in {
679 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>;
680 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>;
681 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>;
682 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>;
683 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>;
684 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>;
685 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>;
686 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>;
687 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>;
688 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>;
689 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
690 }
691 foreach name = ["vstore" # VSize] in {
692 def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>;
693 def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>;
694 def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>;
695 def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>;
696 def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>;
697 def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>;
698 def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>;
699 def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>;
700 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>;
701 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>;
702 def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
703 }
704 foreach name = ["vloada_half" # VSize] in {
705 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
706 }
707 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
708 foreach name = ["vstorea_half" # VSize # rnd] in {
709 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
710 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
711 }
712 }
713 }
714 }
715}
716// Variants for OpenCL versions above 2.0, using pointers to the generic
717// address space.
718let MinVersion = CL20 in {
719 foreach VSize = [2, 3, 4, 8, 16] in {
720 foreach name = ["vload" # VSize] in {
721 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
722 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>;
723 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>;
724 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>;
725 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>;
726 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>;
727 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>;
728 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>;
729 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>;
730 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>;
731 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
732 }
733 foreach name = ["vstore" # VSize] in {
734 def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
735 def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>;
736 def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>;
737 def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>;
738 def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>;
739 def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>;
740 def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>;
741 def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>;
742 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>;
743 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>;
744 def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
745 }
746 foreach name = ["vloada_half" # VSize] in {
747 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
748 }
749 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
750 foreach name = ["vstorea_half" # VSize # rnd] in {
751 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, GenericAS>]>;
752 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, GenericAS>]>;
753 }
754 }
755 }
756}
757// Variants using pointers to the constant address space.
758foreach VSize = [2, 3, 4, 8, 16] in {
759 foreach name = ["vload" # VSize] in {
760 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, ConstantAS>]>;
761 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, ConstantAS>]>;
762 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, ConstantAS>]>;
763 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, ConstantAS>]>;
764 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, ConstantAS>]>;
765 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, ConstantAS>]>;
766 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, ConstantAS>]>;
767 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, ConstantAS>]>;
768 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, ConstantAS>]>;
769 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, ConstantAS>]>;
770 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
771 }
772 foreach name = ["vloada_half" # VSize] in {
773 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
774 }
775 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
776 foreach name = ["vstorea_half" # VSize # rnd] in {
777 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, ConstantAS>]>;
778 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, ConstantAS>]>;
779 }
780 }
781}
Sven van Haastregt2fe674b2019-11-13 10:16:33 +0000782let MaxVersion = CL20 in {
783 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
784 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
785 foreach VSize = [2, 3, 4, 8, 16] in {
786 foreach name = ["vload_half" # VSize] in {
787 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
788 }
789 }
790 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
791 def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType<Half, AS>]>;
792 def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType<Half, AS>]>;
793 foreach VSize = [2, 3, 4, 8, 16] in {
794 foreach name = ["vstore_half" # VSize # rnd] in {
795 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
796 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
797 }
798 }
799 }
800 }
801}
802let MinVersion = CL20 in {
803 foreach AS = [GenericAS] in {
804 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
805 foreach VSize = [2, 3, 4, 8, 16] in {
806 foreach name = ["vload_half" # VSize] in {
807 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
808 }
809 }
810 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
811 def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType<Half, AS>]>;
812 def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType<Half, AS>]>;
813 foreach VSize = [2, 3, 4, 8, 16] in {
814 foreach name = ["vstore_half" # VSize # rnd] in {
815 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
816 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
817 }
818 }
819 }
820 }
821}
822
823foreach AS = [ConstantAS] in {
824 def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>;
825 foreach VSize = [2, 3, 4, 8, 16] in {
826 foreach name = ["vload_half" # VSize] in {
827 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
828 }
829 }
830}
Sven van Haastregted69faa2019-09-19 13:41:51 +0000831
832//--------------------------------------------------------------------
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000833// 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
834// OpenCL Extension v2.0 s5.1.7 and s6.1.7: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
835// --- Table 18 ---
836foreach name = ["async_work_group_copy"] in {
837 def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Event]>;
838 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Event]>;
839}
840foreach name = ["async_work_group_strided_copy"] in {
841 def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Size, Event]>;
842 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Size, Event]>;
843}
844foreach name = ["wait_group_events"] in {
845 def : Builtin<name, [Void, Int, PointerType<Event, GenericAS>]>;
846}
847foreach name = ["prefetch"] in {
848 def : Builtin<name, [Void, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size]>;
849}
850
851//--------------------------------------------------------------------
852// OpenCL v2.0 s6.13.11 - Atomics Functions.
853// Functions that use memory_order and cl_mem_fence_flags enums are not
854// declared here as the TableGen backend does not handle enums.
855
856// OpenCL v1.0 s9.5, s9.6, s9.7 - Atomic Functions for 32-bit integers.
857// --- Table 9.1 ---
858foreach Type = [Int, UInt] in {
859 foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
860 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type]>;
861 }
862 foreach name = ["atom_inc", "atom_dec"] in {
863 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>]>;
864 }
865 foreach name = ["atom_cmpxchg"] in {
866 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type, Type]>;
867 }
868}
869
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000870//--------------------------------------------------------------------
871// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14: Image Read and Write Functions
872// OpenCL Extension v2.0 s5.1.8 and s6.1.8: Image Read and Write Functions
873// --- Table 22: Image Read Functions with Samplers ---
874foreach imgTy = [Image1d] in {
875 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000876 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
877 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
878 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000879 }
880}
881foreach imgTy = [Image2d, Image1dArray] in {
882 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000883 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
884 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
885 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000886 }
887}
888foreach imgTy = [Image3d, Image2dArray] in {
889 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000890 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
891 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
892 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000893 }
894}
895foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000896 def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
897 def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000898}
899
900// --- Table 23: Sampler-less Read Functions ---
901foreach aQual = ["RO", "RW"] in {
902 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000903 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
904 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
905 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000906 }
907 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000908 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
909 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
910 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000911 }
912 foreach imgTy = [Image1d, Image1dBuffer] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000913 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
914 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
915 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000916 }
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000917 def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>], Attr.Pure>;
918 def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000919}
920
921// --- Table 24: Image Write Functions ---
922foreach aQual = ["WO", "RW"] in {
923 foreach imgTy = [Image2d] in {
924 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
925 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
926 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
927 }
928 foreach imgTy = [Image2dArray] in {
929 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
930 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
931 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
932 }
933 foreach imgTy = [Image1d, Image1dBuffer] in {
934 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, Int, VectorType<Float, 4>]>;
935 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, Int, VectorType<Int, 4>]>;
936 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, Int, VectorType<UInt, 4>]>;
937 }
938 foreach imgTy = [Image1dArray] in {
939 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
940 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
941 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
942 }
943 foreach imgTy = [Image3d] in {
944 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
945 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
946 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
947 }
948 def : Builtin<"write_imagef", [Void, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>, Float]>;
949 def : Builtin<"write_imagef", [Void, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>, Float]>;
950}
951
Sven van Haastregt2a69ed02019-09-25 09:12:59 +0000952// --- Table 25: Image Query Functions ---
953foreach aQual = ["RO", "WO", "RW"] in {
954 foreach imgTy = [Image1d, Image1dBuffer, Image2d, Image3d,
955 Image1dArray, Image2dArray, Image2dDepth,
956 Image2dArrayDepth] in {
957 foreach name = ["get_image_width", "get_image_channel_data_type",
958 "get_image_channel_order"] in {
959 def : Builtin<name, [Int, ImageType<imgTy, aQual>]>;
960 }
961 }
962 foreach imgTy = [Image2d, Image3d, Image2dArray, Image2dDepth,
963 Image2dArrayDepth] in {
964 def : Builtin<"get_image_height", [Int, ImageType<imgTy, aQual>]>;
965 }
966 def : Builtin<"get_image_depth", [Int, ImageType<Image3d, aQual>]>;
967 foreach imgTy = [Image2d, Image2dArray, Image2dDepth,
968 Image2dArrayDepth] in {
969 def : Builtin<"get_image_dim", [VectorType<Int, 2>, ImageType<imgTy, aQual>]>;
970 }
971 def : Builtin<"get_image_dim", [VectorType<Int, 4>, ImageType<Image3d, aQual>]>;
972 foreach imgTy = [Image1dArray, Image2dArray, Image2dArrayDepth] in {
973 def : Builtin<"get_image_array_size", [Size, ImageType<imgTy, aQual>]>;
974 }
975}
976
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000977// OpenCL extension v2.0 s5.1.9: Built-in Image Read Functions
978// --- Table 8 ---
979foreach aQual = ["RO"] in {
980 foreach name = ["read_imageh"] in {
981 foreach coordTy = [Int, Float] in {
982 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000983 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000984 }
985 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000986 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000987 }
988 foreach imgTy = [Image1d] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000989 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, coordTy], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000990 }
991 }
992 }
993}
994// OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
995// --- Table 9 ---
996foreach aQual = ["RO", "RW"] in {
997 foreach name = ["read_imageh"] in {
998 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000999 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001000 }
1001 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001002 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001003 }
1004 foreach imgTy = [Image1d, Image1dBuffer] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +00001005 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +00001006 }
1007 }
1008}
1009// OpenCL extension v2.0 s5.1.11: Built-in Image Write Functions
1010// --- Table 10 ---
1011foreach aQual = ["WO", "RW"] in {
1012 foreach name = ["write_imageh"] in {
1013 def : Builtin<name, [Void, ImageType<Image2d, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
1014 def : Builtin<name, [Void, ImageType<Image2dArray, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
1015 def : Builtin<name, [Void, ImageType<Image1d, aQual>, Int, VectorType<Half, 4>]>;
1016 def : Builtin<name, [Void, ImageType<Image1dBuffer, aQual>, Int, VectorType<Half, 4>]>;
1017 def : Builtin<name, [Void, ImageType<Image1dArray, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
1018 def : Builtin<name, [Void, ImageType<Image3d, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
1019 }
1020}
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001021
1022
1023// OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions
Sven van Haastregted69faa2019-09-19 13:41:51 +00001024let MinVersion = CL20 in {
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001025 let Extension = "cl_khr_subgroups" in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +00001026 def get_sub_group_size : Builtin<"get_sub_group_size", [UInt]>;
1027 def get_max_sub_group_size : Builtin<"get_max_sub_group_size", [UInt]>;
1028 def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +00001029 }
1030}