1//===-- SPIRVBuiltins.td - Describe SPIRV Builtins ---------*- tablegen -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // TableGen records defining implementation details of demangled builtin 10 // functions and types. 11 // 12 //===----------------------------------------------------------------------===// 13 14// Define SPIR-V external builtin/instruction sets 15def InstructionSet : GenericEnum { 16 let FilterClass = "InstructionSet"; 17 let NameField = "Name"; 18 let ValueField = "Value"; 19} 20 21class InstructionSet<bits<32> value> { 22 string Name = NAME; 23 bits<32> Value = value; 24} 25 26def OpenCL_std : InstructionSet<0>; 27def GLSL_std_450 : InstructionSet<1>; 28def SPV_AMD_shader_trinary_minmax : InstructionSet<2>; 29 30// Define various builtin groups 31def BuiltinGroup : GenericEnum { 32 let FilterClass = "BuiltinGroup"; 33} 34 35class BuiltinGroup; 36 37def Extended : BuiltinGroup; 38def Relational : BuiltinGroup; 39def Group : BuiltinGroup; 40def Variable : BuiltinGroup; 41def Atomic : BuiltinGroup; 42def Barrier : BuiltinGroup; 43def Dot : BuiltinGroup; 44def GetQuery : BuiltinGroup; 45def ImageSizeQuery : BuiltinGroup; 46def ImageMiscQuery : BuiltinGroup; 47def Convert : BuiltinGroup; 48def ReadImage : BuiltinGroup; 49def WriteImage : BuiltinGroup; 50def SampleImage : BuiltinGroup; 51def Select : BuiltinGroup; 52def SpecConstant : BuiltinGroup; 53def Enqueue : BuiltinGroup; 54def AsyncCopy : BuiltinGroup; 55def VectorLoadStore : BuiltinGroup; 56def LoadStore : BuiltinGroup; 57 58//===----------------------------------------------------------------------===// 59// Class defining a demangled builtin record. The information in the record 60// should be used to expand the builtin into either native SPIR-V instructions 61// or an external call (in case of builtins without a direct mapping). 62// 63// name is the demangled name of the given builtin. 64// set specifies which external instruction set the builtin belongs to. 65// group specifies to which implementation group given record belongs. 66// minNumArgs is the minimum required number of arguments for lowering. 67// maxNumArgs specifies the maximum used number of arguments for lowering. 68//===----------------------------------------------------------------------===// 69class DemangledBuiltin<string name, InstructionSet set, BuiltinGroup group, bits<8> minNumArgs, bits<8> maxNumArgs> { 70 string Name = name; 71 InstructionSet Set = set; 72 BuiltinGroup Group = group; 73 bits<8> MinNumArgs = minNumArgs; 74 bits<8> MaxNumArgs = maxNumArgs; 75} 76 77// Table gathering all the builtins. 78def DemangledBuiltins : GenericTable { 79 let FilterClass = "DemangledBuiltin"; 80 let Fields = ["Name", "Set", "Group", "MinNumArgs", "MaxNumArgs"]; 81 string TypeOf_Set = "InstructionSet"; 82 string TypeOf_Group = "BuiltinGroup"; 83} 84 85// Function to lookup builtins by their demangled name and set. 86def lookupBuiltin : SearchIndex { 87 let Table = DemangledBuiltins; 88 let Key = ["Name", "Set"]; 89} 90 91// Dot builtin record: 92def : DemangledBuiltin<"dot", OpenCL_std, Dot, 2, 2>; 93 94// Image builtin records: 95def : DemangledBuiltin<"read_imagei", OpenCL_std, ReadImage, 2, 4>; 96def : DemangledBuiltin<"read_imageui", OpenCL_std, ReadImage, 2, 4>; 97def : DemangledBuiltin<"read_imagef", OpenCL_std, ReadImage, 2, 4>; 98 99def : DemangledBuiltin<"write_imagef", OpenCL_std, WriteImage, 3, 4>; 100def : DemangledBuiltin<"write_imagei", OpenCL_std, WriteImage, 3, 4>; 101def : DemangledBuiltin<"write_imageui", OpenCL_std, WriteImage, 3, 4>; 102def : DemangledBuiltin<"write_imageh", OpenCL_std, WriteImage, 3, 4>; 103 104def : DemangledBuiltin<"__translate_sampler_initializer", OpenCL_std, SampleImage, 1, 1>; 105def : DemangledBuiltin<"__spirv_SampledImage", OpenCL_std, SampleImage, 2, 2>; 106def : DemangledBuiltin<"__spirv_ImageSampleExplicitLod", OpenCL_std, SampleImage, 3, 4>; 107 108// Select builtin record: 109def : DemangledBuiltin<"__spirv_Select", OpenCL_std, Select, 3, 3>; 110 111//===----------------------------------------------------------------------===// 112// Class defining an extended builtin record used for lowering into an 113// OpExtInst instruction. 114// 115// name is the demangled name of the given builtin. 116// set specifies which external instruction set the builtin belongs to. 117// number specifies the number of the instruction in the external set. 118//===----------------------------------------------------------------------===// 119class ExtendedBuiltin<string name, InstructionSet set, int number> { 120 string Name = name; 121 InstructionSet Set = set; 122 bits<32> Number = number; 123} 124 125// Table gathering all the extended builtins. 126def ExtendedBuiltins : GenericTable { 127 let FilterClass = "ExtendedBuiltin"; 128 let Fields = ["Name", "Set", "Number"]; 129 string TypeOf_Set = "InstructionSet"; 130} 131 132// Function to lookup extended builtins by their name and set. 133def lookupExtendedBuiltin : SearchIndex { 134 let Table = ExtendedBuiltins; 135 let Key = ["Name", "Set"]; 136} 137 138// Function to lookup extended builtins by their set and number. 139def lookupExtendedBuiltinBySetAndNumber : SearchIndex { 140 let Table = ExtendedBuiltins; 141 let Key = ["Set", "Number"]; 142} 143 144// OpenCL extended instruction enums 145def OpenCLExtInst : GenericEnum { 146 let FilterClass = "OpenCLExtInst"; 147 let NameField = "Name"; 148 let ValueField = "Value"; 149} 150 151class OpenCLExtInst<string name, bits<32> value> { 152 string Name = name; 153 bits<32> Value = value; 154} 155 156// GLSL extended instruction enums 157def GLSLExtInst : GenericEnum { 158 let FilterClass = "GLSLExtInst"; 159 let NameField = "Name"; 160 let ValueField = "Value"; 161} 162 163class GLSLExtInst<string name, bits<32> value> { 164 string Name = name; 165 bits<32> Value = value; 166} 167 168// Multiclass used to define at the same time both a demangled builtin record 169// and a corresponding extended builtin record. 170multiclass DemangledExtendedBuiltin<string name, InstructionSet set, int number> { 171 def : DemangledBuiltin<name, set, Extended, 1, 3>; 172 def : ExtendedBuiltin<name, set, number>; 173 174 if !eq(set, OpenCL_std) then { 175 def : OpenCLExtInst<name, number>; 176 } 177 178 if !eq(set, GLSL_std_450) then { 179 def : GLSLExtInst<name, number>; 180 } 181} 182 183// Extended builtin records: 184defm : DemangledExtendedBuiltin<"acos", OpenCL_std, 0>; 185defm : DemangledExtendedBuiltin<"acosh", OpenCL_std, 1>; 186defm : DemangledExtendedBuiltin<"acospi", OpenCL_std, 2>; 187defm : DemangledExtendedBuiltin<"asin", OpenCL_std, 3>; 188defm : DemangledExtendedBuiltin<"asinh", OpenCL_std, 4>; 189defm : DemangledExtendedBuiltin<"asinpi", OpenCL_std, 5>; 190defm : DemangledExtendedBuiltin<"atan", OpenCL_std, 6>; 191defm : DemangledExtendedBuiltin<"atan2", OpenCL_std, 7>; 192defm : DemangledExtendedBuiltin<"atanh", OpenCL_std, 8>; 193defm : DemangledExtendedBuiltin<"atanpi", OpenCL_std, 9>; 194defm : DemangledExtendedBuiltin<"atan2pi", OpenCL_std, 10>; 195defm : DemangledExtendedBuiltin<"cbrt", OpenCL_std, 11>; 196defm : DemangledExtendedBuiltin<"ceil", OpenCL_std, 12>; 197defm : DemangledExtendedBuiltin<"copysign", OpenCL_std, 13>; 198defm : DemangledExtendedBuiltin<"cos", OpenCL_std, 14>; 199defm : DemangledExtendedBuiltin<"cosh", OpenCL_std, 15>; 200defm : DemangledExtendedBuiltin<"cospi", OpenCL_std, 16>; 201defm : DemangledExtendedBuiltin<"erfc", OpenCL_std, 17>; 202defm : DemangledExtendedBuiltin<"erf", OpenCL_std, 18>; 203defm : DemangledExtendedBuiltin<"exp", OpenCL_std, 19>; 204defm : DemangledExtendedBuiltin<"exp2", OpenCL_std, 20>; 205defm : DemangledExtendedBuiltin<"exp10", OpenCL_std, 21>; 206defm : DemangledExtendedBuiltin<"expm1", OpenCL_std, 22>; 207defm : DemangledExtendedBuiltin<"fabs", OpenCL_std, 23>; 208defm : DemangledExtendedBuiltin<"fdim", OpenCL_std, 24>; 209defm : DemangledExtendedBuiltin<"floor", OpenCL_std, 25>; 210defm : DemangledExtendedBuiltin<"fma", OpenCL_std, 26>; 211defm : DemangledExtendedBuiltin<"fmax", OpenCL_std, 27>; 212defm : DemangledExtendedBuiltin<"fmin", OpenCL_std, 28>; 213defm : DemangledExtendedBuiltin<"fmod", OpenCL_std, 29>; 214defm : DemangledExtendedBuiltin<"fract", OpenCL_std, 30>; 215defm : DemangledExtendedBuiltin<"frexp", OpenCL_std, 31>; 216defm : DemangledExtendedBuiltin<"hypot", OpenCL_std, 32>; 217defm : DemangledExtendedBuiltin<"ilogb", OpenCL_std, 33>; 218defm : DemangledExtendedBuiltin<"ldexp", OpenCL_std, 34>; 219defm : DemangledExtendedBuiltin<"lgamma", OpenCL_std, 35>; 220defm : DemangledExtendedBuiltin<"lgamma_r", OpenCL_std, 36>; 221defm : DemangledExtendedBuiltin<"log", OpenCL_std, 37>; 222defm : DemangledExtendedBuiltin<"log2", OpenCL_std, 38>; 223defm : DemangledExtendedBuiltin<"log10", OpenCL_std, 39>; 224defm : DemangledExtendedBuiltin<"log1p", OpenCL_std, 40>; 225defm : DemangledExtendedBuiltin<"logb", OpenCL_std, 41>; 226defm : DemangledExtendedBuiltin<"mad", OpenCL_std, 42>; 227defm : DemangledExtendedBuiltin<"maxmag", OpenCL_std, 43>; 228defm : DemangledExtendedBuiltin<"minmag", OpenCL_std, 44>; 229defm : DemangledExtendedBuiltin<"modf", OpenCL_std, 45>; 230defm : DemangledExtendedBuiltin<"nan", OpenCL_std, 46>; 231defm : DemangledExtendedBuiltin<"nextafter", OpenCL_std, 47>; 232defm : DemangledExtendedBuiltin<"pow", OpenCL_std, 48>; 233defm : DemangledExtendedBuiltin<"pown", OpenCL_std, 49>; 234defm : DemangledExtendedBuiltin<"powr", OpenCL_std, 50>; 235defm : DemangledExtendedBuiltin<"remainder", OpenCL_std, 51>; 236defm : DemangledExtendedBuiltin<"remquo", OpenCL_std, 52>; 237defm : DemangledExtendedBuiltin<"rint", OpenCL_std, 53>; 238defm : DemangledExtendedBuiltin<"rootn", OpenCL_std, 54>; 239defm : DemangledExtendedBuiltin<"round", OpenCL_std, 55>; 240defm : DemangledExtendedBuiltin<"rsqrt", OpenCL_std, 56>; 241defm : DemangledExtendedBuiltin<"sin", OpenCL_std, 57>; 242defm : DemangledExtendedBuiltin<"sincos", OpenCL_std, 58>; 243defm : DemangledExtendedBuiltin<"sinh", OpenCL_std, 59>; 244defm : DemangledExtendedBuiltin<"sinpi", OpenCL_std, 60>; 245defm : DemangledExtendedBuiltin<"sqrt", OpenCL_std, 61>; 246defm : DemangledExtendedBuiltin<"tan", OpenCL_std, 62>; 247defm : DemangledExtendedBuiltin<"tanh", OpenCL_std, 63>; 248defm : DemangledExtendedBuiltin<"tanpi", OpenCL_std, 64>; 249defm : DemangledExtendedBuiltin<"tgamma", OpenCL_std, 65>; 250defm : DemangledExtendedBuiltin<"trunc", OpenCL_std, 66>; 251defm : DemangledExtendedBuiltin<"half_cos", OpenCL_std, 67>; 252defm : DemangledExtendedBuiltin<"half_divide", OpenCL_std, 68>; 253defm : DemangledExtendedBuiltin<"half_exp", OpenCL_std, 69>; 254defm : DemangledExtendedBuiltin<"half_exp2", OpenCL_std, 70>; 255defm : DemangledExtendedBuiltin<"half_exp10", OpenCL_std, 71>; 256defm : DemangledExtendedBuiltin<"half_log", OpenCL_std, 72>; 257defm : DemangledExtendedBuiltin<"half_log2", OpenCL_std, 73>; 258defm : DemangledExtendedBuiltin<"half_log10", OpenCL_std, 74>; 259defm : DemangledExtendedBuiltin<"half_powr", OpenCL_std, 75>; 260defm : DemangledExtendedBuiltin<"half_recip", OpenCL_std, 76>; 261defm : DemangledExtendedBuiltin<"half_rsqrt", OpenCL_std, 77>; 262defm : DemangledExtendedBuiltin<"half_sin", OpenCL_std, 78>; 263defm : DemangledExtendedBuiltin<"half_sqrt", OpenCL_std, 79>; 264defm : DemangledExtendedBuiltin<"half_tan", OpenCL_std, 80>; 265defm : DemangledExtendedBuiltin<"native_cos", OpenCL_std, 81>; 266defm : DemangledExtendedBuiltin<"native_divide", OpenCL_std, 82>; 267defm : DemangledExtendedBuiltin<"native_exp", OpenCL_std, 83>; 268defm : DemangledExtendedBuiltin<"native_exp2", OpenCL_std, 84>; 269defm : DemangledExtendedBuiltin<"native_exp10", OpenCL_std, 85>; 270defm : DemangledExtendedBuiltin<"native_log", OpenCL_std, 86>; 271defm : DemangledExtendedBuiltin<"native_log2", OpenCL_std, 87>; 272defm : DemangledExtendedBuiltin<"native_log10", OpenCL_std, 88>; 273defm : DemangledExtendedBuiltin<"native_powr", OpenCL_std, 89>; 274defm : DemangledExtendedBuiltin<"native_recip", OpenCL_std, 90>; 275defm : DemangledExtendedBuiltin<"native_rsqrt", OpenCL_std, 91>; 276defm : DemangledExtendedBuiltin<"native_sin", OpenCL_std, 92>; 277defm : DemangledExtendedBuiltin<"native_sqrt", OpenCL_std, 93>; 278defm : DemangledExtendedBuiltin<"native_tan", OpenCL_std, 94>; 279defm : DemangledExtendedBuiltin<"s_abs", OpenCL_std, 141>; 280defm : DemangledExtendedBuiltin<"s_abs_diff", OpenCL_std, 142>; 281defm : DemangledExtendedBuiltin<"s_add_sat", OpenCL_std, 143>; 282defm : DemangledExtendedBuiltin<"u_add_sat", OpenCL_std, 144>; 283defm : DemangledExtendedBuiltin<"s_hadd", OpenCL_std, 145>; 284defm : DemangledExtendedBuiltin<"u_hadd", OpenCL_std, 146>; 285defm : DemangledExtendedBuiltin<"s_rhadd", OpenCL_std, 147>; 286defm : DemangledExtendedBuiltin<"u_rhadd", OpenCL_std, 148>; 287defm : DemangledExtendedBuiltin<"s_clamp", OpenCL_std, 149>; 288defm : DemangledExtendedBuiltin<"u_clamp", OpenCL_std, 150>; 289defm : DemangledExtendedBuiltin<"clz", OpenCL_std, 151>; 290defm : DemangledExtendedBuiltin<"ctz", OpenCL_std, 152>; 291defm : DemangledExtendedBuiltin<"s_mad_hi", OpenCL_std, 153>; 292defm : DemangledExtendedBuiltin<"u_mad_sat", OpenCL_std, 154>; 293defm : DemangledExtendedBuiltin<"s_mad_sat", OpenCL_std, 155>; 294defm : DemangledExtendedBuiltin<"s_max", OpenCL_std, 156>; 295defm : DemangledExtendedBuiltin<"u_max", OpenCL_std, 157>; 296defm : DemangledExtendedBuiltin<"s_min", OpenCL_std, 158>; 297defm : DemangledExtendedBuiltin<"u_min", OpenCL_std, 159>; 298defm : DemangledExtendedBuiltin<"s_mul_hi", OpenCL_std, 160>; 299defm : DemangledExtendedBuiltin<"rotate", OpenCL_std, 161>; 300defm : DemangledExtendedBuiltin<"s_sub_sat", OpenCL_std, 162>; 301defm : DemangledExtendedBuiltin<"u_sub_sat", OpenCL_std, 163>; 302defm : DemangledExtendedBuiltin<"u_upsample", OpenCL_std, 164>; 303defm : DemangledExtendedBuiltin<"s_upsample", OpenCL_std, 165>; 304defm : DemangledExtendedBuiltin<"popcount", OpenCL_std, 166>; 305defm : DemangledExtendedBuiltin<"s_mad24", OpenCL_std, 167>; 306defm : DemangledExtendedBuiltin<"u_mad24", OpenCL_std, 168>; 307defm : DemangledExtendedBuiltin<"s_mul24", OpenCL_std, 169>; 308defm : DemangledExtendedBuiltin<"u_mul24", OpenCL_std, 170>; 309defm : DemangledExtendedBuiltin<"u_abs", OpenCL_std, 201>; 310defm : DemangledExtendedBuiltin<"u_abs_diff", OpenCL_std, 202>; 311defm : DemangledExtendedBuiltin<"u_mul_hi", OpenCL_std, 203>; 312defm : DemangledExtendedBuiltin<"u_mad_hi", OpenCL_std, 204>; 313defm : DemangledExtendedBuiltin<"fclamp", OpenCL_std, 95>; 314defm : DemangledExtendedBuiltin<"degrees", OpenCL_std, 96>; 315defm : DemangledExtendedBuiltin<"fmax_common", OpenCL_std, 97>; 316defm : DemangledExtendedBuiltin<"fmin_common", OpenCL_std, 98>; 317defm : DemangledExtendedBuiltin<"mix", OpenCL_std, 99>; 318defm : DemangledExtendedBuiltin<"radians", OpenCL_std, 100>; 319defm : DemangledExtendedBuiltin<"step", OpenCL_std, 101>; 320defm : DemangledExtendedBuiltin<"smoothstep", OpenCL_std, 102>; 321defm : DemangledExtendedBuiltin<"sign", OpenCL_std, 103>; 322defm : DemangledExtendedBuiltin<"cross", OpenCL_std, 104>; 323defm : DemangledExtendedBuiltin<"distance", OpenCL_std, 105>; 324defm : DemangledExtendedBuiltin<"length", OpenCL_std, 106>; 325defm : DemangledExtendedBuiltin<"normalize", OpenCL_std, 107>; 326defm : DemangledExtendedBuiltin<"fast_distance", OpenCL_std, 108>; 327defm : DemangledExtendedBuiltin<"fast_length", OpenCL_std, 109>; 328defm : DemangledExtendedBuiltin<"fast_normalize", OpenCL_std, 110>; 329defm : DemangledExtendedBuiltin<"bitselect", OpenCL_std, 186>; 330defm : DemangledExtendedBuiltin<"select", OpenCL_std, 187>; 331defm : DemangledExtendedBuiltin<"vloadn", OpenCL_std, 171>; 332defm : DemangledExtendedBuiltin<"vstoren", OpenCL_std, 172>; 333defm : DemangledExtendedBuiltin<"vload_half", OpenCL_std, 173>; 334defm : DemangledExtendedBuiltin<"vload_halfn", OpenCL_std, 174>; 335defm : DemangledExtendedBuiltin<"vstore_half", OpenCL_std, 175>; 336defm : DemangledExtendedBuiltin<"vstore_half_r", OpenCL_std, 176>; 337defm : DemangledExtendedBuiltin<"vstore_halfn", OpenCL_std, 177>; 338defm : DemangledExtendedBuiltin<"vstore_halfn_r", OpenCL_std, 178>; 339defm : DemangledExtendedBuiltin<"vloada_halfn", OpenCL_std, 179>; 340defm : DemangledExtendedBuiltin<"vstorea_halfn", OpenCL_std, 180>; 341defm : DemangledExtendedBuiltin<"vstorea_halfn_r", OpenCL_std, 181>; 342defm : DemangledExtendedBuiltin<"shuffle", OpenCL_std, 182>; 343defm : DemangledExtendedBuiltin<"shuffle2", OpenCL_std, 183>; 344defm : DemangledExtendedBuiltin<"printf", OpenCL_std, 184>; 345defm : DemangledExtendedBuiltin<"prefetch", OpenCL_std, 185>; 346 347defm : DemangledExtendedBuiltin<"Round", GLSL_std_450, 1>; 348defm : DemangledExtendedBuiltin<"RoundEven", GLSL_std_450, 2>; 349defm : DemangledExtendedBuiltin<"Trunc", GLSL_std_450, 3>; 350defm : DemangledExtendedBuiltin<"FAbs", GLSL_std_450, 4>; 351defm : DemangledExtendedBuiltin<"SAbs", GLSL_std_450, 5>; 352defm : DemangledExtendedBuiltin<"FSign", GLSL_std_450, 6>; 353defm : DemangledExtendedBuiltin<"SSign", GLSL_std_450, 7>; 354defm : DemangledExtendedBuiltin<"Floor", GLSL_std_450, 8>; 355defm : DemangledExtendedBuiltin<"Ceil", GLSL_std_450, 9>; 356defm : DemangledExtendedBuiltin<"Fract", GLSL_std_450, 10>; 357defm : DemangledExtendedBuiltin<"Radians", GLSL_std_450, 11>; 358defm : DemangledExtendedBuiltin<"Degrees", GLSL_std_450, 12>; 359defm : DemangledExtendedBuiltin<"Sin", GLSL_std_450, 13>; 360defm : DemangledExtendedBuiltin<"Cos", GLSL_std_450, 14>; 361defm : DemangledExtendedBuiltin<"Tan", GLSL_std_450, 15>; 362defm : DemangledExtendedBuiltin<"Asin", GLSL_std_450, 16>; 363defm : DemangledExtendedBuiltin<"Acos", GLSL_std_450, 17>; 364defm : DemangledExtendedBuiltin<"Atan", GLSL_std_450, 18>; 365defm : DemangledExtendedBuiltin<"Sinh", GLSL_std_450, 19>; 366defm : DemangledExtendedBuiltin<"Cosh", GLSL_std_450, 20>; 367defm : DemangledExtendedBuiltin<"Tanh", GLSL_std_450, 21>; 368defm : DemangledExtendedBuiltin<"Asinh", GLSL_std_450, 22>; 369defm : DemangledExtendedBuiltin<"Acosh", GLSL_std_450, 23>; 370defm : DemangledExtendedBuiltin<"Atanh", GLSL_std_450, 24>; 371defm : DemangledExtendedBuiltin<"Atan2", GLSL_std_450, 25>; 372defm : DemangledExtendedBuiltin<"Pow", GLSL_std_450, 26>; 373defm : DemangledExtendedBuiltin<"Exp", GLSL_std_450, 27>; 374defm : DemangledExtendedBuiltin<"Log", GLSL_std_450, 28>; 375defm : DemangledExtendedBuiltin<"Exp2", GLSL_std_450, 29>; 376defm : DemangledExtendedBuiltin<"Log2", GLSL_std_450, 30>; 377defm : DemangledExtendedBuiltin<"Sqrt", GLSL_std_450, 31>; 378defm : DemangledExtendedBuiltin<"InverseSqrt", GLSL_std_450, 32>; 379defm : DemangledExtendedBuiltin<"Determinant", GLSL_std_450, 33>; 380defm : DemangledExtendedBuiltin<"MatrixInverse", GLSL_std_450, 34>; 381defm : DemangledExtendedBuiltin<"Modf", GLSL_std_450, 35>; 382defm : DemangledExtendedBuiltin<"ModfStruct", GLSL_std_450, 36>; 383defm : DemangledExtendedBuiltin<"FMin", GLSL_std_450, 37>; 384defm : DemangledExtendedBuiltin<"UMin", GLSL_std_450, 38>; 385defm : DemangledExtendedBuiltin<"SMin", GLSL_std_450, 39>; 386defm : DemangledExtendedBuiltin<"FMax", GLSL_std_450, 40>; 387defm : DemangledExtendedBuiltin<"UMax", GLSL_std_450, 41>; 388defm : DemangledExtendedBuiltin<"SMax", GLSL_std_450, 42>; 389defm : DemangledExtendedBuiltin<"FClamp", GLSL_std_450, 43>; 390defm : DemangledExtendedBuiltin<"UClamp", GLSL_std_450, 44>; 391defm : DemangledExtendedBuiltin<"SClamp", GLSL_std_450, 45>; 392defm : DemangledExtendedBuiltin<"FMix", GLSL_std_450, 46>; 393defm : DemangledExtendedBuiltin<"Step", GLSL_std_450, 48>; 394defm : DemangledExtendedBuiltin<"SmoothStep", GLSL_std_450, 49>; 395defm : DemangledExtendedBuiltin<"Fma", GLSL_std_450, 50>; 396defm : DemangledExtendedBuiltin<"Frexp", GLSL_std_450, 51>; 397defm : DemangledExtendedBuiltin<"FrexpStruct", GLSL_std_450, 52>; 398defm : DemangledExtendedBuiltin<"Ldexp", GLSL_std_450, 53>; 399defm : DemangledExtendedBuiltin<"PackSnorm4x8", GLSL_std_450, 54>; 400defm : DemangledExtendedBuiltin<"PackUnorm4x8", GLSL_std_450, 55>; 401defm : DemangledExtendedBuiltin<"PackSnorm2x16", GLSL_std_450, 56>; 402defm : DemangledExtendedBuiltin<"PackUnorm2x16", GLSL_std_450, 57>; 403defm : DemangledExtendedBuiltin<"PackHalf2x16", GLSL_std_450, 58>; 404defm : DemangledExtendedBuiltin<"PackDouble2x32", GLSL_std_450, 59>; 405defm : DemangledExtendedBuiltin<"UnpackSnorm2x16", GLSL_std_450, 60>; 406defm : DemangledExtendedBuiltin<"UnpackUnorm2x16", GLSL_std_450, 61>; 407defm : DemangledExtendedBuiltin<"UnpackHalf2x16", GLSL_std_450, 62>; 408defm : DemangledExtendedBuiltin<"UnpackSnorm4x8", GLSL_std_450, 63>; 409defm : DemangledExtendedBuiltin<"UnpackUnorm4x8", GLSL_std_450, 64>; 410defm : DemangledExtendedBuiltin<"UnpackDouble2x32", GLSL_std_450, 65>; 411defm : DemangledExtendedBuiltin<"Length", GLSL_std_450, 66>; 412defm : DemangledExtendedBuiltin<"Distance", GLSL_std_450, 67>; 413defm : DemangledExtendedBuiltin<"Cross", GLSL_std_450, 68>; 414defm : DemangledExtendedBuiltin<"Normalize", GLSL_std_450, 69>; 415defm : DemangledExtendedBuiltin<"FaceForward", GLSL_std_450, 70>; 416defm : DemangledExtendedBuiltin<"Reflect", GLSL_std_450, 71>; 417defm : DemangledExtendedBuiltin<"Refract", GLSL_std_450, 72>; 418defm : DemangledExtendedBuiltin<"FindILsb", GLSL_std_450, 73>; 419defm : DemangledExtendedBuiltin<"FindSMsb", GLSL_std_450, 74>; 420defm : DemangledExtendedBuiltin<"FindUMsb", GLSL_std_450, 75>; 421defm : DemangledExtendedBuiltin<"InterpolateAtCentroid", GLSL_std_450, 76>; 422defm : DemangledExtendedBuiltin<"InterpolateAtSample", GLSL_std_450, 77>; 423defm : DemangledExtendedBuiltin<"InterpolateAtOffset", GLSL_std_450, 78>; 424defm : DemangledExtendedBuiltin<"NMin", GLSL_std_450, 79>; 425defm : DemangledExtendedBuiltin<"NMax", GLSL_std_450, 80>; 426defm : DemangledExtendedBuiltin<"NClamp", GLSL_std_450, 81>; 427 428//===----------------------------------------------------------------------===// 429// Class defining an native builtin record used for direct translation into a 430// SPIR-V instruction. 431// 432// name is the demangled name of the given builtin. 433// set specifies which external instruction set the builtin belongs to. 434// opcode specifies the SPIR-V operation code of the generated instruction. 435//===----------------------------------------------------------------------===// 436class NativeBuiltin<string name, InstructionSet set, Op operation> { 437 string Name = name; 438 InstructionSet Set = set; 439 Op Opcode = operation; 440} 441 442// Table gathering all the native builtins. 443def NativeBuiltins : GenericTable { 444 let FilterClass = "NativeBuiltin"; 445 let Fields = ["Name", "Set", "Opcode"]; 446 string TypeOf_Set = "InstructionSet"; 447} 448 449// Function to lookup native builtins by their name and set. 450def lookupNativeBuiltin : SearchIndex { 451 let Table = NativeBuiltins; 452 let Key = ["Name", "Set"]; 453} 454 455// Multiclass used to define at the same time both an incoming builtin record 456// and a corresponding native builtin record. 457multiclass DemangledNativeBuiltin<string name, InstructionSet set, BuiltinGroup group, bits<8> minNumArgs, bits<8> maxNumArgs, Op operation> { 458 def : DemangledBuiltin<name, set, group, minNumArgs, maxNumArgs>; 459 def : NativeBuiltin<name, set, operation>; 460} 461 462// Relational builtin records: 463defm : DemangledNativeBuiltin<"isequal", OpenCL_std, Relational, 2, 2, OpFOrdEqual>; 464defm : DemangledNativeBuiltin<"__spirv_FOrdEqual", OpenCL_std, Relational, 2, 2, OpFOrdEqual>; 465defm : DemangledNativeBuiltin<"isnotequal", OpenCL_std, Relational, 2, 2, OpFUnordNotEqual>; 466defm : DemangledNativeBuiltin<"__spirv_FUnordNotEqual", OpenCL_std, Relational, 2, 2, OpFUnordNotEqual>; 467defm : DemangledNativeBuiltin<"isgreater", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThan>; 468defm : DemangledNativeBuiltin<"__spirv_FOrdGreaterThan", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThan>; 469defm : DemangledNativeBuiltin<"isgreaterequal", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThanEqual>; 470defm : DemangledNativeBuiltin<"__spirv_FOrdGreaterThanEqual", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThanEqual>; 471defm : DemangledNativeBuiltin<"isless", OpenCL_std, Relational, 2, 2, OpFOrdLessThan>; 472defm : DemangledNativeBuiltin<"__spirv_FOrdLessThan", OpenCL_std, Relational, 2, 2, OpFOrdLessThan>; 473defm : DemangledNativeBuiltin<"islessequal", OpenCL_std, Relational, 2, 2, OpFOrdLessThanEqual>; 474defm : DemangledNativeBuiltin<"__spirv_FOrdLessThanEqual", OpenCL_std, Relational, 2, 2, OpFOrdLessThanEqual>; 475defm : DemangledNativeBuiltin<"islessgreater", OpenCL_std, Relational, 2, 2, OpFOrdNotEqual>; 476defm : DemangledNativeBuiltin<"__spirv_FOrdNotEqual", OpenCL_std, Relational, 2, 2, OpFOrdNotEqual>; 477defm : DemangledNativeBuiltin<"isordered", OpenCL_std, Relational, 2, 2, OpOrdered>; 478defm : DemangledNativeBuiltin<"__spirv_Ordered", OpenCL_std, Relational, 2, 2, OpOrdered>; 479defm : DemangledNativeBuiltin<"isunordered", OpenCL_std, Relational, 2, 2, OpUnordered>; 480defm : DemangledNativeBuiltin<"__spirv_Unordered", OpenCL_std, Relational, 2, 2, OpUnordered>; 481defm : DemangledNativeBuiltin<"isfinite", OpenCL_std, Relational, 1, 1, OpIsFinite>; 482defm : DemangledNativeBuiltin<"__spirv_IsFinite", OpenCL_std, Relational, 1, 1, OpIsFinite>; 483defm : DemangledNativeBuiltin<"isinf", OpenCL_std, Relational, 1, 1, OpIsInf>; 484defm : DemangledNativeBuiltin<"__spirv_IsInf", OpenCL_std, Relational, 1, 1, OpIsInf>; 485defm : DemangledNativeBuiltin<"isnan", OpenCL_std, Relational, 1, 1, OpIsNan>; 486defm : DemangledNativeBuiltin<"__spirv_IsNan", OpenCL_std, Relational, 1, 1, OpIsNan>; 487defm : DemangledNativeBuiltin<"isnormal", OpenCL_std, Relational, 1, 1, OpIsNormal>; 488defm : DemangledNativeBuiltin<"__spirv_IsNormal", OpenCL_std, Relational, 1, 1, OpIsNormal>; 489defm : DemangledNativeBuiltin<"signbit", OpenCL_std, Relational, 1, 1, OpSignBitSet>; 490defm : DemangledNativeBuiltin<"__spirv_SignBitSet", OpenCL_std, Relational, 1, 1, OpSignBitSet>; 491defm : DemangledNativeBuiltin<"any", OpenCL_std, Relational, 1, 1, OpAny>; 492defm : DemangledNativeBuiltin<"__spirv_Any", OpenCL_std, Relational, 1, 1, OpAny>; 493defm : DemangledNativeBuiltin<"all", OpenCL_std, Relational, 1, 1, OpAll>; 494defm : DemangledNativeBuiltin<"__spirv_All", OpenCL_std, Relational, 1, 1, OpAll>; 495 496// Atomic builtin records: 497defm : DemangledNativeBuiltin<"atomic_init", OpenCL_std, Atomic, 2, 2, OpStore>; 498defm : DemangledNativeBuiltin<"atomic_load", OpenCL_std, Atomic, 1, 1, OpAtomicLoad>; 499defm : DemangledNativeBuiltin<"atomic_load_explicit", OpenCL_std, Atomic, 2, 3, OpAtomicLoad>; 500defm : DemangledNativeBuiltin<"atomic_store", OpenCL_std, Atomic, 2, 2, OpAtomicStore>; 501defm : DemangledNativeBuiltin<"atomic_store_explicit", OpenCL_std, Atomic, 2, 4, OpAtomicStore>; 502defm : DemangledNativeBuiltin<"atomic_compare_exchange_strong", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchange>; 503defm : DemangledNativeBuiltin<"atomic_compare_exchange_strong_explicit", OpenCL_std, Atomic, 5, 6, OpAtomicCompareExchange>; 504defm : DemangledNativeBuiltin<"atomic_compare_exchange_weak", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchangeWeak>; 505defm : DemangledNativeBuiltin<"atomic_compare_exchange_weak_explicit", OpenCL_std, Atomic, 5, 6, OpAtomicCompareExchangeWeak>; 506defm : DemangledNativeBuiltin<"atom_cmpxchg", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchange>; 507defm : DemangledNativeBuiltin<"atomic_cmpxchg", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchange>; 508defm : DemangledNativeBuiltin<"atom_add", OpenCL_std, Atomic, 2, 4, OpAtomicIAdd>; 509defm : DemangledNativeBuiltin<"atomic_add", OpenCL_std, Atomic, 2, 4, OpAtomicIAdd>; 510defm : DemangledNativeBuiltin<"atom_sub", OpenCL_std, Atomic, 2, 4, OpAtomicISub>; 511defm : DemangledNativeBuiltin<"atomic_sub", OpenCL_std, Atomic, 2, 4, OpAtomicISub>; 512defm : DemangledNativeBuiltin<"atom_or", OpenCL_std, Atomic, 2, 4, OpAtomicOr>; 513defm : DemangledNativeBuiltin<"atomic_or", OpenCL_std, Atomic, 2, 4, OpAtomicOr>; 514defm : DemangledNativeBuiltin<"atom_xor", OpenCL_std, Atomic, 2, 4, OpAtomicXor>; 515defm : DemangledNativeBuiltin<"atomic_xor", OpenCL_std, Atomic, 2, 4, OpAtomicXor>; 516defm : DemangledNativeBuiltin<"atom_and", OpenCL_std, Atomic, 2, 4, OpAtomicAnd>; 517defm : DemangledNativeBuiltin<"atomic_and", OpenCL_std, Atomic, 2, 4, OpAtomicAnd>; 518defm : DemangledNativeBuiltin<"atomic_exchange", OpenCL_std, Atomic, 2, 4, OpAtomicExchange>; 519defm : DemangledNativeBuiltin<"atomic_exchange_explicit", OpenCL_std, Atomic, 2, 4, OpAtomicExchange>; 520defm : DemangledNativeBuiltin<"atomic_work_item_fence", OpenCL_std, Atomic, 1, 3, OpMemoryBarrier>; 521defm : DemangledNativeBuiltin<"atomic_fetch_add", OpenCL_std, Atomic, 2, 4, OpAtomicIAdd>; 522defm : DemangledNativeBuiltin<"atomic_fetch_sub", OpenCL_std, Atomic, 2, 4, OpAtomicISub>; 523defm : DemangledNativeBuiltin<"atomic_fetch_or", OpenCL_std, Atomic, 2, 4, OpAtomicOr>; 524defm : DemangledNativeBuiltin<"atomic_fetch_xor", OpenCL_std, Atomic, 2, 4, OpAtomicXor>; 525defm : DemangledNativeBuiltin<"atomic_fetch_and", OpenCL_std, Atomic, 2, 4, OpAtomicAnd>; 526defm : DemangledNativeBuiltin<"atomic_fetch_add_explicit", OpenCL_std, Atomic, 4, 6, OpAtomicIAdd>; 527defm : DemangledNativeBuiltin<"atomic_fetch_sub_explicit", OpenCL_std, Atomic, 4, 6, OpAtomicISub>; 528defm : DemangledNativeBuiltin<"atomic_fetch_or_explicit", OpenCL_std, Atomic, 4, 6, OpAtomicOr>; 529defm : DemangledNativeBuiltin<"atomic_fetch_xor_explicit", OpenCL_std, Atomic, 4, 6, OpAtomicXor>; 530defm : DemangledNativeBuiltin<"atomic_fetch_and_explicit", OpenCL_std, Atomic, 4, 6, OpAtomicAnd>; 531defm : DemangledNativeBuiltin<"atomic_flag_test_and_set", OpenCL_std, Atomic, 1, 1, OpAtomicFlagTestAndSet>; 532defm : DemangledNativeBuiltin<"atomic_flag_test_and_set_explicit", OpenCL_std, Atomic, 2, 3, OpAtomicFlagTestAndSet>; 533defm : DemangledNativeBuiltin<"atomic_flag_clear", OpenCL_std, Atomic, 1, 1, OpAtomicFlagClear>; 534defm : DemangledNativeBuiltin<"atomic_flag_clear_explicit", OpenCL_std, Atomic, 2, 3, OpAtomicFlagClear>; 535 536// Barrier builtin records: 537defm : DemangledNativeBuiltin<"barrier", OpenCL_std, Barrier, 1, 3, OpControlBarrier>; 538defm : DemangledNativeBuiltin<"work_group_barrier", OpenCL_std, Barrier, 1, 3, OpControlBarrier>; 539 540// Kernel enqueue builtin records: 541defm : DemangledNativeBuiltin<"__enqueue_kernel_basic", OpenCL_std, Enqueue, 5, 5, OpEnqueueKernel>; 542defm : DemangledNativeBuiltin<"__enqueue_kernel_basic_events", OpenCL_std, Enqueue, 8, 8, OpEnqueueKernel>; 543defm : DemangledNativeBuiltin<"__enqueue_kernel_varargs", OpenCL_std, Enqueue, 7, 7, OpEnqueueKernel>; 544defm : DemangledNativeBuiltin<"__enqueue_kernel_events_varargs", OpenCL_std, Enqueue, 10, 10, OpEnqueueKernel>; 545defm : DemangledNativeBuiltin<"retain_event", OpenCL_std, Enqueue, 1, 1, OpRetainEvent>; 546defm : DemangledNativeBuiltin<"release_event", OpenCL_std, Enqueue, 1, 1, OpReleaseEvent>; 547defm : DemangledNativeBuiltin<"create_user_event", OpenCL_std, Enqueue, 0, 0, OpCreateUserEvent>; 548defm : DemangledNativeBuiltin<"is_valid_event", OpenCL_std, Enqueue, 1, 1, OpIsValidEvent>; 549defm : DemangledNativeBuiltin<"set_user_event_status", OpenCL_std, Enqueue, 2, 2, OpSetUserEventStatus>; 550defm : DemangledNativeBuiltin<"capture_event_profiling_info", OpenCL_std, Enqueue, 3, 3, OpCaptureEventProfilingInfo>; 551defm : DemangledNativeBuiltin<"get_default_queue", OpenCL_std, Enqueue, 0, 0, OpGetDefaultQueue>; 552defm : DemangledNativeBuiltin<"ndrange_1D", OpenCL_std, Enqueue, 1, 3, OpBuildNDRange>; 553defm : DemangledNativeBuiltin<"ndrange_2D", OpenCL_std, Enqueue, 1, 3, OpBuildNDRange>; 554defm : DemangledNativeBuiltin<"ndrange_3D", OpenCL_std, Enqueue, 1, 3, OpBuildNDRange>; 555 556// Spec constant builtin records: 557defm : DemangledNativeBuiltin<"__spirv_SpecConstant", OpenCL_std, SpecConstant, 2, 2, OpSpecConstant>; 558defm : DemangledNativeBuiltin<"__spirv_SpecConstantComposite", OpenCL_std, SpecConstant, 1, 0, OpSpecConstantComposite>; 559 560// Async Copy and Prefetch builtin records: 561defm : DemangledNativeBuiltin<"async_work_group_copy", OpenCL_std, AsyncCopy, 4, 4, OpGroupAsyncCopy>; 562defm : DemangledNativeBuiltin<"wait_group_events", OpenCL_std, AsyncCopy, 2, 2, OpGroupWaitEvents>; 563 564// Load and store builtin records: 565defm : DemangledNativeBuiltin<"__spirv_Load", OpenCL_std, LoadStore, 1, 3, OpLoad>; 566defm : DemangledNativeBuiltin<"__spirv_Store", OpenCL_std, LoadStore, 2, 4, OpStore>; 567 568//===----------------------------------------------------------------------===// 569// Class defining a work/sub group builtin that should be translated into a 570// SPIR-V instruction using the defined properties. 571// 572// name is the demangled name of the given builtin. 573// opcode specifies the SPIR-V operation code of the generated instruction. 574//===----------------------------------------------------------------------===// 575class GroupBuiltin<string name, Op operation> { 576 string Name = name; 577 Op Opcode = operation; 578 bits<32> GroupOperation = !cond(!not(!eq(!find(name, "group_reduce"), -1)) : Reduce.Value, 579 !not(!eq(!find(name, "group_scan_inclusive"), -1)) : InclusiveScan.Value, 580 !not(!eq(!find(name, "group_scan_exclusive"), -1)) : ExclusiveScan.Value, 581 !not(!eq(!find(name, "group_ballot_bit_count"), -1)) : Reduce.Value, 582 !not(!eq(!find(name, "group_ballot_inclusive_scan"), -1)) : InclusiveScan.Value, 583 !not(!eq(!find(name, "group_ballot_exclusive_scan"), -1)) : ExclusiveScan.Value, 584 !not(!eq(!find(name, "group_non_uniform_reduce"), -1)) : Reduce.Value, 585 !not(!eq(!find(name, "group_non_uniform_scan_inclusive"), -1)) : InclusiveScan.Value, 586 !not(!eq(!find(name, "group_non_uniform_scan_exclusive"), -1)) : ExclusiveScan.Value, 587 !not(!eq(!find(name, "group_non_uniform_reduce_logical"), -1)) : Reduce.Value, 588 !not(!eq(!find(name, "group_non_uniform_scan_inclusive_logical"), -1)) : InclusiveScan.Value, 589 !not(!eq(!find(name, "group_non_uniform_scan_exclusive_logical"), -1)) : ExclusiveScan.Value, 590 !not(!eq(!find(name, "group_clustered_reduce"), -1)) : ClusteredReduce.Value, 591 !not(!eq(!find(name, "group_clustered_reduce_logical"), -1)) : ClusteredReduce.Value, 592 true : 0); 593 bit IsElect = !eq(operation, OpGroupNonUniformElect); 594 bit IsAllOrAny = !or(!eq(operation, OpGroupAll), 595 !eq(operation, OpGroupAny), 596 !eq(operation, OpGroupNonUniformAll), 597 !eq(operation, OpGroupNonUniformAny)); 598 bit IsAllEqual = !eq(operation, OpGroupNonUniformAllEqual); 599 bit IsBallot = !eq(operation, OpGroupNonUniformBallot); 600 bit IsInverseBallot = !eq(operation, OpGroupNonUniformInverseBallot); 601 bit IsBallotBitExtract = !eq(operation, OpGroupNonUniformBallotBitExtract); 602 bit IsBallotFindBit = !or(!eq(operation, OpGroupNonUniformBallotFindLSB), 603 !eq(operation, OpGroupNonUniformBallotFindMSB)); 604 bit IsLogical = !or(!eq(operation, OpGroupNonUniformLogicalAnd), 605 !eq(operation, OpGroupNonUniformLogicalOr), 606 !eq(operation, OpGroupNonUniformLogicalXor)); 607 bit NoGroupOperation = !or(IsElect, IsAllOrAny, IsAllEqual, 608 IsBallot, IsInverseBallot, 609 IsBallotBitExtract, IsBallotFindBit, 610 !eq(operation, OpGroupNonUniformShuffle), 611 !eq(operation, OpGroupNonUniformShuffleXor), 612 !eq(operation, OpGroupNonUniformShuffleUp), 613 !eq(operation, OpGroupNonUniformShuffleDown), 614 !eq(operation, OpGroupBroadcast), 615 !eq(operation, OpGroupNonUniformBroadcast), 616 !eq(operation, OpGroupNonUniformBroadcastFirst)); 617 bit HasBoolArg = !or(!and(IsAllOrAny, !eq(IsAllEqual, false)), IsBallot, IsLogical); 618} 619 620// Table gathering all the work/sub group builtins. 621def GroupBuiltins : GenericTable { 622 let FilterClass = "GroupBuiltin"; 623 let Fields = ["Name", "Opcode", "GroupOperation", "IsElect", "IsAllOrAny", 624 "IsAllEqual", "IsBallot", "IsInverseBallot", "IsBallotBitExtract", 625 "IsBallotFindBit", "IsLogical", "NoGroupOperation", "HasBoolArg"]; 626} 627 628// Function to lookup native builtins by their name and set. 629def lookupGroupBuiltin : SearchIndex { 630 let Table = GroupBuiltins; 631 let Key = ["Name"]; 632} 633 634// Multiclass used to define at the same time both incoming builtin records 635// and corresponding work/sub group builtin records. 636defvar OnlyWork = 0; defvar OnlySub = 1; defvar WorkOrSub = 2; 637multiclass DemangledGroupBuiltin<string name, int level /* OnlyWork/OnlySub/... */, Op operation> { 638 assert !and(!ge(level, 0), !le(level, 2)), "group level is invalid: " # level; 639 640 if !or(!eq(level, OnlyWork), !eq(level, WorkOrSub)) then { 641 def : DemangledBuiltin<!strconcat("work_", name), OpenCL_std, Group, 0, 4>; 642 def : GroupBuiltin<!strconcat("work_", name), operation>; 643 } 644 645 if !or(!eq(level, OnlySub), !eq(level, WorkOrSub)) then { 646 def : DemangledBuiltin<!strconcat("sub_", name), OpenCL_std, Group, 0, 4>; 647 def : GroupBuiltin<!strconcat("sub_", name), operation>; 648 } 649} 650 651defm : DemangledGroupBuiltin<"group_all", WorkOrSub, OpGroupAll>; 652defm : DemangledGroupBuiltin<"group_any", WorkOrSub, OpGroupAny>; 653defm : DemangledGroupBuiltin<"group_broadcast", WorkOrSub, OpGroupBroadcast>; 654defm : DemangledGroupBuiltin<"group_non_uniform_broadcast", OnlySub, OpGroupNonUniformBroadcast>; 655defm : DemangledGroupBuiltin<"group_broadcast_first", OnlySub, OpGroupNonUniformBroadcastFirst>; 656 657// cl_khr_subgroup_non_uniform_vote 658defm : DemangledGroupBuiltin<"group_elect", OnlySub, OpGroupNonUniformElect>; 659defm : DemangledGroupBuiltin<"group_non_uniform_all", OnlySub, OpGroupNonUniformAll>; 660defm : DemangledGroupBuiltin<"group_non_uniform_any", OnlySub, OpGroupNonUniformAny>; 661defm : DemangledGroupBuiltin<"group_non_uniform_all_equal", OnlySub, OpGroupNonUniformAllEqual>; 662 663// cl_khr_subgroup_ballot 664defm : DemangledGroupBuiltin<"group_ballot", OnlySub, OpGroupNonUniformBallot>; 665defm : DemangledGroupBuiltin<"group_inverse_ballot", OnlySub, OpGroupNonUniformInverseBallot>; 666defm : DemangledGroupBuiltin<"group_ballot_bit_extract", OnlySub, OpGroupNonUniformBallotBitExtract>; 667defm : DemangledGroupBuiltin<"group_ballot_bit_count", OnlySub, OpGroupNonUniformBallotBitCount>; 668defm : DemangledGroupBuiltin<"group_ballot_inclusive_scan", OnlySub, OpGroupNonUniformBallotBitCount>; 669defm : DemangledGroupBuiltin<"group_ballot_exclusive_scan", OnlySub, OpGroupNonUniformBallotBitCount>; 670defm : DemangledGroupBuiltin<"group_ballot_find_lsb", OnlySub, OpGroupNonUniformBallotFindLSB>; 671defm : DemangledGroupBuiltin<"group_ballot_find_msb", OnlySub, OpGroupNonUniformBallotFindMSB>; 672 673// cl_khr_subgroup_shuffle 674defm : DemangledGroupBuiltin<"group_shuffle", OnlySub, OpGroupNonUniformShuffle>; 675defm : DemangledGroupBuiltin<"group_shuffle_xor", OnlySub, OpGroupNonUniformShuffleXor>; 676 677// cl_khr_subgroup_shuffle_relative 678defm : DemangledGroupBuiltin<"group_shuffle_up", OnlySub, OpGroupNonUniformShuffleUp>; 679defm : DemangledGroupBuiltin<"group_shuffle_down", OnlySub, OpGroupNonUniformShuffleDown>; 680 681defm : DemangledGroupBuiltin<"group_iadd", WorkOrSub, OpGroupIAdd>; 682defm : DemangledGroupBuiltin<"group_reduce_adds", WorkOrSub, OpGroupIAdd>; 683defm : DemangledGroupBuiltin<"group_scan_exclusive_adds", WorkOrSub, OpGroupIAdd>; 684defm : DemangledGroupBuiltin<"group_scan_inclusive_adds", WorkOrSub, OpGroupIAdd>; 685defm : DemangledGroupBuiltin<"group_reduce_addu", WorkOrSub, OpGroupIAdd>; 686defm : DemangledGroupBuiltin<"group_scan_exclusive_addu", WorkOrSub, OpGroupIAdd>; 687defm : DemangledGroupBuiltin<"group_scan_inclusive_addu", WorkOrSub, OpGroupIAdd>; 688 689defm : DemangledGroupBuiltin<"group_fadd", WorkOrSub, OpGroupFAdd>; 690defm : DemangledGroupBuiltin<"group_reduce_addf", WorkOrSub, OpGroupFAdd>; 691defm : DemangledGroupBuiltin<"group_scan_exclusive_addf", WorkOrSub, OpGroupFAdd>; 692defm : DemangledGroupBuiltin<"group_scan_inclusive_addf", WorkOrSub, OpGroupFAdd>; 693 694defm : DemangledGroupBuiltin<"group_fmin", WorkOrSub, OpGroupFMin>; 695defm : DemangledGroupBuiltin<"group_reduce_minf", WorkOrSub, OpGroupFMin>; 696defm : DemangledGroupBuiltin<"group_scan_exclusive_minf", WorkOrSub, OpGroupFMin>; 697defm : DemangledGroupBuiltin<"group_scan_inclusive_minf", WorkOrSub, OpGroupFMin>; 698 699defm : DemangledGroupBuiltin<"group_umin", WorkOrSub, OpGroupUMin>; 700defm : DemangledGroupBuiltin<"group_reduce_minu", WorkOrSub, OpGroupUMin>; 701defm : DemangledGroupBuiltin<"group_scan_exclusive_minu", WorkOrSub, OpGroupUMin>; 702defm : DemangledGroupBuiltin<"group_scan_inclusive_minu", WorkOrSub, OpGroupUMin>; 703 704defm : DemangledGroupBuiltin<"group_smin", WorkOrSub, OpGroupSMin>; 705defm : DemangledGroupBuiltin<"group_reduce_mins", WorkOrSub, OpGroupSMin>; 706defm : DemangledGroupBuiltin<"group_scan_exclusive_mins", WorkOrSub, OpGroupSMin>; 707defm : DemangledGroupBuiltin<"group_scan_inclusive_mins", WorkOrSub, OpGroupSMin>; 708 709defm : DemangledGroupBuiltin<"group_fmax", WorkOrSub, OpGroupFMax>; 710defm : DemangledGroupBuiltin<"group_reduce_maxf", WorkOrSub, OpGroupFMax>; 711defm : DemangledGroupBuiltin<"group_scan_exclusive_maxf", WorkOrSub, OpGroupFMax>; 712defm : DemangledGroupBuiltin<"group_scan_inclusive_maxf", WorkOrSub, OpGroupFMax>; 713 714defm : DemangledGroupBuiltin<"group_umax", WorkOrSub, OpGroupUMax>; 715defm : DemangledGroupBuiltin<"group_reduce_maxu", WorkOrSub, OpGroupUMax>; 716defm : DemangledGroupBuiltin<"group_scan_exclusive_maxu", WorkOrSub, OpGroupUMax>; 717defm : DemangledGroupBuiltin<"group_scan_inclusive_maxu", WorkOrSub, OpGroupUMax>; 718 719defm : DemangledGroupBuiltin<"group_smax", WorkOrSub, OpGroupSMax>; 720defm : DemangledGroupBuiltin<"group_reduce_maxs", WorkOrSub, OpGroupSMax>; 721defm : DemangledGroupBuiltin<"group_scan_exclusive_maxs", WorkOrSub, OpGroupSMax>; 722defm : DemangledGroupBuiltin<"group_scan_inclusive_maxs", WorkOrSub, OpGroupSMax>; 723 724// cl_khr_subgroup_non_uniform_arithmetic 725defm : DemangledGroupBuiltin<"group_non_uniform_iadd", WorkOrSub, OpGroupNonUniformIAdd>; 726defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addu", WorkOrSub, OpGroupNonUniformIAdd>; 727defm : DemangledGroupBuiltin<"group_non_uniform_reduce_adds", WorkOrSub, OpGroupNonUniformIAdd>; 728defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addu", WorkOrSub, OpGroupNonUniformIAdd>; 729defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_adds", WorkOrSub, OpGroupNonUniformIAdd>; 730defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addu", WorkOrSub, OpGroupNonUniformIAdd>; 731defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_adds", WorkOrSub, OpGroupNonUniformIAdd>; 732defm : DemangledGroupBuiltin<"group_clustered_reduce_addu", WorkOrSub, OpGroupNonUniformIAdd>; 733defm : DemangledGroupBuiltin<"group_clustered_reduce_adds", WorkOrSub, OpGroupNonUniformIAdd>; 734 735defm : DemangledGroupBuiltin<"group_non_uniform_fadd", WorkOrSub, OpGroupNonUniformFAdd>; 736defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addf", WorkOrSub, OpGroupNonUniformFAdd>; 737defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addh", WorkOrSub, OpGroupNonUniformFAdd>; 738defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addd", WorkOrSub, OpGroupNonUniformFAdd>; 739defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addf", WorkOrSub, OpGroupNonUniformFAdd>; 740defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addh", WorkOrSub, OpGroupNonUniformFAdd>; 741defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addd", WorkOrSub, OpGroupNonUniformFAdd>; 742defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addf", WorkOrSub, OpGroupNonUniformFAdd>; 743defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addh", WorkOrSub, OpGroupNonUniformFAdd>; 744defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addd", WorkOrSub, OpGroupNonUniformFAdd>; 745defm : DemangledGroupBuiltin<"group_clustered_reduce_addf", WorkOrSub, OpGroupNonUniformFAdd>; 746defm : DemangledGroupBuiltin<"group_clustered_reduce_addh", WorkOrSub, OpGroupNonUniformFAdd>; 747defm : DemangledGroupBuiltin<"group_clustered_reduce_addd", WorkOrSub, OpGroupNonUniformFAdd>; 748 749defm : DemangledGroupBuiltin<"group_non_uniform_imul", WorkOrSub, OpGroupNonUniformIMul>; 750defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mulu", WorkOrSub, OpGroupNonUniformIMul>; 751defm : DemangledGroupBuiltin<"group_non_uniform_reduce_muls", WorkOrSub, OpGroupNonUniformIMul>; 752defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mulu", WorkOrSub, OpGroupNonUniformIMul>; 753defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_muls", WorkOrSub, OpGroupNonUniformIMul>; 754defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mulu", WorkOrSub, OpGroupNonUniformIMul>; 755defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_muls", WorkOrSub, OpGroupNonUniformIMul>; 756defm : DemangledGroupBuiltin<"group_clustered_reduce_mulu", WorkOrSub, OpGroupNonUniformIMul>; 757defm : DemangledGroupBuiltin<"group_clustered_reduce_muls", WorkOrSub, OpGroupNonUniformIMul>; 758 759defm : DemangledGroupBuiltin<"group_non_uniform_fmul", WorkOrSub, OpGroupNonUniformFMul>; 760defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mulf", WorkOrSub, OpGroupNonUniformFMul>; 761defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mulh", WorkOrSub, OpGroupNonUniformFMul>; 762defm : DemangledGroupBuiltin<"group_non_uniform_reduce_muld", WorkOrSub, OpGroupNonUniformFMul>; 763defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mulf", WorkOrSub, OpGroupNonUniformFMul>; 764defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mulh", WorkOrSub, OpGroupNonUniformFMul>; 765defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_muld", WorkOrSub, OpGroupNonUniformFMul>; 766defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mulf", WorkOrSub, OpGroupNonUniformFMul>; 767defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mulh", WorkOrSub, OpGroupNonUniformFMul>; 768defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_muld", WorkOrSub, OpGroupNonUniformFMul>; 769defm : DemangledGroupBuiltin<"group_clustered_reduce_mulf", WorkOrSub, OpGroupNonUniformFMul>; 770defm : DemangledGroupBuiltin<"group_clustered_reduce_mulh", WorkOrSub, OpGroupNonUniformFMul>; 771defm : DemangledGroupBuiltin<"group_clustered_reduce_muld", WorkOrSub, OpGroupNonUniformFMul>; 772 773defm : DemangledGroupBuiltin<"group_non_uniform_smin", WorkOrSub, OpGroupNonUniformSMin>; 774defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mins", WorkOrSub, OpGroupNonUniformSMin>; 775defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mins", WorkOrSub, OpGroupNonUniformSMin>; 776defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mins", WorkOrSub, OpGroupNonUniformSMin>; 777defm : DemangledGroupBuiltin<"group_clustered_reduce_mins", WorkOrSub, OpGroupNonUniformSMin>; 778 779 780defm : DemangledGroupBuiltin<"group_non_uniform_umin", WorkOrSub, OpGroupNonUniformUMin>; 781defm : DemangledGroupBuiltin<"group_non_uniform_reduce_minu", WorkOrSub, OpGroupNonUniformUMin>; 782defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_minu", WorkOrSub, OpGroupNonUniformUMin>; 783defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_minu", WorkOrSub, OpGroupNonUniformUMin>; 784defm : DemangledGroupBuiltin<"group_clustered_reduce_minu", WorkOrSub, OpGroupNonUniformUMin>; 785 786defm : DemangledGroupBuiltin<"group_non_uniform_fmin", WorkOrSub, OpGroupNonUniformFMin>; 787defm : DemangledGroupBuiltin<"group_non_uniform_reduce_minf", WorkOrSub, OpGroupNonUniformFMin>; 788defm : DemangledGroupBuiltin<"group_non_uniform_reduce_minh", WorkOrSub, OpGroupNonUniformFMin>; 789defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mind", WorkOrSub, OpGroupNonUniformFMin>; 790defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_minf", WorkOrSub, OpGroupNonUniformFMin>; 791defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_minh", WorkOrSub, OpGroupNonUniformFMin>; 792defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mind", WorkOrSub, OpGroupNonUniformFMin>; 793defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_minf", WorkOrSub, OpGroupNonUniformFMin>; 794defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_minh", WorkOrSub, OpGroupNonUniformFMin>; 795defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mind", WorkOrSub, OpGroupNonUniformFMin>; 796defm : DemangledGroupBuiltin<"group_clustered_reduce_minf", WorkOrSub, OpGroupNonUniformFMin>; 797defm : DemangledGroupBuiltin<"group_clustered_reduce_minh", WorkOrSub, OpGroupNonUniformFMin>; 798defm : DemangledGroupBuiltin<"group_clustered_reduce_mind", WorkOrSub, OpGroupNonUniformFMin>; 799 800defm : DemangledGroupBuiltin<"group_non_uniform_smax", WorkOrSub, OpGroupNonUniformSMax>; 801defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxs", WorkOrSub, OpGroupNonUniformSMax>; 802defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxs", WorkOrSub, OpGroupNonUniformSMax>; 803defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxs", WorkOrSub, OpGroupNonUniformSMax>; 804defm : DemangledGroupBuiltin<"group_clustered_reduce_maxs", WorkOrSub, OpGroupNonUniformSMax>; 805 806defm : DemangledGroupBuiltin<"group_non_uniform_umax", WorkOrSub, OpGroupNonUniformUMax>; 807defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxu", WorkOrSub, OpGroupNonUniformUMax>; 808defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxu", WorkOrSub, OpGroupNonUniformUMax>; 809defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxu", WorkOrSub, OpGroupNonUniformUMax>; 810defm : DemangledGroupBuiltin<"group_clustered_reduce_maxu", WorkOrSub, OpGroupNonUniformUMax>; 811 812defm : DemangledGroupBuiltin<"group_non_uniform_fmax", WorkOrSub, OpGroupNonUniformFMax>; 813defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxf", WorkOrSub, OpGroupNonUniformFMax>; 814defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxh", WorkOrSub, OpGroupNonUniformFMax>; 815defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxd", WorkOrSub, OpGroupNonUniformFMax>; 816defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxf", WorkOrSub, OpGroupNonUniformFMax>; 817defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxh", WorkOrSub, OpGroupNonUniformFMax>; 818defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxd", WorkOrSub, OpGroupNonUniformFMax>; 819defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxf", WorkOrSub, OpGroupNonUniformFMax>; 820defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxh", WorkOrSub, OpGroupNonUniformFMax>; 821defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxd", WorkOrSub, OpGroupNonUniformFMax>; 822defm : DemangledGroupBuiltin<"group_clustered_reduce_maxf", WorkOrSub, OpGroupNonUniformFMax>; 823defm : DemangledGroupBuiltin<"group_clustered_reduce_maxh", WorkOrSub, OpGroupNonUniformFMax>; 824defm : DemangledGroupBuiltin<"group_clustered_reduce_maxd", WorkOrSub, OpGroupNonUniformFMax>; 825 826defm : DemangledGroupBuiltin<"group_non_uniform_iand", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 827defm : DemangledGroupBuiltin<"group_non_uniform_reduce_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 828defm : DemangledGroupBuiltin<"group_non_uniform_reduce_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 829defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 830defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 831defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 832defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 833defm : DemangledGroupBuiltin<"group_clustered_reduce_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 834defm : DemangledGroupBuiltin<"group_clustered_reduce_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 835 836defm : DemangledGroupBuiltin<"group_non_uniform_ior", WorkOrSub, OpGroupNonUniformBitwiseOr>; 837defm : DemangledGroupBuiltin<"group_non_uniform_reduce_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 838defm : DemangledGroupBuiltin<"group_non_uniform_reduce_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 839defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 840defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 841defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 842defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 843defm : DemangledGroupBuiltin<"group_clustered_reduce_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 844defm : DemangledGroupBuiltin<"group_clustered_reduce_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 845 846defm : DemangledGroupBuiltin<"group_non_uniform_ixor", WorkOrSub, OpGroupNonUniformBitwiseXor>; 847defm : DemangledGroupBuiltin<"group_non_uniform_reduce_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 848defm : DemangledGroupBuiltin<"group_non_uniform_reduce_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 849defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 850defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 851defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 852defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 853defm : DemangledGroupBuiltin<"group_clustered_reduce_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 854defm : DemangledGroupBuiltin<"group_clustered_reduce_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 855 856defm : DemangledGroupBuiltin<"group_non_uniform_logical_iand", WorkOrSub, OpGroupNonUniformLogicalAnd>; 857defm : DemangledGroupBuiltin<"group_non_uniform_reduce_logical_ands", WorkOrSub, OpGroupNonUniformLogicalAnd>; 858defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_logical_ands", WorkOrSub, OpGroupNonUniformLogicalAnd>; 859defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_logical_ands", WorkOrSub, OpGroupNonUniformLogicalAnd>; 860defm : DemangledGroupBuiltin<"group_clustered_reduce_logical_and", WorkOrSub, OpGroupNonUniformLogicalAnd>; 861 862defm : DemangledGroupBuiltin<"group_non_uniform_logical_ior", WorkOrSub, OpGroupNonUniformLogicalOr>; 863defm : DemangledGroupBuiltin<"group_non_uniform_reduce_logical_ors", WorkOrSub, OpGroupNonUniformLogicalOr>; 864defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_logical_ors", WorkOrSub, OpGroupNonUniformLogicalOr>; 865defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_logical_ors", WorkOrSub, OpGroupNonUniformLogicalOr>; 866defm : DemangledGroupBuiltin<"group_clustered_reduce_logical_or", WorkOrSub, OpGroupNonUniformLogicalOr>; 867 868defm : DemangledGroupBuiltin<"group_non_uniform_logical_ixor", WorkOrSub, OpGroupNonUniformLogicalXor>; 869defm : DemangledGroupBuiltin<"group_non_uniform_reduce_logical_xors", WorkOrSub, OpGroupNonUniformLogicalXor>; 870defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_logical_xors", WorkOrSub, OpGroupNonUniformLogicalXor>; 871defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_logical_xors", WorkOrSub, OpGroupNonUniformLogicalXor>; 872defm : DemangledGroupBuiltin<"group_clustered_reduce_logical_xor", WorkOrSub, OpGroupNonUniformLogicalXor>; 873 874 875//===----------------------------------------------------------------------===// 876// Class defining a get builtin record used for lowering builtin calls such as 877// "get_sub_group_eq_mask" or "get_global_id" to SPIR-V instructions. 878// 879// name is the demangled name of the given builtin. 880// set specifies which external instruction set the builtin belongs to. 881// value specifies the value of the BuiltIn enum. 882//===----------------------------------------------------------------------===// 883class GetBuiltin<string name, InstructionSet set, BuiltIn value> { 884 string Name = name; 885 InstructionSet Set = set; 886 BuiltIn Value = value; 887} 888 889// Table gathering all the get builtin records. 890def GetBuiltins : GenericTable { 891 let FilterClass = "GetBuiltin"; 892 let Fields = ["Name", "Set", "Value"]; 893 string TypeOf_Set = "InstructionSet"; 894 string TypeOf_Value = "BuiltIn"; 895} 896 897// Function to lookup get builtin records by their name and set. 898def lookupGetBuiltin : SearchIndex { 899 let Table = GetBuiltins; 900 let Key = ["Name", "Set"]; 901} 902 903// Multiclass used to define at the same time both a demangled builtin record 904// and a corresponding get builtin record. 905multiclass DemangledGetBuiltin<string name, InstructionSet set, BuiltinGroup group, BuiltIn value> { 906 def : DemangledBuiltin<name, set, group, 0, 1>; 907 def : GetBuiltin<name, set, value>; 908} 909 910// Builtin variable records: 911defm : DemangledGetBuiltin<"get_sub_group_eq_mask", OpenCL_std, Variable, SubgroupEqMask>; 912defm : DemangledGetBuiltin<"get_sub_group_ge_mask", OpenCL_std, Variable, SubgroupGeMask>; 913defm : DemangledGetBuiltin<"get_sub_group_gt_mask", OpenCL_std, Variable, SubgroupGtMask>; 914defm : DemangledGetBuiltin<"get_sub_group_le_mask", OpenCL_std, Variable, SubgroupLeMask>; 915defm : DemangledGetBuiltin<"get_sub_group_lt_mask", OpenCL_std, Variable, SubgroupLtMask>; 916defm : DemangledGetBuiltin<"__spirv_BuiltInGlobalLinearId", OpenCL_std, Variable, GlobalLinearId>; 917defm : DemangledGetBuiltin<"__spirv_BuiltInGlobalInvocationId", OpenCL_std, Variable, GlobalInvocationId>; 918 919// GetQuery builtin records: 920defm : DemangledGetBuiltin<"get_local_id", OpenCL_std, GetQuery, LocalInvocationId>; 921defm : DemangledGetBuiltin<"get_global_id", OpenCL_std, GetQuery, GlobalInvocationId>; 922defm : DemangledGetBuiltin<"get_local_size", OpenCL_std, GetQuery, WorkgroupSize>; 923defm : DemangledGetBuiltin<"get_global_size", OpenCL_std, GetQuery, GlobalSize>; 924defm : DemangledGetBuiltin<"get_group_id", OpenCL_std, GetQuery, WorkgroupId>; 925defm : DemangledGetBuiltin<"get_enqueued_local_size", OpenCL_std, GetQuery, EnqueuedWorkgroupSize>; 926defm : DemangledGetBuiltin<"get_num_groups", OpenCL_std, GetQuery, NumWorkgroups>; 927 928//===----------------------------------------------------------------------===// 929// Class defining an image query builtin record used for lowering the OpenCL 930// "get_image_*" calls into OpImageQuerySize/OpImageQuerySizeLod instructions. 931// 932// name is the demangled name of the given builtin. 933// set specifies which external instruction set the builtin belongs to. 934// component specifies the unsigned number of the query component. 935//===----------------------------------------------------------------------===// 936class ImageQueryBuiltin<string name, InstructionSet set, bits<32> component> { 937 string Name = name; 938 InstructionSet Set = set; 939 bits<32> Component = component; 940} 941 942// Table gathering all the image query builtins. 943def ImageQueryBuiltins : GenericTable { 944 let FilterClass = "ImageQueryBuiltin"; 945 let Fields = ["Name", "Set", "Component"]; 946 string TypeOf_Set = "InstructionSet"; 947} 948 949// Function to lookup image query builtins by their name and set. 950def lookupImageQueryBuiltin : SearchIndex { 951 let Table = ImageQueryBuiltins; 952 let Key = ["Name", "Set"]; 953} 954 955// Multiclass used to define at the same time both a demangled builtin record 956// and a corresponding image query builtin record. 957multiclass DemangledImageQueryBuiltin<string name, InstructionSet set, int component> { 958 def : DemangledBuiltin<name, set, ImageSizeQuery, 1, 1>; 959 def : ImageQueryBuiltin<name, set, component>; 960} 961 962// Image query builtin records: 963defm : DemangledImageQueryBuiltin<"get_image_width", OpenCL_std, 0>; 964defm : DemangledImageQueryBuiltin<"get_image_height", OpenCL_std, 1>; 965defm : DemangledImageQueryBuiltin<"get_image_depth", OpenCL_std, 2>; 966defm : DemangledImageQueryBuiltin<"get_image_dim", OpenCL_std, 0>; 967defm : DemangledImageQueryBuiltin<"get_image_array_size", OpenCL_std, 3>; 968 969defm : DemangledNativeBuiltin<"get_image_num_samples", OpenCL_std, ImageMiscQuery, 1, 1, OpImageQuerySamples>; 970defm : DemangledNativeBuiltin<"get_image_num_mip_levels", OpenCL_std, ImageMiscQuery, 1, 1, OpImageQueryLevels>; 971 972//===----------------------------------------------------------------------===// 973// Class defining a "convert_destType<_sat><_roundingMode>" call record for 974// lowering into OpConvert instructions. 975// 976// name is the demangled name of the given builtin. 977// set specifies which external instruction set the builtin belongs to. 978//===----------------------------------------------------------------------===// 979class ConvertBuiltin<string name, InstructionSet set> { 980 string Name = name; 981 InstructionSet Set = set; 982 bit IsDestinationSigned = !eq(!find(name, "convert_u"), -1); 983 bit IsSaturated = !not(!eq(!find(name, "_sat"), -1)); 984 bit IsRounded = !not(!eq(!find(name, "_rt"), -1)); 985 FPRoundingMode RoundingMode = !cond(!not(!eq(!find(name, "_rte"), -1)) : RTE, 986 !not(!eq(!find(name, "_rtz"), -1)) : RTZ, 987 !not(!eq(!find(name, "_rtp"), -1)) : RTP, 988 !not(!eq(!find(name, "_rtn"), -1)) : RTN, 989 true : RTE); 990} 991 992// Table gathering all the convert builtins. 993def ConvertBuiltins : GenericTable { 994 let FilterClass = "ConvertBuiltin"; 995 let Fields = ["Name", "Set", "IsDestinationSigned", "IsSaturated", "IsRounded", "RoundingMode"]; 996 string TypeOf_Set = "InstructionSet"; 997 string TypeOf_RoundingMode = "FPRoundingMode"; 998} 999 1000// Function to lookup convert builtins by their name and set. 1001def lookupConvertBuiltin : SearchIndex { 1002 let Table = ConvertBuiltins; 1003 let Key = ["Name", "Set"]; 1004} 1005 1006// Multiclass used to define at the same time both a demangled builtin records 1007// and a corresponding convert builtin records. 1008multiclass DemangledConvertBuiltin<string name, InstructionSet set> { 1009 // Create records for scalar and 2, 4, 8, and 16 element vector conversions. 1010 foreach i = ["", "2", "3", "4", "8", "16"] in { 1011 // Also create records for each rounding mode. 1012 foreach j = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { 1013 def : DemangledBuiltin<!strconcat(name, i, j), set, Convert, 1, 1>; 1014 def : ConvertBuiltin<!strconcat(name, i, j), set>; 1015 1016 // Create records with the "_sat" modifier for all conversions except 1017 // those targeting floating-point types. 1018 if !eq(!find(name, "float"), -1) then { 1019 def : DemangledBuiltin<!strconcat(name, i, "_sat", j), set, Convert, 1, 1>; 1020 def : ConvertBuiltin<!strconcat(name, i, "_sat", j), set>; 1021 } 1022 } 1023 } 1024} 1025 1026// Explicit conversion builtin records: 1027defm : DemangledConvertBuiltin<"convert_char", OpenCL_std>; 1028defm : DemangledConvertBuiltin<"convert_uchar", OpenCL_std>; 1029defm : DemangledConvertBuiltin<"convert_short", OpenCL_std>; 1030defm : DemangledConvertBuiltin<"convert_ushort", OpenCL_std>; 1031defm : DemangledConvertBuiltin<"convert_int", OpenCL_std>; 1032defm : DemangledConvertBuiltin<"convert_uint", OpenCL_std>; 1033defm : DemangledConvertBuiltin<"convert_long", OpenCL_std>; 1034defm : DemangledConvertBuiltin<"convert_ulong", OpenCL_std>; 1035defm : DemangledConvertBuiltin<"convert_float", OpenCL_std>; 1036 1037//===----------------------------------------------------------------------===// 1038// Class defining a vector data load/store builtin record used for lowering 1039// into OpExtInst instruction. 1040// 1041// name is the demangled name of the given builtin. 1042// set specifies which external instruction set the builtin belongs to. 1043// number specifies the number of the instruction in the external set. 1044//===----------------------------------------------------------------------===// 1045class VectorLoadStoreBuiltin<string name, InstructionSet set, int number> { 1046 string Name = name; 1047 InstructionSet Set = set; 1048 bits<32> Number = number; 1049 bit IsRounded = !not(!eq(!find(name, "_rt"), -1)); 1050 FPRoundingMode RoundingMode = !cond(!not(!eq(!find(name, "_rte"), -1)) : RTE, 1051 !not(!eq(!find(name, "_rtz"), -1)) : RTZ, 1052 !not(!eq(!find(name, "_rtp"), -1)) : RTP, 1053 !not(!eq(!find(name, "_rtn"), -1)) : RTN, 1054 true : RTE); 1055} 1056 1057// Table gathering all the vector data load/store builtins. 1058def VectorLoadStoreBuiltins : GenericTable { 1059 let FilterClass = "VectorLoadStoreBuiltin"; 1060 let Fields = ["Name", "Set", "Number", "IsRounded", "RoundingMode"]; 1061 string TypeOf_Set = "InstructionSet"; 1062 string TypeOf_RoundingMode = "FPRoundingMode"; 1063} 1064 1065// Function to lookup vector data load/store builtins by their name and set. 1066def lookupVectorLoadStoreBuiltin : SearchIndex { 1067 let Table = VectorLoadStoreBuiltins; 1068 let Key = ["Name", "Set"]; 1069} 1070 1071// Multiclass used to define at the same time both a demangled builtin record 1072// and a corresponding vector data load/store builtin record. 1073multiclass DemangledVectorLoadStoreBuiltin<string name, bits<8> minNumArgs, bits<8> maxNumArgs, int number> { 1074 def : DemangledBuiltin<name, OpenCL_std, VectorLoadStore, minNumArgs, maxNumArgs>; 1075 def : VectorLoadStoreBuiltin<name, OpenCL_std, number>; 1076} 1077 1078// Create records for scalar and 2, 4, 8, and 16 vector element count. 1079foreach i = ["", "2", "3", "4", "8", "16"] in { 1080 if !eq(i, "") then { 1081 defm : DemangledVectorLoadStoreBuiltin<"vload_half", 2, 2, 173>; 1082 defm : DemangledVectorLoadStoreBuiltin<"vstore_half", 3, 3, 175>; 1083 } else { 1084 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vload_half", i), 3, 3, 174>; 1085 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore_half", i), 3, 3, 177>; 1086 } 1087 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vload", i), 2, 2, 171>; 1088 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore", i), 3, 3, 172>; 1089 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vloada_half", i), 2, 2, 174>; 1090 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstorea_half", i), 3, 3, 180>; 1091 1092 // Also create records for each rounding mode. 1093 foreach j = ["_rte", "_rtz", "_rtp", "_rtn"] in { 1094 if !eq(i, "") then { 1095 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore_half", j), 3, 3, 176>; 1096 } else { 1097 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore_half", i, j), 3, 3, 178>; 1098 } 1099 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstorea_half", i, j), 3, 3, 181>; 1100 } 1101} 1102 1103//===----------------------------------------------------------------------===// 1104// Class defining implementation details of demangled builtin types. The info 1105// in the record is used for lowering into OpType. 1106// 1107// name is the demangled name of the given builtin. 1108// operation specifies the SPIR-V opcode the StructType should be lowered to. 1109//===----------------------------------------------------------------------===// 1110class DemangledType<string name, Op operation> { 1111 string Name = name; 1112 Op Opcode = operation; 1113} 1114 1115// Table gathering all the demangled type records. 1116def DemangledTypes : GenericTable { 1117 let FilterClass = "DemangledType"; 1118 let Fields = ["Name", "Opcode"]; 1119} 1120 1121// Function to lookup builtin types by their demangled name. 1122def lookupBuiltinType : SearchIndex { 1123 let Table = DemangledTypes; 1124 let Key = ["Name"]; 1125} 1126 1127def : DemangledType<"opencl.reserve_id_t", OpTypeReserveId>; 1128def : DemangledType<"opencl.event_t", OpTypeEvent>; 1129def : DemangledType<"opencl.queue_t", OpTypeQueue>; 1130def : DemangledType<"opencl.sampler_t", OpTypeSampler>; 1131def : DemangledType<"opencl.clk_event_t", OpTypeDeviceEvent>; 1132 1133def : DemangledType<"spirv.ReserveId", OpTypeReserveId>; 1134def : DemangledType<"spirv.PipeStorage", OpTypePipeStorage>; 1135def : DemangledType<"spirv.Queue", OpTypeQueue>; 1136def : DemangledType<"spirv.Event", OpTypeEvent>; 1137def : DemangledType<"spirv.Sampler", OpTypeSampler>; 1138def : DemangledType<"spirv.DeviceEvent", OpTypeDeviceEvent>; 1139 1140// Some SPIR-V builtin types (e.g. spirv.Image) have a complex list of 1141// parameters as part of their name. Some of those parameters should be treated 1142// as numeric literals and therefore they cannot be represented in TableGen and 1143// should be parsed instead. 1144def : DemangledType<"spirv.Image", OpTypeImage>; 1145def : DemangledType<"spirv.SampledImage", OpTypeSampledImage>; 1146def : DemangledType<"spirv.Pipe", OpTypePipe>; 1147 1148// Class definining lowering details for various variants of image type indentifiers. 1149class ImageType<string name> { 1150 string Name = name; 1151 string Type = "void"; 1152 AccessQualifier Qualifier = !cond(!not(!eq(!find(name, "_ro_t"), -1)) : ReadOnly, 1153 !not(!eq(!find(name, "_wo_t"), -1)) : WriteOnly, 1154 !not(!eq(!find(name, "_rw_t"), -1)) : ReadWrite, 1155 true : ReadOnly); 1156 Dim Dimensionality = !cond(!not(!eq(!find(name, "buffer"), -1)) : DIM_Buffer, 1157 !not(!eq(!find(name, "image1"), -1)) : DIM_1D, 1158 !not(!eq(!find(name, "image2"), -1)) : DIM_2D, 1159 !not(!eq(!find(name, "image3"), -1)) : DIM_3D); 1160 bit Arrayed = !not(!eq(!find(name, "array"), -1)); 1161 bit Depth = !not(!eq(!find(name, "depth"), -1)); 1162 bit Multisampled = false; 1163 bit Sampled = false; 1164 ImageFormat Format = Unknown; 1165} 1166 1167// Table gathering all the image type records. 1168def ImageTypes : GenericTable { 1169 let FilterClass = "ImageType"; 1170 let Fields = ["Name", "Type", "Qualifier", "Dimensionality", "Arrayed", 1171 "Depth", "Multisampled", "Sampled", "Format"]; 1172 string TypeOf_Qualifier = "AccessQualifier"; 1173 string TypeOf_Dimensionality = "Dim"; 1174 string TypeOf_Format = "ImageFormat"; 1175} 1176 1177// Function to lookup builtin image types by their demangled name. 1178def lookupImageType : SearchIndex { 1179 let Table = ImageTypes; 1180 let Key = ["Name"]; 1181} 1182 1183// Multiclass used to define at the same time a DemangledType record used 1184// for matching an incoming demangled string to the OpTypeImage opcode and 1185// ImageType conatining the lowering details. 1186multiclass DemangledImageType<string name> { 1187 def : DemangledType<name, OpTypeImage>; 1188 def : ImageType<name>; 1189} 1190 1191foreach aq = ["_t", "_ro_t", "_wo_t", "_rw_t"] in { 1192 defm : DemangledImageType<!strconcat("opencl.image1d", aq)>; 1193 defm : DemangledImageType<!strconcat("opencl.image1d_array", aq)>; 1194 defm : DemangledImageType<!strconcat("opencl.image1d_buffer", aq)>; 1195 1196 foreach a1 = ["", "_array"] in { 1197 foreach a2 = ["", "_msaa"] in { 1198 foreach a3 = ["", "_depth"] in { 1199 defm : DemangledImageType<!strconcat("opencl.image2d", a1, a2, a3, aq)>; 1200 } 1201 } 1202 } 1203 1204 defm : DemangledImageType<!strconcat("opencl.image3d", aq)>; 1205} 1206 1207// Class definining lowering details for various variants of pipe type indentifiers. 1208class PipeType<string name> { 1209 string Name = name; 1210 AccessQualifier Qualifier = !cond(!not(!eq(!find(name, "_ro_t"), -1)) : ReadOnly, 1211 !not(!eq(!find(name, "_wo_t"), -1)) : WriteOnly, 1212 !not(!eq(!find(name, "_rw_t"), -1)) : ReadWrite, 1213 true : ReadOnly); 1214} 1215 1216// Table gathering all the pipe type records. 1217def PipeTypes : GenericTable { 1218 let FilterClass = "PipeType"; 1219 let Fields = ["Name", "Qualifier"]; 1220 string TypeOf_Qualifier = "AccessQualifier"; 1221} 1222 1223// Function to lookup builtin pipe types by their demangled name. 1224def lookupPipeType : SearchIndex { 1225 let Table = PipeTypes; 1226 let Key = ["Name"]; 1227} 1228 1229// Multiclass used to define at the same time a DemangledType record used 1230// for matching an incoming demangled string to the OpTypePipe opcode and 1231// PipeType conatining the lowering details. 1232multiclass DemangledPipeType<string name> { 1233 def : DemangledType<name, OpTypePipe>; 1234 def : PipeType<name>; 1235} 1236 1237foreach aq = ["_t", "_ro_t", "_wo_t", "_rw_t"] in { 1238 defm : DemangledPipeType<!strconcat("opencl.pipe", aq)>; 1239} 1240 1241//===----------------------------------------------------------------------===// 1242// Classes definining various OpenCL enums. 1243//===----------------------------------------------------------------------===// 1244 1245// OpenCL memory_scope enum 1246def CLMemoryScope : GenericEnum { 1247 let FilterClass = "CLMemoryScope"; 1248 let NameField = "Name"; 1249 let ValueField = "Value"; 1250} 1251 1252class CLMemoryScope<bits<32> value> { 1253 string Name = NAME; 1254 bits<32> Value = value; 1255} 1256 1257def memory_scope_work_item : CLMemoryScope<0>; 1258def memory_scope_work_group : CLMemoryScope<1>; 1259def memory_scope_device : CLMemoryScope<2>; 1260def memory_scope_all_svm_devices : CLMemoryScope<3>; 1261def memory_scope_sub_group : CLMemoryScope<4>; 1262 1263// OpenCL sampler addressing mode/bitmask enum 1264def CLSamplerAddressingMode : GenericEnum { 1265 let FilterClass = "CLSamplerAddressingMode"; 1266 let NameField = "Name"; 1267 let ValueField = "Value"; 1268} 1269 1270class CLSamplerAddressingMode<bits<32> value> { 1271 string Name = NAME; 1272 bits<32> Value = value; 1273} 1274 1275def CLK_ADDRESS_NONE : CLSamplerAddressingMode<0x0>; 1276def CLK_ADDRESS_CLAMP : CLSamplerAddressingMode<0x4>; 1277def CLK_ADDRESS_CLAMP_TO_EDGE : CLSamplerAddressingMode<0x2>; 1278def CLK_ADDRESS_REPEAT : CLSamplerAddressingMode<0x6>; 1279def CLK_ADDRESS_MIRRORED_REPEAT : CLSamplerAddressingMode<0x8>; 1280def CLK_ADDRESS_MODE_MASK : CLSamplerAddressingMode<0xE>; 1281def CLK_NORMALIZED_COORDS_FALSE : CLSamplerAddressingMode<0x0>; 1282def CLK_NORMALIZED_COORDS_TRUE : CLSamplerAddressingMode<0x1>; 1283def CLK_FILTER_NEAREST : CLSamplerAddressingMode<0x10>; 1284def CLK_FILTER_LINEAR : CLSamplerAddressingMode<0x20>; 1285 1286// OpenCL memory fences 1287def CLMemoryFenceFlags : GenericEnum { 1288 let FilterClass = "CLMemoryFenceFlags"; 1289 let NameField = "Name"; 1290 let ValueField = "Value"; 1291} 1292 1293class CLMemoryFenceFlags<bits<32> value> { 1294 string Name = NAME; 1295 bits<32> Value = value; 1296} 1297 1298def CLK_LOCAL_MEM_FENCE : CLMemoryFenceFlags<0x1>; 1299def CLK_GLOBAL_MEM_FENCE : CLMemoryFenceFlags<0x2>; 1300def CLK_IMAGE_MEM_FENCE : CLMemoryFenceFlags<0x4>; 1301