Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 1 | //==--- 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 |
| 22 | class Version<int _Version> { |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 23 | int ID = _Version; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 24 | } |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 25 | def CLAll : Version< 0>; |
| 26 | def CL10 : Version<100>; |
| 27 | def CL11 : Version<110>; |
| 28 | def CL12 : Version<120>; |
| 29 | def CL20 : Version<200>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 30 | |
| 31 | // Address spaces |
| 32 | // Pointer types need to be assigned an address space. |
| 33 | class AddressSpace<string _AS> { |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 34 | string Name = _AS; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 35 | } |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 36 | def DefaultAS : AddressSpace<"clang::LangAS::Default">; |
| 37 | def PrivateAS : AddressSpace<"clang::LangAS::opencl_private">; |
| 38 | def GlobalAS : AddressSpace<"clang::LangAS::opencl_global">; |
| 39 | def ConstantAS : AddressSpace<"clang::LangAS::opencl_constant">; |
| 40 | def LocalAS : AddressSpace<"clang::LangAS::opencl_local">; |
| 41 | def GenericAS : AddressSpace<"clang::LangAS::opencl_generic">; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 42 | |
Sven van Haastregt | 308b8b7 | 2019-12-18 10:13:51 +0000 | [diff] [blame] | 43 | // OpenCL language extension. |
| 44 | class AbstractExtension<string _Ext> { |
| 45 | // One or more OpenCL extensions, space separated. Each extension must be |
| 46 | // a valid extension name for the opencl extension pragma. |
| 47 | string ExtName = _Ext; |
| 48 | } |
| 49 | |
| 50 | // Extension associated to a builtin function. |
| 51 | class FunctionExtension<string _Ext> : AbstractExtension<_Ext>; |
| 52 | |
| 53 | // FunctionExtension definitions. |
| 54 | def FuncExtNone : FunctionExtension<"">; |
| 55 | def FuncExtKhrSubgroups : FunctionExtension<"cl_khr_subgroups">; |
| 56 | def FuncExtKhrGlobalInt32BaseAtomics : FunctionExtension<"cl_khr_global_int32_base_atomics">; |
| 57 | def FuncExtKhrGlobalInt32ExtendedAtomics : FunctionExtension<"cl_khr_global_int32_extended_atomics">; |
Sven van Haastregt | b714583 | 2019-12-23 12:29:01 +0000 | [diff] [blame] | 58 | def FuncExtKhrLocalInt32BaseAtomics : FunctionExtension<"cl_khr_local_int32_base_atomics">; |
| 59 | def FuncExtKhrLocalInt32ExtendedAtomics : FunctionExtension<"cl_khr_local_int32_extended_atomics">; |
| 60 | def FuncExtKhrInt64BaseAtomics : FunctionExtension<"cl_khr_int64_base_atomics">; |
| 61 | def FuncExtKhrInt64ExtendedAtomics : FunctionExtension<"cl_khr_int64_extended_atomics">; |
Sven van Haastregt | 4a188fd | 2019-12-30 10:47:58 +0000 | [diff] [blame^] | 62 | def FuncExtKhrMipmapImage : FunctionExtension<"cl_khr_mipmap_image">; |
| 63 | |
| 64 | // Multiple extensions |
| 65 | def FuncExtKhrMipmapAndWrite3d : FunctionExtension<"cl_khr_mipmap_image cl_khr_3d_image_writes">; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 66 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 67 | // Qualified Type. These map to ASTContext::QualType. |
| 68 | class QualType<string _Name, bit _IsAbstract=0> { |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 69 | // Name of the field or function in a clang::ASTContext |
| 70 | // E.g. Name="IntTy" for the int type, and "getIntPtrType()" for an intptr_t |
| 71 | string Name = _Name; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 72 | // Some QualTypes in this file represent an abstract type for which there is |
| 73 | // no corresponding AST QualType, e.g. a GenType or an `image2d_t` type |
| 74 | // without access qualifiers. |
| 75 | bit IsAbstract = _IsAbstract; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 78 | // List of integers. |
| 79 | class IntList<string _Name, list<int> _List> { |
| 80 | string Name = _Name; |
| 81 | list<int> List = _List; |
| 82 | } |
| 83 | |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 84 | //===----------------------------------------------------------------------===// |
| 85 | // OpenCL C classes for types |
| 86 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 87 | // OpenCL C basic data types (int, float, image2d_t, ...). |
Sven van Haastregt | 47e95ff | 2019-09-17 13:32:56 +0000 | [diff] [blame] | 88 | // Its child classes can represent concrete types (e.g. VectorType) or |
| 89 | // abstract types (e.g. GenType). |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 90 | class Type<string _Name, QualType _QTName> { |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 91 | // Name of the Type. |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 92 | string Name = _Name; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 93 | // QualType associated with this type. |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 94 | QualType QTName = _QTName; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 95 | // Size of the vector (if applicable). |
| 96 | int VecWidth = 1; |
| 97 | // Is a pointer. |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 98 | bit IsPointer = 0; |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 99 | // "const" qualifier. |
| 100 | bit IsConst = 0; |
| 101 | // "volatile" qualifier. |
| 102 | bit IsVolatile = 0; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 103 | // Access qualifier. Must be one of ("RO", "WO", "RW"). |
| 104 | string AccessQualifier = ""; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 105 | // Address space. |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 106 | string AddrSpace = DefaultAS.Name; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 109 | // OpenCL vector types (e.g. int2, int3, int16, float8, ...). |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 110 | class VectorType<Type _Ty, int _VecWidth> : Type<_Ty.Name, _Ty.QTName> { |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 111 | let VecWidth = _VecWidth; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 112 | let AccessQualifier = ""; |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 113 | // Inherited fields |
| 114 | let IsPointer = _Ty.IsPointer; |
| 115 | let IsConst = _Ty.IsConst; |
| 116 | let IsVolatile = _Ty.IsVolatile; |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 117 | let AddrSpace = _Ty.AddrSpace; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 120 | // OpenCL pointer types (e.g. int*, float*, ...). |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 121 | class PointerType<Type _Ty, AddressSpace _AS = DefaultAS> : |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 122 | Type<_Ty.Name, _Ty.QTName> { |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 123 | let AddrSpace = _AS.Name; |
| 124 | // Inherited fields |
| 125 | let VecWidth = _Ty.VecWidth; |
| 126 | let IsPointer = 1; |
| 127 | let IsConst = _Ty.IsConst; |
| 128 | let IsVolatile = _Ty.IsVolatile; |
| 129 | let AccessQualifier = _Ty.AccessQualifier; |
| 130 | } |
| 131 | |
| 132 | // OpenCL const types (e.g. const int). |
| 133 | class ConstType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> { |
| 134 | let IsConst = 1; |
| 135 | // Inherited fields |
| 136 | let VecWidth = _Ty.VecWidth; |
| 137 | let IsPointer = _Ty.IsPointer; |
| 138 | let IsVolatile = _Ty.IsVolatile; |
| 139 | let AccessQualifier = _Ty.AccessQualifier; |
| 140 | let AddrSpace = _Ty.AddrSpace; |
| 141 | } |
| 142 | |
| 143 | // OpenCL volatile types (e.g. volatile int). |
| 144 | class VolatileType<Type _Ty> : Type<_Ty.Name, _Ty.QTName> { |
| 145 | let IsVolatile = 1; |
| 146 | // Inherited fields |
| 147 | let VecWidth = _Ty.VecWidth; |
| 148 | let IsPointer = _Ty.IsPointer; |
| 149 | let IsConst = _Ty.IsConst; |
| 150 | let AccessQualifier = _Ty.AccessQualifier; |
| 151 | let AddrSpace = _Ty.AddrSpace; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 154 | // OpenCL image types (e.g. image2d). |
| 155 | class ImageType<Type _Ty, string _AccessQualifier> : |
| 156 | Type<_Ty.Name, QualType<_Ty.QTName.Name#_AccessQualifier#"Ty", 0>> { |
| 157 | let VecWidth = 0; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 158 | let AccessQualifier = _AccessQualifier; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 159 | // Inherited fields |
| 160 | let IsPointer = _Ty.IsPointer; |
| 161 | let IsConst = _Ty.IsConst; |
| 162 | let IsVolatile = _Ty.IsVolatile; |
| 163 | let AddrSpace = _Ty.AddrSpace; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 166 | // List of Types. |
| 167 | class TypeList<string _Name, list<Type> _Type> { |
| 168 | string Name = _Name; |
| 169 | list<Type> List = _Type; |
| 170 | } |
| 171 | |
| 172 | // A GenericType is an abstract type that defines a set of types as a |
| 173 | // combination of Types and vector sizes. |
| 174 | // |
Sven van Haastregt | 47e95ff | 2019-09-17 13:32:56 +0000 | [diff] [blame] | 175 | // For example, if TypeList = <int, float> and VectorList = <1, 2, 4>, then it |
| 176 | // represents <int, int2, int4, float, float2, float4>. |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 177 | // |
| 178 | // Some rules apply when using multiple GenericType arguments in a declaration: |
| 179 | // 1. The number of vector sizes must be equal or 1 for all gentypes in a |
| 180 | // declaration. |
| 181 | // 2. The number of Types must be equal or 1 for all gentypes in a |
| 182 | // declaration. |
| 183 | // 3. Generic types are combined by iterating over all generic types at once. |
| 184 | // For example, for the following GenericTypes |
| 185 | // GenT1 = GenericType<half, [1, 2]> and |
| 186 | // GenT2 = GenericType<float, int, [1, 2]> |
| 187 | // A declaration f(GenT1, GenT2) results in the combinations |
| 188 | // f(half, float), f(half2, float2), f(half, int), f(half2, int2) . |
| 189 | // 4. "sgentype" from the OpenCL specification is supported by specifying |
| 190 | // a single vector size. |
| 191 | // For example, for the following GenericTypes |
| 192 | // GenT = GenericType<half, int, [1, 2]> and |
| 193 | // SGenT = GenericType<half, int, [1]> |
| 194 | // A declaration f(GenT, SGenT) results in the combinations |
| 195 | // f(half, half), f(half2, half), f(int, int), f(int2, int) . |
| 196 | class GenericType<string _Ty, TypeList _TypeList, IntList _VectorList> : |
| 197 | Type<_Ty, QualType<"null", 1>> { |
| 198 | // Possible element types of the generic type. |
| 199 | TypeList TypeList = _TypeList; |
| 200 | // Possible vector sizes of the types in the TypeList. |
| 201 | IntList VectorList = _VectorList; |
| 202 | // The VecWidth field is ignored for GenericTypes. Use VectorList instead. |
| 203 | let VecWidth = 0; |
| 204 | } |
| 205 | |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 206 | // Builtin function attributes. |
| 207 | def Attr { |
| 208 | list<bit> None = [0, 0, 0]; |
| 209 | list<bit> Pure = [1, 0, 0]; |
| 210 | list<bit> Const = [0, 1, 0]; |
| 211 | list<bit> Convergent = [0, 0, 1]; |
| 212 | } |
| 213 | |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 214 | //===----------------------------------------------------------------------===// |
| 215 | // OpenCL C class for builtin functions |
| 216 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 217 | class Builtin<string _Name, list<Type> _Signature, list<bit> _Attributes = Attr.None> { |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 218 | // Name of the builtin function |
| 219 | string Name = _Name; |
| 220 | // List of types used by the function. The first one is the return type and |
| 221 | // the following are the arguments. The list must have at least one element |
| 222 | // (the return type). |
| 223 | list<Type> Signature = _Signature; |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 224 | // Function attribute __attribute__((pure)) |
| 225 | bit IsPure = _Attributes[0]; |
| 226 | // Function attribute __attribute__((const)) |
| 227 | bit IsConst = _Attributes[1]; |
| 228 | // Function attribute __attribute__((convergent)) |
| 229 | bit IsConv = _Attributes[2]; |
Sven van Haastregt | 308b8b7 | 2019-12-18 10:13:51 +0000 | [diff] [blame] | 230 | // OpenCL extensions to which the function belongs. |
| 231 | FunctionExtension Extension = FuncExtNone; |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 232 | // Version of OpenCL from which the function is available (e.g.: CL10). |
| 233 | // MinVersion is inclusive. |
| 234 | Version MinVersion = CL10; |
| 235 | // Version of OpenCL from which the function is not supported anymore. |
| 236 | // MaxVersion is exclusive. |
| 237 | // CLAll makes the function available for all versions. |
| 238 | Version MaxVersion = CLAll; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 242 | // Definitions of OpenCL C types |
| 243 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 244 | |
| 245 | // OpenCL v1.0/1.2/2.0 s6.1.1: Built-in Scalar Data Types. |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 246 | def Bool : Type<"bool", QualType<"BoolTy">>; |
| 247 | def Char : Type<"char", QualType<"CharTy">>; |
| 248 | def UChar : Type<"uchar", QualType<"UnsignedCharTy">>; |
| 249 | def Short : Type<"short", QualType<"ShortTy">>; |
| 250 | def UShort : Type<"ushort", QualType<"UnsignedShortTy">>; |
| 251 | def Int : Type<"int", QualType<"IntTy">>; |
| 252 | def UInt : Type<"uint", QualType<"UnsignedIntTy">>; |
| 253 | def Long : Type<"long", QualType<"LongTy">>; |
| 254 | def ULong : Type<"ulong", QualType<"UnsignedLongTy">>; |
| 255 | def Float : Type<"float", QualType<"FloatTy">>; |
| 256 | def Double : Type<"double", QualType<"DoubleTy">>; |
| 257 | def Half : Type<"half", QualType<"HalfTy">>; |
| 258 | def Size : Type<"size_t", QualType<"getSizeType()">>; |
| 259 | def PtrDiff : Type<"ptrdiff_t", QualType<"getPointerDiffType()">>; |
| 260 | def IntPtr : Type<"intptr_t", QualType<"getIntPtrType()">>; |
| 261 | def UIntPtr : Type<"uintPtr_t", QualType<"getUIntPtrType()">>; |
| 262 | def Void : Type<"void_t", QualType<"VoidTy">>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 263 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 264 | // OpenCL v1.0/1.2/2.0 s6.1.2: Built-in Vector Data Types. |
| 265 | // Built-in vector data types are created by TableGen's OpenCLBuiltinEmitter. |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 266 | |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 267 | // OpenCL v1.0/1.2/2.0 s6.1.3: Other Built-in Data Types. |
| 268 | // The image definitions are "abstract". They should not be used without |
| 269 | // specifying an access qualifier (RO/WO/RW). |
| 270 | def Image1d : Type<"Image1d", QualType<"OCLImage1d", 1>>; |
| 271 | def Image2d : Type<"Image2d", QualType<"OCLImage2d", 1>>; |
| 272 | def Image3d : Type<"Image3d", QualType<"OCLImage3d", 1>>; |
| 273 | def Image1dArray : Type<"Image1dArray", QualType<"OCLImage1dArray", 1>>; |
| 274 | def Image1dBuffer : Type<"Image1dBuffer", QualType<"OCLImage1dBuffer", 1>>; |
| 275 | def Image2dArray : Type<"Image2dArray", QualType<"OCLImage2dArray", 1>>; |
| 276 | def Image2dDepth : Type<"Image2dDepth", QualType<"OCLImage2dDepth", 1>>; |
| 277 | def Image2dArrayDepth : Type<"Image2dArrayDepth", QualType<"OCLImage2dArrayDepth", 1>>; |
| 278 | def Image2dMsaa : Type<"Image2dMsaa", QualType<"OCLImage2dMSAA", 1>>; |
| 279 | def Image2dArrayMsaa : Type<"Image2dArrayMsaa", QualType<"OCLImage2dArrayMSAA", 1>>; |
| 280 | def Image2dMsaaDepth : Type<"Image2dMsaaDepth", QualType<"OCLImage2dMSAADepth", 1>>; |
| 281 | def Image2dArrayMsaaDepth : Type<"Image2dArrayMsaaDepth", QualType<"OCLImage2dArrayMSAADepth", 1>>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 282 | |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 283 | def Sampler : Type<"Sampler", QualType<"OCLSamplerTy">>; |
| 284 | def Event : Type<"Event", QualType<"OCLEventTy">>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 285 | |
| 286 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 287 | // Definitions of OpenCL gentype variants |
| 288 | //===----------------------------------------------------------------------===// |
| 289 | // The OpenCL specification often uses "gentype" in builtin function |
| 290 | // declarations to indicate that a builtin function is available with various |
| 291 | // argument and return types. The types represented by "gentype" vary between |
| 292 | // different parts of the specification. The following definitions capture |
| 293 | // the different type lists for gentypes in different parts of the |
| 294 | // specification. |
| 295 | |
| 296 | // Vector width lists. |
| 297 | def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>; |
| 298 | def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>; |
| 299 | def Vec1 : IntList<"Vec1", [1]>; |
Sven van Haastregt | e54c83e | 2019-11-26 10:44:49 +0000 | [diff] [blame] | 300 | def Vec2 : IntList<"Vec2", [2]>; |
| 301 | def Vec4 : IntList<"Vec4", [4]>; |
| 302 | def Vec8 : IntList<"Vec8", [8]>; |
| 303 | def Vec16 : IntList<"Vec16", [16]>; |
Sven van Haastregt | 3d30f2c | 2019-11-07 15:00:19 +0000 | [diff] [blame] | 304 | def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 305 | |
| 306 | // Type lists. |
Sven van Haastregt | e54c83e | 2019-11-26 10:44:49 +0000 | [diff] [blame] | 307 | def TLAll : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, ULong, Float, Double, Half]>; |
| 308 | def TLAllUnsigned : TypeList<"TLAllUnsigned", [UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong, UInt, ULong, UShort]>; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 309 | def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>; |
Sven van Haastregt | 3d30f2c | 2019-11-07 15:00:19 +0000 | [diff] [blame] | 310 | def TLSignedInts : TypeList<"TLSignedInts", [Char, Short, Int, Long]>; |
| 311 | def TLUnsignedInts : TypeList<"TLUnsignedInts", [UChar, UShort, UInt, ULong]>; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 312 | |
Sven van Haastregt | e54c83e | 2019-11-26 10:44:49 +0000 | [diff] [blame] | 313 | def TLIntLongFloats : TypeList<"TLIntLongFloats", [Int, UInt, Long, ULong, Float, Double, Half]>; |
| 314 | |
Sven van Haastregt | 0e70c35 | 2019-11-06 11:53:19 +0000 | [diff] [blame] | 315 | // All unsigned integer types twice, to facilitate unsigned return types for e.g. |
| 316 | // uchar abs(char) and |
| 317 | // uchar abs(uchar). |
| 318 | def TLAllUIntsTwice : TypeList<"TLAllUIntsTwice", [UChar, UChar, UShort, UShort, UInt, UInt, ULong, ULong]>; |
| 319 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 320 | def TLAllInts : TypeList<"TLAllInts", [Char, UChar, Short, UShort, Int, UInt, Long, ULong]>; |
| 321 | |
| 322 | // GenType definitions for multiple base types (e.g. all floating point types, |
| 323 | // or all integer types). |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 324 | // All types |
| 325 | def AGenTypeN : GenericType<"AGenTypeN", TLAll, VecAndScalar>; |
| 326 | def AGenTypeNNoScalar : GenericType<"AGenTypeNNoScalar", TLAll, VecNoScalar>; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 327 | // All integer |
| 328 | def AIGenType1 : GenericType<"AIGenType1", TLAllInts, Vec1>; |
| 329 | def AIGenTypeN : GenericType<"AIGenTypeN", TLAllInts, VecAndScalar>; |
| 330 | def AIGenTypeNNoScalar : GenericType<"AIGenTypeNNoScalar", TLAllInts, VecNoScalar>; |
Sven van Haastregt | 0e70c35 | 2019-11-06 11:53:19 +0000 | [diff] [blame] | 331 | // All integer to unsigned |
| 332 | def AI2UGenTypeN : GenericType<"AI2UGenTypeN", TLAllUIntsTwice, VecAndScalar>; |
Sven van Haastregt | 3d30f2c | 2019-11-07 15:00:19 +0000 | [diff] [blame] | 333 | // Signed integer |
| 334 | def SGenTypeN : GenericType<"SGenTypeN", TLSignedInts, VecAndScalar>; |
| 335 | // Unsigned integer |
| 336 | def UGenTypeN : GenericType<"UGenTypeN", TLUnsignedInts, VecAndScalar>; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 337 | // Float |
| 338 | def FGenTypeN : GenericType<"FGenTypeN", TLFloat, VecAndScalar>; |
Sven van Haastregt | e54c83e | 2019-11-26 10:44:49 +0000 | [diff] [blame] | 339 | // (u)int, (u)long, and all floats |
| 340 | def IntLongFloatGenType1 : GenericType<"IntLongFloatGenType1", TLIntLongFloats, Vec1>; |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 341 | |
| 342 | // GenType definitions for every single base type (e.g. fp32 only). |
| 343 | // Names are like: GenTypeFloatVecAndScalar. |
| 344 | foreach Type = [Char, UChar, Short, UShort, |
| 345 | Int, UInt, Long, ULong, |
| 346 | Float, Double, Half] in { |
| 347 | foreach VecSizes = [VecAndScalar, VecNoScalar] in { |
| 348 | def "GenType" # Type # VecSizes : |
| 349 | GenericType<"GenType" # Type # VecSizes, |
| 350 | TypeList<"GL" # Type.Name, [Type]>, |
| 351 | VecSizes>; |
| 352 | } |
| 353 | } |
| 354 | |
Sven van Haastregt | 3d30f2c | 2019-11-07 15:00:19 +0000 | [diff] [blame] | 355 | // GenType definitions for vec1234. |
| 356 | foreach Type = [Float, Double, Half] in { |
| 357 | def "GenType" # Type # Vec1234 : |
| 358 | GenericType<"GenType" # Type # Vec1234, |
| 359 | TypeList<"GL" # Type.Name, [Type]>, |
| 360 | Vec1234>; |
| 361 | } |
| 362 | |
Sven van Haastregt | b21a365 | 2019-08-19 11:56:03 +0000 | [diff] [blame] | 363 | |
| 364 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 365 | // Definitions of OpenCL builtin functions |
| 366 | //===----------------------------------------------------------------------===// |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 367 | //-------------------------------------------------------------------- |
| 368 | // OpenCL v1.1/1.2/2.0 s6.2.3 - Explicit conversions. |
| 369 | // OpenCL v2.0 Extensions s5.1.1 and s6.1.1 - Conversions. |
| 370 | |
| 371 | // Generate the convert_* builtins functions. |
| 372 | foreach RType = [Float, Double, Half, Char, UChar, Short, |
| 373 | UShort, Int, UInt, Long, ULong] in { |
| 374 | foreach IType = [Float, Double, Half, Char, UChar, Short, |
| 375 | UShort, Int, UInt, Long, ULong] in { |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 376 | foreach sat = ["", "_sat"] in { |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 377 | foreach rnd = ["", "_rte", "_rtn", "_rtp", "_rtz"] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 378 | def : Builtin<"convert_" # RType.Name # sat # rnd, [RType, IType], |
| 379 | Attr.Const>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 380 | foreach v = [2, 3, 4, 8, 16] in { |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 381 | def : Builtin<"convert_" # RType.Name # v # sat # rnd, |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 382 | [VectorType<RType, v>, VectorType<IType, v>], |
| 383 | Attr.Const>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 384 | } |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 390 | //-------------------------------------------------------------------- |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 391 | // OpenCL v1.1 s6.11.1, v1.2 s6.12.1, v2.0 s6.13.1 - Work-item Functions |
| 392 | // --- Table 7 --- |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 393 | def : Builtin<"get_work_dim", [UInt], Attr.Const>; |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 394 | foreach name = ["get_global_size", "get_global_id", "get_local_size", |
| 395 | "get_local_id", "get_num_groups", "get_group_id", |
| 396 | "get_global_offset"] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 397 | def : Builtin<name, [Size, UInt], Attr.Const>; |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | let MinVersion = CL20 in { |
| 401 | def : Builtin<"get_enqueued_local_size", [Size, UInt]>; |
| 402 | foreach name = ["get_global_linear_id", "get_local_linear_id"] in { |
| 403 | def : Builtin<name, [Size]>; |
| 404 | } |
| 405 | } |
| 406 | |
Sven van Haastregt | 6fc73f6 | 2019-11-05 19:47:21 +0000 | [diff] [blame] | 407 | |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 408 | //-------------------------------------------------------------------- |
Sven van Haastregt | 6fc73f6 | 2019-11-05 19:47:21 +0000 | [diff] [blame] | 409 | // OpenCL v1.1 s6.11.2, v1.2 s6.12.2, v2.0 s6.13.2 - Math functions |
| 410 | // OpenCL Extension v2.0 s5.1.2 and s6.1.2 - Math Functions |
| 411 | // --- Table 8 --- |
| 412 | // --- 1 argument --- |
| 413 | foreach name = ["acos", "acosh", "acospi", |
| 414 | "asin", "asinh", "asinpi", |
| 415 | "atan", "atanh", "atanpi", |
| 416 | "cbrt", "ceil", |
| 417 | "cos", "cosh", "cospi", |
| 418 | "erfc", "erf", |
| 419 | "exp", "exp2", "exp10", "expm1", |
| 420 | "fabs", "floor", |
| 421 | "log", "log2", "log10", "log1p", "logb", |
| 422 | "rint", "round", "rsqrt", |
| 423 | "sin", "sinh", "sinpi", |
| 424 | "sqrt", |
| 425 | "tan", "tanh", "tanpi", |
| 426 | "tgamma", "trunc", |
| 427 | "lgamma"] in { |
| 428 | def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>; |
| 429 | } |
| 430 | foreach name = ["nan"] in { |
| 431 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>; |
| 432 | def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>; |
| 433 | def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>; |
| 434 | } |
| 435 | |
| 436 | // --- 2 arguments --- |
| 437 | foreach name = ["atan2", "atan2pi", "copysign", "fdim", "fmod", "hypot", |
| 438 | "maxmag", "minmag", "nextafter", "pow", "powr", |
| 439 | "remainder"] in { |
| 440 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 441 | } |
| 442 | foreach name = ["fmax", "fmin"] in { |
| 443 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 444 | def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>; |
| 445 | def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>; |
| 446 | def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>; |
| 447 | } |
| 448 | foreach name = ["ilogb"] in { |
| 449 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>; |
| 450 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeDoubleVecAndScalar], Attr.Const>; |
| 451 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeHalfVecAndScalar], Attr.Const>; |
| 452 | } |
| 453 | foreach name = ["ldexp"] in { |
| 454 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 455 | def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Int], Attr.Const>; |
| 456 | def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 457 | def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Int], Attr.Const>; |
| 458 | def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 459 | def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Int], Attr.Const>; |
| 460 | } |
| 461 | foreach name = ["pown", "rootn"] in { |
| 462 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 463 | def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 464 | def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 465 | } |
| 466 | |
| 467 | // --- 3 arguments --- |
| 468 | foreach name = ["fma", "mad"] in { |
| 469 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 470 | } |
| 471 | |
| 472 | // --- Version dependent --- |
| 473 | let MaxVersion = CL20 in { |
| 474 | foreach AS = [GlobalAS, LocalAS, PrivateAS] in { |
| 475 | foreach name = ["fract", "modf", "sincos"] in { |
| 476 | def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, AS>]>; |
| 477 | } |
| 478 | foreach name = ["frexp", "lgamma_r"] in { |
| 479 | foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in { |
| 480 | def : Builtin<name, [Type, Type, PointerType<GenTypeIntVecAndScalar, AS>]>; |
| 481 | } |
| 482 | } |
| 483 | foreach name = ["remquo"] in { |
| 484 | foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in { |
| 485 | def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, AS>]>; |
| 486 | } |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | let MinVersion = CL20 in { |
| 491 | foreach name = ["fract", "modf", "sincos"] in { |
| 492 | def : Builtin<name, [FGenTypeN, FGenTypeN, PointerType<FGenTypeN, GenericAS>]>; |
| 493 | } |
| 494 | foreach name = ["frexp", "lgamma_r"] in { |
| 495 | foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in { |
| 496 | def : Builtin<name, [Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>; |
| 497 | } } |
| 498 | foreach name = ["remquo"] in { |
| 499 | foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in { |
| 500 | def : Builtin<name, [Type, Type, Type, PointerType<GenTypeIntVecAndScalar, GenericAS>]>; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | // --- Table 9 --- |
| 506 | foreach name = ["half_cos", |
| 507 | "half_exp", "half_exp2", "half_exp10", |
| 508 | "half_log", "half_log2", "half_log10", |
| 509 | "half_recip", "half_rsqrt", |
| 510 | "half_sin", "half_sqrt", "half_tan", |
| 511 | "native_cos", |
| 512 | "native_exp", "native_exp2", "native_exp10", |
| 513 | "native_log", "native_log2", "native_log10", |
| 514 | "native_recip", "native_rsqrt", |
| 515 | "native_sin", "native_sqrt", "native_tan"] in { |
| 516 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>; |
| 517 | } |
| 518 | foreach name = ["half_divide", "half_powr", |
| 519 | "native_divide", "native_powr"] in { |
| 520 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>; |
| 521 | } |
| 522 | |
| 523 | //-------------------------------------------------------------------- |
Sven van Haastregt | 0e70c35 | 2019-11-06 11:53:19 +0000 | [diff] [blame] | 524 | // OpenCL v1.1 s6.11.3, v1.2 s6.12.3, v2.0 s6.13.3 - Integer Functions |
| 525 | // --- Table 10 --- |
| 526 | // --- 1 argument --- |
| 527 | foreach name = ["abs"] in { |
| 528 | def : Builtin<name, [AI2UGenTypeN, AIGenTypeN], Attr.Const>; |
| 529 | } |
| 530 | foreach name = ["clz", "popcount"] in { |
| 531 | def : Builtin<name, [AIGenTypeN, AIGenTypeN], Attr.Const>; |
| 532 | } |
| 533 | let MinVersion = CL20 in { |
| 534 | foreach name = ["ctz"] in { |
| 535 | def : Builtin<name, [AIGenTypeN, AIGenTypeN]>; |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | // --- 2 arguments --- |
| 540 | foreach name = ["abs_diff"] in { |
| 541 | def : Builtin<name, [AI2UGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>; |
| 542 | } |
| 543 | foreach name = ["add_sat", "hadd", "rhadd", "mul_hi", "rotate", "sub_sat"] in { |
| 544 | def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>; |
| 545 | } |
| 546 | foreach name = ["max", "min"] in { |
| 547 | def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>; |
| 548 | def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1], Attr.Const>; |
| 549 | } |
| 550 | foreach name = ["upsample"] in { |
| 551 | def : Builtin<name, [GenTypeShortVecAndScalar, GenTypeCharVecAndScalar, GenTypeUCharVecAndScalar], Attr.Const>; |
| 552 | def : Builtin<name, [GenTypeUShortVecAndScalar, GenTypeUCharVecAndScalar, GenTypeUCharVecAndScalar], Attr.Const>; |
| 553 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeShortVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>; |
| 554 | def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUShortVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>; |
| 555 | def : Builtin<name, [GenTypeLongVecAndScalar, GenTypeIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>; |
| 556 | def : Builtin<name, [GenTypeULongVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>; |
| 557 | } |
| 558 | |
| 559 | // --- 3 arguments --- |
| 560 | foreach name = ["clamp"] in { |
| 561 | def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>; |
| 562 | def : Builtin<name, [AIGenTypeNNoScalar, AIGenTypeNNoScalar, AIGenType1, AIGenType1], Attr.Const>; |
| 563 | } |
| 564 | foreach name = ["mad_hi", "mad_sat"] in { |
| 565 | def : Builtin<name, [AIGenTypeN, AIGenTypeN, AIGenTypeN, AIGenTypeN], Attr.Const>; |
| 566 | } |
| 567 | |
| 568 | // --- Table 11 --- |
| 569 | foreach name = ["mad24"] in { |
| 570 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 571 | def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>; |
| 572 | } |
| 573 | foreach name = ["mul24"] in { |
| 574 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeIntVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 575 | def : Builtin<name, [GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>; |
| 576 | } |
| 577 | |
| 578 | //-------------------------------------------------------------------- |
Sven van Haastregt | 6fc73f6 | 2019-11-05 19:47:21 +0000 | [diff] [blame] | 579 | // OpenCL v1.1 s6.11.4, v1.2 s6.12.4, v2.0 s6.13.4 - Common Functions |
| 580 | // OpenCL Extension v2.0 s5.1.3 and s6.1.3 - Common Functions |
| 581 | // --- Table 12 --- |
| 582 | // --- 1 argument --- |
| 583 | foreach name = ["degrees", "radians", "sign"] in { |
| 584 | def : Builtin<name, [FGenTypeN, FGenTypeN], Attr.Const>; |
| 585 | } |
| 586 | |
| 587 | // --- 2 arguments --- |
| 588 | foreach name = ["max", "min"] in { |
| 589 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 590 | def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float], Attr.Const>; |
| 591 | def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double], Attr.Const>; |
| 592 | def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half], Attr.Const>; |
| 593 | } |
| 594 | foreach name = ["step"] in { |
| 595 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 596 | def : Builtin<name, [GenTypeFloatVecNoScalar, Float, GenTypeFloatVecNoScalar], Attr.Const>; |
| 597 | def : Builtin<name, [GenTypeDoubleVecNoScalar, Double, GenTypeDoubleVecNoScalar], Attr.Const>; |
| 598 | def : Builtin<name, [GenTypeHalfVecNoScalar, Half, GenTypeHalfVecNoScalar], Attr.Const>; |
| 599 | } |
| 600 | |
| 601 | // --- 3 arguments --- |
| 602 | foreach name = ["clamp", "mix"] in { |
| 603 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 604 | def : Builtin<name, [GenTypeFloatVecNoScalar, GenTypeFloatVecNoScalar, Float, Float], Attr.Const>; |
| 605 | def : Builtin<name, [GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar, Double, Double], Attr.Const>; |
| 606 | def : Builtin<name, [GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar, Half, Half], Attr.Const>; |
| 607 | } |
| 608 | foreach name = ["smoothstep"] in { |
| 609 | def : Builtin<name, [FGenTypeN, FGenTypeN, FGenTypeN, FGenTypeN], Attr.Const>; |
| 610 | def : Builtin<name, [GenTypeFloatVecNoScalar, Float, Float, GenTypeFloatVecNoScalar], Attr.Const>; |
| 611 | def : Builtin<name, [GenTypeDoubleVecNoScalar, Double, Double, GenTypeDoubleVecNoScalar], Attr.Const>; |
| 612 | def : Builtin<name, [GenTypeHalfVecNoScalar, Half, Half, GenTypeHalfVecNoScalar], Attr.Const>; |
| 613 | } |
| 614 | |
| 615 | |
Sven van Haastregt | 3d30f2c | 2019-11-07 15:00:19 +0000 | [diff] [blame] | 616 | //-------------------------------------------------------------------- |
| 617 | // OpenCL v1.1 s6.11.5, v1.2 s6.12.5, v2.0 s6.13.5 - Geometric Functions |
| 618 | // OpenCL Extension v2.0 s5.1.4 and s6.1.4 - Geometric Functions |
| 619 | // --- Table 13 --- |
| 620 | // --- 1 argument --- |
| 621 | foreach name = ["length"] in { |
| 622 | def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>; |
| 623 | def : Builtin<name, [Double, GenTypeDoubleVec1234], Attr.Const>; |
| 624 | def : Builtin<name, [Half, GenTypeHalfVec1234], Attr.Const>; |
| 625 | } |
| 626 | foreach name = ["normalize"] in { |
| 627 | def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>; |
| 628 | def : Builtin<name, [GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>; |
| 629 | def : Builtin<name, [GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>; |
| 630 | } |
| 631 | foreach name = ["fast_length"] in { |
| 632 | def : Builtin<name, [Float, GenTypeFloatVec1234], Attr.Const>; |
| 633 | } |
| 634 | foreach name = ["fast_normalize"] in { |
| 635 | def : Builtin<name, [GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>; |
| 636 | } |
| 637 | |
| 638 | // --- 2 arguments --- |
| 639 | foreach name = ["cross"] in { |
| 640 | foreach VSize = [3, 4] in { |
| 641 | def : Builtin<name, [VectorType<Float, VSize>, VectorType<Float, VSize>, VectorType<Float, VSize>], Attr.Const>; |
| 642 | def : Builtin<name, [VectorType<Double, VSize>, VectorType<Double, VSize>, VectorType<Double, VSize>], Attr.Const>; |
| 643 | def : Builtin<name, [VectorType<Half, VSize>, VectorType<Half, VSize>, VectorType<Half, VSize>], Attr.Const>; |
| 644 | } |
| 645 | } |
| 646 | foreach name = ["dot", "distance"] in { |
| 647 | def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>; |
| 648 | def : Builtin<name, [Double, GenTypeDoubleVec1234, GenTypeDoubleVec1234], Attr.Const>; |
| 649 | def : Builtin<name, [Half, GenTypeHalfVec1234, GenTypeHalfVec1234], Attr.Const>; |
| 650 | } |
| 651 | foreach name = ["fast_distance"] in { |
| 652 | def : Builtin<name, [Float, GenTypeFloatVec1234, GenTypeFloatVec1234], Attr.Const>; |
| 653 | } |
| 654 | |
| 655 | |
| 656 | //-------------------------------------------------------------------- |
| 657 | // OpenCL v1.1 s6.11.6, v1.2 s6.12.6, v2.0 s6.13.6 - Relational Functions |
| 658 | // OpenCL Extension v2.0 s5.1.5 and s6.1.5 - Relational Functions |
| 659 | // --- Table 14 --- |
| 660 | // --- 1 argument --- |
| 661 | foreach name = ["isfinite", "isinf", "isnan", "isnormal", "signbit"] in { |
| 662 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>; |
| 663 | def : Builtin<name, [Int, Double], Attr.Const>; |
| 664 | def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>; |
| 665 | def : Builtin<name, [Int, Half], Attr.Const>; |
| 666 | def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>; |
| 667 | } |
| 668 | foreach name = ["any", "all"] in { |
| 669 | def : Builtin<name, [Int, AIGenTypeN], Attr.Const>; |
| 670 | } |
| 671 | |
| 672 | // --- 2 arguments --- |
| 673 | foreach name = ["isequal", "isnotequal", "isgreater", "isgreaterequal", |
| 674 | "isless", "islessequal", "islessgreater", "isordered", |
| 675 | "isunordered"] in { |
| 676 | def : Builtin<name, [GenTypeIntVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar], Attr.Const>; |
| 677 | def : Builtin<name, [Int, Double, Double], Attr.Const>; |
| 678 | def : Builtin<name, [GenTypeLongVecNoScalar, GenTypeDoubleVecNoScalar, GenTypeDoubleVecNoScalar], Attr.Const>; |
| 679 | def : Builtin<name, [Int, Half, Half], Attr.Const>; |
| 680 | def : Builtin<name, [GenTypeShortVecNoScalar, GenTypeHalfVecNoScalar, GenTypeHalfVecNoScalar], Attr.Const>; |
| 681 | } |
| 682 | |
| 683 | // --- 3 arguments --- |
| 684 | foreach name = ["bitselect"] in { |
| 685 | def : Builtin<name, [AGenTypeN, AGenTypeN, AGenTypeN, AGenTypeN], Attr.Const>; |
| 686 | } |
| 687 | foreach name = ["select"] in { |
| 688 | def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, SGenTypeN], Attr.Const>; |
| 689 | def : Builtin<name, [SGenTypeN, SGenTypeN, SGenTypeN, UGenTypeN], Attr.Const>; |
| 690 | def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, UGenTypeN], Attr.Const>; |
| 691 | def : Builtin<name, [UGenTypeN, UGenTypeN, UGenTypeN, SGenTypeN], Attr.Const>; |
| 692 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeIntVecAndScalar], Attr.Const>; |
| 693 | def : Builtin<name, [GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeFloatVecAndScalar, GenTypeUIntVecAndScalar], Attr.Const>; |
| 694 | def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeLongVecAndScalar], Attr.Const>; |
| 695 | def : Builtin<name, [GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeULongVecAndScalar], Attr.Const>; |
| 696 | def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeShortVecAndScalar], Attr.Const>; |
| 697 | def : Builtin<name, [GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeHalfVecAndScalar, GenTypeUShortVecAndScalar], Attr.Const>; |
| 698 | } |
| 699 | |
| 700 | |
Sven van Haastregt | 2fe674b | 2019-11-13 10:16:33 +0000 | [diff] [blame] | 701 | //-------------------------------------------------------------------- |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 702 | // OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions |
Sven van Haastregt | 2fe674b | 2019-11-13 10:16:33 +0000 | [diff] [blame] | 703 | // 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 Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 704 | // --- Table 15 --- |
| 705 | // Variants for OpenCL versions below 2.0, using pointers to the global, local |
| 706 | // and private address spaces. |
| 707 | let MaxVersion = CL20 in { |
| 708 | foreach AS = [GlobalAS, LocalAS, PrivateAS] in { |
| 709 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 710 | foreach name = ["vload" # VSize] in { |
| 711 | def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>; |
| 712 | def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>; |
| 713 | def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>; |
| 714 | def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>; |
| 715 | def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>; |
| 716 | def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>; |
| 717 | def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>; |
| 718 | def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>; |
| 719 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>; |
| 720 | def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>; |
| 721 | def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>; |
| 722 | } |
| 723 | foreach name = ["vstore" # VSize] in { |
| 724 | def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, AS>]>; |
| 725 | def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, AS>]>; |
| 726 | def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, AS>]>; |
| 727 | def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, AS>]>; |
| 728 | def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, AS>]>; |
| 729 | def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, AS>]>; |
| 730 | def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, AS>]>; |
| 731 | def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, AS>]>; |
| 732 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, AS>]>; |
| 733 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, AS>]>; |
| 734 | def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, AS>]>; |
| 735 | } |
| 736 | foreach name = ["vloada_half" # VSize] in { |
| 737 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>; |
| 738 | } |
| 739 | foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { |
| 740 | foreach name = ["vstorea_half" # VSize # rnd] in { |
| 741 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>; |
| 742 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>; |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | // Variants for OpenCL versions above 2.0, using pointers to the generic |
| 749 | // address space. |
| 750 | let MinVersion = CL20 in { |
| 751 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 752 | foreach name = ["vload" # VSize] in { |
| 753 | def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>; |
| 754 | def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>; |
| 755 | def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>; |
| 756 | def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>; |
| 757 | def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>; |
| 758 | def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>; |
| 759 | def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>; |
| 760 | def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>; |
| 761 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>; |
| 762 | def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>; |
| 763 | def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>; |
| 764 | } |
| 765 | foreach name = ["vstore" # VSize] in { |
| 766 | def : Builtin<name, [Void, VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, GenericAS>]>; |
| 767 | def : Builtin<name, [Void, VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, GenericAS>]>; |
| 768 | def : Builtin<name, [Void, VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, GenericAS>]>; |
| 769 | def : Builtin<name, [Void, VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, GenericAS>]>; |
| 770 | def : Builtin<name, [Void, VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, GenericAS>]>; |
| 771 | def : Builtin<name, [Void, VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, GenericAS>]>; |
| 772 | def : Builtin<name, [Void, VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, GenericAS>]>; |
| 773 | def : Builtin<name, [Void, VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, GenericAS>]>; |
| 774 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, GenericAS>]>; |
| 775 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, GenericAS>]>; |
| 776 | def : Builtin<name, [Void, VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>; |
| 777 | } |
| 778 | foreach name = ["vloada_half" # VSize] in { |
| 779 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, GenericAS>]>; |
| 780 | } |
| 781 | foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { |
| 782 | foreach name = ["vstorea_half" # VSize # rnd] in { |
| 783 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, GenericAS>]>; |
| 784 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, GenericAS>]>; |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | } |
| 789 | // Variants using pointers to the constant address space. |
| 790 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 791 | foreach name = ["vload" # VSize] in { |
| 792 | def : Builtin<name, [VectorType<Char, VSize>, Size, PointerType<ConstType<Char>, ConstantAS>]>; |
| 793 | def : Builtin<name, [VectorType<UChar, VSize>, Size, PointerType<ConstType<UChar>, ConstantAS>]>; |
| 794 | def : Builtin<name, [VectorType<Short, VSize>, Size, PointerType<ConstType<Short>, ConstantAS>]>; |
| 795 | def : Builtin<name, [VectorType<UShort, VSize>, Size, PointerType<ConstType<UShort>, ConstantAS>]>; |
| 796 | def : Builtin<name, [VectorType<Int, VSize>, Size, PointerType<ConstType<Int>, ConstantAS>]>; |
| 797 | def : Builtin<name, [VectorType<UInt, VSize>, Size, PointerType<ConstType<UInt>, ConstantAS>]>; |
| 798 | def : Builtin<name, [VectorType<Long, VSize>, Size, PointerType<ConstType<Long>, ConstantAS>]>; |
| 799 | def : Builtin<name, [VectorType<ULong, VSize>, Size, PointerType<ConstType<ULong>, ConstantAS>]>; |
| 800 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Float>, ConstantAS>]>; |
| 801 | def : Builtin<name, [VectorType<Double, VSize>, Size, PointerType<ConstType<Double>, ConstantAS>]>; |
| 802 | def : Builtin<name, [VectorType<Half, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>; |
| 803 | } |
| 804 | foreach name = ["vloada_half" # VSize] in { |
| 805 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, ConstantAS>]>; |
| 806 | } |
| 807 | foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { |
| 808 | foreach name = ["vstorea_half" # VSize # rnd] in { |
| 809 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, ConstantAS>]>; |
| 810 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, ConstantAS>]>; |
| 811 | } |
| 812 | } |
| 813 | } |
Sven van Haastregt | 2fe674b | 2019-11-13 10:16:33 +0000 | [diff] [blame] | 814 | let MaxVersion = CL20 in { |
| 815 | foreach AS = [GlobalAS, LocalAS, PrivateAS] in { |
| 816 | def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>; |
| 817 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 818 | foreach name = ["vload_half" # VSize] in { |
| 819 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>; |
| 820 | } |
| 821 | } |
| 822 | foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { |
| 823 | def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType<Half, AS>]>; |
| 824 | def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType<Half, AS>]>; |
| 825 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 826 | foreach name = ["vstore_half" # VSize # rnd] in { |
| 827 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>; |
| 828 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>; |
| 829 | } |
| 830 | } |
| 831 | } |
| 832 | } |
| 833 | } |
| 834 | let MinVersion = CL20 in { |
| 835 | foreach AS = [GenericAS] in { |
| 836 | def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>; |
| 837 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 838 | foreach name = ["vload_half" # VSize] in { |
| 839 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>; |
| 840 | } |
| 841 | } |
| 842 | foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { |
| 843 | def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType<Half, AS>]>; |
| 844 | def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType<Half, AS>]>; |
| 845 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 846 | foreach name = ["vstore_half" # VSize # rnd] in { |
| 847 | def : Builtin<name, [Void, VectorType<Float, VSize>, Size, PointerType<Half, AS>]>; |
| 848 | def : Builtin<name, [Void, VectorType<Double, VSize>, Size, PointerType<Half, AS>]>; |
| 849 | } |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | foreach AS = [ConstantAS] in { |
| 856 | def : Builtin<"vload_half", [Float, Size, PointerType<ConstType<Half>, AS>]>; |
| 857 | foreach VSize = [2, 3, 4, 8, 16] in { |
| 858 | foreach name = ["vload_half" # VSize] in { |
| 859 | def : Builtin<name, [VectorType<Float, VSize>, Size, PointerType<ConstType<Half>, AS>]>; |
| 860 | } |
| 861 | } |
| 862 | } |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 863 | |
| 864 | //-------------------------------------------------------------------- |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 865 | // OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch |
| 866 | // OpenCL Extension v2.0 s5.1.7 and s6.1.7: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch |
| 867 | // --- Table 18 --- |
| 868 | foreach name = ["async_work_group_copy"] in { |
| 869 | def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Event]>; |
| 870 | def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Event]>; |
| 871 | } |
| 872 | foreach name = ["async_work_group_strided_copy"] in { |
| 873 | def : Builtin<name, [Event, PointerType<AGenTypeN, LocalAS>, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size, Size, Event]>; |
| 874 | def : Builtin<name, [Event, PointerType<AGenTypeN, GlobalAS>, PointerType<ConstType<AGenTypeN>, LocalAS>, Size, Size, Event]>; |
| 875 | } |
| 876 | foreach name = ["wait_group_events"] in { |
| 877 | def : Builtin<name, [Void, Int, PointerType<Event, GenericAS>]>; |
| 878 | } |
| 879 | foreach name = ["prefetch"] in { |
| 880 | def : Builtin<name, [Void, PointerType<ConstType<AGenTypeN>, GlobalAS>, Size]>; |
| 881 | } |
| 882 | |
| 883 | //-------------------------------------------------------------------- |
| 884 | // OpenCL v2.0 s6.13.11 - Atomics Functions. |
| 885 | // Functions that use memory_order and cl_mem_fence_flags enums are not |
| 886 | // declared here as the TableGen backend does not handle enums. |
| 887 | |
Sven van Haastregt | 308b8b7 | 2019-12-18 10:13:51 +0000 | [diff] [blame] | 888 | // OpenCL v1.0 s9.5, s9.6, s9.7 - Atomic Functions for 32-bit integers |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 889 | // --- Table 9.1 --- |
Sven van Haastregt | 308b8b7 | 2019-12-18 10:13:51 +0000 | [diff] [blame] | 890 | let Extension = FuncExtKhrGlobalInt32BaseAtomics in { |
| 891 | foreach Type = [Int, UInt] in { |
| 892 | foreach name = ["atom_add", "atom_sub", "atom_xchg"] in { |
| 893 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type]>; |
| 894 | } |
| 895 | foreach name = ["atom_inc", "atom_dec"] in { |
| 896 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>]>; |
| 897 | } |
| 898 | foreach name = ["atom_cmpxchg"] in { |
| 899 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type, Type]>; |
| 900 | } |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 901 | } |
| 902 | } |
Sven van Haastregt | b714583 | 2019-12-23 12:29:01 +0000 | [diff] [blame] | 903 | // --- Table 9.3 --- |
| 904 | let Extension = FuncExtKhrLocalInt32BaseAtomics in { |
| 905 | foreach Type = [Int, UInt] in { |
| 906 | foreach name = ["atom_add", "atom_sub", "atom_xchg"] in { |
| 907 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>, Type]>; |
| 908 | } |
| 909 | foreach name = ["atom_inc", "atom_dec"] in { |
| 910 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>]>; |
| 911 | } |
| 912 | foreach name = ["atom_cmpxchg"] in { |
| 913 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>, Type, Type]>; |
| 914 | } |
| 915 | } |
| 916 | } |
| 917 | // --- Table 9.5 --- |
| 918 | let Extension = FuncExtKhrInt64BaseAtomics in { |
| 919 | foreach AS = [GlobalAS, LocalAS] in { |
| 920 | foreach Type = [Long, ULong] in { |
| 921 | foreach name = ["atom_add", "atom_sub", "atom_xchg"] in { |
| 922 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type]>; |
| 923 | } |
| 924 | foreach name = ["atom_inc", "atom_dec"] in { |
| 925 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>]>; |
| 926 | } |
| 927 | foreach name = ["atom_cmpxchg"] in { |
| 928 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type, Type]>; |
| 929 | } |
| 930 | } |
| 931 | } |
| 932 | } |
| 933 | // --- Table 9.2 --- |
| 934 | let Extension = FuncExtKhrGlobalInt32ExtendedAtomics in { |
| 935 | foreach Type = [Int, UInt] in { |
| 936 | foreach name = ["atom_min", "atom_max", "atom_and", |
| 937 | "atom_or", "atom_xor"] in { |
| 938 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, GlobalAS>, Type]>; |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | // --- Table 9.4 --- |
| 943 | let Extension = FuncExtKhrLocalInt32ExtendedAtomics in { |
| 944 | foreach Type = [Int, UInt] in { |
| 945 | foreach name = ["atom_min", "atom_max", "atom_and", |
| 946 | "atom_or", "atom_xor"] in { |
| 947 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, LocalAS>, Type]>; |
| 948 | } |
| 949 | } |
| 950 | } |
| 951 | // --- Table 9.6 --- |
| 952 | let Extension = FuncExtKhrInt64ExtendedAtomics in { |
| 953 | foreach AS = [GlobalAS, LocalAS] in { |
| 954 | foreach Type = [Long, ULong] in { |
| 955 | foreach name = ["atom_min", "atom_max", "atom_and", |
| 956 | "atom_or", "atom_xor"] in { |
| 957 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type]>; |
| 958 | } |
| 959 | } |
| 960 | } |
| 961 | } |
| 962 | // OpenCL v1.1 s6.11.1, v1.2 s6.12.11 - Atomic Functions |
| 963 | foreach AS = [GlobalAS, LocalAS] in { |
| 964 | foreach Type = [Int, UInt] in { |
| 965 | foreach name = ["atomic_add", "atomic_sub", "atomic_xchg", |
| 966 | "atomic_min", "atomic_max", "atomic_and", |
| 967 | "atomic_or", "atomic_xor"] in { |
| 968 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type]>; |
| 969 | } |
| 970 | foreach name = ["atomic_inc", "atomic_dec"] in { |
| 971 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>]>; |
| 972 | } |
| 973 | foreach name = ["atomic_cmpxchg"] in { |
| 974 | def : Builtin<name, [Type, PointerType<VolatileType<Type>, AS>, Type, Type]>; |
| 975 | } |
| 976 | } |
| 977 | } |
Sven van Haastregt | cc0ba28 | 2019-08-20 12:21:03 +0000 | [diff] [blame] | 978 | |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 979 | //-------------------------------------------------------------------- |
Sven van Haastregt | e54c83e | 2019-11-26 10:44:49 +0000 | [diff] [blame] | 980 | // OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector Functions |
| 981 | // --- Table 19 --- |
| 982 | foreach name = ["shuffle"] in { |
| 983 | foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in { |
| 984 | foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in { |
| 985 | def : Builtin<name, [GenericType<"TLAll" # VSize1.Name, TLAll, VSize1>, |
| 986 | GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>, |
| 987 | GenericType<"TLAllUnsigned" # VSize1.Name, TLAllUnsigned, VSize1>], |
| 988 | Attr.Const>; |
| 989 | } |
| 990 | } |
| 991 | } |
| 992 | foreach name = ["shuffle2"] in { |
| 993 | foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in { |
| 994 | foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in { |
| 995 | def : Builtin<name, [GenericType<"TLAll" # VSize1.Name, TLAll, VSize1>, |
| 996 | GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>, |
| 997 | GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>, |
| 998 | GenericType<"TLAllUnsigned" # VSize1.Name, TLAllUnsigned, VSize1>], |
| 999 | Attr.Const>; |
| 1000 | } |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | //-------------------------------------------------------------------- |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1005 | // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14: Image Read and Write Functions |
| 1006 | // OpenCL Extension v2.0 s5.1.8 and s6.1.8: Image Read and Write Functions |
| 1007 | // --- Table 22: Image Read Functions with Samplers --- |
| 1008 | foreach imgTy = [Image1d] in { |
| 1009 | foreach coordTy = [Int, Float] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1010 | def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>; |
| 1011 | def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>; |
| 1012 | def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, coordTy], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1013 | } |
| 1014 | } |
| 1015 | foreach imgTy = [Image2d, Image1dArray] in { |
| 1016 | foreach coordTy = [Int, Float] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1017 | def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>; |
| 1018 | def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>; |
| 1019 | def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1020 | } |
| 1021 | } |
| 1022 | foreach imgTy = [Image3d, Image2dArray] in { |
| 1023 | foreach coordTy = [Int, Float] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1024 | def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>; |
| 1025 | def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>; |
| 1026 | def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1027 | } |
| 1028 | } |
| 1029 | foreach coordTy = [Int, Float] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1030 | def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, "RO">, Sampler, VectorType<coordTy, 2>], Attr.Pure>; |
| 1031 | def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, "RO">, Sampler, VectorType<coordTy, 4>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | // --- Table 23: Sampler-less Read Functions --- |
| 1035 | foreach aQual = ["RO", "RW"] in { |
| 1036 | foreach imgTy = [Image2d, Image1dArray] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1037 | def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>; |
| 1038 | def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>; |
| 1039 | def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1040 | } |
| 1041 | foreach imgTy = [Image3d, Image2dArray] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1042 | def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>; |
| 1043 | def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>; |
| 1044 | def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1045 | } |
| 1046 | foreach imgTy = [Image1d, Image1dBuffer] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1047 | def : Builtin<"read_imagef", [VectorType<Float, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>; |
| 1048 | def : Builtin<"read_imagei", [VectorType<Int, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>; |
| 1049 | def : Builtin<"read_imageui", [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1050 | } |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1051 | def : Builtin<"read_imagef", [Float, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>], Attr.Pure>; |
| 1052 | def : Builtin<"read_imagef", [Float, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | // --- Table 24: Image Write Functions --- |
| 1056 | foreach aQual = ["WO", "RW"] in { |
| 1057 | foreach imgTy = [Image2d] in { |
| 1058 | def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>; |
| 1059 | def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>; |
| 1060 | def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>; |
| 1061 | } |
| 1062 | foreach imgTy = [Image2dArray] in { |
| 1063 | def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>; |
| 1064 | def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>; |
| 1065 | def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>; |
| 1066 | } |
| 1067 | foreach imgTy = [Image1d, Image1dBuffer] in { |
| 1068 | def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, Int, VectorType<Float, 4>]>; |
| 1069 | def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, Int, VectorType<Int, 4>]>; |
| 1070 | def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, Int, VectorType<UInt, 4>]>; |
| 1071 | } |
| 1072 | foreach imgTy = [Image1dArray] in { |
| 1073 | def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Float, 4>]>; |
| 1074 | def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<Int, 4>]>; |
| 1075 | def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, VectorType<UInt, 4>]>; |
| 1076 | } |
| 1077 | foreach imgTy = [Image3d] in { |
| 1078 | def : Builtin<"write_imagef", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Float, 4>]>; |
| 1079 | def : Builtin<"write_imagei", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<Int, 4>]>; |
| 1080 | def : Builtin<"write_imageui", [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, VectorType<UInt, 4>]>; |
| 1081 | } |
| 1082 | def : Builtin<"write_imagef", [Void, ImageType<Image2dDepth, aQual>, VectorType<Int, 2>, Float]>; |
| 1083 | def : Builtin<"write_imagef", [Void, ImageType<Image2dArrayDepth, aQual>, VectorType<Int, 4>, Float]>; |
| 1084 | } |
| 1085 | |
Sven van Haastregt | 2a69ed0 | 2019-09-25 09:12:59 +0000 | [diff] [blame] | 1086 | // --- Table 25: Image Query Functions --- |
| 1087 | foreach aQual = ["RO", "WO", "RW"] in { |
| 1088 | foreach imgTy = [Image1d, Image1dBuffer, Image2d, Image3d, |
| 1089 | Image1dArray, Image2dArray, Image2dDepth, |
| 1090 | Image2dArrayDepth] in { |
| 1091 | foreach name = ["get_image_width", "get_image_channel_data_type", |
| 1092 | "get_image_channel_order"] in { |
| 1093 | def : Builtin<name, [Int, ImageType<imgTy, aQual>]>; |
| 1094 | } |
| 1095 | } |
| 1096 | foreach imgTy = [Image2d, Image3d, Image2dArray, Image2dDepth, |
| 1097 | Image2dArrayDepth] in { |
| 1098 | def : Builtin<"get_image_height", [Int, ImageType<imgTy, aQual>]>; |
| 1099 | } |
| 1100 | def : Builtin<"get_image_depth", [Int, ImageType<Image3d, aQual>]>; |
| 1101 | foreach imgTy = [Image2d, Image2dArray, Image2dDepth, |
| 1102 | Image2dArrayDepth] in { |
| 1103 | def : Builtin<"get_image_dim", [VectorType<Int, 2>, ImageType<imgTy, aQual>]>; |
| 1104 | } |
| 1105 | def : Builtin<"get_image_dim", [VectorType<Int, 4>, ImageType<Image3d, aQual>]>; |
| 1106 | foreach imgTy = [Image1dArray, Image2dArray, Image2dArrayDepth] in { |
| 1107 | def : Builtin<"get_image_array_size", [Size, ImageType<imgTy, aQual>]>; |
| 1108 | } |
| 1109 | } |
| 1110 | |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1111 | // OpenCL extension v2.0 s5.1.9: Built-in Image Read Functions |
| 1112 | // --- Table 8 --- |
| 1113 | foreach aQual = ["RO"] in { |
| 1114 | foreach name = ["read_imageh"] in { |
| 1115 | foreach coordTy = [Int, Float] in { |
| 1116 | foreach imgTy = [Image2d, Image1dArray] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1117 | def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 2>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1118 | } |
| 1119 | foreach imgTy = [Image3d, Image2dArray] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1120 | def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<coordTy, 4>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1121 | } |
| 1122 | foreach imgTy = [Image1d] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1123 | def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Sampler, coordTy], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1124 | } |
| 1125 | } |
| 1126 | } |
| 1127 | } |
| 1128 | // OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions |
| 1129 | // --- Table 9 --- |
| 1130 | foreach aQual = ["RO", "RW"] in { |
| 1131 | foreach name = ["read_imageh"] in { |
| 1132 | foreach imgTy = [Image2d, Image1dArray] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1133 | def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 2>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1134 | } |
| 1135 | foreach imgTy = [Image3d, Image2dArray] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1136 | def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, VectorType<Int, 4>], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1137 | } |
| 1138 | foreach imgTy = [Image1d, Image1dBuffer] in { |
Sven van Haastregt | 9a8d477 | 2019-11-05 10:07:43 +0000 | [diff] [blame] | 1139 | def : Builtin<name, [VectorType<Half, 4>, ImageType<imgTy, aQual>, Int], Attr.Pure>; |
Sven van Haastregt | 988f1e3 | 2019-09-05 10:01:24 +0000 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | } |
| 1143 | // OpenCL extension v2.0 s5.1.11: Built-in Image Write Functions |
| 1144 | // --- Table 10 --- |
| 1145 | foreach aQual = ["WO", "RW"] in { |
| 1146 | foreach name = ["write_imageh"] in { |
| 1147 | def : Builtin<name, [Void, ImageType<Image2d, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>; |
| 1148 | def : Builtin<name, [Void, ImageType<Image2dArray, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>; |
| 1149 | def : Builtin<name, [Void, ImageType<Image1d, aQual>, Int, VectorType<Half, 4>]>; |
| 1150 | def : Builtin<name, [Void, ImageType<Image1dBuffer, aQual>, Int, VectorType<Half, 4>]>; |
| 1151 | def : Builtin<name, [Void, ImageType<Image1dArray, aQual>, VectorType<Int, 2>, VectorType<Half, 4>]>; |
| 1152 | def : Builtin<name, [Void, ImageType<Image3d, aQual>, VectorType<Int, 4>, VectorType<Half, 4>]>; |
| 1153 | } |
| 1154 | } |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 1155 | |
| 1156 | |
Sven van Haastregt | e54c83e | 2019-11-26 10:44:49 +0000 | [diff] [blame] | 1157 | //-------------------------------------------------------------------- |
| 1158 | // OpenCL v2.0 s6.13.15 - Work-group Functions |
| 1159 | // --- Table 26 --- |
| 1160 | let MinVersion = CL20 in { |
| 1161 | foreach name = ["work_group_all", "work_group_any"] in { |
| 1162 | def : Builtin<name, [Int, Int], Attr.Convergent>; |
| 1163 | } |
| 1164 | foreach name = ["work_group_broadcast"] in { |
| 1165 | def : Builtin<name, [IntLongFloatGenType1, IntLongFloatGenType1, Size], Attr.Convergent>; |
| 1166 | def : Builtin<name, [IntLongFloatGenType1, IntLongFloatGenType1, Size, Size], Attr.Convergent>; |
| 1167 | def : Builtin<name, [IntLongFloatGenType1, IntLongFloatGenType1, Size, Size, Size], Attr.Convergent>; |
| 1168 | } |
| 1169 | foreach op = ["add", "min", "max"] in { |
| 1170 | foreach name = ["work_group_reduce_", "work_group_scan_exclusive_", |
| 1171 | "work_group_scan_inclusive_"] in { |
| 1172 | def : Builtin<name # op, [IntLongFloatGenType1, IntLongFloatGenType1], Attr.Convergent>; |
| 1173 | } |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 1178 | // OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions |
Sven van Haastregt | ed69faa | 2019-09-19 13:41:51 +0000 | [diff] [blame] | 1179 | let MinVersion = CL20 in { |
Sven van Haastregt | 308b8b7 | 2019-12-18 10:13:51 +0000 | [diff] [blame] | 1180 | let Extension = FuncExtKhrSubgroups in { |
Sven van Haastregt | 89fb9e8 | 2019-07-29 14:55:29 +0000 | [diff] [blame] | 1181 | def get_sub_group_size : Builtin<"get_sub_group_size", [UInt]>; |
| 1182 | def get_max_sub_group_size : Builtin<"get_max_sub_group_size", [UInt]>; |
| 1183 | def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>; |
Sven van Haastregt | 79a222f | 2019-06-03 09:39:11 +0000 | [diff] [blame] | 1184 | } |
| 1185 | } |
Sven van Haastregt | 4a188fd | 2019-12-30 10:47:58 +0000 | [diff] [blame^] | 1186 | |
| 1187 | //-------------------------------------------------------------------- |
| 1188 | // End of the builtin functions defined in the OpenCL C specification. |
| 1189 | // Builtin functions defined in the OpenCL C Extension are below. |
| 1190 | //-------------------------------------------------------------------- |
| 1191 | |
| 1192 | |
| 1193 | // OpenCL Extension v2.0 s9.18 - Mipmaps |
| 1194 | let Extension = FuncExtKhrMipmapImage in { |
| 1195 | // Added to section 6.13.14.2. |
| 1196 | foreach aQual = ["RO"] in { |
| 1197 | foreach imgTy = [Image2d] in { |
| 1198 | foreach name = ["read_imagef"] in { |
| 1199 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1200 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1201 | } |
| 1202 | foreach name = ["read_imagei"] in { |
| 1203 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1204 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1205 | } |
| 1206 | foreach name = ["read_imageui"] in { |
| 1207 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1208 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1209 | } |
| 1210 | } |
| 1211 | foreach imgTy = [Image2dDepth] in { |
| 1212 | foreach name = ["read_imagef"] in { |
| 1213 | def : Builtin<name, [Float, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1214 | def : Builtin<name, [Float, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1215 | } |
| 1216 | } |
| 1217 | foreach imgTy = [Image1d] in { |
| 1218 | foreach name = ["read_imagef"] in { |
| 1219 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float], Attr.Pure>; |
| 1220 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float, Float], Attr.Pure>; |
| 1221 | } |
| 1222 | foreach name = ["read_imagei"] in { |
| 1223 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float], Attr.Pure>; |
| 1224 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float, Float], Attr.Pure>; |
| 1225 | } |
| 1226 | foreach name = ["read_imageui"] in { |
| 1227 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float], Attr.Pure>; |
| 1228 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, Float, Float, Float], Attr.Pure>; |
| 1229 | } |
| 1230 | } |
| 1231 | foreach imgTy = [Image3d] in { |
| 1232 | foreach name = ["read_imagef"] in { |
| 1233 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 4>, VectorType<Float, 4>], Attr.Pure>; |
| 1234 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1235 | } |
| 1236 | foreach name = ["read_imagei"] in { |
| 1237 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 4>, VectorType<Float, 4>], Attr.Pure>; |
| 1238 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1239 | } |
| 1240 | foreach name = ["read_imageui"] in { |
| 1241 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 4>, VectorType<Float, 4>], Attr.Pure>; |
| 1242 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1243 | } |
| 1244 | } |
| 1245 | foreach imgTy = [Image1dArray] in { |
| 1246 | foreach name = ["read_imagef"] in { |
| 1247 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1248 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float, Float], Attr.Pure>; |
| 1249 | } |
| 1250 | foreach name = ["read_imagei"] in { |
| 1251 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1252 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float, Float], Attr.Pure>; |
| 1253 | } |
| 1254 | foreach name = ["read_imageui"] in { |
| 1255 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float], Attr.Pure>; |
| 1256 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 2>, Float, Float], Attr.Pure>; |
| 1257 | } |
| 1258 | } |
| 1259 | foreach imgTy = [Image2dArray] in { |
| 1260 | foreach name = ["read_imagef"] in { |
| 1261 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1262 | def : Builtin<name, [VectorType<Float, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1263 | } |
| 1264 | foreach name = ["read_imagei"] in { |
| 1265 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1266 | def : Builtin<name, [VectorType<Int, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1267 | } |
| 1268 | foreach name = ["read_imageui"] in { |
| 1269 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1270 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1271 | } |
| 1272 | } |
| 1273 | foreach imgTy = [Image2dArrayDepth] in { |
| 1274 | foreach name = ["read_imagef"] in { |
| 1275 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, Float], Attr.Pure>; |
| 1276 | def : Builtin<name, [VectorType<UInt, 4>, ImageType<imgTy, aQual>, Sampler, VectorType<Float, 4>, VectorType<Float, 2>, VectorType<Float, 2>], Attr.Pure>; |
| 1277 | } |
| 1278 | } |
| 1279 | } |
| 1280 | // Added to section 6.13.14.4. |
| 1281 | foreach aQual = ["WO"] in { |
| 1282 | foreach imgTy = [Image2d] in { |
| 1283 | foreach name = ["write_imagef"] in { |
| 1284 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Float, 4>]>; |
| 1285 | } |
| 1286 | foreach name = ["write_imagei"] in { |
| 1287 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Int, 4>]>; |
| 1288 | } |
| 1289 | foreach name = ["write_imageui"] in { |
| 1290 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<UInt, 4>]>; |
| 1291 | } |
| 1292 | } |
| 1293 | foreach imgTy = [Image2dDepth] in { |
| 1294 | foreach name = ["write_imagef"] in { |
| 1295 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, Float]>; |
| 1296 | } |
| 1297 | } |
| 1298 | foreach imgTy = [Image1d] in { |
| 1299 | foreach name = ["write_imagef"] in { |
| 1300 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, Int, Int, VectorType<Float, 4>]>; |
| 1301 | } |
| 1302 | foreach name = ["write_imagei"] in { |
| 1303 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, Int, Int, VectorType<Int, 4>]>; |
| 1304 | } |
| 1305 | foreach name = ["write_imageui"] in { |
| 1306 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, Int, Int, VectorType<UInt, 4>]>; |
| 1307 | } |
| 1308 | } |
| 1309 | foreach imgTy = [Image1dArray] in { |
| 1310 | foreach name = ["write_imagef"] in { |
| 1311 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Float, 4>]>; |
| 1312 | } |
| 1313 | foreach name = ["write_imagei"] in { |
| 1314 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<Int, 4>]>; |
| 1315 | } |
| 1316 | foreach name = ["write_imageui"] in { |
| 1317 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 2>, Int, VectorType<UInt, 4>]>; |
| 1318 | } |
| 1319 | } |
| 1320 | foreach imgTy = [Image2dArray] in { |
| 1321 | foreach name = ["write_imagef"] in { |
| 1322 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Float, 4>]>; |
| 1323 | } |
| 1324 | foreach name = ["write_imagei"] in { |
| 1325 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Int, 4>]>; |
| 1326 | } |
| 1327 | foreach name = ["write_imageui"] in { |
| 1328 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<UInt, 4>]>; |
| 1329 | } |
| 1330 | } |
| 1331 | foreach imgTy = [Image2dArrayDepth] in { |
| 1332 | foreach name = ["write_imagef"] in { |
| 1333 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, Float]>; |
| 1334 | } |
| 1335 | } |
| 1336 | let Extension = FuncExtKhrMipmapAndWrite3d in { |
| 1337 | foreach imgTy = [Image3d] in { |
| 1338 | foreach name = ["write_imagef"] in { |
| 1339 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Float, 4>]>; |
| 1340 | } |
| 1341 | foreach name = ["write_imagei"] in { |
| 1342 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<Int, 4>]>; |
| 1343 | } |
| 1344 | foreach name = ["write_imageui"] in { |
| 1345 | def : Builtin<name, [Void, ImageType<imgTy, aQual>, VectorType<Int, 4>, Int, VectorType<UInt, 4>]>; |
| 1346 | } |
| 1347 | } |
| 1348 | } |
| 1349 | } |
| 1350 | // Added to section 6.13.14.5 |
| 1351 | foreach aQual = ["RO", "WO", "RW"] in { |
| 1352 | foreach name = ["get_image_num_mip_levels"] in { |
| 1353 | foreach imgTy = [Image1d, Image2d, Image3d, Image1dArray, Image2dArray, Image2dDepth, Image2dArrayDepth] in { |
| 1354 | def : Builtin<name, [Int, ImageType<imgTy, aQual>]>; |
| 1355 | } |
| 1356 | } |
| 1357 | } |
| 1358 | } |