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>; 29def NonSemantic_Shader_DebugInfo_100 : InstructionSet<3>; 30 31// Define various builtin groups 32def BuiltinGroup : GenericEnum { 33 let FilterClass = "BuiltinGroup"; 34} 35 36class BuiltinGroup; 37 38def Extended : BuiltinGroup; 39def Relational : BuiltinGroup; 40def Group : BuiltinGroup; 41def Variable : BuiltinGroup; 42def Atomic : BuiltinGroup; 43def Barrier : BuiltinGroup; 44def Dot : BuiltinGroup; 45def Wave : BuiltinGroup; 46def GetQuery : BuiltinGroup; 47def ImageSizeQuery : BuiltinGroup; 48def ImageMiscQuery : BuiltinGroup; 49def Convert : BuiltinGroup; 50def ReadImage : BuiltinGroup; 51def WriteImage : BuiltinGroup; 52def SampleImage : BuiltinGroup; 53def Select : BuiltinGroup; 54def SpecConstant : BuiltinGroup; 55def Enqueue : BuiltinGroup; 56def AsyncCopy : BuiltinGroup; 57def VectorLoadStore : BuiltinGroup; 58def LoadStore : BuiltinGroup; 59def IntelSubgroups : BuiltinGroup; 60def AtomicFloating : BuiltinGroup; 61def GroupUniform : BuiltinGroup; 62def KernelClock : BuiltinGroup; 63def CastToPtr : BuiltinGroup; 64def Construct : BuiltinGroup; 65def CoopMatr : BuiltinGroup; 66def ICarryBorrow : BuiltinGroup; 67 68//===----------------------------------------------------------------------===// 69// Class defining a demangled builtin record. The information in the record 70// should be used to expand the builtin into either native SPIR-V instructions 71// or an external call (in case of builtins without a direct mapping). 72// 73// name is the demangled name of the given builtin. 74// set specifies which external instruction set the builtin belongs to. 75// group specifies to which implementation group given record belongs. 76// minNumArgs is the minimum required number of arguments for lowering. 77// maxNumArgs specifies the maximum used number of arguments for lowering. 78//===----------------------------------------------------------------------===// 79class DemangledBuiltin<string name, InstructionSet set, BuiltinGroup group, bits<8> minNumArgs, bits<8> maxNumArgs> { 80 string Name = name; 81 InstructionSet Set = set; 82 BuiltinGroup Group = group; 83 bits<8> MinNumArgs = minNumArgs; 84 bits<8> MaxNumArgs = maxNumArgs; 85} 86 87// Table gathering all the builtins. 88def DemangledBuiltins : GenericTable { 89 let FilterClass = "DemangledBuiltin"; 90 let Fields = ["Name", "Set", "Group", "MinNumArgs", "MaxNumArgs"]; 91 string TypeOf_Set = "InstructionSet"; 92 string TypeOf_Group = "BuiltinGroup"; 93} 94 95// Function to lookup builtins by their demangled name and set. 96def lookupBuiltin : SearchIndex { 97 let Table = DemangledBuiltins; 98 let Key = ["Name", "Set"]; 99} 100 101// Dot builtin record: 102def : DemangledBuiltin<"dot", OpenCL_std, Dot, 2, 2>; 103def : DemangledBuiltin<"__spirv_Dot", OpenCL_std, Dot, 2, 2>; 104 105// Image builtin records: 106def : DemangledBuiltin<"read_imagei", OpenCL_std, ReadImage, 2, 4>; 107def : DemangledBuiltin<"read_imageui", OpenCL_std, ReadImage, 2, 4>; 108def : DemangledBuiltin<"read_imagef", OpenCL_std, ReadImage, 2, 4>; 109 110def : DemangledBuiltin<"write_imagef", OpenCL_std, WriteImage, 3, 4>; 111def : DemangledBuiltin<"write_imagei", OpenCL_std, WriteImage, 3, 4>; 112def : DemangledBuiltin<"write_imageui", OpenCL_std, WriteImage, 3, 4>; 113def : DemangledBuiltin<"write_imageh", OpenCL_std, WriteImage, 3, 4>; 114 115def : DemangledBuiltin<"__translate_sampler_initializer", OpenCL_std, SampleImage, 1, 1>; 116def : DemangledBuiltin<"__spirv_SampledImage", OpenCL_std, SampleImage, 2, 2>; 117def : DemangledBuiltin<"__spirv_ImageSampleExplicitLod", OpenCL_std, SampleImage, 3, 4>; 118 119// Select builtin record: 120def : DemangledBuiltin<"__spirv_Select", OpenCL_std, Select, 3, 3>; 121 122// Composite Construct builtin record: 123def : DemangledBuiltin<"__spirv_CompositeConstruct", OpenCL_std, Construct, 1, 0>; 124 125//===----------------------------------------------------------------------===// 126// Class defining an extended builtin record used for lowering into an 127// OpExtInst instruction. 128// 129// name is the demangled name of the given builtin. 130// set specifies which external instruction set the builtin belongs to. 131// number specifies the number of the instruction in the external set. 132//===----------------------------------------------------------------------===// 133class ExtendedBuiltin<string name, InstructionSet set, int number> { 134 string Name = name; 135 InstructionSet Set = set; 136 bits<32> Number = number; 137} 138 139// Table gathering all the extended builtins. 140def ExtendedBuiltins : GenericTable { 141 let FilterClass = "ExtendedBuiltin"; 142 let Fields = ["Name", "Set", "Number"]; 143 string TypeOf_Set = "InstructionSet"; 144} 145 146// Function to lookup extended builtins by their name and set. 147def lookupExtendedBuiltin : SearchIndex { 148 let Table = ExtendedBuiltins; 149 let Key = ["Name", "Set"]; 150} 151 152// Function to lookup extended builtins by their set and number. 153def lookupExtendedBuiltinBySetAndNumber : SearchIndex { 154 let Table = ExtendedBuiltins; 155 let Key = ["Set", "Number"]; 156} 157 158// OpenCL extended instruction enums 159def OpenCLExtInst : GenericEnum { 160 let FilterClass = "OpenCLExtInst"; 161 let NameField = "Name"; 162 let ValueField = "Value"; 163} 164 165class OpenCLExtInst<string name, bits<32> value> { 166 string Name = name; 167 bits<32> Value = value; 168} 169 170// GLSL extended instruction enums 171def GLSLExtInst : GenericEnum { 172 let FilterClass = "GLSLExtInst"; 173 let NameField = "Name"; 174 let ValueField = "Value"; 175} 176 177class GLSLExtInst<string name, bits<32> value> { 178 string Name = name; 179 bits<32> Value = value; 180} 181 182def NonSemanticExtInst : GenericEnum { 183 let FilterClass = "NonSemanticExtInst"; 184 let NameField = "Name"; 185 let ValueField = "Value"; 186} 187 188class NonSemanticExtInst<string name, bits<32> value> { 189 string Name = name; 190 bits<32> Value = value; 191} 192 193// Multiclass used to define at the same time both a demangled builtin record 194// and a corresponding extended builtin record. 195multiclass DemangledExtendedBuiltin<string name, InstructionSet set, int number> { 196 def : DemangledBuiltin<name, set, Extended, 1, 3>; 197 def : ExtendedBuiltin<name, set, number>; 198 199 if !eq(set, OpenCL_std) then { 200 def : OpenCLExtInst<name, number>; 201 } 202 203 if !eq(set, GLSL_std_450) then { 204 def : GLSLExtInst<name, number>; 205 } 206 207 if !eq(set, NonSemantic_Shader_DebugInfo_100) then { 208 def : NonSemanticExtInst<name, number>; 209 } 210} 211 212// Extended builtin records: 213defm : DemangledExtendedBuiltin<"acos", OpenCL_std, 0>; 214defm : DemangledExtendedBuiltin<"acosh", OpenCL_std, 1>; 215defm : DemangledExtendedBuiltin<"acospi", OpenCL_std, 2>; 216defm : DemangledExtendedBuiltin<"asin", OpenCL_std, 3>; 217defm : DemangledExtendedBuiltin<"asinh", OpenCL_std, 4>; 218defm : DemangledExtendedBuiltin<"asinpi", OpenCL_std, 5>; 219defm : DemangledExtendedBuiltin<"atan", OpenCL_std, 6>; 220defm : DemangledExtendedBuiltin<"atan2", OpenCL_std, 7>; 221defm : DemangledExtendedBuiltin<"atanh", OpenCL_std, 8>; 222defm : DemangledExtendedBuiltin<"atanpi", OpenCL_std, 9>; 223defm : DemangledExtendedBuiltin<"atan2pi", OpenCL_std, 10>; 224defm : DemangledExtendedBuiltin<"cbrt", OpenCL_std, 11>; 225defm : DemangledExtendedBuiltin<"ceil", OpenCL_std, 12>; 226defm : DemangledExtendedBuiltin<"copysign", OpenCL_std, 13>; 227defm : DemangledExtendedBuiltin<"cos", OpenCL_std, 14>; 228defm : DemangledExtendedBuiltin<"cosh", OpenCL_std, 15>; 229defm : DemangledExtendedBuiltin<"cospi", OpenCL_std, 16>; 230defm : DemangledExtendedBuiltin<"erfc", OpenCL_std, 17>; 231defm : DemangledExtendedBuiltin<"erf", OpenCL_std, 18>; 232defm : DemangledExtendedBuiltin<"exp", OpenCL_std, 19>; 233defm : DemangledExtendedBuiltin<"exp2", OpenCL_std, 20>; 234defm : DemangledExtendedBuiltin<"exp10", OpenCL_std, 21>; 235defm : DemangledExtendedBuiltin<"expm1", OpenCL_std, 22>; 236defm : DemangledExtendedBuiltin<"fabs", OpenCL_std, 23>; 237defm : DemangledExtendedBuiltin<"fdim", OpenCL_std, 24>; 238defm : DemangledExtendedBuiltin<"floor", OpenCL_std, 25>; 239defm : DemangledExtendedBuiltin<"fma", OpenCL_std, 26>; 240defm : DemangledExtendedBuiltin<"fmax", OpenCL_std, 27>; 241defm : DemangledExtendedBuiltin<"fmin", OpenCL_std, 28>; 242defm : DemangledExtendedBuiltin<"fmod", OpenCL_std, 29>; 243defm : DemangledExtendedBuiltin<"fract", OpenCL_std, 30>; 244defm : DemangledExtendedBuiltin<"frexp", OpenCL_std, 31>; 245defm : DemangledExtendedBuiltin<"hypot", OpenCL_std, 32>; 246defm : DemangledExtendedBuiltin<"ilogb", OpenCL_std, 33>; 247defm : DemangledExtendedBuiltin<"ldexp", OpenCL_std, 34>; 248defm : DemangledExtendedBuiltin<"lgamma", OpenCL_std, 35>; 249defm : DemangledExtendedBuiltin<"lgamma_r", OpenCL_std, 36>; 250defm : DemangledExtendedBuiltin<"log", OpenCL_std, 37>; 251defm : DemangledExtendedBuiltin<"log2", OpenCL_std, 38>; 252defm : DemangledExtendedBuiltin<"log10", OpenCL_std, 39>; 253defm : DemangledExtendedBuiltin<"log1p", OpenCL_std, 40>; 254defm : DemangledExtendedBuiltin<"logb", OpenCL_std, 41>; 255defm : DemangledExtendedBuiltin<"mad", OpenCL_std, 42>; 256defm : DemangledExtendedBuiltin<"maxmag", OpenCL_std, 43>; 257defm : DemangledExtendedBuiltin<"minmag", OpenCL_std, 44>; 258defm : DemangledExtendedBuiltin<"modf", OpenCL_std, 45>; 259defm : DemangledExtendedBuiltin<"nan", OpenCL_std, 46>; 260defm : DemangledExtendedBuiltin<"nextafter", OpenCL_std, 47>; 261defm : DemangledExtendedBuiltin<"pow", OpenCL_std, 48>; 262defm : DemangledExtendedBuiltin<"pown", OpenCL_std, 49>; 263defm : DemangledExtendedBuiltin<"powr", OpenCL_std, 50>; 264defm : DemangledExtendedBuiltin<"remainder", OpenCL_std, 51>; 265defm : DemangledExtendedBuiltin<"remquo", OpenCL_std, 52>; 266defm : DemangledExtendedBuiltin<"rint", OpenCL_std, 53>; 267defm : DemangledExtendedBuiltin<"rootn", OpenCL_std, 54>; 268defm : DemangledExtendedBuiltin<"round", OpenCL_std, 55>; 269defm : DemangledExtendedBuiltin<"rsqrt", OpenCL_std, 56>; 270defm : DemangledExtendedBuiltin<"sin", OpenCL_std, 57>; 271defm : DemangledExtendedBuiltin<"sincos", OpenCL_std, 58>; 272defm : DemangledExtendedBuiltin<"sinh", OpenCL_std, 59>; 273defm : DemangledExtendedBuiltin<"sinpi", OpenCL_std, 60>; 274defm : DemangledExtendedBuiltin<"sqrt", OpenCL_std, 61>; 275defm : DemangledExtendedBuiltin<"tan", OpenCL_std, 62>; 276defm : DemangledExtendedBuiltin<"tanh", OpenCL_std, 63>; 277defm : DemangledExtendedBuiltin<"tanpi", OpenCL_std, 64>; 278defm : DemangledExtendedBuiltin<"tgamma", OpenCL_std, 65>; 279defm : DemangledExtendedBuiltin<"trunc", OpenCL_std, 66>; 280defm : DemangledExtendedBuiltin<"half_cos", OpenCL_std, 67>; 281defm : DemangledExtendedBuiltin<"half_divide", OpenCL_std, 68>; 282defm : DemangledExtendedBuiltin<"half_exp", OpenCL_std, 69>; 283defm : DemangledExtendedBuiltin<"half_exp2", OpenCL_std, 70>; 284defm : DemangledExtendedBuiltin<"half_exp10", OpenCL_std, 71>; 285defm : DemangledExtendedBuiltin<"half_log", OpenCL_std, 72>; 286defm : DemangledExtendedBuiltin<"half_log2", OpenCL_std, 73>; 287defm : DemangledExtendedBuiltin<"half_log10", OpenCL_std, 74>; 288defm : DemangledExtendedBuiltin<"half_powr", OpenCL_std, 75>; 289defm : DemangledExtendedBuiltin<"half_recip", OpenCL_std, 76>; 290defm : DemangledExtendedBuiltin<"half_rsqrt", OpenCL_std, 77>; 291defm : DemangledExtendedBuiltin<"half_sin", OpenCL_std, 78>; 292defm : DemangledExtendedBuiltin<"half_sqrt", OpenCL_std, 79>; 293defm : DemangledExtendedBuiltin<"half_tan", OpenCL_std, 80>; 294defm : DemangledExtendedBuiltin<"native_cos", OpenCL_std, 81>; 295defm : DemangledExtendedBuiltin<"native_divide", OpenCL_std, 82>; 296defm : DemangledExtendedBuiltin<"native_exp", OpenCL_std, 83>; 297defm : DemangledExtendedBuiltin<"native_exp2", OpenCL_std, 84>; 298defm : DemangledExtendedBuiltin<"native_exp10", OpenCL_std, 85>; 299defm : DemangledExtendedBuiltin<"native_log", OpenCL_std, 86>; 300defm : DemangledExtendedBuiltin<"native_log2", OpenCL_std, 87>; 301defm : DemangledExtendedBuiltin<"native_log10", OpenCL_std, 88>; 302defm : DemangledExtendedBuiltin<"native_powr", OpenCL_std, 89>; 303defm : DemangledExtendedBuiltin<"native_recip", OpenCL_std, 90>; 304defm : DemangledExtendedBuiltin<"native_rsqrt", OpenCL_std, 91>; 305defm : DemangledExtendedBuiltin<"native_sin", OpenCL_std, 92>; 306defm : DemangledExtendedBuiltin<"native_sqrt", OpenCL_std, 93>; 307defm : DemangledExtendedBuiltin<"native_tan", OpenCL_std, 94>; 308defm : DemangledExtendedBuiltin<"s_abs", OpenCL_std, 141>; 309defm : DemangledExtendedBuiltin<"s_abs_diff", OpenCL_std, 142>; 310defm : DemangledExtendedBuiltin<"s_add_sat", OpenCL_std, 143>; 311defm : DemangledExtendedBuiltin<"u_add_sat", OpenCL_std, 144>; 312defm : DemangledExtendedBuiltin<"s_hadd", OpenCL_std, 145>; 313defm : DemangledExtendedBuiltin<"u_hadd", OpenCL_std, 146>; 314defm : DemangledExtendedBuiltin<"s_rhadd", OpenCL_std, 147>; 315defm : DemangledExtendedBuiltin<"u_rhadd", OpenCL_std, 148>; 316defm : DemangledExtendedBuiltin<"s_clamp", OpenCL_std, 149>; 317defm : DemangledExtendedBuiltin<"u_clamp", OpenCL_std, 150>; 318defm : DemangledExtendedBuiltin<"clz", OpenCL_std, 151>; 319defm : DemangledExtendedBuiltin<"ctz", OpenCL_std, 152>; 320defm : DemangledExtendedBuiltin<"s_mad_hi", OpenCL_std, 153>; 321defm : DemangledExtendedBuiltin<"u_mad_sat", OpenCL_std, 154>; 322defm : DemangledExtendedBuiltin<"s_mad_sat", OpenCL_std, 155>; 323defm : DemangledExtendedBuiltin<"s_max", OpenCL_std, 156>; 324defm : DemangledExtendedBuiltin<"u_max", OpenCL_std, 157>; 325defm : DemangledExtendedBuiltin<"s_min", OpenCL_std, 158>; 326defm : DemangledExtendedBuiltin<"u_min", OpenCL_std, 159>; 327defm : DemangledExtendedBuiltin<"s_mul_hi", OpenCL_std, 160>; 328defm : DemangledExtendedBuiltin<"rotate", OpenCL_std, 161>; 329defm : DemangledExtendedBuiltin<"s_sub_sat", OpenCL_std, 162>; 330defm : DemangledExtendedBuiltin<"u_sub_sat", OpenCL_std, 163>; 331defm : DemangledExtendedBuiltin<"u_upsample", OpenCL_std, 164>; 332defm : DemangledExtendedBuiltin<"s_upsample", OpenCL_std, 165>; 333defm : DemangledExtendedBuiltin<"popcount", OpenCL_std, 166>; 334defm : DemangledExtendedBuiltin<"s_mad24", OpenCL_std, 167>; 335defm : DemangledExtendedBuiltin<"u_mad24", OpenCL_std, 168>; 336defm : DemangledExtendedBuiltin<"s_mul24", OpenCL_std, 169>; 337defm : DemangledExtendedBuiltin<"u_mul24", OpenCL_std, 170>; 338defm : DemangledExtendedBuiltin<"u_abs", OpenCL_std, 201>; 339defm : DemangledExtendedBuiltin<"u_abs_diff", OpenCL_std, 202>; 340defm : DemangledExtendedBuiltin<"u_mul_hi", OpenCL_std, 203>; 341defm : DemangledExtendedBuiltin<"u_mad_hi", OpenCL_std, 204>; 342defm : DemangledExtendedBuiltin<"fclamp", OpenCL_std, 95>; 343defm : DemangledExtendedBuiltin<"degrees", OpenCL_std, 96>; 344defm : DemangledExtendedBuiltin<"fmax_common", OpenCL_std, 97>; 345defm : DemangledExtendedBuiltin<"fmin_common", OpenCL_std, 98>; 346defm : DemangledExtendedBuiltin<"mix", OpenCL_std, 99>; 347defm : DemangledExtendedBuiltin<"radians", OpenCL_std, 100>; 348defm : DemangledExtendedBuiltin<"step", OpenCL_std, 101>; 349defm : DemangledExtendedBuiltin<"smoothstep", OpenCL_std, 102>; 350defm : DemangledExtendedBuiltin<"sign", OpenCL_std, 103>; 351defm : DemangledExtendedBuiltin<"cross", OpenCL_std, 104>; 352defm : DemangledExtendedBuiltin<"distance", OpenCL_std, 105>; 353defm : DemangledExtendedBuiltin<"length", OpenCL_std, 106>; 354defm : DemangledExtendedBuiltin<"normalize", OpenCL_std, 107>; 355defm : DemangledExtendedBuiltin<"fast_distance", OpenCL_std, 108>; 356defm : DemangledExtendedBuiltin<"fast_length", OpenCL_std, 109>; 357defm : DemangledExtendedBuiltin<"fast_normalize", OpenCL_std, 110>; 358defm : DemangledExtendedBuiltin<"bitselect", OpenCL_std, 186>; 359defm : DemangledExtendedBuiltin<"select", OpenCL_std, 187>; 360defm : DemangledExtendedBuiltin<"vloadn", OpenCL_std, 171>; 361defm : DemangledExtendedBuiltin<"vstoren", OpenCL_std, 172>; 362defm : DemangledExtendedBuiltin<"vload_half", OpenCL_std, 173>; 363defm : DemangledExtendedBuiltin<"vload_halfn", OpenCL_std, 174>; 364defm : DemangledExtendedBuiltin<"vstore_half", OpenCL_std, 175>; 365defm : DemangledExtendedBuiltin<"vstore_half_r", OpenCL_std, 176>; 366defm : DemangledExtendedBuiltin<"vstore_halfn", OpenCL_std, 177>; 367defm : DemangledExtendedBuiltin<"vstore_halfn_r", OpenCL_std, 178>; 368defm : DemangledExtendedBuiltin<"vloada_halfn", OpenCL_std, 179>; 369defm : DemangledExtendedBuiltin<"vstorea_halfn", OpenCL_std, 180>; 370defm : DemangledExtendedBuiltin<"vstorea_halfn_r", OpenCL_std, 181>; 371defm : DemangledExtendedBuiltin<"shuffle", OpenCL_std, 182>; 372defm : DemangledExtendedBuiltin<"shuffle2", OpenCL_std, 183>; 373defm : DemangledExtendedBuiltin<"printf", OpenCL_std, 184>; 374defm : DemangledExtendedBuiltin<"prefetch", OpenCL_std, 185>; 375 376defm : DemangledExtendedBuiltin<"Round", GLSL_std_450, 1>; 377defm : DemangledExtendedBuiltin<"RoundEven", GLSL_std_450, 2>; 378defm : DemangledExtendedBuiltin<"Trunc", GLSL_std_450, 3>; 379defm : DemangledExtendedBuiltin<"FAbs", GLSL_std_450, 4>; 380defm : DemangledExtendedBuiltin<"SAbs", GLSL_std_450, 5>; 381defm : DemangledExtendedBuiltin<"FSign", GLSL_std_450, 6>; 382defm : DemangledExtendedBuiltin<"SSign", GLSL_std_450, 7>; 383defm : DemangledExtendedBuiltin<"Floor", GLSL_std_450, 8>; 384defm : DemangledExtendedBuiltin<"Ceil", GLSL_std_450, 9>; 385defm : DemangledExtendedBuiltin<"Fract", GLSL_std_450, 10>; 386defm : DemangledExtendedBuiltin<"Radians", GLSL_std_450, 11>; 387defm : DemangledExtendedBuiltin<"Degrees", GLSL_std_450, 12>; 388defm : DemangledExtendedBuiltin<"Sin", GLSL_std_450, 13>; 389defm : DemangledExtendedBuiltin<"Cos", GLSL_std_450, 14>; 390defm : DemangledExtendedBuiltin<"Tan", GLSL_std_450, 15>; 391defm : DemangledExtendedBuiltin<"Asin", GLSL_std_450, 16>; 392defm : DemangledExtendedBuiltin<"Acos", GLSL_std_450, 17>; 393defm : DemangledExtendedBuiltin<"Atan", GLSL_std_450, 18>; 394defm : DemangledExtendedBuiltin<"Sinh", GLSL_std_450, 19>; 395defm : DemangledExtendedBuiltin<"Cosh", GLSL_std_450, 20>; 396defm : DemangledExtendedBuiltin<"Tanh", GLSL_std_450, 21>; 397defm : DemangledExtendedBuiltin<"Asinh", GLSL_std_450, 22>; 398defm : DemangledExtendedBuiltin<"Acosh", GLSL_std_450, 23>; 399defm : DemangledExtendedBuiltin<"Atanh", GLSL_std_450, 24>; 400defm : DemangledExtendedBuiltin<"Atan2", GLSL_std_450, 25>; 401defm : DemangledExtendedBuiltin<"Pow", GLSL_std_450, 26>; 402defm : DemangledExtendedBuiltin<"Exp", GLSL_std_450, 27>; 403defm : DemangledExtendedBuiltin<"Log", GLSL_std_450, 28>; 404defm : DemangledExtendedBuiltin<"Exp2", GLSL_std_450, 29>; 405defm : DemangledExtendedBuiltin<"Log2", GLSL_std_450, 30>; 406defm : DemangledExtendedBuiltin<"Sqrt", GLSL_std_450, 31>; 407defm : DemangledExtendedBuiltin<"InverseSqrt", GLSL_std_450, 32>; 408defm : DemangledExtendedBuiltin<"Determinant", GLSL_std_450, 33>; 409defm : DemangledExtendedBuiltin<"MatrixInverse", GLSL_std_450, 34>; 410defm : DemangledExtendedBuiltin<"Modf", GLSL_std_450, 35>; 411defm : DemangledExtendedBuiltin<"ModfStruct", GLSL_std_450, 36>; 412defm : DemangledExtendedBuiltin<"FMin", GLSL_std_450, 37>; 413defm : DemangledExtendedBuiltin<"UMin", GLSL_std_450, 38>; 414defm : DemangledExtendedBuiltin<"SMin", GLSL_std_450, 39>; 415defm : DemangledExtendedBuiltin<"FMax", GLSL_std_450, 40>; 416defm : DemangledExtendedBuiltin<"UMax", GLSL_std_450, 41>; 417defm : DemangledExtendedBuiltin<"SMax", GLSL_std_450, 42>; 418defm : DemangledExtendedBuiltin<"FClamp", GLSL_std_450, 43>; 419defm : DemangledExtendedBuiltin<"UClamp", GLSL_std_450, 44>; 420defm : DemangledExtendedBuiltin<"SClamp", GLSL_std_450, 45>; 421defm : DemangledExtendedBuiltin<"FMix", GLSL_std_450, 46>; 422defm : DemangledExtendedBuiltin<"Step", GLSL_std_450, 48>; 423defm : DemangledExtendedBuiltin<"SmoothStep", GLSL_std_450, 49>; 424defm : DemangledExtendedBuiltin<"Fma", GLSL_std_450, 50>; 425defm : DemangledExtendedBuiltin<"Frexp", GLSL_std_450, 51>; 426defm : DemangledExtendedBuiltin<"FrexpStruct", GLSL_std_450, 52>; 427defm : DemangledExtendedBuiltin<"Ldexp", GLSL_std_450, 53>; 428defm : DemangledExtendedBuiltin<"PackSnorm4x8", GLSL_std_450, 54>; 429defm : DemangledExtendedBuiltin<"PackUnorm4x8", GLSL_std_450, 55>; 430defm : DemangledExtendedBuiltin<"PackSnorm2x16", GLSL_std_450, 56>; 431defm : DemangledExtendedBuiltin<"PackUnorm2x16", GLSL_std_450, 57>; 432defm : DemangledExtendedBuiltin<"PackHalf2x16", GLSL_std_450, 58>; 433defm : DemangledExtendedBuiltin<"PackDouble2x32", GLSL_std_450, 59>; 434defm : DemangledExtendedBuiltin<"UnpackSnorm2x16", GLSL_std_450, 60>; 435defm : DemangledExtendedBuiltin<"UnpackUnorm2x16", GLSL_std_450, 61>; 436defm : DemangledExtendedBuiltin<"UnpackHalf2x16", GLSL_std_450, 62>; 437defm : DemangledExtendedBuiltin<"UnpackSnorm4x8", GLSL_std_450, 63>; 438defm : DemangledExtendedBuiltin<"UnpackUnorm4x8", GLSL_std_450, 64>; 439defm : DemangledExtendedBuiltin<"UnpackDouble2x32", GLSL_std_450, 65>; 440defm : DemangledExtendedBuiltin<"Length", GLSL_std_450, 66>; 441defm : DemangledExtendedBuiltin<"Distance", GLSL_std_450, 67>; 442defm : DemangledExtendedBuiltin<"Cross", GLSL_std_450, 68>; 443defm : DemangledExtendedBuiltin<"Normalize", GLSL_std_450, 69>; 444defm : DemangledExtendedBuiltin<"FaceForward", GLSL_std_450, 70>; 445defm : DemangledExtendedBuiltin<"Reflect", GLSL_std_450, 71>; 446defm : DemangledExtendedBuiltin<"Refract", GLSL_std_450, 72>; 447defm : DemangledExtendedBuiltin<"FindILsb", GLSL_std_450, 73>; 448defm : DemangledExtendedBuiltin<"FindSMsb", GLSL_std_450, 74>; 449defm : DemangledExtendedBuiltin<"FindUMsb", GLSL_std_450, 75>; 450defm : DemangledExtendedBuiltin<"InterpolateAtCentroid", GLSL_std_450, 76>; 451defm : DemangledExtendedBuiltin<"InterpolateAtSample", GLSL_std_450, 77>; 452defm : DemangledExtendedBuiltin<"InterpolateAtOffset", GLSL_std_450, 78>; 453defm : DemangledExtendedBuiltin<"NMin", GLSL_std_450, 79>; 454defm : DemangledExtendedBuiltin<"NMax", GLSL_std_450, 80>; 455defm : DemangledExtendedBuiltin<"NClamp", GLSL_std_450, 81>; 456 457defm : DemangledExtendedBuiltin<"DebugInfoNone", NonSemantic_Shader_DebugInfo_100, 0>; 458defm : DemangledExtendedBuiltin<"DebugCompilationUnit", NonSemantic_Shader_DebugInfo_100, 1>; 459defm : DemangledExtendedBuiltin<"DebugTypeBasic", NonSemantic_Shader_DebugInfo_100, 2>; 460defm : DemangledExtendedBuiltin<"DebugTypePointer", NonSemantic_Shader_DebugInfo_100, 3>; 461defm : DemangledExtendedBuiltin<"DebugTypeQualifier", NonSemantic_Shader_DebugInfo_100, 4>; 462defm : DemangledExtendedBuiltin<"DebugTypeArray", NonSemantic_Shader_DebugInfo_100, 5>; 463defm : DemangledExtendedBuiltin<"DebugTypeVector", NonSemantic_Shader_DebugInfo_100, 6>; 464defm : DemangledExtendedBuiltin<"DebugTypedef", NonSemantic_Shader_DebugInfo_100, 7>; 465defm : DemangledExtendedBuiltin<"DebugTypeFunction", NonSemantic_Shader_DebugInfo_100, 8>; 466defm : DemangledExtendedBuiltin<"DebugTypeEnum", NonSemantic_Shader_DebugInfo_100, 9>; 467defm : DemangledExtendedBuiltin<"DebugTypeComposite", NonSemantic_Shader_DebugInfo_100, 10>; 468defm : DemangledExtendedBuiltin<"DebugTypeMember", NonSemantic_Shader_DebugInfo_100, 11>; 469defm : DemangledExtendedBuiltin<"DebugTypeInheritance", NonSemantic_Shader_DebugInfo_100, 12>; 470defm : DemangledExtendedBuiltin<"DebugTypePtrToMember", NonSemantic_Shader_DebugInfo_100, 13>; 471defm : DemangledExtendedBuiltin<"DebugTypeTemplate", NonSemantic_Shader_DebugInfo_100, 14>; 472defm : DemangledExtendedBuiltin<"DebugTypeTemplateParameter", NonSemantic_Shader_DebugInfo_100, 15>; 473defm : DemangledExtendedBuiltin<"DebugTypeTemplateTemplateParameter", NonSemantic_Shader_DebugInfo_100, 16>; 474defm : DemangledExtendedBuiltin<"DebugTypeTemplateParameterPack", NonSemantic_Shader_DebugInfo_100, 17>; 475defm : DemangledExtendedBuiltin<"DebugGlobalVariable", NonSemantic_Shader_DebugInfo_100, 18>; 476defm : DemangledExtendedBuiltin<"DebugFunctionDeclaration", NonSemantic_Shader_DebugInfo_100, 19>; 477defm : DemangledExtendedBuiltin<"DebugFunction", NonSemantic_Shader_DebugInfo_100, 20>; 478defm : DemangledExtendedBuiltin<"DebugLexicalBlock", NonSemantic_Shader_DebugInfo_100, 21>; 479defm : DemangledExtendedBuiltin<"DebugLexicalBlockDiscriminator", NonSemantic_Shader_DebugInfo_100, 22>; 480defm : DemangledExtendedBuiltin<"DebugScope", NonSemantic_Shader_DebugInfo_100, 23>; 481defm : DemangledExtendedBuiltin<"DebugNoScope", NonSemantic_Shader_DebugInfo_100, 24>; 482defm : DemangledExtendedBuiltin<"DebugInlinedAt", NonSemantic_Shader_DebugInfo_100, 25>; 483defm : DemangledExtendedBuiltin<"DebugLocalVariable", NonSemantic_Shader_DebugInfo_100, 26>; 484defm : DemangledExtendedBuiltin<"DebugInlinedVariable", NonSemantic_Shader_DebugInfo_100, 27>; 485defm : DemangledExtendedBuiltin<"DebugDeclare", NonSemantic_Shader_DebugInfo_100, 28>; 486defm : DemangledExtendedBuiltin<"DebugValue", NonSemantic_Shader_DebugInfo_100, 29>; 487defm : DemangledExtendedBuiltin<"DebugOperation", NonSemantic_Shader_DebugInfo_100, 30>; 488defm : DemangledExtendedBuiltin<"DebugExpression", NonSemantic_Shader_DebugInfo_100, 31>; 489defm : DemangledExtendedBuiltin<"DebugMacroDef", NonSemantic_Shader_DebugInfo_100, 32>; 490defm : DemangledExtendedBuiltin<"DebugMacroUndef", NonSemantic_Shader_DebugInfo_100, 33>; 491defm : DemangledExtendedBuiltin<"DebugImportedEntity", NonSemantic_Shader_DebugInfo_100, 34>; 492defm : DemangledExtendedBuiltin<"DebugSource", NonSemantic_Shader_DebugInfo_100, 35>; 493defm : DemangledExtendedBuiltin<"DebugFunctionDefinition", NonSemantic_Shader_DebugInfo_100, 101>; 494defm : DemangledExtendedBuiltin<"DebugSourceContinued", NonSemantic_Shader_DebugInfo_100, 102>; 495defm : DemangledExtendedBuiltin<"DebugLine", NonSemantic_Shader_DebugInfo_100, 103>; 496defm : DemangledExtendedBuiltin<"DebugNoLine", NonSemantic_Shader_DebugInfo_100, 104>; 497defm : DemangledExtendedBuiltin<"DebugBuildIdentifier", NonSemantic_Shader_DebugInfo_100, 105>; 498defm : DemangledExtendedBuiltin<"DebugStoragePath", NonSemantic_Shader_DebugInfo_100, 106>; 499defm : DemangledExtendedBuiltin<"DebugEntryPoint", NonSemantic_Shader_DebugInfo_100, 107>; 500defm : DemangledExtendedBuiltin<"DebugTypeMatrix", NonSemantic_Shader_DebugInfo_100, 108>; 501//===----------------------------------------------------------------------===// 502// Class defining an native builtin record used for direct translation into a 503// SPIR-V instruction. 504// 505// name is the demangled name of the given builtin. 506// set specifies which external instruction set the builtin belongs to. 507// opcode specifies the SPIR-V operation code of the generated instruction. 508//===----------------------------------------------------------------------===// 509class NativeBuiltin<string name, InstructionSet set, Op operation> { 510 string Name = name; 511 InstructionSet Set = set; 512 Op Opcode = operation; 513} 514 515// Table gathering all the native builtins. 516def NativeBuiltins : GenericTable { 517 let FilterClass = "NativeBuiltin"; 518 let Fields = ["Name", "Set", "Opcode"]; 519 string TypeOf_Set = "InstructionSet"; 520} 521 522// Function to lookup native builtins by their name and set. 523def lookupNativeBuiltin : SearchIndex { 524 let Table = NativeBuiltins; 525 let Key = ["Name", "Set"]; 526} 527 528// Multiclass used to define at the same time both an incoming builtin record 529// and a corresponding native builtin record. 530multiclass DemangledNativeBuiltin<string name, InstructionSet set, BuiltinGroup group, bits<8> minNumArgs, bits<8> maxNumArgs, Op operation> { 531 def : DemangledBuiltin<name, set, group, minNumArgs, maxNumArgs>; 532 def : NativeBuiltin<name, set, operation>; 533} 534 535// Relational builtin records: 536defm : DemangledNativeBuiltin<"isequal", OpenCL_std, Relational, 2, 2, OpFOrdEqual>; 537defm : DemangledNativeBuiltin<"__spirv_FOrdEqual", OpenCL_std, Relational, 2, 2, OpFOrdEqual>; 538defm : DemangledNativeBuiltin<"isnotequal", OpenCL_std, Relational, 2, 2, OpFUnordNotEqual>; 539defm : DemangledNativeBuiltin<"__spirv_FUnordNotEqual", OpenCL_std, Relational, 2, 2, OpFUnordNotEqual>; 540defm : DemangledNativeBuiltin<"isgreater", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThan>; 541defm : DemangledNativeBuiltin<"__spirv_FOrdGreaterThan", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThan>; 542defm : DemangledNativeBuiltin<"isgreaterequal", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThanEqual>; 543defm : DemangledNativeBuiltin<"__spirv_FOrdGreaterThanEqual", OpenCL_std, Relational, 2, 2, OpFOrdGreaterThanEqual>; 544defm : DemangledNativeBuiltin<"isless", OpenCL_std, Relational, 2, 2, OpFOrdLessThan>; 545defm : DemangledNativeBuiltin<"__spirv_FOrdLessThan", OpenCL_std, Relational, 2, 2, OpFOrdLessThan>; 546defm : DemangledNativeBuiltin<"islessequal", OpenCL_std, Relational, 2, 2, OpFOrdLessThanEqual>; 547defm : DemangledNativeBuiltin<"__spirv_FOrdLessThanEqual", OpenCL_std, Relational, 2, 2, OpFOrdLessThanEqual>; 548defm : DemangledNativeBuiltin<"islessgreater", OpenCL_std, Relational, 2, 2, OpFOrdNotEqual>; 549defm : DemangledNativeBuiltin<"__spirv_FOrdNotEqual", OpenCL_std, Relational, 2, 2, OpFOrdNotEqual>; 550defm : DemangledNativeBuiltin<"isordered", OpenCL_std, Relational, 2, 2, OpOrdered>; 551defm : DemangledNativeBuiltin<"__spirv_Ordered", OpenCL_std, Relational, 2, 2, OpOrdered>; 552defm : DemangledNativeBuiltin<"isunordered", OpenCL_std, Relational, 2, 2, OpUnordered>; 553defm : DemangledNativeBuiltin<"__spirv_Unordered", OpenCL_std, Relational, 2, 2, OpUnordered>; 554defm : DemangledNativeBuiltin<"isfinite", OpenCL_std, Relational, 1, 1, OpIsFinite>; 555defm : DemangledNativeBuiltin<"__spirv_IsFinite", OpenCL_std, Relational, 1, 1, OpIsFinite>; 556defm : DemangledNativeBuiltin<"isinf", OpenCL_std, Relational, 1, 1, OpIsInf>; 557defm : DemangledNativeBuiltin<"__spirv_IsInf", OpenCL_std, Relational, 1, 1, OpIsInf>; 558defm : DemangledNativeBuiltin<"isnan", OpenCL_std, Relational, 1, 1, OpIsNan>; 559defm : DemangledNativeBuiltin<"__spirv_IsNan", OpenCL_std, Relational, 1, 1, OpIsNan>; 560defm : DemangledNativeBuiltin<"isnormal", OpenCL_std, Relational, 1, 1, OpIsNormal>; 561defm : DemangledNativeBuiltin<"__spirv_IsNormal", OpenCL_std, Relational, 1, 1, OpIsNormal>; 562defm : DemangledNativeBuiltin<"signbit", OpenCL_std, Relational, 1, 1, OpSignBitSet>; 563defm : DemangledNativeBuiltin<"__spirv_SignBitSet", OpenCL_std, Relational, 1, 1, OpSignBitSet>; 564defm : DemangledNativeBuiltin<"any", OpenCL_std, Relational, 1, 1, OpAny>; 565defm : DemangledNativeBuiltin<"__spirv_Any", OpenCL_std, Relational, 1, 1, OpAny>; 566defm : DemangledNativeBuiltin<"all", OpenCL_std, Relational, 1, 1, OpAll>; 567defm : DemangledNativeBuiltin<"__spirv_All", OpenCL_std, Relational, 1, 1, OpAll>; 568 569// Atomic builtin records: 570defm : DemangledNativeBuiltin<"atomic_init", OpenCL_std, Atomic, 2, 2, OpStore>; 571defm : DemangledNativeBuiltin<"atomic_load", OpenCL_std, Atomic, 1, 1, OpAtomicLoad>; 572defm : DemangledNativeBuiltin<"atomic_load_explicit", OpenCL_std, Atomic, 2, 3, OpAtomicLoad>; 573defm : DemangledNativeBuiltin<"__spirv_AtomicLoad", OpenCL_std, Atomic, 3, 3, OpAtomicLoad>; 574defm : DemangledNativeBuiltin<"atomic_store", OpenCL_std, Atomic, 2, 2, OpAtomicStore>; 575defm : DemangledNativeBuiltin<"atomic_store_explicit", OpenCL_std, Atomic, 2, 4, OpAtomicStore>; 576defm : DemangledNativeBuiltin<"__spirv_AtomicStore", OpenCL_std, Atomic, 4, 4, OpAtomicStore>; 577defm : DemangledNativeBuiltin<"atomic_compare_exchange_strong", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchange>; 578defm : DemangledNativeBuiltin<"__spirv_AtomicCompareExchange", OpenCL_std, Atomic, 6, 6, OpAtomicCompareExchange>; 579defm : DemangledNativeBuiltin<"atomic_compare_exchange_strong_explicit", OpenCL_std, Atomic, 5, 6, OpAtomicCompareExchange>; 580defm : DemangledNativeBuiltin<"atomic_compare_exchange_weak", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchangeWeak>; 581defm : DemangledNativeBuiltin<"atomic_compare_exchange_weak_explicit", OpenCL_std, Atomic, 5, 6, OpAtomicCompareExchangeWeak>; 582defm : DemangledNativeBuiltin<"__spirv_AtomicCompareExchangeWeak", OpenCL_std, Atomic, 6, 6, OpAtomicCompareExchangeWeak>; 583defm : DemangledNativeBuiltin<"atom_cmpxchg", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchange>; 584defm : DemangledNativeBuiltin<"atomic_cmpxchg", OpenCL_std, Atomic, 3, 6, OpAtomicCompareExchange>; 585defm : DemangledNativeBuiltin<"atom_add", OpenCL_std, Atomic, 2, 4, OpAtomicIAdd>; 586defm : DemangledNativeBuiltin<"atomic_add", OpenCL_std, Atomic, 2, 4, OpAtomicIAdd>; 587defm : DemangledNativeBuiltin<"__spirv_AtomicIAdd", OpenCL_std, Atomic, 4, 4, OpAtomicIAdd>; 588defm : DemangledNativeBuiltin<"atom_sub", OpenCL_std, Atomic, 2, 4, OpAtomicISub>; 589defm : DemangledNativeBuiltin<"atomic_sub", OpenCL_std, Atomic, 2, 4, OpAtomicISub>; 590defm : DemangledNativeBuiltin<"__spirv_AtomicISub", OpenCL_std, Atomic, 4, 4, OpAtomicISub>; 591defm : DemangledNativeBuiltin<"atom_or", OpenCL_std, Atomic, 2, 4, OpAtomicOr>; 592defm : DemangledNativeBuiltin<"atomic_or", OpenCL_std, Atomic, 2, 4, OpAtomicOr>; 593defm : DemangledNativeBuiltin<"__spirv_AtomicOr", OpenCL_std, Atomic, 4, 4, OpAtomicOr>; 594defm : DemangledNativeBuiltin<"atom_xor", OpenCL_std, Atomic, 2, 4, OpAtomicXor>; 595defm : DemangledNativeBuiltin<"atomic_xor", OpenCL_std, Atomic, 2, 4, OpAtomicXor>; 596defm : DemangledNativeBuiltin<"__spirv_AtomicXor", OpenCL_std, Atomic, 4, 4, OpAtomicXor>; 597defm : DemangledNativeBuiltin<"atom_and", OpenCL_std, Atomic, 2, 4, OpAtomicAnd>; 598defm : DemangledNativeBuiltin<"atomic_and", OpenCL_std, Atomic, 2, 4, OpAtomicAnd>; 599defm : DemangledNativeBuiltin<"__spirv_AtomicAnd", OpenCL_std, Atomic, 4, 4, OpAtomicAnd>; 600defm : DemangledNativeBuiltin<"atomic_exchange", OpenCL_std, Atomic, 2, 4, OpAtomicExchange>; 601defm : DemangledNativeBuiltin<"atomic_exchange_explicit", OpenCL_std, Atomic, 2, 4, OpAtomicExchange>; 602defm : DemangledNativeBuiltin<"AtomicEx__spirv_change", OpenCL_std, Atomic, 2, 4, OpAtomicExchange>; 603defm : DemangledNativeBuiltin<"__spirv_AtomicExchange", OpenCL_std, Atomic, 4, 4, OpAtomicExchange>; 604defm : DemangledNativeBuiltin<"atomic_work_item_fence", OpenCL_std, Atomic, 1, 3, OpMemoryBarrier>; 605defm : DemangledNativeBuiltin<"__spirv_MemoryBarrier", OpenCL_std, Atomic, 2, 2, OpMemoryBarrier>; 606defm : DemangledNativeBuiltin<"atomic_fetch_add", OpenCL_std, Atomic, 2, 4, OpAtomicIAdd>; 607defm : DemangledNativeBuiltin<"atomic_fetch_sub", OpenCL_std, Atomic, 2, 4, OpAtomicISub>; 608defm : DemangledNativeBuiltin<"atomic_fetch_or", OpenCL_std, Atomic, 2, 4, OpAtomicOr>; 609defm : DemangledNativeBuiltin<"atomic_fetch_xor", OpenCL_std, Atomic, 2, 4, OpAtomicXor>; 610defm : DemangledNativeBuiltin<"atomic_fetch_and", OpenCL_std, Atomic, 2, 4, OpAtomicAnd>; 611defm : DemangledNativeBuiltin<"atomic_fetch_add_explicit", OpenCL_std, Atomic, 3, 4, OpAtomicIAdd>; 612defm : DemangledNativeBuiltin<"atomic_fetch_sub_explicit", OpenCL_std, Atomic, 3, 4, OpAtomicISub>; 613defm : DemangledNativeBuiltin<"atomic_fetch_or_explicit", OpenCL_std, Atomic, 3, 4, OpAtomicOr>; 614defm : DemangledNativeBuiltin<"atomic_fetch_xor_explicit", OpenCL_std, Atomic, 3, 4, OpAtomicXor>; 615defm : DemangledNativeBuiltin<"atomic_fetch_and_explicit", OpenCL_std, Atomic, 3, 4, OpAtomicAnd>; 616defm : DemangledNativeBuiltin<"atomic_flag_test_and_set", OpenCL_std, Atomic, 1, 1, OpAtomicFlagTestAndSet>; 617defm : DemangledNativeBuiltin<"__spirv_AtomicFlagTestAndSet", OpenCL_std, Atomic, 3, 3, OpAtomicFlagTestAndSet>; 618defm : DemangledNativeBuiltin<"atomic_flag_test_and_set_explicit", OpenCL_std, Atomic, 2, 3, OpAtomicFlagTestAndSet>; 619defm : DemangledNativeBuiltin<"atomic_flag_clear", OpenCL_std, Atomic, 1, 1, OpAtomicFlagClear>; 620defm : DemangledNativeBuiltin<"__spirv_AtomicFlagClear", OpenCL_std, Atomic, 3, 3, OpAtomicFlagClear>; 621defm : DemangledNativeBuiltin<"atomic_flag_clear_explicit", OpenCL_std, Atomic, 2, 3, OpAtomicFlagClear>; 622defm : DemangledNativeBuiltin<"__spirv_AtomicSMin", OpenCL_std, Atomic, 4, 4, OpAtomicSMin>; 623defm : DemangledNativeBuiltin<"__spirv_AtomicSMax", OpenCL_std, Atomic, 4, 4, OpAtomicSMax>; 624defm : DemangledNativeBuiltin<"__spirv_AtomicUMin", OpenCL_std, Atomic, 4, 4, OpAtomicUMin>; 625defm : DemangledNativeBuiltin<"__spirv_AtomicUMax", OpenCL_std, Atomic, 4, 4, OpAtomicUMax>; 626 627// Barrier builtin records: 628defm : DemangledNativeBuiltin<"barrier", OpenCL_std, Barrier, 1, 3, OpControlBarrier>; 629defm : DemangledNativeBuiltin<"work_group_barrier", OpenCL_std, Barrier, 1, 3, OpControlBarrier>; 630defm : DemangledNativeBuiltin<"__spirv_ControlBarrier", OpenCL_std, Barrier, 3, 3, OpControlBarrier>; 631 632// ICarryBorrow builtin record: 633defm : DemangledNativeBuiltin<"__spirv_IAddCarry", OpenCL_std, ICarryBorrow, 3, 3, OpIAddCarryS>; 634defm : DemangledNativeBuiltin<"__spirv_ISubBorrow", OpenCL_std, ICarryBorrow, 3, 3, OpISubBorrowS>; 635 636// cl_intel_split_work_group_barrier 637defm : DemangledNativeBuiltin<"intel_work_group_barrier_arrive", OpenCL_std, Barrier, 1, 2, OpControlBarrierArriveINTEL>; 638defm : DemangledNativeBuiltin<"__spirv_ControlBarrierArriveINTEL", OpenCL_std, Barrier, 3, 3, OpControlBarrierArriveINTEL>; 639defm : DemangledNativeBuiltin<"intel_work_group_barrier_wait", OpenCL_std, Barrier, 1, 2, OpControlBarrierWaitINTEL>; 640defm : DemangledNativeBuiltin<"__spirv_ControlBarrierWaitINTEL", OpenCL_std, Barrier, 3, 3, OpControlBarrierWaitINTEL>; 641 642// Kernel enqueue builtin records: 643defm : DemangledNativeBuiltin<"__enqueue_kernel_basic", OpenCL_std, Enqueue, 5, 5, OpEnqueueKernel>; 644defm : DemangledNativeBuiltin<"__enqueue_kernel_basic_events", OpenCL_std, Enqueue, 8, 8, OpEnqueueKernel>; 645defm : DemangledNativeBuiltin<"__enqueue_kernel_varargs", OpenCL_std, Enqueue, 7, 7, OpEnqueueKernel>; 646defm : DemangledNativeBuiltin<"__enqueue_kernel_events_varargs", OpenCL_std, Enqueue, 10, 10, OpEnqueueKernel>; 647defm : DemangledNativeBuiltin<"__spirv_EnqueueKernel", OpenCL_std, Enqueue, 10, 0, OpEnqueueKernel>; 648defm : DemangledNativeBuiltin<"retain_event", OpenCL_std, Enqueue, 1, 1, OpRetainEvent>; 649defm : DemangledNativeBuiltin<"__spirv_RetainEvent", OpenCL_std, Enqueue, 1, 1, OpRetainEvent>; 650defm : DemangledNativeBuiltin<"release_event", OpenCL_std, Enqueue, 1, 1, OpReleaseEvent>; 651defm : DemangledNativeBuiltin<"__spirv_ReleaseEvent", OpenCL_std, Enqueue, 1, 1, OpReleaseEvent>; 652defm : DemangledNativeBuiltin<"create_user_event", OpenCL_std, Enqueue, 0, 0, OpCreateUserEvent>; 653defm : DemangledNativeBuiltin<"__spirv_CreateUserEvent", OpenCL_std, Enqueue, 0, 0, OpCreateUserEvent>; 654defm : DemangledNativeBuiltin<"is_valid_event", OpenCL_std, Enqueue, 1, 1, OpIsValidEvent>; 655defm : DemangledNativeBuiltin<"__spirv_IsValidEvent", OpenCL_std, Enqueue, 1, 1, OpIsValidEvent>; 656defm : DemangledNativeBuiltin<"set_user_event_status", OpenCL_std, Enqueue, 2, 2, OpSetUserEventStatus>; 657defm : DemangledNativeBuiltin<"__spirv_SetUserEventStatus", OpenCL_std, Enqueue, 2, 2, OpSetUserEventStatus>; 658defm : DemangledNativeBuiltin<"capture_event_profiling_info", OpenCL_std, Enqueue, 3, 3, OpCaptureEventProfilingInfo>; 659defm : DemangledNativeBuiltin<"__spirv_CaptureEventProfilingInfo", OpenCL_std, Enqueue, 3, 3, OpCaptureEventProfilingInfo>; 660defm : DemangledNativeBuiltin<"get_default_queue", OpenCL_std, Enqueue, 0, 0, OpGetDefaultQueue>; 661defm : DemangledNativeBuiltin<"__spirv_GetDefaultQueue", OpenCL_std, Enqueue, 0, 0, OpGetDefaultQueue>; 662defm : DemangledNativeBuiltin<"ndrange_1D", OpenCL_std, Enqueue, 1, 3, OpBuildNDRange>; 663defm : DemangledNativeBuiltin<"ndrange_2D", OpenCL_std, Enqueue, 1, 3, OpBuildNDRange>; 664defm : DemangledNativeBuiltin<"ndrange_3D", OpenCL_std, Enqueue, 1, 3, OpBuildNDRange>; 665 666// Spec constant builtin records: 667defm : DemangledNativeBuiltin<"__spirv_SpecConstant", OpenCL_std, SpecConstant, 2, 2, OpSpecConstant>; 668defm : DemangledNativeBuiltin<"__spirv_SpecConstantComposite", OpenCL_std, SpecConstant, 1, 0, OpSpecConstantComposite>; 669 670// Async Copy and Prefetch builtin records: 671defm : DemangledNativeBuiltin<"async_work_group_copy", OpenCL_std, AsyncCopy, 4, 4, OpGroupAsyncCopy>; 672defm : DemangledNativeBuiltin<"async_work_group_strided_copy", OpenCL_std, AsyncCopy, 5, 5, OpGroupAsyncCopy>; 673defm : DemangledNativeBuiltin<"__spirv_GroupAsyncCopy", OpenCL_std, AsyncCopy, 6, 6, OpGroupAsyncCopy>; 674defm : DemangledNativeBuiltin<"wait_group_events", OpenCL_std, AsyncCopy, 2, 2, OpGroupWaitEvents>; 675defm : DemangledNativeBuiltin<"__spirv_GroupWaitEvents", OpenCL_std, AsyncCopy, 3, 3, OpGroupWaitEvents>; 676 677// Load and store builtin records: 678defm : DemangledNativeBuiltin<"__spirv_Load", OpenCL_std, LoadStore, 1, 3, OpLoad>; 679defm : DemangledNativeBuiltin<"__spirv_Store", OpenCL_std, LoadStore, 2, 4, OpStore>; 680 681// Address Space Qualifier Functions/Pointers Conversion Instructions: 682defm : DemangledNativeBuiltin<"to_global", OpenCL_std, CastToPtr, 1, 1, OpGenericCastToPtr>; 683defm : DemangledNativeBuiltin<"to_local", OpenCL_std, CastToPtr, 1, 1, OpGenericCastToPtr>; 684defm : DemangledNativeBuiltin<"to_private", OpenCL_std, CastToPtr, 1, 1, OpGenericCastToPtr>; 685defm : DemangledNativeBuiltin<"__spirv_GenericCastToPtr_ToGlobal", OpenCL_std, CastToPtr, 2, 2, OpGenericCastToPtr>; 686defm : DemangledNativeBuiltin<"__spirv_GenericCastToPtr_ToLocal", OpenCL_std, CastToPtr, 2, 2, OpGenericCastToPtr>; 687defm : DemangledNativeBuiltin<"__spirv_GenericCastToPtr_ToPrivate", OpenCL_std, CastToPtr, 2, 2, OpGenericCastToPtr>; 688defm : DemangledNativeBuiltin<"__spirv_GenericCastToPtrExplicit_ToGlobal", OpenCL_std, CastToPtr, 2, 2, OpGenericCastToPtr>; 689defm : DemangledNativeBuiltin<"__spirv_GenericCastToPtrExplicit_ToLocal", OpenCL_std, CastToPtr, 2, 2, OpGenericCastToPtr>; 690defm : DemangledNativeBuiltin<"__spirv_GenericCastToPtrExplicit_ToPrivate", OpenCL_std, CastToPtr, 2, 2, OpGenericCastToPtr>; 691 692// Cooperative Matrix builtin records: 693defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixLoadKHR", OpenCL_std, CoopMatr, 2, 4, OpCooperativeMatrixLoadKHR>; 694defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixStoreKHR", OpenCL_std, CoopMatr, 3, 5, OpCooperativeMatrixStoreKHR>; 695defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixMulAddKHR", OpenCL_std, CoopMatr, 3, 4, OpCooperativeMatrixMulAddKHR>; 696defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixLengthKHR", OpenCL_std, CoopMatr, 1, 1, OpCooperativeMatrixLengthKHR>; 697 698// Cooperative Matrix Intel builtin records: 699defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixPrefetchINTEL", OpenCL_std, CoopMatr, 5, 7, OpCooperativeMatrixPrefetchINTEL>; 700defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixLoadCheckedINTEL", OpenCL_std, CoopMatr, 6, 8, OpCooperativeMatrixLoadCheckedINTEL>; 701defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixStoreCheckedINTEL", OpenCL_std, CoopMatr, 7, 9, OpCooperativeMatrixStoreCheckedINTEL>; 702defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixConstructCheckedINTEL", OpenCL_std, CoopMatr, 5, 5, OpCooperativeMatrixConstructCheckedINTEL>; 703defm : DemangledNativeBuiltin<"__spirv_CooperativeMatrixGetElementCoordINTEL", OpenCL_std, CoopMatr, 2, 2, OpCooperativeMatrixGetElementCoordINTEL>; 704 705//===----------------------------------------------------------------------===// 706// Class defining a work/sub group builtin that should be translated into a 707// SPIR-V instruction using the defined properties. 708// 709// name is the demangled name of the given builtin. 710// opcode specifies the SPIR-V operation code of the generated instruction. 711//===----------------------------------------------------------------------===// 712class GroupBuiltin<string name, Op operation> { 713 string Name = name; 714 Op Opcode = operation; 715 bits<32> GroupOperation = !cond(!not(!eq(!find(name, "group_reduce"), -1)) : Reduce.Value, 716 !not(!eq(!find(name, "group_scan_inclusive"), -1)) : InclusiveScan.Value, 717 !not(!eq(!find(name, "group_scan_exclusive"), -1)) : ExclusiveScan.Value, 718 !not(!eq(!find(name, "group_ballot_bit_count"), -1)) : Reduce.Value, 719 !not(!eq(!find(name, "group_ballot_inclusive_scan"), -1)) : InclusiveScan.Value, 720 !not(!eq(!find(name, "group_ballot_exclusive_scan"), -1)) : ExclusiveScan.Value, 721 !not(!eq(!find(name, "group_non_uniform_reduce"), -1)) : Reduce.Value, 722 !not(!eq(!find(name, "group_non_uniform_scan_inclusive"), -1)) : InclusiveScan.Value, 723 !not(!eq(!find(name, "group_non_uniform_scan_exclusive"), -1)) : ExclusiveScan.Value, 724 !not(!eq(!find(name, "group_non_uniform_reduce_logical"), -1)) : Reduce.Value, 725 !not(!eq(!find(name, "group_non_uniform_scan_inclusive_logical"), -1)) : InclusiveScan.Value, 726 !not(!eq(!find(name, "group_non_uniform_scan_exclusive_logical"), -1)) : ExclusiveScan.Value, 727 !not(!eq(!find(name, "group_clustered_reduce"), -1)) : ClusteredReduce.Value, 728 !not(!eq(!find(name, "group_clustered_reduce_logical"), -1)) : ClusteredReduce.Value, 729 true : 0); 730 bit IsElect = !eq(operation, OpGroupNonUniformElect); 731 bit IsAllOrAny = !or(!eq(operation, OpGroupAll), 732 !eq(operation, OpGroupAny), 733 !eq(operation, OpGroupNonUniformAll), 734 !eq(operation, OpGroupNonUniformAny)); 735 bit IsAllEqual = !eq(operation, OpGroupNonUniformAllEqual); 736 bit IsBallot = !eq(operation, OpGroupNonUniformBallot); 737 bit IsInverseBallot = !eq(operation, OpGroupNonUniformInverseBallot); 738 bit IsBallotBitExtract = !eq(operation, OpGroupNonUniformBallotBitExtract); 739 bit IsBallotFindBit = !or(!eq(operation, OpGroupNonUniformBallotFindLSB), 740 !eq(operation, OpGroupNonUniformBallotFindMSB)); 741 bit IsLogical = !or(!eq(operation, OpGroupNonUniformLogicalAnd), 742 !eq(operation, OpGroupNonUniformLogicalOr), 743 !eq(operation, OpGroupNonUniformLogicalXor), 744 !eq(operation, OpGroupLogicalAndKHR), 745 !eq(operation, OpGroupLogicalOrKHR), 746 !eq(operation, OpGroupLogicalXorKHR)); 747 bit NoGroupOperation = !or(IsElect, IsAllOrAny, IsAllEqual, 748 IsBallot, IsInverseBallot, 749 IsBallotBitExtract, IsBallotFindBit, 750 !eq(operation, OpGroupNonUniformShuffle), 751 !eq(operation, OpGroupNonUniformShuffleXor), 752 !eq(operation, OpGroupNonUniformShuffleUp), 753 !eq(operation, OpGroupNonUniformShuffleDown), 754 !eq(operation, OpGroupBroadcast), 755 !eq(operation, OpGroupNonUniformBroadcast), 756 !eq(operation, OpGroupNonUniformBroadcastFirst), 757 !eq(operation, OpGroupNonUniformRotateKHR)); 758 bit HasBoolArg = !or(!and(IsAllOrAny, !eq(IsAllEqual, false)), IsBallot, IsLogical); 759} 760 761// Table gathering all the work/sub group builtins. 762def GroupBuiltins : GenericTable { 763 let FilterClass = "GroupBuiltin"; 764 let Fields = ["Name", "Opcode", "GroupOperation", "IsElect", "IsAllOrAny", 765 "IsAllEqual", "IsBallot", "IsInverseBallot", "IsBallotBitExtract", 766 "IsBallotFindBit", "IsLogical", "NoGroupOperation", "HasBoolArg"]; 767} 768 769// Function to lookup group builtins by their name and set. 770def lookupGroupBuiltin : SearchIndex { 771 let Table = GroupBuiltins; 772 let Key = ["Name"]; 773} 774 775// Multiclass used to define at the same time both incoming builtin records 776// and corresponding work/sub group builtin records. 777defvar OnlyWork = 0; defvar OnlySub = 1; defvar WorkOrSub = 2; 778multiclass DemangledGroupBuiltin<string name, int level /* OnlyWork/OnlySub/... */, Op operation> { 779 assert !and(!ge(level, 0), !le(level, 2)), "group level is invalid: " # level; 780 781 if !or(!eq(level, OnlyWork), !eq(level, WorkOrSub)) then { 782 def : DemangledBuiltin<!strconcat("work_", name), OpenCL_std, Group, 0, 4>; 783 def : GroupBuiltin<!strconcat("work_", name), operation>; 784 } 785 786 if !or(!eq(level, OnlySub), !eq(level, WorkOrSub)) then { 787 def : DemangledBuiltin<!strconcat("sub_", name), OpenCL_std, Group, 0, 4>; 788 def : GroupBuiltin<!strconcat("sub_", name), operation>; 789 } 790} 791 792multiclass DemangledGroupBuiltinWrapper<string name, bits<8> minNumArgs, bits<8> maxNumArgs, Op operation> { 793 def : DemangledBuiltin<name, OpenCL_std, Group, minNumArgs, maxNumArgs>; 794 def : GroupBuiltin<name, operation>; 795} 796 797defm : DemangledGroupBuiltin<"group_all", WorkOrSub, OpGroupAll>; 798defm : DemangledGroupBuiltinWrapper<"__spirv_GroupAll", 2, 2, OpGroupAll>; 799defm : DemangledGroupBuiltin<"group_any", WorkOrSub, OpGroupAny>; 800defm : DemangledGroupBuiltinWrapper<"__spirv_GroupAny", 2, 2, OpGroupAny>; 801defm : DemangledGroupBuiltin<"group_broadcast", WorkOrSub, OpGroupBroadcast>; 802defm : DemangledGroupBuiltinWrapper<"__spirv_GroupBroadcast", 3, 3, OpGroupBroadcast>; 803defm : DemangledGroupBuiltin<"group_non_uniform_broadcast", OnlySub, OpGroupNonUniformBroadcast>; 804defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBroadcast", 3, 3, OpGroupNonUniformBroadcast>; 805defm : DemangledGroupBuiltin<"group_broadcast_first", OnlySub, OpGroupNonUniformBroadcastFirst>; 806defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBroadcastFirst", 2, 2, OpGroupNonUniformBroadcastFirst>; 807 808// cl_khr_subgroup_non_uniform_vote 809defm : DemangledGroupBuiltin<"group_elect", OnlySub, OpGroupNonUniformElect>; 810defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformElect", 1, 1, OpGroupNonUniformElect>; 811defm : DemangledGroupBuiltin<"group_non_uniform_all", OnlySub, OpGroupNonUniformAll>; 812defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformAll", 2, 2, OpGroupNonUniformAll>; 813defm : DemangledGroupBuiltin<"group_non_uniform_any", OnlySub, OpGroupNonUniformAny>; 814defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformAny", 2, 2, OpGroupNonUniformAny>; 815defm : DemangledGroupBuiltin<"group_non_uniform_all_equal", OnlySub, OpGroupNonUniformAllEqual>; 816defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformAllEqual", 2, 2, OpGroupNonUniformAllEqual>; 817 818// cl_khr_subgroup_ballot 819defm : DemangledGroupBuiltin<"group_ballot", OnlySub, OpGroupNonUniformBallot>; 820defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBallot", 2, 2, OpGroupNonUniformBallot>; 821defm : DemangledGroupBuiltin<"group_inverse_ballot", OnlySub, OpGroupNonUniformInverseBallot>; 822defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformInverseBallot", 2, 2, OpGroupNonUniformInverseBallot>; 823defm : DemangledGroupBuiltin<"group_ballot_bit_extract", OnlySub, OpGroupNonUniformBallotBitExtract>; 824defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBallotBitExtract", 3, 3, OpGroupNonUniformBallotBitExtract>; 825defm : DemangledGroupBuiltin<"group_ballot_bit_count", OnlySub, OpGroupNonUniformBallotBitCount>; 826defm : DemangledGroupBuiltin<"group_ballot_inclusive_scan", OnlySub, OpGroupNonUniformBallotBitCount>; 827defm : DemangledGroupBuiltin<"group_ballot_exclusive_scan", OnlySub, OpGroupNonUniformBallotBitCount>; 828defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBallotBitCount", 3, 3, OpGroupNonUniformBallotBitCount>; 829defm : DemangledGroupBuiltin<"group_ballot_find_lsb", OnlySub, OpGroupNonUniformBallotFindLSB>; 830defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBallotFindLSB", 2, 2, OpGroupNonUniformBallotFindLSB>; 831defm : DemangledGroupBuiltin<"group_ballot_find_msb", OnlySub, OpGroupNonUniformBallotFindMSB>; 832defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBallotFindMSB", 2, 2, OpGroupNonUniformBallotFindMSB>; 833 834// cl_khr_subgroup_shuffle 835defm : DemangledGroupBuiltin<"group_shuffle", OnlySub, OpGroupNonUniformShuffle>; 836defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformShuffle", 3, 3, OpGroupNonUniformShuffle>; 837defm : DemangledGroupBuiltin<"group_shuffle_xor", OnlySub, OpGroupNonUniformShuffleXor>; 838defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformShuffleXor", 3, 3, OpGroupNonUniformShuffleXor>; 839 840// cl_khr_subgroup_shuffle_relative 841defm : DemangledGroupBuiltin<"group_shuffle_up", OnlySub, OpGroupNonUniformShuffleUp>; 842defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformShuffleUp", 3, 3, OpGroupNonUniformShuffleUp>; 843defm : DemangledGroupBuiltin<"group_shuffle_down", OnlySub, OpGroupNonUniformShuffleDown>; 844defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformShuffleDown", 3, 3, OpGroupNonUniformShuffleDown>; 845 846defm : DemangledGroupBuiltin<"group_iadd", WorkOrSub, OpGroupIAdd>; 847defm : DemangledGroupBuiltin<"group_reduce_adds", WorkOrSub, OpGroupIAdd>; 848defm : DemangledGroupBuiltin<"group_scan_exclusive_adds", WorkOrSub, OpGroupIAdd>; 849defm : DemangledGroupBuiltin<"group_scan_inclusive_adds", WorkOrSub, OpGroupIAdd>; 850defm : DemangledGroupBuiltin<"group_reduce_addu", WorkOrSub, OpGroupIAdd>; 851defm : DemangledGroupBuiltin<"group_scan_exclusive_addu", WorkOrSub, OpGroupIAdd>; 852defm : DemangledGroupBuiltin<"group_scan_inclusive_addu", WorkOrSub, OpGroupIAdd>; 853defm : DemangledGroupBuiltinWrapper<"__spirv_GroupIAdd", 3, 3, OpGroupIAdd>; 854 855defm : DemangledGroupBuiltin<"group_fadd", WorkOrSub, OpGroupFAdd>; 856defm : DemangledGroupBuiltin<"group_reduce_addf", WorkOrSub, OpGroupFAdd>; 857defm : DemangledGroupBuiltin<"group_scan_exclusive_addf", WorkOrSub, OpGroupFAdd>; 858defm : DemangledGroupBuiltin<"group_scan_inclusive_addf", WorkOrSub, OpGroupFAdd>; 859defm : DemangledGroupBuiltinWrapper<"__spirv_GroupFAdd", 3, 3, OpGroupFAdd>; 860 861defm : DemangledGroupBuiltin<"group_fmin", WorkOrSub, OpGroupFMin>; 862defm : DemangledGroupBuiltin<"group_reduce_minf", WorkOrSub, OpGroupFMin>; 863defm : DemangledGroupBuiltin<"group_scan_exclusive_minf", WorkOrSub, OpGroupFMin>; 864defm : DemangledGroupBuiltin<"group_scan_inclusive_minf", WorkOrSub, OpGroupFMin>; 865defm : DemangledGroupBuiltinWrapper<"__spirv_GroupFMin", 3, 3, OpGroupFMin>; 866 867defm : DemangledGroupBuiltin<"group_umin", WorkOrSub, OpGroupUMin>; 868defm : DemangledGroupBuiltin<"group_reduce_minu", WorkOrSub, OpGroupUMin>; 869defm : DemangledGroupBuiltin<"group_scan_exclusive_minu", WorkOrSub, OpGroupUMin>; 870defm : DemangledGroupBuiltin<"group_scan_inclusive_minu", WorkOrSub, OpGroupUMin>; 871defm : DemangledGroupBuiltinWrapper<"__spirv_GroupUMin", 3, 3, OpGroupUMin>; 872 873defm : DemangledGroupBuiltin<"group_smin", WorkOrSub, OpGroupSMin>; 874defm : DemangledGroupBuiltin<"group_reduce_mins", WorkOrSub, OpGroupSMin>; 875defm : DemangledGroupBuiltin<"group_scan_exclusive_mins", WorkOrSub, OpGroupSMin>; 876defm : DemangledGroupBuiltin<"group_scan_inclusive_mins", WorkOrSub, OpGroupSMin>; 877defm : DemangledGroupBuiltinWrapper<"__spirv_GroupSMin", 3, 3, OpGroupSMin>; 878 879defm : DemangledGroupBuiltin<"group_fmax", WorkOrSub, OpGroupFMax>; 880defm : DemangledGroupBuiltin<"group_reduce_maxf", WorkOrSub, OpGroupFMax>; 881defm : DemangledGroupBuiltin<"group_scan_exclusive_maxf", WorkOrSub, OpGroupFMax>; 882defm : DemangledGroupBuiltin<"group_scan_inclusive_maxf", WorkOrSub, OpGroupFMax>; 883defm : DemangledGroupBuiltinWrapper<"__spirv_GroupFMax", 3, 3, OpGroupFMax>; 884 885defm : DemangledGroupBuiltin<"group_umax", WorkOrSub, OpGroupUMax>; 886defm : DemangledGroupBuiltin<"group_reduce_maxu", WorkOrSub, OpGroupUMax>; 887defm : DemangledGroupBuiltin<"group_scan_exclusive_maxu", WorkOrSub, OpGroupUMax>; 888defm : DemangledGroupBuiltin<"group_scan_inclusive_maxu", WorkOrSub, OpGroupUMax>; 889defm : DemangledGroupBuiltinWrapper<"__spirv_GroupUMax", 3, 3, OpGroupUMax>; 890 891defm : DemangledGroupBuiltin<"group_smax", WorkOrSub, OpGroupSMax>; 892defm : DemangledGroupBuiltin<"group_reduce_maxs", WorkOrSub, OpGroupSMax>; 893defm : DemangledGroupBuiltin<"group_scan_exclusive_maxs", WorkOrSub, OpGroupSMax>; 894defm : DemangledGroupBuiltin<"group_scan_inclusive_maxs", WorkOrSub, OpGroupSMax>; 895defm : DemangledGroupBuiltinWrapper<"__spirv_GroupSMax", 3, 3, OpGroupSMax>; 896 897// cl_khr_subgroup_non_uniform_arithmetic 898defm : DemangledGroupBuiltin<"group_non_uniform_iadd", WorkOrSub, OpGroupNonUniformIAdd>; 899defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addu", WorkOrSub, OpGroupNonUniformIAdd>; 900defm : DemangledGroupBuiltin<"group_non_uniform_reduce_adds", WorkOrSub, OpGroupNonUniformIAdd>; 901defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addu", WorkOrSub, OpGroupNonUniformIAdd>; 902defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_adds", WorkOrSub, OpGroupNonUniformIAdd>; 903defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addu", WorkOrSub, OpGroupNonUniformIAdd>; 904defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_adds", WorkOrSub, OpGroupNonUniformIAdd>; 905defm : DemangledGroupBuiltin<"group_clustered_reduce_addu", WorkOrSub, OpGroupNonUniformIAdd>; 906defm : DemangledGroupBuiltin<"group_clustered_reduce_adds", WorkOrSub, OpGroupNonUniformIAdd>; 907defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformIAdd", 3, 4, OpGroupNonUniformIAdd>; 908 909defm : DemangledGroupBuiltin<"group_non_uniform_fadd", WorkOrSub, OpGroupNonUniformFAdd>; 910defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addf", WorkOrSub, OpGroupNonUniformFAdd>; 911defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addh", WorkOrSub, OpGroupNonUniformFAdd>; 912defm : DemangledGroupBuiltin<"group_non_uniform_reduce_addd", WorkOrSub, OpGroupNonUniformFAdd>; 913defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addf", WorkOrSub, OpGroupNonUniformFAdd>; 914defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addh", WorkOrSub, OpGroupNonUniformFAdd>; 915defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_addd", WorkOrSub, OpGroupNonUniformFAdd>; 916defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addf", WorkOrSub, OpGroupNonUniformFAdd>; 917defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addh", WorkOrSub, OpGroupNonUniformFAdd>; 918defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_addd", WorkOrSub, OpGroupNonUniformFAdd>; 919defm : DemangledGroupBuiltin<"group_clustered_reduce_addf", WorkOrSub, OpGroupNonUniformFAdd>; 920defm : DemangledGroupBuiltin<"group_clustered_reduce_addh", WorkOrSub, OpGroupNonUniformFAdd>; 921defm : DemangledGroupBuiltin<"group_clustered_reduce_addd", WorkOrSub, OpGroupNonUniformFAdd>; 922defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformFAdd", 3, 4, OpGroupNonUniformFAdd>; 923 924defm : DemangledGroupBuiltin<"group_non_uniform_imul", WorkOrSub, OpGroupNonUniformIMul>; 925defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mulu", WorkOrSub, OpGroupNonUniformIMul>; 926defm : DemangledGroupBuiltin<"group_non_uniform_reduce_muls", WorkOrSub, OpGroupNonUniformIMul>; 927defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mulu", WorkOrSub, OpGroupNonUniformIMul>; 928defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_muls", WorkOrSub, OpGroupNonUniformIMul>; 929defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mulu", WorkOrSub, OpGroupNonUniformIMul>; 930defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_muls", WorkOrSub, OpGroupNonUniformIMul>; 931defm : DemangledGroupBuiltin<"group_clustered_reduce_mulu", WorkOrSub, OpGroupNonUniformIMul>; 932defm : DemangledGroupBuiltin<"group_clustered_reduce_muls", WorkOrSub, OpGroupNonUniformIMul>; 933defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformIMul", 3, 4, OpGroupNonUniformIMul>; 934 935defm : DemangledGroupBuiltin<"group_non_uniform_fmul", WorkOrSub, OpGroupNonUniformFMul>; 936defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mulf", WorkOrSub, OpGroupNonUniformFMul>; 937defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mulh", WorkOrSub, OpGroupNonUniformFMul>; 938defm : DemangledGroupBuiltin<"group_non_uniform_reduce_muld", WorkOrSub, OpGroupNonUniformFMul>; 939defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mulf", WorkOrSub, OpGroupNonUniformFMul>; 940defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mulh", WorkOrSub, OpGroupNonUniformFMul>; 941defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_muld", WorkOrSub, OpGroupNonUniformFMul>; 942defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mulf", WorkOrSub, OpGroupNonUniformFMul>; 943defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mulh", WorkOrSub, OpGroupNonUniformFMul>; 944defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_muld", WorkOrSub, OpGroupNonUniformFMul>; 945defm : DemangledGroupBuiltin<"group_clustered_reduce_mulf", WorkOrSub, OpGroupNonUniformFMul>; 946defm : DemangledGroupBuiltin<"group_clustered_reduce_mulh", WorkOrSub, OpGroupNonUniformFMul>; 947defm : DemangledGroupBuiltin<"group_clustered_reduce_muld", WorkOrSub, OpGroupNonUniformFMul>; 948defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformFMul", 3, 4, OpGroupNonUniformFMul>; 949 950defm : DemangledGroupBuiltin<"group_non_uniform_smin", WorkOrSub, OpGroupNonUniformSMin>; 951defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mins", WorkOrSub, OpGroupNonUniformSMin>; 952defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mins", WorkOrSub, OpGroupNonUniformSMin>; 953defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mins", WorkOrSub, OpGroupNonUniformSMin>; 954defm : DemangledGroupBuiltin<"group_clustered_reduce_mins", WorkOrSub, OpGroupNonUniformSMin>; 955defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformSMin", 3, 4, OpGroupNonUniformSMin>; 956 957defm : DemangledGroupBuiltin<"group_non_uniform_umin", WorkOrSub, OpGroupNonUniformUMin>; 958defm : DemangledGroupBuiltin<"group_non_uniform_reduce_minu", WorkOrSub, OpGroupNonUniformUMin>; 959defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_minu", WorkOrSub, OpGroupNonUniformUMin>; 960defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_minu", WorkOrSub, OpGroupNonUniformUMin>; 961defm : DemangledGroupBuiltin<"group_clustered_reduce_minu", WorkOrSub, OpGroupNonUniformUMin>; 962defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformUMin", 3, 4, OpGroupNonUniformUMin>; 963 964defm : DemangledGroupBuiltin<"group_non_uniform_fmin", WorkOrSub, OpGroupNonUniformFMin>; 965defm : DemangledGroupBuiltin<"group_non_uniform_reduce_minf", WorkOrSub, OpGroupNonUniformFMin>; 966defm : DemangledGroupBuiltin<"group_non_uniform_reduce_minh", WorkOrSub, OpGroupNonUniformFMin>; 967defm : DemangledGroupBuiltin<"group_non_uniform_reduce_mind", WorkOrSub, OpGroupNonUniformFMin>; 968defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_minf", WorkOrSub, OpGroupNonUniformFMin>; 969defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_minh", WorkOrSub, OpGroupNonUniformFMin>; 970defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_mind", WorkOrSub, OpGroupNonUniformFMin>; 971defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_minf", WorkOrSub, OpGroupNonUniformFMin>; 972defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_minh", WorkOrSub, OpGroupNonUniformFMin>; 973defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_mind", WorkOrSub, OpGroupNonUniformFMin>; 974defm : DemangledGroupBuiltin<"group_clustered_reduce_minf", WorkOrSub, OpGroupNonUniformFMin>; 975defm : DemangledGroupBuiltin<"group_clustered_reduce_minh", WorkOrSub, OpGroupNonUniformFMin>; 976defm : DemangledGroupBuiltin<"group_clustered_reduce_mind", WorkOrSub, OpGroupNonUniformFMin>; 977defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformFMin", 3, 4, OpGroupNonUniformFMin>; 978 979defm : DemangledGroupBuiltin<"group_non_uniform_smax", WorkOrSub, OpGroupNonUniformSMax>; 980defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxs", WorkOrSub, OpGroupNonUniformSMax>; 981defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxs", WorkOrSub, OpGroupNonUniformSMax>; 982defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxs", WorkOrSub, OpGroupNonUniformSMax>; 983defm : DemangledGroupBuiltin<"group_clustered_reduce_maxs", WorkOrSub, OpGroupNonUniformSMax>; 984defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformSMax", 3, 4, OpGroupNonUniformSMax>; 985 986defm : DemangledGroupBuiltin<"group_non_uniform_umax", WorkOrSub, OpGroupNonUniformUMax>; 987defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxu", WorkOrSub, OpGroupNonUniformUMax>; 988defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxu", WorkOrSub, OpGroupNonUniformUMax>; 989defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxu", WorkOrSub, OpGroupNonUniformUMax>; 990defm : DemangledGroupBuiltin<"group_clustered_reduce_maxu", WorkOrSub, OpGroupNonUniformUMax>; 991defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformUMax", 3, 4, OpGroupNonUniformUMax>; 992 993defm : DemangledGroupBuiltin<"group_non_uniform_fmax", WorkOrSub, OpGroupNonUniformFMax>; 994defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxf", WorkOrSub, OpGroupNonUniformFMax>; 995defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxh", WorkOrSub, OpGroupNonUniformFMax>; 996defm : DemangledGroupBuiltin<"group_non_uniform_reduce_maxd", WorkOrSub, OpGroupNonUniformFMax>; 997defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxf", WorkOrSub, OpGroupNonUniformFMax>; 998defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxh", WorkOrSub, OpGroupNonUniformFMax>; 999defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_maxd", WorkOrSub, OpGroupNonUniformFMax>; 1000defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxf", WorkOrSub, OpGroupNonUniformFMax>; 1001defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxh", WorkOrSub, OpGroupNonUniformFMax>; 1002defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_maxd", WorkOrSub, OpGroupNonUniformFMax>; 1003defm : DemangledGroupBuiltin<"group_clustered_reduce_maxf", WorkOrSub, OpGroupNonUniformFMax>; 1004defm : DemangledGroupBuiltin<"group_clustered_reduce_maxh", WorkOrSub, OpGroupNonUniformFMax>; 1005defm : DemangledGroupBuiltin<"group_clustered_reduce_maxd", WorkOrSub, OpGroupNonUniformFMax>; 1006defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformFMax", 3, 4, OpGroupNonUniformFMax>; 1007 1008defm : DemangledGroupBuiltin<"group_non_uniform_iand", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1009defm : DemangledGroupBuiltin<"group_non_uniform_reduce_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1010defm : DemangledGroupBuiltin<"group_non_uniform_reduce_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1011defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1012defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1013defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1014defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1015defm : DemangledGroupBuiltin<"group_clustered_reduce_andu", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1016defm : DemangledGroupBuiltin<"group_clustered_reduce_ands", WorkOrSub, OpGroupNonUniformBitwiseAnd>; 1017defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBitwiseAnd", 3, 4, OpGroupNonUniformBitwiseAnd>; 1018 1019defm : DemangledGroupBuiltin<"group_non_uniform_ior", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1020defm : DemangledGroupBuiltin<"group_non_uniform_reduce_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1021defm : DemangledGroupBuiltin<"group_non_uniform_reduce_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1022defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1023defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1024defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1025defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1026defm : DemangledGroupBuiltin<"group_clustered_reduce_oru", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1027defm : DemangledGroupBuiltin<"group_clustered_reduce_ors", WorkOrSub, OpGroupNonUniformBitwiseOr>; 1028defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBitwiseOr", 3, 4, OpGroupNonUniformBitwiseOr>; 1029 1030defm : DemangledGroupBuiltin<"group_non_uniform_ixor", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1031defm : DemangledGroupBuiltin<"group_non_uniform_reduce_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1032defm : DemangledGroupBuiltin<"group_non_uniform_reduce_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1033defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1034defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1035defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1036defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1037defm : DemangledGroupBuiltin<"group_clustered_reduce_xoru", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1038defm : DemangledGroupBuiltin<"group_clustered_reduce_xors", WorkOrSub, OpGroupNonUniformBitwiseXor>; 1039defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformBitwiseXor", 3, 4, OpGroupNonUniformBitwiseXor>; 1040 1041defm : DemangledGroupBuiltin<"group_non_uniform_logical_iand", WorkOrSub, OpGroupNonUniformLogicalAnd>; 1042defm : DemangledGroupBuiltin<"group_non_uniform_reduce_logical_ands", WorkOrSub, OpGroupNonUniformLogicalAnd>; 1043defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_logical_ands", WorkOrSub, OpGroupNonUniformLogicalAnd>; 1044defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_logical_ands", WorkOrSub, OpGroupNonUniformLogicalAnd>; 1045defm : DemangledGroupBuiltin<"group_clustered_reduce_logical_and", WorkOrSub, OpGroupNonUniformLogicalAnd>; 1046defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformLogicalAnd", 3, 4, OpGroupNonUniformLogicalAnd>; 1047 1048defm : DemangledGroupBuiltin<"group_non_uniform_logical_ior", WorkOrSub, OpGroupNonUniformLogicalOr>; 1049defm : DemangledGroupBuiltin<"group_non_uniform_reduce_logical_ors", WorkOrSub, OpGroupNonUniformLogicalOr>; 1050defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_logical_ors", WorkOrSub, OpGroupNonUniformLogicalOr>; 1051defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_logical_ors", WorkOrSub, OpGroupNonUniformLogicalOr>; 1052defm : DemangledGroupBuiltin<"group_clustered_reduce_logical_or", WorkOrSub, OpGroupNonUniformLogicalOr>; 1053defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformLogicalOr", 3, 4, OpGroupNonUniformLogicalOr>; 1054 1055defm : DemangledGroupBuiltin<"group_non_uniform_logical_ixor", WorkOrSub, OpGroupNonUniformLogicalXor>; 1056defm : DemangledGroupBuiltin<"group_non_uniform_reduce_logical_xors", WorkOrSub, OpGroupNonUniformLogicalXor>; 1057defm : DemangledGroupBuiltin<"group_non_uniform_scan_inclusive_logical_xors", WorkOrSub, OpGroupNonUniformLogicalXor>; 1058defm : DemangledGroupBuiltin<"group_non_uniform_scan_exclusive_logical_xors", WorkOrSub, OpGroupNonUniformLogicalXor>; 1059defm : DemangledGroupBuiltin<"group_clustered_reduce_logical_xor", WorkOrSub, OpGroupNonUniformLogicalXor>; 1060defm : DemangledGroupBuiltinWrapper<"__spirv_GroupNonUniformLogicalXor", 3, 4, OpGroupNonUniformLogicalXor>; 1061 1062// cl_khr_subgroup_rotate / SPV_KHR_subgroup_rotate 1063defm : DemangledGroupBuiltin<"group_rotate", OnlySub, OpGroupNonUniformRotateKHR>; 1064defm : DemangledGroupBuiltin<"group_clustered_rotate", OnlySub, OpGroupNonUniformRotateKHR>; 1065 1066// cl_khr_work_group_uniform_arithmetic / SPV_KHR_uniform_group_instructions 1067defm : DemangledGroupBuiltin<"group_reduce_imul", OnlyWork, OpGroupIMulKHR>; 1068defm : DemangledGroupBuiltin<"group_reduce_mulu", OnlyWork, OpGroupIMulKHR>; 1069defm : DemangledGroupBuiltin<"group_reduce_muls", OnlyWork, OpGroupIMulKHR>; 1070defm : DemangledGroupBuiltin<"group_scan_inclusive_imul", OnlyWork, OpGroupIMulKHR>; 1071defm : DemangledGroupBuiltin<"group_scan_inclusive_mulu", OnlyWork, OpGroupIMulKHR>; 1072defm : DemangledGroupBuiltin<"group_scan_inclusive_muls", OnlyWork, OpGroupIMulKHR>; 1073defm : DemangledGroupBuiltin<"group_scan_exclusive_imul", OnlyWork, OpGroupIMulKHR>; 1074defm : DemangledGroupBuiltin<"group_scan_exclusive_mulu", OnlyWork, OpGroupIMulKHR>; 1075defm : DemangledGroupBuiltin<"group_scan_exclusive_muls", OnlyWork, OpGroupIMulKHR>; 1076 1077defm : DemangledGroupBuiltin<"group_reduce_mulf", OnlyWork, OpGroupFMulKHR>; 1078defm : DemangledGroupBuiltin<"group_reduce_mulh", OnlyWork, OpGroupFMulKHR>; 1079defm : DemangledGroupBuiltin<"group_reduce_muld", OnlyWork, OpGroupFMulKHR>; 1080defm : DemangledGroupBuiltin<"group_scan_inclusive_mulf", OnlyWork, OpGroupFMulKHR>; 1081defm : DemangledGroupBuiltin<"group_scan_inclusive_mulh", OnlyWork, OpGroupFMulKHR>; 1082defm : DemangledGroupBuiltin<"group_scan_inclusive_muld", OnlyWork, OpGroupFMulKHR>; 1083defm : DemangledGroupBuiltin<"group_scan_exclusive_mulf", OnlyWork, OpGroupFMulKHR>; 1084defm : DemangledGroupBuiltin<"group_scan_exclusive_mulh", OnlyWork, OpGroupFMulKHR>; 1085defm : DemangledGroupBuiltin<"group_scan_exclusive_muld", OnlyWork, OpGroupFMulKHR>; 1086 1087defm : DemangledGroupBuiltin<"group_scan_exclusive_and", OnlyWork, OpGroupBitwiseAndKHR>; 1088defm : DemangledGroupBuiltin<"group_scan_inclusive_and", OnlyWork, OpGroupBitwiseAndKHR>; 1089defm : DemangledGroupBuiltin<"group_reduce_and", OnlyWork, OpGroupBitwiseAndKHR>; 1090 1091defm : DemangledGroupBuiltin<"group_scan_exclusive_or", OnlyWork, OpGroupBitwiseOrKHR>; 1092defm : DemangledGroupBuiltin<"group_scan_inclusive_or", OnlyWork, OpGroupBitwiseOrKHR>; 1093defm : DemangledGroupBuiltin<"group_reduce_or", OnlyWork, OpGroupBitwiseOrKHR>; 1094 1095defm : DemangledGroupBuiltin<"group_scan_exclusive_xor", OnlyWork, OpGroupBitwiseXorKHR>; 1096defm : DemangledGroupBuiltin<"group_scan_inclusive_xor", OnlyWork, OpGroupBitwiseXorKHR>; 1097defm : DemangledGroupBuiltin<"group_reduce_xor", OnlyWork, OpGroupBitwiseXorKHR>; 1098 1099defm : DemangledGroupBuiltin<"group_scan_exclusive_logical_and", OnlyWork, OpGroupLogicalAndKHR>; 1100defm : DemangledGroupBuiltin<"group_scan_inclusive_logical_and", OnlyWork, OpGroupLogicalAndKHR>; 1101defm : DemangledGroupBuiltin<"group_reduce_logical_and", OnlyWork, OpGroupLogicalAndKHR>; 1102 1103defm : DemangledGroupBuiltin<"group_scan_exclusive_logical_or", OnlyWork, OpGroupLogicalOrKHR>; 1104defm : DemangledGroupBuiltin<"group_scan_inclusive_logical_or", OnlyWork, OpGroupLogicalOrKHR>; 1105defm : DemangledGroupBuiltin<"group_reduce_logical_or", OnlyWork, OpGroupLogicalOrKHR>; 1106 1107defm : DemangledGroupBuiltin<"group_scan_exclusive_logical_xor", OnlyWork, OpGroupLogicalXorKHR>; 1108defm : DemangledGroupBuiltin<"group_scan_inclusive_logical_xor", OnlyWork, OpGroupLogicalXorKHR>; 1109defm : DemangledGroupBuiltin<"group_reduce_logical_xor", OnlyWork, OpGroupLogicalXorKHR>; 1110 1111// cl_khr_kernel_clock / SPV_KHR_shader_clock 1112defm : DemangledNativeBuiltin<"clock_read_device", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>; 1113defm : DemangledNativeBuiltin<"clock_read_work_group", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>; 1114defm : DemangledNativeBuiltin<"clock_read_sub_group", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>; 1115defm : DemangledNativeBuiltin<"clock_read_hilo_device", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>; 1116defm : DemangledNativeBuiltin<"clock_read_hilo_work_group", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>; 1117defm : DemangledNativeBuiltin<"clock_read_hilo_sub_group", OpenCL_std, KernelClock, 0, 0, OpReadClockKHR>; 1118 1119//===----------------------------------------------------------------------===// 1120// Class defining an atomic instruction on floating-point numbers. 1121// 1122// name is the demangled name of the given builtin. 1123// opcode specifies the SPIR-V operation code of the generated instruction. 1124//===----------------------------------------------------------------------===// 1125class AtomicFloatingBuiltin<string name, Op operation> { 1126 string Name = name; 1127 Op Opcode = operation; 1128} 1129 1130// Table gathering all builtins for atomic instructions on floating-point numbers 1131def AtomicFloatingBuiltins : GenericTable { 1132 let FilterClass = "AtomicFloatingBuiltin"; 1133 let Fields = ["Name", "Opcode"]; 1134} 1135 1136// Function to lookup builtins by their name and set. 1137def lookupAtomicFloatingBuiltin : SearchIndex { 1138 let Table = AtomicFloatingBuiltins; 1139 let Key = ["Name"]; 1140} 1141 1142// Multiclass used to define incoming demangled builtin records and 1143// corresponding builtin records for atomic instructions on floating-point numbers. 1144multiclass DemangledAtomicFloatingBuiltin<string name, bits<8> minNumArgs, bits<8> maxNumArgs, Op operation> { 1145 def : DemangledBuiltin<!strconcat("__spirv_AtomicF", name), OpenCL_std, AtomicFloating, minNumArgs, maxNumArgs>; 1146 def : AtomicFloatingBuiltin<!strconcat("__spirv_AtomicF", name), operation>; 1147} 1148 1149// SPV_EXT_shader_atomic_float_add, SPV_EXT_shader_atomic_float_min_max, SPV_EXT_shader_atomic_float16_add 1150// Atomic add, min and max instruction on floating-point numbers: 1151defm : DemangledAtomicFloatingBuiltin<"AddEXT", 4, 4, OpAtomicFAddEXT>; 1152defm : DemangledAtomicFloatingBuiltin<"MinEXT", 4, 4, OpAtomicFMinEXT>; 1153defm : DemangledAtomicFloatingBuiltin<"MaxEXT", 4, 4, OpAtomicFMaxEXT>; 1154 1155//===----------------------------------------------------------------------===// 1156// Class defining a sub group builtin that should be translated into a 1157// SPIR-V instruction using the SPV_INTEL_subgroups extension. 1158// 1159// name is the demangled name of the given builtin. 1160// opcode specifies the SPIR-V operation code of the generated instruction. 1161//===----------------------------------------------------------------------===// 1162class IntelSubgroupsBuiltin<string name, Op operation> { 1163 string Name = name; 1164 Op Opcode = operation; 1165 bit IsBlock = !or(!eq(operation, OpSubgroupBlockReadINTEL), 1166 !eq(operation, OpSubgroupBlockWriteINTEL), 1167 !eq(operation, OpSubgroupImageMediaBlockReadINTEL), 1168 !eq(operation, OpSubgroupImageMediaBlockWriteINTEL)); 1169 bit IsWrite = !or(!eq(operation, OpSubgroupBlockWriteINTEL), 1170 !eq(operation, OpSubgroupImageMediaBlockWriteINTEL)); 1171 bit IsMedia = !or(!eq(operation, OpSubgroupImageMediaBlockReadINTEL), 1172 !eq(operation, OpSubgroupImageMediaBlockWriteINTEL)); 1173} 1174 1175// Table gathering all the Intel sub group builtins. 1176def IntelSubgroupsBuiltins : GenericTable { 1177 let FilterClass = "IntelSubgroupsBuiltin"; 1178 let Fields = ["Name", "Opcode", "IsBlock", "IsWrite", "IsMedia"]; 1179} 1180 1181// Function to lookup group builtins by their name and set. 1182def lookupIntelSubgroupsBuiltin : SearchIndex { 1183 let Table = IntelSubgroupsBuiltins; 1184 let Key = ["Name"]; 1185} 1186 1187// Multiclass used to define incoming builtin records for the SPV_INTEL_subgroups extension 1188// and corresponding work/sub group builtin records. 1189multiclass DemangledIntelSubgroupsBuiltin<string name, bits<8> minNumArgs, bits<8> maxNumArgs, Op operation> { 1190 def : DemangledBuiltin<!strconcat("intel_sub_group_", name), OpenCL_std, IntelSubgroups, minNumArgs, maxNumArgs>; 1191 def : IntelSubgroupsBuiltin<!strconcat("intel_sub_group_", name), operation>; 1192} 1193 1194// cl_intel_subgroups 1195defm : DemangledIntelSubgroupsBuiltin<"shuffle", 2, 2, OpSubgroupShuffleINTEL>; 1196defm : DemangledIntelSubgroupsBuiltin<"shuffle_down", 3, 3, OpSubgroupShuffleDownINTEL>; 1197defm : DemangledIntelSubgroupsBuiltin<"shuffle_up", 3, 3, OpSubgroupShuffleUpINTEL>; 1198defm : DemangledIntelSubgroupsBuiltin<"shuffle_xor", 2, 2, OpSubgroupShuffleXorINTEL>; 1199foreach i = ["", "2", "4", "8"] in { 1200 // cl_intel_subgroups, cl_intel_subgroup_local_block_io 1201 defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_read", i), 1, 2, OpSubgroupBlockReadINTEL>; 1202 defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_write", i), 2, 3, OpSubgroupBlockWriteINTEL>; 1203 // cl_intel_subgroups_short, cl_intel_subgroup_local_block_io 1204 defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_read_ui", i), 1, 2, OpSubgroupBlockReadINTEL>; 1205 defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_write_ui", i), 2, 3, OpSubgroupBlockWriteINTEL>; 1206 // cl_intel_media_block_io 1207 defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_read", i), 4, 4, OpSubgroupImageMediaBlockReadINTEL>; 1208 defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_read_ui", i), 4, 4, OpSubgroupImageMediaBlockReadINTEL>; 1209 defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_write", i), 5, 5, OpSubgroupImageMediaBlockWriteINTEL>; 1210 defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_write_ui", i), 5, 5, OpSubgroupImageMediaBlockWriteINTEL>; 1211} 1212// cl_intel_subgroups_char, cl_intel_subgroups_short, cl_intel_subgroups_long, cl_intel_media_block_io, cl_intel_subgroup_local_block_io 1213foreach i = ["", "2", "4", "8", "16"] in { 1214 foreach j = ["c", "s", "l"] in { 1215 defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_read_u", j, i), 1, 2, OpSubgroupBlockReadINTEL>; 1216 defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_write_u", j, i), 2, 3, OpSubgroupBlockWriteINTEL>; 1217 defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_read_u", j, i), 4, 4, OpSubgroupImageMediaBlockReadINTEL>; 1218 defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_write_u", j, i), 5, 5, OpSubgroupImageMediaBlockWriteINTEL>; 1219 } 1220} 1221// OpSubgroupImageBlockReadINTEL and OpSubgroupImageBlockWriteINTEL are to be resolved later on (in code) 1222 1223// Multiclass used to define builtin wrappers for the SPV_INTEL_subgroups and the SPV_INTEL_media_block_io extensions. 1224multiclass DemangledIntelSubgroupsBuiltinWrapper<string name, bits<8> numArgs, Op operation> { 1225 def : DemangledBuiltin<!strconcat("__spirv_", name), OpenCL_std, IntelSubgroups, numArgs, numArgs>; 1226 def : IntelSubgroupsBuiltin<!strconcat("__spirv_", name), operation>; 1227} 1228 1229defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupShuffleINTEL", 2, OpSubgroupShuffleINTEL>; 1230defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupShuffleDownINTEL", 3, OpSubgroupShuffleDownINTEL>; 1231defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupShuffleUpINTEL", 3, OpSubgroupShuffleUpINTEL>; 1232defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupShuffleXorINTEL", 2, OpSubgroupShuffleXorINTEL>; 1233defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupBlockReadINTEL", 1, OpSubgroupBlockReadINTEL>; 1234defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupBlockWriteINTEL", 2, OpSubgroupBlockWriteINTEL>; 1235defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupImageBlockReadINTEL", 2, OpSubgroupImageBlockReadINTEL>; 1236defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupImageBlockWriteINTEL", 3, OpSubgroupImageBlockWriteINTEL>; 1237defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupImageMediaBlockReadINTEL", 4, OpSubgroupImageMediaBlockReadINTEL>; 1238defm : DemangledIntelSubgroupsBuiltinWrapper<"SubgroupImageMediaBlockWriteINTEL", 5, OpSubgroupImageMediaBlockWriteINTEL>; 1239 1240//===----------------------------------------------------------------------===// 1241// Class defining a builtin for group operations within uniform control flow. 1242// It should be translated into a SPIR-V instruction using 1243// the SPV_KHR_uniform_group_instructions extension. 1244// 1245// name is the demangled name of the given builtin. 1246// opcode specifies the SPIR-V operation code of the generated instruction. 1247//===----------------------------------------------------------------------===// 1248class GroupUniformBuiltin<string name, Op operation> { 1249 string Name = name; 1250 Op Opcode = operation; 1251 bit IsLogical = !or(!eq(operation, OpGroupLogicalAndKHR), 1252 !eq(operation, OpGroupLogicalOrKHR), 1253 !eq(operation, OpGroupLogicalXorKHR)); 1254} 1255 1256// Table gathering all the Intel sub group builtins. 1257def GroupUniformBuiltins : GenericTable { 1258 let FilterClass = "GroupUniformBuiltin"; 1259 let Fields = ["Name", "Opcode", "IsLogical"]; 1260} 1261 1262// Function to lookup group builtins by their name and set. 1263def lookupGroupUniformBuiltin : SearchIndex { 1264 let Table = GroupUniformBuiltins; 1265 let Key = ["Name"]; 1266} 1267 1268// Multiclass used to define incoming builtin records for 1269// the SPV_KHR_uniform_group_instructions extension 1270// and corresponding work group builtin records. 1271multiclass DemangledGroupUniformBuiltin<string name, bits<8> minNumArgs, bits<8> maxNumArgs, Op operation> { 1272 def : DemangledBuiltin<!strconcat("__spirv_Group", name), OpenCL_std, GroupUniform, minNumArgs, maxNumArgs>; 1273 def : GroupUniformBuiltin<!strconcat("__spirv_Group", name), operation>; 1274} 1275 1276// cl_khr_work_group_uniform_arithmetic / SPV_KHR_uniform_group_instructions 1277defm : DemangledGroupUniformBuiltin<"IMulKHR", 3, 3, OpGroupIMulKHR>; 1278defm : DemangledGroupUniformBuiltin<"FMulKHR", 3, 3, OpGroupFMulKHR>; 1279defm : DemangledGroupUniformBuiltin<"BitwiseAndKHR", 3, 3, OpGroupBitwiseAndKHR>; 1280defm : DemangledGroupUniformBuiltin<"BitwiseOrKHR", 3, 3, OpGroupBitwiseOrKHR>; 1281defm : DemangledGroupUniformBuiltin<"BitwiseXorKHR", 3, 3, OpGroupBitwiseXorKHR>; 1282defm : DemangledGroupUniformBuiltin<"LogicalAndKHR", 3, 3, OpGroupLogicalAndKHR>; 1283defm : DemangledGroupUniformBuiltin<"LogicalOrKHR", 3, 3, OpGroupLogicalOrKHR>; 1284defm : DemangledGroupUniformBuiltin<"LogicalXorKHR", 3, 3, OpGroupLogicalXorKHR>; 1285 1286//===----------------------------------------------------------------------===// 1287// Class defining a get builtin record used for lowering builtin calls such as 1288// "get_sub_group_eq_mask" or "get_global_id" to SPIR-V instructions. 1289// 1290// name is the demangled name of the given builtin. 1291// set specifies which external instruction set the builtin belongs to. 1292// value specifies the value of the BuiltIn enum. 1293//===----------------------------------------------------------------------===// 1294class GetBuiltin<string name, InstructionSet set, BuiltIn value> { 1295 string Name = name; 1296 InstructionSet Set = set; 1297 BuiltIn Value = value; 1298} 1299 1300// Table gathering all the get builtin records. 1301def GetBuiltins : GenericTable { 1302 let FilterClass = "GetBuiltin"; 1303 let Fields = ["Name", "Set", "Value"]; 1304 string TypeOf_Set = "InstructionSet"; 1305 string TypeOf_Value = "BuiltIn"; 1306} 1307 1308// Function to lookup get builtin records by their name and set. 1309def lookupGetBuiltin : SearchIndex { 1310 let Table = GetBuiltins; 1311 let Key = ["Name", "Set"]; 1312} 1313 1314// Multiclass used to define at the same time both a demangled builtin record 1315// and a corresponding get builtin record. 1316multiclass DemangledGetBuiltin<string name, InstructionSet set, BuiltinGroup group, BuiltIn value> { 1317 def : DemangledBuiltin<name, set, group, 0, 1>; 1318 def : GetBuiltin<name, set, value>; 1319} 1320 1321// Builtin variable records: 1322defm : DemangledGetBuiltin<"get_sub_group_eq_mask", OpenCL_std, Variable, SubgroupEqMask>; 1323defm : DemangledGetBuiltin<"get_sub_group_ge_mask", OpenCL_std, Variable, SubgroupGeMask>; 1324defm : DemangledGetBuiltin<"get_sub_group_gt_mask", OpenCL_std, Variable, SubgroupGtMask>; 1325defm : DemangledGetBuiltin<"get_sub_group_le_mask", OpenCL_std, Variable, SubgroupLeMask>; 1326defm : DemangledGetBuiltin<"get_sub_group_lt_mask", OpenCL_std, Variable, SubgroupLtMask>; 1327defm : DemangledGetBuiltin<"__spirv_BuiltInGlobalLinearId", OpenCL_std, Variable, GlobalLinearId>; 1328defm : DemangledGetBuiltin<"__spirv_BuiltInGlobalInvocationId", OpenCL_std, Variable, GlobalInvocationId>; 1329 1330// GetQuery builtin records: 1331defm : DemangledGetBuiltin<"get_local_id", OpenCL_std, GetQuery, LocalInvocationId>; 1332defm : DemangledGetBuiltin<"get_global_id", OpenCL_std, GetQuery, GlobalInvocationId>; 1333defm : DemangledGetBuiltin<"get_local_size", OpenCL_std, GetQuery, WorkgroupSize>; 1334defm : DemangledGetBuiltin<"get_global_size", OpenCL_std, GetQuery, GlobalSize>; 1335defm : DemangledGetBuiltin<"get_group_id", OpenCL_std, GetQuery, WorkgroupId>; 1336defm : DemangledGetBuiltin<"get_enqueued_local_size", OpenCL_std, GetQuery, EnqueuedWorkgroupSize>; 1337defm : DemangledGetBuiltin<"get_num_groups", OpenCL_std, GetQuery, NumWorkgroups>; 1338defm : DemangledGetBuiltin<"__hlsl_wave_get_lane_index", GLSL_std_450, Wave, SubgroupLocalInvocationId>; 1339 1340//===----------------------------------------------------------------------===// 1341// Class defining an image query builtin record used for lowering the OpenCL 1342// "get_image_*" calls into OpImageQuerySize/OpImageQuerySizeLod instructions. 1343// 1344// name is the demangled name of the given builtin. 1345// set specifies which external instruction set the builtin belongs to. 1346// component specifies the unsigned number of the query component. 1347//===----------------------------------------------------------------------===// 1348class ImageQueryBuiltin<string name, InstructionSet set, bits<32> component> { 1349 string Name = name; 1350 InstructionSet Set = set; 1351 bits<32> Component = component; 1352} 1353 1354// Table gathering all the image query builtins. 1355def ImageQueryBuiltins : GenericTable { 1356 let FilterClass = "ImageQueryBuiltin"; 1357 let Fields = ["Name", "Set", "Component"]; 1358 string TypeOf_Set = "InstructionSet"; 1359} 1360 1361// Function to lookup image query builtins by their name and set. 1362def lookupImageQueryBuiltin : SearchIndex { 1363 let Table = ImageQueryBuiltins; 1364 let Key = ["Name", "Set"]; 1365} 1366 1367// Multiclass used to define at the same time both a demangled builtin record 1368// and a corresponding image query builtin record. 1369multiclass DemangledImageQueryBuiltin<string name, InstructionSet set, int component> { 1370 def : DemangledBuiltin<name, set, ImageSizeQuery, 1, 1>; 1371 def : ImageQueryBuiltin<name, set, component>; 1372} 1373 1374// Image query builtin records: 1375defm : DemangledImageQueryBuiltin<"get_image_width", OpenCL_std, 0>; 1376defm : DemangledImageQueryBuiltin<"get_image_height", OpenCL_std, 1>; 1377defm : DemangledImageQueryBuiltin<"get_image_depth", OpenCL_std, 2>; 1378defm : DemangledImageQueryBuiltin<"get_image_dim", OpenCL_std, 0>; 1379defm : DemangledImageQueryBuiltin<"get_image_array_size", OpenCL_std, 3>; 1380 1381defm : DemangledNativeBuiltin<"get_image_num_samples", OpenCL_std, ImageMiscQuery, 1, 1, OpImageQuerySamples>; 1382defm : DemangledNativeBuiltin<"get_image_num_mip_levels", OpenCL_std, ImageMiscQuery, 1, 1, OpImageQueryLevels>; 1383 1384//===----------------------------------------------------------------------===// 1385// Class defining a "convert_destType<_sat><_roundingMode>" call record for 1386// lowering into OpConvert instructions. 1387// 1388// name is the demangled name of the given builtin. 1389// set specifies which external instruction set the builtin belongs to. 1390//===----------------------------------------------------------------------===// 1391class ConvertBuiltin<string name, InstructionSet set> { 1392 string Name = name; 1393 InstructionSet Set = set; 1394 bit IsDestinationSigned = !eq(!find(name, "convert_u"), -1); 1395 bit IsSaturated = !not(!eq(!find(name, "_sat"), -1)); 1396 bit IsRounded = !not(!eq(!find(name, "_rt"), -1)); 1397 bit IsBfloat16 = !or(!not(!eq(!find(name, "BF16"), -1)), 1398 !not(!eq(!find(name, "bfloat16"), -1))); 1399 FPRoundingMode RoundingMode = !cond(!not(!eq(!find(name, "_rte"), -1)) : RTE, 1400 !not(!eq(!find(name, "_rtz"), -1)) : RTZ, 1401 !not(!eq(!find(name, "_rtp"), -1)) : RTP, 1402 !not(!eq(!find(name, "_rtn"), -1)) : RTN, 1403 true : RTE); 1404} 1405 1406// Table gathering all the convert builtins. 1407def ConvertBuiltins : GenericTable { 1408 let FilterClass = "ConvertBuiltin"; 1409 let Fields = ["Name", "Set", "IsDestinationSigned", "IsSaturated", 1410 "IsRounded", "IsBfloat16", "RoundingMode"]; 1411 string TypeOf_Set = "InstructionSet"; 1412 string TypeOf_RoundingMode = "FPRoundingMode"; 1413} 1414 1415// Function to lookup convert builtins by their name and set. 1416def lookupConvertBuiltin : SearchIndex { 1417 let Table = ConvertBuiltins; 1418 let Key = ["Name", "Set"]; 1419} 1420 1421// Multiclass used to define at the same time both a demangled builtin records 1422// and a corresponding convert builtin records. 1423multiclass DemangledConvertBuiltin<string name, InstructionSet set> { 1424 // Create records for scalar and 2, 4, 8, and 16 element vector conversions. 1425 foreach i = ["", "2", "3", "4", "8", "16"] in { 1426 // Also create records for each rounding mode. 1427 foreach j = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { 1428 def : DemangledBuiltin<!strconcat(name, i, j), set, Convert, 1, 1>; 1429 def : ConvertBuiltin<!strconcat(name, i, j), set>; 1430 1431 // Create records with the "_sat" modifier for all conversions except 1432 // those targeting floating-point types. 1433 if !eq(!find(name, "float"), -1) then { 1434 def : DemangledBuiltin<!strconcat(name, i, "_sat", j), set, Convert, 1, 1>; 1435 def : ConvertBuiltin<!strconcat(name, i, "_sat", j), set>; 1436 } 1437 } 1438 } 1439} 1440 1441// Explicit conversion builtin records: 1442defm : DemangledConvertBuiltin<"convert_char", OpenCL_std>; 1443defm : DemangledConvertBuiltin<"convert_uchar", OpenCL_std>; 1444defm : DemangledConvertBuiltin<"convert_short", OpenCL_std>; 1445defm : DemangledConvertBuiltin<"convert_ushort", OpenCL_std>; 1446defm : DemangledConvertBuiltin<"convert_int", OpenCL_std>; 1447defm : DemangledConvertBuiltin<"convert_uint", OpenCL_std>; 1448defm : DemangledConvertBuiltin<"convert_long", OpenCL_std>; 1449defm : DemangledConvertBuiltin<"convert_ulong", OpenCL_std>; 1450defm : DemangledConvertBuiltin<"convert_float", OpenCL_std>; 1451 1452defm : DemangledNativeBuiltin<"__spirv_ConvertFToU", OpenCL_std, Convert, 1, 1, OpConvertFToU>; 1453defm : DemangledNativeBuiltin<"__spirv_ConvertFToS", OpenCL_std, Convert, 1, 1, OpConvertFToS>; 1454defm : DemangledNativeBuiltin<"__spirv_ConvertSToF", OpenCL_std, Convert, 1, 1, OpConvertSToF>; 1455defm : DemangledNativeBuiltin<"__spirv_ConvertUToF", OpenCL_std, Convert, 1, 1, OpConvertUToF>; 1456defm : DemangledNativeBuiltin<"__spirv_UConvert", OpenCL_std, Convert, 1, 1, OpUConvert>; 1457defm : DemangledNativeBuiltin<"__spirv_SConvert", OpenCL_std, Convert, 1, 1, OpSConvert>; 1458defm : DemangledNativeBuiltin<"__spirv_FConvert", OpenCL_std, Convert, 1, 1, OpFConvert>; 1459defm : DemangledNativeBuiltin<"__spirv_QuantizeToF16", OpenCL_std, Convert, 1, 1, OpQuantizeToF16>; 1460defm : DemangledNativeBuiltin<"__spirv_ConvertPtrToU", OpenCL_std, Convert, 1, 1, OpConvertPtrToU>; 1461defm : DemangledNativeBuiltin<"__spirv_SatConvertSToU", OpenCL_std, Convert, 1, 1, OpSatConvertSToU>; 1462defm : DemangledNativeBuiltin<"__spirv_SatConvertUToS", OpenCL_std, Convert, 1, 1, OpSatConvertUToS>; 1463defm : DemangledNativeBuiltin<"__spirv_ConvertUToPtr", OpenCL_std, Convert, 1, 1, OpConvertUToPtr>; 1464 1465// cl_intel_bfloat16_conversions / SPV_INTEL_bfloat16_conversion 1466// Multiclass used to define at the same time both a demangled builtin records 1467// and a corresponding convert builtin records. 1468multiclass DemangledBF16ConvertBuiltin<string name1, string name2> { 1469 // Create records for scalar and vector conversions. 1470 foreach i = ["", "2", "3", "4", "8", "16"] in { 1471 def : DemangledBuiltin<!strconcat("intel_convert_", name1, i, name2, i), OpenCL_std, Convert, 1, 1>; 1472 def : ConvertBuiltin<!strconcat("intel_convert_", name1, i, name2, i), OpenCL_std>; 1473 } 1474} 1475 1476defm : DemangledBF16ConvertBuiltin<"bfloat16", "_as_ushort">; 1477defm : DemangledBF16ConvertBuiltin<"as_bfloat16", "_float">; 1478 1479foreach conv = ["FToBF16INTEL", "BF16ToFINTEL"] in { 1480 def : DemangledBuiltin<!strconcat("__spirv_Convert", conv), OpenCL_std, Convert, 1, 1>; 1481 def : ConvertBuiltin<!strconcat("__spirv_Convert", conv), OpenCL_std>; 1482} 1483 1484//===----------------------------------------------------------------------===// 1485// Class defining a vector data load/store builtin record used for lowering 1486// into OpExtInst instruction. 1487// 1488// name is the demangled name of the given builtin. 1489// set specifies which external instruction set the builtin belongs to. 1490// number specifies the number of the instruction in the external set. 1491//===----------------------------------------------------------------------===// 1492class VectorLoadStoreBuiltin<string name, InstructionSet set, int number> { 1493 string Name = name; 1494 InstructionSet Set = set; 1495 bits<32> Number = number; 1496 bits<32> ElementCount = !cond(!not(!eq(!find(name, "2"), -1)) : 2, 1497 !not(!eq(!find(name, "3"), -1)) : 3, 1498 !not(!eq(!find(name, "4"), -1)) : 4, 1499 !not(!eq(!find(name, "8"), -1)) : 8, 1500 !not(!eq(!find(name, "16"), -1)) : 16, 1501 true : 1); 1502 bit IsRounded = !not(!eq(!find(name, "_rt"), -1)); 1503 FPRoundingMode RoundingMode = !cond(!not(!eq(!find(name, "_rte"), -1)) : RTE, 1504 !not(!eq(!find(name, "_rtz"), -1)) : RTZ, 1505 !not(!eq(!find(name, "_rtp"), -1)) : RTP, 1506 !not(!eq(!find(name, "_rtn"), -1)) : RTN, 1507 true : RTE); 1508} 1509 1510// Table gathering all the vector data load/store builtins. 1511def VectorLoadStoreBuiltins : GenericTable { 1512 let FilterClass = "VectorLoadStoreBuiltin"; 1513 let Fields = ["Name", "Set", "Number", "ElementCount", "IsRounded", "RoundingMode"]; 1514 string TypeOf_Set = "InstructionSet"; 1515 string TypeOf_RoundingMode = "FPRoundingMode"; 1516} 1517 1518// Function to lookup vector data load/store builtins by their name and set. 1519def lookupVectorLoadStoreBuiltin : SearchIndex { 1520 let Table = VectorLoadStoreBuiltins; 1521 let Key = ["Name", "Set"]; 1522} 1523 1524// Multiclass used to define at the same time both a demangled builtin record 1525// and a corresponding vector data load/store builtin record. 1526multiclass DemangledVectorLoadStoreBuiltin<string name, bits<8> minNumArgs, bits<8> maxNumArgs, int number> { 1527 def : DemangledBuiltin<name, OpenCL_std, VectorLoadStore, minNumArgs, maxNumArgs>; 1528 def : VectorLoadStoreBuiltin<name, OpenCL_std, number>; 1529} 1530 1531// Create records for scalar and 2, 4, 8, and 16 vector element count. 1532foreach i = ["", "2", "3", "4", "8", "16"] in { 1533 if !eq(i, "") then { 1534 defm : DemangledVectorLoadStoreBuiltin<"vload_half", 2, 2, 173>; 1535 defm : DemangledVectorLoadStoreBuiltin<"vstore_half", 3, 3, 175>; 1536 } else { 1537 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vload_half", i), 2, 2, 174>; 1538 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore_half", i), 3, 3, 177>; 1539 } 1540 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vload", i), 2, 2, 171>; 1541 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore", i), 3, 3, 172>; 1542 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vloada_half", i), 2, 2, 174>; 1543 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstorea_half", i), 3, 3, 180>; 1544 1545 // Also create records for each rounding mode. 1546 foreach j = ["_rte", "_rtz", "_rtp", "_rtn"] in { 1547 if !eq(i, "") then { 1548 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore_half", j), 3, 3, 176>; 1549 } else { 1550 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstore_half", i, j), 3, 3, 178>; 1551 } 1552 defm : DemangledVectorLoadStoreBuiltin<!strconcat("vstorea_half", i, j), 3, 3, 181>; 1553 } 1554} 1555 1556//===----------------------------------------------------------------------===// 1557// Class defining implementation details of SPIR-V builtin types. The info 1558// in the record is used for lowering into OpType. 1559// 1560// name is the name of the given SPIR-V builtin type. 1561// operation specifies the SPIR-V opcode the StructType should be lowered to. 1562//===----------------------------------------------------------------------===// 1563class BuiltinType<string name, Op operation> { 1564 string Name = name; 1565 Op Opcode = operation; 1566} 1567 1568// Table gathering all the builtin type records. 1569def BuiltinTypes : GenericTable { 1570 let FilterClass = "BuiltinType"; 1571 let Fields = ["Name", "Opcode"]; 1572} 1573 1574// Function to lookup builtin types by their demangled name. 1575def lookupBuiltinType : SearchIndex { 1576 let Table = BuiltinTypes; 1577 let Key = ["Name"]; 1578} 1579 1580def : BuiltinType<"spirv.ReserveId", OpTypeReserveId>; 1581def : BuiltinType<"spirv.PipeStorage", OpTypePipeStorage>; 1582def : BuiltinType<"spirv.Queue", OpTypeQueue>; 1583def : BuiltinType<"spirv.Event", OpTypeEvent>; 1584def : BuiltinType<"spirv.Sampler", OpTypeSampler>; 1585def : BuiltinType<"spirv.DeviceEvent", OpTypeDeviceEvent>; 1586def : BuiltinType<"spirv.Image", OpTypeImage>; 1587def : BuiltinType<"spirv.SampledImage", OpTypeSampledImage>; 1588def : BuiltinType<"spirv.Pipe", OpTypePipe>; 1589def : BuiltinType<"spirv.CooperativeMatrixKHR", OpTypeCooperativeMatrixKHR>; 1590 1591//===----------------------------------------------------------------------===// 1592// Class matching an OpenCL builtin type name to an equivalent SPIR-V 1593// builtin type literal. 1594// 1595// name is the name of the given OpenCL builtin type. 1596// spirvTypeLiteral is the literal of an equivalent SPIR-V builtin type. 1597//===----------------------------------------------------------------------===// 1598class OpenCLType<string name, string spirvTypeLiteral> { 1599 string Name = name; 1600 string SpirvTypeLiteral = spirvTypeLiteral; 1601} 1602 1603// Table gathering all the OpenCL type records. 1604def OpenCLTypes : GenericTable { 1605 let FilterClass = "OpenCLType"; 1606 let Fields = ["Name", "SpirvTypeLiteral"]; 1607} 1608 1609// Function to lookup OpenCL types by their name. 1610def lookupOpenCLType : SearchIndex { 1611 let Table = OpenCLTypes; 1612 let Key = ["Name"]; 1613} 1614 1615def : OpenCLType<"opencl.reserve_id_t", "spirv.ReserveId">; 1616def : OpenCLType<"opencl.event_t", "spirv.Event">; 1617def : OpenCLType<"opencl.queue_t", "spirv.Queue">; 1618def : OpenCLType<"opencl.sampler_t", "spirv.Sampler">; 1619def : OpenCLType<"opencl.clk_event_t", "spirv.DeviceEvent">; 1620 1621foreach aq = ["_t", "_ro_t", "_wo_t", "_rw_t"] in { 1622 defvar p = !cond(!not(!eq(!find(aq, "_rw_t"), -1)) : "2", 1623 !not(!eq(!find(aq, "_wo_t"), -1)) : "1", 1624 true : "0"); 1625 def : OpenCLType<!strconcat("opencl.pipe", aq), 1626 !strconcat("spirv.Pipe._", p)>; 1627} 1628 1629foreach aq = ["_t", "_ro_t", "_wo_t", "_rw_t"] in { 1630 defvar p7 = !cond(!not(!eq(!find(aq, "_rw_t"), -1)) : "2", 1631 !not(!eq(!find(aq, "_wo_t"), -1)) : "1", 1632 true : "0"); 1633 1634 def : OpenCLType<!strconcat("opencl.image1d", aq), 1635 !strconcat("spirv.Image._void_0_0_0_0_0_0_", p7)>; 1636 def : OpenCLType<!strconcat("opencl.image1d_array", aq), 1637 !strconcat("spirv.Image._void_0_0_1_0_0_0_", p7)>; 1638 def : OpenCLType<!strconcat("opencl.image1d_buffer", aq), 1639 !strconcat("spirv.Image._void_5_0_0_0_0_0_", p7)>; 1640 1641 foreach a1 = ["", "_array"] in { 1642 foreach a2 = ["", "_msaa"] in { 1643 foreach a3 = ["", "_depth"] in { 1644 defvar p2 = !cond(!not(!eq(!find(a3, "_depth"), -1)) : "1", true : "0"); 1645 defvar p3 = !cond(!not(!eq(!find(a1, "_array"), -1)) : "1", true : "0"); 1646 defvar p4 = !cond(!not(!eq(!find(a2, "msaa"), -1)) : "1", true : "0"); 1647 1648 def : OpenCLType<!strconcat("opencl.image2d", a1, a2, a3, aq), 1649 !strconcat("spirv.Image._void_1_", p2 , "_", p3, "_", p4, "_0_0_", p7)>; 1650 } 1651 } 1652 } 1653 1654 def : OpenCLType<!strconcat("opencl.image3d", aq), 1655 !strconcat("spirv.Image._void_2_0_0_0_0_0_", p7)>; 1656} 1657 1658//===----------------------------------------------------------------------===// 1659// Classes definining various OpenCL enums. 1660//===----------------------------------------------------------------------===// 1661 1662// OpenCL memory_scope enum 1663def CLMemoryScope : GenericEnum { 1664 let FilterClass = "CLMemoryScope"; 1665 let NameField = "Name"; 1666 let ValueField = "Value"; 1667} 1668 1669class CLMemoryScope<bits<32> value> { 1670 string Name = NAME; 1671 bits<32> Value = value; 1672} 1673 1674def memory_scope_work_item : CLMemoryScope<0>; 1675def memory_scope_work_group : CLMemoryScope<1>; 1676def memory_scope_device : CLMemoryScope<2>; 1677def memory_scope_all_svm_devices : CLMemoryScope<3>; 1678def memory_scope_sub_group : CLMemoryScope<4>; 1679 1680// OpenCL sampler addressing mode/bitmask enum 1681def CLSamplerAddressingMode : GenericEnum { 1682 let FilterClass = "CLSamplerAddressingMode"; 1683 let NameField = "Name"; 1684 let ValueField = "Value"; 1685} 1686 1687class CLSamplerAddressingMode<bits<32> value> { 1688 string Name = NAME; 1689 bits<32> Value = value; 1690} 1691 1692def CLK_ADDRESS_NONE : CLSamplerAddressingMode<0x0>; 1693def CLK_ADDRESS_CLAMP : CLSamplerAddressingMode<0x4>; 1694def CLK_ADDRESS_CLAMP_TO_EDGE : CLSamplerAddressingMode<0x2>; 1695def CLK_ADDRESS_REPEAT : CLSamplerAddressingMode<0x6>; 1696def CLK_ADDRESS_MIRRORED_REPEAT : CLSamplerAddressingMode<0x8>; 1697def CLK_ADDRESS_MODE_MASK : CLSamplerAddressingMode<0xE>; 1698def CLK_NORMALIZED_COORDS_FALSE : CLSamplerAddressingMode<0x0>; 1699def CLK_NORMALIZED_COORDS_TRUE : CLSamplerAddressingMode<0x1>; 1700def CLK_FILTER_NEAREST : CLSamplerAddressingMode<0x10>; 1701def CLK_FILTER_LINEAR : CLSamplerAddressingMode<0x20>; 1702 1703// OpenCL memory fences 1704def CLMemoryFenceFlags : GenericEnum { 1705 let FilterClass = "CLMemoryFenceFlags"; 1706 let NameField = "Name"; 1707 let ValueField = "Value"; 1708} 1709 1710class CLMemoryFenceFlags<bits<32> value> { 1711 string Name = NAME; 1712 bits<32> Value = value; 1713} 1714 1715def CLK_LOCAL_MEM_FENCE : CLMemoryFenceFlags<0x1>; 1716def CLK_GLOBAL_MEM_FENCE : CLMemoryFenceFlags<0x2>; 1717def CLK_IMAGE_MEM_FENCE : CLMemoryFenceFlags<0x4>; 1718