blob: 4f458652ff73bda1f8057c063820ce61bed827a8 [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]>;
277
278// Type lists.
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000279def TLAll : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000280def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>;
281
282def TLAllInts : TypeList<"TLAllInts", [Char, UChar, Short, UShort, Int, UInt, Long, ULong]>;
283
284// GenType definitions for multiple base types (e.g. all floating point types,
285// or all integer types).
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000286// All types
287def AGenTypeN : GenericType<"AGenTypeN", TLAll, VecAndScalar>;
288def AGenTypeNNoScalar : GenericType<"AGenTypeNNoScalar", TLAll, VecNoScalar>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000289// All integer
290def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>;
291def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>;
292def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>;
293// Float
294def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>;
295
296// GenType definitions for every single base type (e.g. fp32 only).
297// Names are like: GenTypeFloatVecAndScalar.
298foreach Type = [Char, UChar, Short, UShort,
299 Int, UInt, Long, ULong,
300 Float, Double, Half] in {
301 foreach VecSizes = [VecAndScalar, VecNoScalar] in {
302 def "GenType" # Type # VecSizes :
303 GenericType<"GenType" # Type # VecSizes,
304 TypeList<"GL" # Type.Name, [Type]>,
305 VecSizes>;
306 }
307}
308
309
310//===----------------------------------------------------------------------===//
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000311// Definitions of OpenCL builtin functions
312//===----------------------------------------------------------------------===//
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000313//--------------------------------------------------------------------
314// OpenCL v1.1/1.2/2.0 s6.2.3 - Explicit conversions.
315// OpenCL v2.0 Extensions s5.1.1 and s6.1.1 - Conversions.
316
317// Generate the convert_* builtins functions.
318foreach RType = [Float, Double, Half, Char, UChar, Short,
319 UShort, Int, UInt, Long, ULong] in {
320 foreach IType = [Float, Double, Half, Char, UChar, Short,
321 UShort, Int, UInt, Long, ULong] in {
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000322 foreach sat = ["", "_sat"] in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000323 foreach rnd = ["", "_rte", "_rtn", "_rtp", "_rtz"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000324 def : Builtin<"convert_" # RType.Name # sat # rnd, [RType, IType],
325 Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000326 foreach v = [2, 3, 4, 8, 16] in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000327 def : Builtin<"convert_" # RType.Name # v # sat # rnd,
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000328 [VectorType<RType, v>, VectorType<IType, v>],
329 Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000330 }
331 }
332 }
333 }
334}
335
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000336//--------------------------------------------------------------------
Sven van Haastregted69faa2019-09-19 13:41:51 +0000337// OpenCL v1.1 s6.11.1, v1.2 s6.12.1, v2.0 s6.13.1 - Work-item Functions
338// --- Table 7 ---
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000339def : Builtin<"get_work_dim", [UInt], Attr.Const>;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000340foreach name = ["get_global_size", "get_global_id", "get_local_size",
341 "get_local_id", "get_num_groups", "get_group_id",
342 "get_global_offset"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000343 def : Builtin<name, [Size, UInt], Attr.Const>;
Sven van Haastregted69faa2019-09-19 13:41:51 +0000344}
345
346let MinVersion = CL20 in {
347 def : Builtin<"get_enqueued_local_size", [Size, UInt]>;
348 foreach name = ["get_global_linear_id", "get_local_linear_id"] in {
349 def : Builtin<name, [Size]>;
350 }
351}
352
353//--------------------------------------------------------------------
354// OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions
355// OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s9.4.6, v2.0 s5.1.6 and 6.1.6 - Vector Data Load and Store Functions
356// --- Table 15 ---
357// Variants for OpenCL versions below 2.0, using pointers to the global, local
358// and private address spaces.
359let MaxVersion = CL20 in {
360 foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
361 foreach VSize = [2, 3, 4, 8, 16] in {
362 foreach name = ["vload" # VSize] in {
363 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>;
364 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>;
365 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>;
366 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>;
367 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>;
368 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>;
369 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>;
370 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>;
371 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>;
372 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>;
373 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
374 }
375 foreach name = ["vstore" # VSize] in {
376 def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>;
377 def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>;
378 def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>;
379 def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>;
380 def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>;
381 def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>;
382 def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>;
383 def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>;
384 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>;
385 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>;
386 def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
387 }
388 foreach name = ["vloada_half" # VSize] in {
389 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>;
390 }
391 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
392 foreach name = ["vstorea_half" # VSize # rnd] in {
393 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>;
394 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>;
395 }
396 }
397 }
398 }
399}
400// Variants for OpenCL versions above 2.0, using pointers to the generic
401// address space.
402let MinVersion = CL20 in {
403 foreach VSize = [2, 3, 4, 8, 16] in {
404 foreach name = ["vload" # VSize] in {
405 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
406 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>;
407 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>;
408 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>;
409 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>;
410 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>;
411 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>;
412 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>;
413 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>;
414 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>;
415 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
416 }
417 foreach name = ["vstore" # VSize] in {
418 def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>;
419 def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>;
420 def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>;
421 def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>;
422 def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>;
423 def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>;
424 def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>;
425 def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>;
426 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>;
427 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>;
428 def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
429 }
430 foreach name = ["vloada_half" # VSize] in {
431 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>;
432 }
433 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
434 foreach name = ["vstorea_half" # VSize # rnd] in {
435 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, GenericAS>]>;
436 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, GenericAS>]>;
437 }
438 }
439 }
440}
441// Variants using pointers to the constant address space.
442foreach VSize = [2, 3, 4, 8, 16] in {
443 foreach name = ["vload" # VSize] in {
444 def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, ConstantAS>]>;
445 def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, ConstantAS>]>;
446 def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, ConstantAS>]>;
447 def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, ConstantAS>]>;
448 def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, ConstantAS>]>;
449 def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, ConstantAS>]>;
450 def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, ConstantAS>]>;
451 def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, ConstantAS>]>;
452 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, ConstantAS>]>;
453 def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, ConstantAS>]>;
454 def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
455 }
456 foreach name = ["vloada_half" # VSize] in {
457 def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>;
458 }
459 foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
460 foreach name = ["vstorea_half" # VSize # rnd] in {
461 def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, ConstantAS>]>;
462 def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, ConstantAS>]>;
463 }
464 }
465}
466
467//--------------------------------------------------------------------
Sven van Haastregtcc0ba282019-08-20 12:21:03 +0000468// 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
469// OpenCL Extension v2.0 s5.1.7 and s6.1.7: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
470// --- Table 18 ---
471foreach name = ["async_work_group_copy"] in {
472 def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Event]>;
473 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Event]>;
474}
475foreach name = ["async_work_group_strided_copy"] in {
476 def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Size, Event]>;
477 def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Size, Event]>;
478}
479foreach name = ["wait_group_events"] in {
480 def : Builtin<name, [Void, Int, PointerType<Event, GenericAS>]>;
481}
482foreach name = ["prefetch"] in {
483 def : Builtin<name, [Void, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size]>;
484}
485
486//--------------------------------------------------------------------
487// OpenCL v2.0 s6.13.11 - Atomics Functions.
488// Functions that use memory_order and cl_mem_fence_flags enums are not
489// declared here as the TableGen backend does not handle enums.
490
491// OpenCL v1.0 s9.5, s9.6, s9.7 - Atomic Functions for 32-bit integers.
492// --- Table 9.1 ---
493foreach Type = [Int, UInt] in {
494 foreach name = ["atom_add", "atom_sub", "atom_xchg"] in {
495 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type]>;
496 }
497 foreach name = ["atom_inc", "atom_dec"] in {
498 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>]>;
499 }
500 foreach name = ["atom_cmpxchg"] in {
501 def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type, Type]>;
502 }
503}
504
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000505// OpenCL v1.2 s6.12.2: Math Functions
506foreach name = ["acos", "acosh", "acospi",
507 "asin", "asinh", "asinpi",
508 "atan", "atanh", "atanpi"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000509 def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000510}
511
512foreach name = ["atan2", "atan2pi"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000513 def : Builtin<name, [FGenTypeN, FGenTypeN,FGenTypeN], Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000514}
515
516foreach name = ["fmax", "fmin"] in {
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000517 def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN]>;
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000518 def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>;
519 def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>;
520 def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>;
Sven van Haastregtb21a3652019-08-19 11:56:03 +0000521}
522
523// OpenCL v1.1 s6.11.3, v1.2 s6.12.3, v2.0 s6.13.3 - Integer Functions
524foreach name = ["max", "min"] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000525 def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>;
526 def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1], Attr.Const>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000527}
528
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000529//--------------------------------------------------------------------
530// OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14: Image Read and Write Functions
531// OpenCL Extension v2.0 s5.1.8 and s6.1.8: Image Read and Write Functions
532// --- Table 22: Image Read Functions with Samplers ---
533foreach imgTy = [Image1d] in {
534 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000535 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
536 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
537 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000538 }
539}
540foreach imgTy = [Image2d, Image1dArray] in {
541 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000542 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
543 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
544 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000545 }
546}
547foreach imgTy = [Image3d, Image2dArray] in {
548 foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000549 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
550 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
551 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000552 }
553}
554foreach coordTy = [Int, Float] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000555 def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
556 def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000557}
558
559// --- Table 23: Sampler-less Read Functions ---
560foreach aQual = ["RO", "RW"] in {
561 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000562 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
563 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
564 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000565 }
566 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000567 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
568 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
569 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000570 }
571 foreach imgTy = [Image1d, Image1dBuffer] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000572 def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
573 def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
574 def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000575 }
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000576 def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>], Attr.Pure>;
577 def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000578}
579
580// --- Table 24: Image Write Functions ---
581foreach aQual = ["WO", "RW"] in {
582 foreach imgTy = [Image2d] in {
583 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
584 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
585 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
586 }
587 foreach imgTy = [Image2dArray] in {
588 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
589 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
590 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
591 }
592 foreach imgTy = [Image1d, Image1dBuffer] in {
593 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, Int, VectorType<Float, 4>]>;
594 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, Int, VectorType<Int, 4>]>;
595 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, Int, VectorType<UInt, 4>]>;
596 }
597 foreach imgTy = [Image1dArray] in {
598 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>;
599 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>;
600 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>;
601 }
602 foreach imgTy = [Image3d] in {
603 def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>;
604 def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>;
605 def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>;
606 }
607 def : Builtin<"write_imagef", [Void, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>, Float]>;
608 def : Builtin<"write_imagef", [Void, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>, Float]>;
609}
610
Sven van Haastregt2a69ed02019-09-25 09:12:59 +0000611// --- Table 25: Image Query Functions ---
612foreach aQual = ["RO", "WO", "RW"] in {
613 foreach imgTy = [Image1d, Image1dBuffer, Image2d, Image3d,
614 Image1dArray, Image2dArray, Image2dDepth,
615 Image2dArrayDepth] in {
616 foreach name = ["get_image_width", "get_image_channel_data_type",
617 "get_image_channel_order"] in {
618 def : Builtin<name, [Int, ImageType<imgTy, aQual>]>;
619 }
620 }
621 foreach imgTy = [Image2d, Image3d, Image2dArray, Image2dDepth,
622 Image2dArrayDepth] in {
623 def : Builtin<"get_image_height", [Int, ImageType<imgTy, aQual>]>;
624 }
625 def : Builtin<"get_image_depth", [Int, ImageType<Image3d, aQual>]>;
626 foreach imgTy = [Image2d, Image2dArray, Image2dDepth,
627 Image2dArrayDepth] in {
628 def : Builtin<"get_image_dim", [VectorType<Int, 2>, ImageType<imgTy, aQual>]>;
629 }
630 def : Builtin<"get_image_dim", [VectorType<Int, 4>, ImageType<Image3d, aQual>]>;
631 foreach imgTy = [Image1dArray, Image2dArray, Image2dArrayDepth] in {
632 def : Builtin<"get_image_array_size", [Size, ImageType<imgTy, aQual>]>;
633 }
634}
635
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000636// OpenCL extension v2.0 s5.1.9: Built-in Image Read Functions
637// --- Table 8 ---
638foreach aQual = ["RO"] in {
639 foreach name = ["read_imageh"] in {
640 foreach coordTy = [Int, Float] in {
641 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000642 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000643 }
644 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000645 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000646 }
647 foreach imgTy = [Image1d] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000648 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, coordTy], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000649 }
650 }
651 }
652}
653// OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
654// --- Table 9 ---
655foreach aQual = ["RO", "RW"] in {
656 foreach name = ["read_imageh"] in {
657 foreach imgTy = [Image2d, Image1dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000658 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000659 }
660 foreach imgTy = [Image3d, Image2dArray] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000661 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000662 }
663 foreach imgTy = [Image1d, Image1dBuffer] in {
Sven van Haastregt9a8d4772019-11-05 10:07:43 +0000664 def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>;
Sven van Haastregt988f1e32019-09-05 10:01:24 +0000665 }
666 }
667}
668// OpenCL extension v2.0 s5.1.11: Built-in Image Write Functions
669// --- Table 10 ---
670foreach aQual = ["WO", "RW"] in {
671 foreach name = ["write_imageh"] in {
672 def : Builtin<name, [Void, ImageType<Image2d, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
673 def : Builtin<name, [Void, ImageType<Image2dArray, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
674 def : Builtin<name, [Void, ImageType<Image1d, aQual>, Int, VectorType<Half, 4>]>;
675 def : Builtin<name, [Void, ImageType<Image1dBuffer, aQual>, Int, VectorType<Half, 4>]>;
676 def : Builtin<name, [Void, ImageType<Image1dArray, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>;
677 def : Builtin<name, [Void, ImageType<Image3d, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>;
678 }
679}
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000680
681
682// OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions
Sven van Haastregted69faa2019-09-19 13:41:51 +0000683let MinVersion = CL20 in {
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000684 let Extension = "cl_khr_subgroups" in {
Sven van Haastregt89fb9e82019-07-29 14:55:29 +0000685 def get_sub_group_size : Builtin<"get_sub_group_size", [UInt]>;
686 def get_max_sub_group_size : Builtin<"get_max_sub_group_size", [UInt]>;
687 def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>;
Sven van Haastregt79a222f2019-06-03 09:39:11 +0000688 }
689}