| 1 |
//=- VectorComputeUtil.h - vector compute utilities declarations -*- C++ -*-=// |
| 2 |
// |
| 3 |
// The LLVM/SPIR-V 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) 2020 Intel Corporation. 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 Intel Corporation, 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 |
// |
| 35 |
// This file declares translation of VectorComputeUtil float control bits, |
| 36 |
// and VC kernel metadata |
| 37 |
// |
| 38 |
//===----------------------------------------------------------------------===// |
| 39 |
|
| 40 |
#ifndef SPIRV_VCUTIL_H |
| 41 |
#define SPIRV_VCUTIL_H |
| 42 |
|
| 43 |
#include "SPIRVInternal.h" |
| 44 |
#include "SPIRVUtil.h" |
| 45 |
#include "spirv/unified1/spirv.hpp" |
| 46 |
|
| 47 |
namespace VectorComputeUtil { |
| 48 |
|
| 49 |
/////////////////////////////////////////////////////////////////////////////// |
| 50 |
// |
| 51 |
// Types |
| 52 |
// |
| 53 |
/////////////////////////////////////////////////////////////////////////////// |
| 54 |
|
| 55 |
enum VCFloatType { |
| 56 |
Double, |
| 57 |
Float, |
| 58 |
Half, |
| 59 |
}; |
| 60 |
|
| 61 |
FPRoundingMode getFPRoundingMode(unsigned FloatControl) noexcept; |
| 62 |
FPDenormMode getFPDenormMode(unsigned FloatControl, |
| 63 |
VCFloatType FloatType) noexcept; |
| 64 |
FPOperationMode getFPOperationMode(unsigned FloatControl) noexcept; |
| 65 |
|
| 66 |
unsigned getVCFloatControl(FPRoundingMode RoundMode) noexcept; |
| 67 |
unsigned getVCFloatControl(FPOperationMode FloatMode) noexcept; |
| 68 |
unsigned getVCFloatControl(FPDenormMode DenormMode, |
| 69 |
VCFloatType FloatType) noexcept; |
| 70 |
|
| 71 |
typedef SPIRV::SPIRVMap<FPRoundingMode, spv::ExecutionMode> |
| 72 |
FPRoundingModeExecModeMap; |
| 73 |
typedef SPIRV::SPIRVMap<FPOperationMode, spv::ExecutionMode> |
| 74 |
FPOperationModeExecModeMap; |
| 75 |
typedef SPIRV::SPIRVMap<FPDenormMode, spv::ExecutionMode> |
| 76 |
FPDenormModeExecModeMap; |
| 77 |
typedef SPIRV::SPIRVMap<VCFloatType, unsigned> VCFloatTypeSizeMap; |
| 78 |
|
| 79 |
/////////////////////////////////////////////////////////////////////////////// |
| 80 |
// |
| 81 |
// Functions |
| 82 |
// |
| 83 |
/////////////////////////////////////////////////////////////////////////////// |
| 84 |
|
| 85 |
SPIRVStorageClassKind |
| 86 |
getVCGlobalVarStorageClass(SPIRAddressSpace AddressSpace) noexcept; |
| 87 |
SPIRAddressSpace |
| 88 |
getVCGlobalVarAddressSpace(SPIRVStorageClassKind StorageClass) noexcept; |
| 89 |
|
| 90 |
std::string getVCBufferSurfaceName(); |
| 91 |
std::string getVCBufferSurfaceName(SPIRVAccessQualifierKind Access); |
| 92 |
|
| 93 |
} // namespace VectorComputeUtil |
| 94 |
|
| 95 |
/////////////////////////////////////////////////////////////////////////////// |
| 96 |
// |
| 97 |
// Constants |
| 98 |
// |
| 99 |
/////////////////////////////////////////////////////////////////////////////// |
| 100 |
|
| 101 |
namespace kVCMetadata { |
| 102 |
const static char VCFunction[] = "VCFunction"; |
| 103 |
const static char VCStackCall[] = "VCStackCall"; |
| 104 |
const static char VCArgumentIOKind[] = "VCArgumentIOKind"; |
| 105 |
const static char VCFloatControl[] = "VCFloatControl"; |
| 106 |
const static char VCSLMSize[] = "VCSLMSize"; |
| 107 |
const static char VCGlobalVariable[] = "VCGlobalVariable"; |
| 108 |
const static char VCVolatile[] = "VCVolatile"; |
| 109 |
const static char VCByteOffset[] = "VCByteOffset"; |
| 110 |
const static char VCSIMTCall[] = "VCSIMTCall"; |
| 111 |
const static char VCCallable[] = "VCCallable"; |
| 112 |
const static char VCSingleElementVector[] = "VCSingleElementVector"; |
| 113 |
const static char VCFCEntry[] = "VCFCEntry"; |
| 114 |
const static char VCMediaBlockIO[] = "VCMediaBlockIO"; |
| 115 |
const static char VCNamedBarrierCount[] = "VCNamedBarrierCount"; |
| 116 |
} // namespace kVCMetadata |
| 117 |
|
| 118 |
namespace kVCType { |
| 119 |
const static char VCBufferSurface[] = "intel.buffer"; |
| 120 |
} |
| 121 |
|
| 122 |
/////////////////////////////////////////////////////////////////////////////// |
| 123 |
// |
| 124 |
// Map definitions |
| 125 |
// |
| 126 |
/////////////////////////////////////////////////////////////////////////////// |
| 127 |
|
| 128 |
namespace SPIRV { |
| 129 |
template <> |
| 130 |
inline void SPIRVMap<spv::FPRoundingMode, spv::ExecutionMode>::init() { |
| 131 |
add(spv::FPRoundingModeRTE, spv::ExecutionModeRoundingModeRTE); |
| 132 |
add(spv::FPRoundingModeRTZ, spv::ExecutionModeRoundingModeRTZ); |
| 133 |
add(spv::FPRoundingModeRTP, spv::ExecutionModeRoundingModeRTPINTEL); |
| 134 |
add(spv::FPRoundingModeRTN, spv::ExecutionModeRoundingModeRTNINTEL); |
| 135 |
} |
| 136 |
template <> |
| 137 |
inline void SPIRVMap<spv::FPDenormMode, spv::ExecutionMode>::init() { |
| 138 |
add(spv::FPDenormModeFlushToZero, spv::ExecutionModeDenormFlushToZero); |
| 139 |
add(spv::FPDenormModePreserve, spv::ExecutionModeDenormPreserve); |
| 140 |
} |
| 141 |
template <> |
| 142 |
inline void SPIRVMap<spv::FPOperationMode, spv::ExecutionMode>::init() { |
| 143 |
add(spv::FPOperationModeIEEE, spv::ExecutionModeFloatingPointModeIEEEINTEL); |
| 144 |
add(spv::FPOperationModeALT, spv::ExecutionModeFloatingPointModeALTINTEL); |
| 145 |
} |
| 146 |
template <> |
| 147 |
inline void SPIRVMap<VectorComputeUtil::VCFloatType, unsigned>::init() { |
| 148 |
add(VectorComputeUtil::Double, 64); |
| 149 |
add(VectorComputeUtil::Float, 32); |
| 150 |
add(VectorComputeUtil::Half, 16); |
| 151 |
} |
| 152 |
} // namespace SPIRV |
| 153 |
|
| 154 |
#endif // SPIRV_VCUTIL_H |