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