| 1 |
//===- SPIRVBuiltin.h - SPIR-V extended instruction -------------*- C++ -*-===// |
| 2 |
// |
| 3 |
// The LLVM/SPIRV Translator |
| 4 |
// |
| 5 |
// This file is distributed under the University of Illinois Open Source |
| 6 |
// License. See LICENSE.TXT for details. |
| 7 |
// |
| 8 |
// Copyright (c) 2014 Advanced Micro Devices, Inc. All rights reserved. |
| 9 |
// |
| 10 |
// Permission is hereby granted, free of charge, to any person obtaining a |
| 11 |
// copy of this software and associated documentation files (the "Software"), |
| 12 |
// to deal with the Software without restriction, including without limitation |
| 13 |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 |
// and/or sell copies of the Software, and to permit persons to whom the |
| 15 |
// Software is furnished to do so, subject to the following conditions: |
| 16 |
// |
| 17 |
// Redistributions of source code must retain the above copyright notice, |
| 18 |
// this list of conditions and the following disclaimers. |
| 19 |
// Redistributions in binary form must reproduce the above copyright notice, |
| 20 |
// this list of conditions and the following disclaimers in the documentation |
| 21 |
// and/or other materials provided with the distribution. |
| 22 |
// Neither the names of Advanced Micro Devices, Inc., nor the names of its |
| 23 |
// contributors may be used to endorse or promote products derived from this |
| 24 |
// Software without specific prior written permission. |
| 25 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 26 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 27 |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 28 |
// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 29 |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 30 |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH |
| 31 |
// THE SOFTWARE. |
| 32 |
// |
| 33 |
//===----------------------------------------------------------------------===// |
| 34 |
/// \file |
| 35 |
/// |
| 36 |
/// This file defines SPIR-V extended instructions. |
| 37 |
/// |
| 38 |
//===----------------------------------------------------------------------===// |
| 39 |
|
| 40 |
#ifndef SPIRV_LIBSPIRV_SPIRVEXTINST_H |
| 41 |
#define SPIRV_LIBSPIRV_SPIRVEXTINST_H |
| 42 |
|
| 43 |
#include "NonSemantic.AuxData.h" |
| 44 |
#include "OpenCL.std.h" |
| 45 |
#include "SPIRV.debug.h" |
| 46 |
#include "SPIRVEnum.h" |
| 47 |
#include "SPIRVUtil.h" |
| 48 |
|
| 49 |
#include <string> |
| 50 |
#include <vector> |
| 51 |
|
| 52 |
namespace SPIRV { |
| 53 |
|
| 54 |
typedef OpenCLLIB::Entrypoints OCLExtOpKind; |
| 55 |
|
| 56 |
template <> inline void SPIRVMap<OCLExtOpKind, std::string>::init() { |
| 57 |
add(OpenCLLIB::Acos, "acos"); |
| 58 |
add(OpenCLLIB::Acosh, "acosh"); |
| 59 |
add(OpenCLLIB::Acospi, "acospi"); |
| 60 |
add(OpenCLLIB::Asin, "asin"); |
| 61 |
add(OpenCLLIB::Asinh, "asinh"); |
| 62 |
add(OpenCLLIB::Asinpi, "asinpi"); |
| 63 |
add(OpenCLLIB::Atan, "atan"); |
| 64 |
add(OpenCLLIB::Atan2, "atan2"); |
| 65 |
add(OpenCLLIB::Atanh, "atanh"); |
| 66 |
add(OpenCLLIB::Atanpi, "atanpi"); |
| 67 |
add(OpenCLLIB::Atan2pi, "atan2pi"); |
| 68 |
add(OpenCLLIB::Cbrt, "cbrt"); |
| 69 |
add(OpenCLLIB::Ceil, "ceil"); |
| 70 |
add(OpenCLLIB::Copysign, "copysign"); |
| 71 |
add(OpenCLLIB::Cos, "cos"); |
| 72 |
add(OpenCLLIB::Cosh, "cosh"); |
| 73 |
add(OpenCLLIB::Cospi, "cospi"); |
| 74 |
add(OpenCLLIB::Erfc, "erfc"); |
| 75 |
add(OpenCLLIB::Erf, "erf"); |
| 76 |
add(OpenCLLIB::Exp, "exp"); |
| 77 |
add(OpenCLLIB::Exp2, "exp2"); |
| 78 |
add(OpenCLLIB::Exp10, "exp10"); |
| 79 |
add(OpenCLLIB::Expm1, "expm1"); |
| 80 |
add(OpenCLLIB::Fabs, "fabs"); |
| 81 |
add(OpenCLLIB::Fdim, "fdim"); |
| 82 |
add(OpenCLLIB::Floor, "floor"); |
| 83 |
add(OpenCLLIB::Fma, "fma"); |
| 84 |
add(OpenCLLIB::Fmax, "fmax"); |
| 85 |
add(OpenCLLIB::Fmin, "fmin"); |
| 86 |
add(OpenCLLIB::Fmod, "fmod"); |
| 87 |
add(OpenCLLIB::Fract, "fract"); |
| 88 |
add(OpenCLLIB::Frexp, "frexp"); |
| 89 |
add(OpenCLLIB::Hypot, "hypot"); |
| 90 |
add(OpenCLLIB::Ilogb, "ilogb"); |
| 91 |
add(OpenCLLIB::Ldexp, "ldexp"); |
| 92 |
add(OpenCLLIB::Lgamma, "lgamma"); |
| 93 |
add(OpenCLLIB::Lgamma_r, "lgamma_r"); |
| 94 |
add(OpenCLLIB::Log, "log"); |
| 95 |
add(OpenCLLIB::Log2, "log2"); |
| 96 |
add(OpenCLLIB::Log10, "log10"); |
| 97 |
add(OpenCLLIB::Log1p, "log1p"); |
| 98 |
add(OpenCLLIB::Logb, "logb"); |
| 99 |
add(OpenCLLIB::Mad, "mad"); |
| 100 |
add(OpenCLLIB::Maxmag, "maxmag"); |
| 101 |
add(OpenCLLIB::Minmag, "minmag"); |
| 102 |
add(OpenCLLIB::Modf, "modf"); |
| 103 |
add(OpenCLLIB::Nan, "nan"); |
| 104 |
add(OpenCLLIB::Nextafter, "nextafter"); |
| 105 |
add(OpenCLLIB::Pow, "pow"); |
| 106 |
add(OpenCLLIB::Pown, "pown"); |
| 107 |
add(OpenCLLIB::Powr, "powr"); |
| 108 |
add(OpenCLLIB::Remainder, "remainder"); |
| 109 |
add(OpenCLLIB::Remquo, "remquo"); |
| 110 |
add(OpenCLLIB::Rint, "rint"); |
| 111 |
add(OpenCLLIB::Rootn, "rootn"); |
| 112 |
add(OpenCLLIB::Round, "round"); |
| 113 |
add(OpenCLLIB::Rsqrt, "rsqrt"); |
| 114 |
add(OpenCLLIB::Sin, "sin"); |
| 115 |
add(OpenCLLIB::Sincos, "sincos"); |
| 116 |
add(OpenCLLIB::Sinh, "sinh"); |
| 117 |
add(OpenCLLIB::Sinpi, "sinpi"); |
| 118 |
add(OpenCLLIB::Sqrt, "sqrt"); |
| 119 |
add(OpenCLLIB::Tan, "tan"); |
| 120 |
add(OpenCLLIB::Tanh, "tanh"); |
| 121 |
add(OpenCLLIB::Tanpi, "tanpi"); |
| 122 |
add(OpenCLLIB::Tgamma, "tgamma"); |
| 123 |
add(OpenCLLIB::Trunc, "trunc"); |
| 124 |
add(OpenCLLIB::Half_cos, "half_cos"); |
| 125 |
add(OpenCLLIB::Half_divide, "half_divide"); |
| 126 |
add(OpenCLLIB::Half_exp, "half_exp"); |
| 127 |
add(OpenCLLIB::Half_exp2, "half_exp2"); |
| 128 |
add(OpenCLLIB::Half_exp10, "half_exp10"); |
| 129 |
add(OpenCLLIB::Half_log, "half_log"); |
| 130 |
add(OpenCLLIB::Half_log2, "half_log2"); |
| 131 |
add(OpenCLLIB::Half_log10, "half_log10"); |
| 132 |
add(OpenCLLIB::Half_powr, "half_powr"); |
| 133 |
add(OpenCLLIB::Half_recip, "half_recip"); |
| 134 |
add(OpenCLLIB::Half_rsqrt, "half_rsqrt"); |
| 135 |
add(OpenCLLIB::Half_sin, "half_sin"); |
| 136 |
add(OpenCLLIB::Half_sqrt, "half_sqrt"); |
| 137 |
add(OpenCLLIB::Half_tan, "half_tan"); |
| 138 |
add(OpenCLLIB::Native_cos, "native_cos"); |
| 139 |
add(OpenCLLIB::Native_divide, "native_divide"); |
| 140 |
add(OpenCLLIB::Native_exp, "native_exp"); |
| 141 |
add(OpenCLLIB::Native_exp2, "native_exp2"); |
| 142 |
add(OpenCLLIB::Native_exp10, "native_exp10"); |
| 143 |
add(OpenCLLIB::Native_log, "native_log"); |
| 144 |
add(OpenCLLIB::Native_log2, "native_log2"); |
| 145 |
add(OpenCLLIB::Native_log10, "native_log10"); |
| 146 |
add(OpenCLLIB::Native_powr, "native_powr"); |
| 147 |
add(OpenCLLIB::Native_recip, "native_recip"); |
| 148 |
add(OpenCLLIB::Native_rsqrt, "native_rsqrt"); |
| 149 |
add(OpenCLLIB::Native_sin, "native_sin"); |
| 150 |
add(OpenCLLIB::Native_sqrt, "native_sqrt"); |
| 151 |
add(OpenCLLIB::Native_tan, "native_tan"); |
| 152 |
add(OpenCLLIB::FClamp, "fclamp"); |
| 153 |
add(OpenCLLIB::Degrees, "degrees"); |
| 154 |
add(OpenCLLIB::Mix, "mix"); |
| 155 |
add(OpenCLLIB::FMax_common, "fmax_common"); |
| 156 |
add(OpenCLLIB::FMin_common, "fmin_common"); |
| 157 |
add(OpenCLLIB::Radians, "radians"); |
| 158 |
add(OpenCLLIB::Step, "step"); |
| 159 |
add(OpenCLLIB::Smoothstep, "smoothstep"); |
| 160 |
add(OpenCLLIB::Sign, "sign"); |
| 161 |
add(OpenCLLIB::Cross, "cross"); |
| 162 |
add(OpenCLLIB::Distance, "distance"); |
| 163 |
add(OpenCLLIB::Length, "length"); |
| 164 |
add(OpenCLLIB::Normalize, "normalize"); |
| 165 |
add(OpenCLLIB::Fast_distance, "fast_distance"); |
| 166 |
add(OpenCLLIB::Fast_length, "fast_length"); |
| 167 |
add(OpenCLLIB::Fast_normalize, "fast_normalize"); |
| 168 |
add(OpenCLLIB::SAbs, "s_abs"); |
| 169 |
add(OpenCLLIB::SAbs_diff, "s_abs_diff"); |
| 170 |
add(OpenCLLIB::SAdd_sat, "s_add_sat"); |
| 171 |
add(OpenCLLIB::UAdd_sat, "u_add_sat"); |
| 172 |
add(OpenCLLIB::SHadd, "s_hadd"); |
| 173 |
add(OpenCLLIB::UHadd, "u_hadd"); |
| 174 |
add(OpenCLLIB::SRhadd, "s_rhadd"); |
| 175 |
add(OpenCLLIB::URhadd, "u_rhadd"); |
| 176 |
add(OpenCLLIB::SClamp, "s_clamp"); |
| 177 |
add(OpenCLLIB::UClamp, "u_clamp"); |
| 178 |
add(OpenCLLIB::Clz, "clz"); |
| 179 |
add(OpenCLLIB::Ctz, "ctz"); |
| 180 |
add(OpenCLLIB::SMad_hi, "s_mad_hi"); |
| 181 |
add(OpenCLLIB::SMad_sat, "s_mad_sat"); |
| 182 |
add(OpenCLLIB::UMad_sat, "u_mad_sat"); |
| 183 |
add(OpenCLLIB::SMax, "s_max"); |
| 184 |
add(OpenCLLIB::SMin, "s_min"); |
| 185 |
add(OpenCLLIB::UMax, "u_max"); |
| 186 |
add(OpenCLLIB::UMin, "u_min"); |
| 187 |
add(OpenCLLIB::SMul_hi, "s_mul_hi"); |
| 188 |
add(OpenCLLIB::Rotate, "rotate"); |
| 189 |
add(OpenCLLIB::SSub_sat, "s_sub_sat"); |
| 190 |
add(OpenCLLIB::USub_sat, "u_sub_sat"); |
| 191 |
add(OpenCLLIB::U_Upsample, "u_upsample"); |
| 192 |
add(OpenCLLIB::S_Upsample, "s_upsample"); |
| 193 |
add(OpenCLLIB::Popcount, "popcount"); |
| 194 |
add(OpenCLLIB::SMad24, "s_mad24"); |
| 195 |
add(OpenCLLIB::UMad24, "u_mad24"); |
| 196 |
add(OpenCLLIB::SMul24, "s_mul24"); |
| 197 |
add(OpenCLLIB::UMul24, "u_mul24"); |
| 198 |
add(OpenCLLIB::Vloadn, "vloadn"); |
| 199 |
add(OpenCLLIB::Vstoren, "vstoren"); |
| 200 |
add(OpenCLLIB::Vload_half, "vload_half"); |
| 201 |
add(OpenCLLIB::Vload_halfn, "vload_halfn"); |
| 202 |
add(OpenCLLIB::Vstore_half, "vstore_half"); |
| 203 |
add(OpenCLLIB::Vstore_half_r, "vstore_half_r"); |
| 204 |
add(OpenCLLIB::Vstore_halfn, "vstore_halfn"); |
| 205 |
add(OpenCLLIB::Vstore_halfn_r, "vstore_halfn_r"); |
| 206 |
add(OpenCLLIB::Vloada_halfn, "vloada_halfn"); |
| 207 |
add(OpenCLLIB::Vstorea_halfn, "vstorea_halfn"); |
| 208 |
add(OpenCLLIB::Vstorea_halfn_r, "vstorea_halfn_r"); |
| 209 |
add(OpenCLLIB::Shuffle, "shuffle"); |
| 210 |
add(OpenCLLIB::Shuffle2, "shuffle2"); |
| 211 |
add(OpenCLLIB::Printf, "printf"); |
| 212 |
add(OpenCLLIB::Prefetch, "prefetch"); |
| 213 |
add(OpenCLLIB::Bitselect, "bitselect"); |
| 214 |
add(OpenCLLIB::Select, "select"); |
| 215 |
add(OpenCLLIB::UAbs, "u_abs"); |
| 216 |
add(OpenCLLIB::UAbs_diff, "u_abs_diff"); |
| 217 |
add(OpenCLLIB::UMul_hi, "u_mul_hi"); |
| 218 |
add(OpenCLLIB::UMad_hi, "u_mad_hi"); |
| 219 |
} |
| 220 |
SPIRV_DEF_NAMEMAP(OCLExtOpKind, OCLExtOpMap) |
| 221 |
|
| 222 |
typedef SPIRVDebug::Instruction SPIRVDebugExtOpKind; |
| 223 |
template <> inline void SPIRVMap<SPIRVDebugExtOpKind, std::string>::init() { |
| 224 |
add(SPIRVDebug::DebugInfoNone, "DebugInfoNone"); |
| 225 |
add(SPIRVDebug::CompilationUnit, "DebugCompilationUnit"); |
| 226 |
add(SPIRVDebug::Source, "DebugSource"); |
| 227 |
add(SPIRVDebug::TypeBasic, "DebugTypeBasic"); |
| 228 |
add(SPIRVDebug::TypePointer, "DebugTypePointer"); |
| 229 |
add(SPIRVDebug::TypeArray, "DebugTypeArray"); |
| 230 |
add(SPIRVDebug::TypeArrayDynamic, "DebugTypeArrayDynamic"); |
| 231 |
add(SPIRVDebug::TypeVector, "DebugTypeVector"); |
| 232 |
add(SPIRVDebug::TypeQualifier, "DebugTypeQualifier"); |
| 233 |
add(SPIRVDebug::TypeFunction, "DebugTypeFunction"); |
| 234 |
add(SPIRVDebug::TypeComposite, "DebugTypeComposite"); |
| 235 |
add(SPIRVDebug::TypeMember, "DebugTypeMember"); |
| 236 |
add(SPIRVDebug::TypeEnum, "DebugTypeEnum"); |
| 237 |
add(SPIRVDebug::Typedef, "DebugTypedef"); |
| 238 |
add(SPIRVDebug::TypeTemplateParameter, "DebugTypeTemplateParameter"); |
| 239 |
add(SPIRVDebug::TypeTemplateParameterPack, "DebugTypeTemplateParameterPack"); |
| 240 |
add(SPIRVDebug::TypeTemplateTemplateParameter, |
| 241 |
"DebugTypeTemplateTemplateParameter"); |
| 242 |
add(SPIRVDebug::TypeTemplate, "DebugTypeTemplate"); |
| 243 |
add(SPIRVDebug::TypePtrToMember, "DebugTypePtrToMember,"); |
| 244 |
add(SPIRVDebug::TypeSubrange, "DebugTypeSubrange"); |
| 245 |
add(SPIRVDebug::TypeString, "DebugTypeString"); |
| 246 |
add(SPIRVDebug::TypeInheritance, "DebugTypeInheritance"); |
| 247 |
add(SPIRVDebug::Function, "DebugFunction"); |
| 248 |
add(SPIRVDebug::FunctionDeclaration, "DebugFunctionDeclaration"); |
| 249 |
add(SPIRVDebug::LexicalBlock, "DebugLexicalBlock"); |
| 250 |
add(SPIRVDebug::LexicalBlockDiscriminator, "DebugLexicalBlockDiscriminator"); |
| 251 |
add(SPIRVDebug::LocalVariable, "DebugLocalVariable"); |
| 252 |
add(SPIRVDebug::InlinedVariable, "DebugInlinedVariable"); |
| 253 |
add(SPIRVDebug::GlobalVariable, "DebugGlobalVariable"); |
| 254 |
add(SPIRVDebug::Declare, "DebugDeclare"); |
| 255 |
add(SPIRVDebug::Value, "DebugValue"); |
| 256 |
add(SPIRVDebug::Scope, "DebugScope"); |
| 257 |
add(SPIRVDebug::NoScope, "DebugNoScope"); |
| 258 |
add(SPIRVDebug::InlinedAt, "DebugInlinedAt"); |
| 259 |
add(SPIRVDebug::ImportedEntity, "DebugImportedEntity"); |
| 260 |
add(SPIRVDebug::ModuleINTEL, "DebugModuleINTEL"); |
| 261 |
add(SPIRVDebug::Module, "DebugModule"); |
| 262 |
add(SPIRVDebug::Expression, "DebugExpression"); |
| 263 |
add(SPIRVDebug::Operation, "DebugOperation"); |
| 264 |
add(SPIRVDebug::FunctionDefinition, "DebugFunctionDefinition"); |
| 265 |
add(SPIRVDebug::SourceContinued, "DebugSourceContinued"); |
| 266 |
add(SPIRVDebug::DebugLine, "DebugLine"); |
| 267 |
add(SPIRVDebug::DebugNoLine, "DebugNoLine"); |
| 268 |
add(SPIRVDebug::EntryPoint, "DebugEntryPoint"); |
| 269 |
add(SPIRVDebug::BuildIdentifier, "DebugBuildIdentifier"); |
| 270 |
add(SPIRVDebug::StoragePath, "DebugStoragePath"); |
| 271 |
} |
| 272 |
SPIRV_DEF_NAMEMAP(SPIRVDebugExtOpKind, SPIRVDebugExtOpMap) |
| 273 |
|
| 274 |
typedef NonSemanticAuxData::Instruction NonSemanticAuxDataOpKind; |
| 275 |
template <> |
| 276 |
inline void SPIRVMap<NonSemanticAuxDataOpKind, std::string>::init() { |
| 277 |
add(NonSemanticAuxData::FunctionMetadata, |
| 278 |
"NonSemanticAuxDataFunctionMetadata"); |
| 279 |
add(NonSemanticAuxData::FunctionAttribute, |
| 280 |
"NonSemanticAuxDataFunctionAttribute"); |
| 281 |
} |
| 282 |
SPIRV_DEF_NAMEMAP(NonSemanticAuxDataOpKind, NonSemanticAuxDataOpMap) |
| 283 |
|
| 284 |
} // namespace SPIRV |
| 285 |
|
| 286 |
#endif // SPIRV_LIBSPIRV_SPIRVEXTINST_H |