...
 
Commits (143)
......@@ -26,7 +26,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "AddCopyIntrinsic.hpp"
#include "Compiler/MetaDataApi/IGCMetaDataHelper.h"
#include "Compiler/MetaDataApi/IGCMetaDataDefs.h"
#include "Compiler/MetaDataUtilsWrapper.h"
#include "Compiler/IGCPassSupport.h"
#include "Compiler/CodeGenPublic.h"
......
This diff is collapsed.
......@@ -322,7 +322,7 @@ namespace IGC
private:
/// @brief All possible implicit arguments
static const ImplicitArg IMPLICIT_ARGS[ImplicitArg::NUM_IMPLICIT_ARGS];
std::vector<ImplicitArg> IMPLICIT_ARGS;
/// @brief Maps operand numbers in the implicit argument metadata
/// nodes to implicit argument types.
......
......@@ -26,7 +26,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "ProcessFuncAttributes.h"
#include "Compiler/MetaDataApi/IGCMetaDataHelper.h"
#include "Compiler/MetaDataApi/IGCMetaDataDefs.h"
#include "Compiler/MetaDataUtilsWrapper.h"
#include "Compiler/IGCPassSupport.h"
#include "Compiler/CodeGenPublic.h"
......@@ -162,24 +161,31 @@ static bool containsOpaque(llvm::Type *T)
return false;
}
static bool hasSLMUsage(llvm::Module &M)
// __builtin_spirv related OpGroup call implementations contain both
// workgroup and subgroup code in them that is switched on based on the
// 'Execution' and 'Operation' parameters and these will almost always
// be compile time literals. Let's inline these functions so we have a chance
// at optimizing away the branches that contain workgroup code that will cause
// SLM allocations when we're really doing a subgroup calls.
static DenseSet<Function*> collectMemPoolUsage(const Module &M)
{
for (auto &G : M.getGlobalList())
const char *BUILTIN_MEMPOOL = "__builtin_IB_AllocLocalMemPool";
auto *MemPool = M.getFunction(BUILTIN_MEMPOOL);
DenseSet<Function*> FuncsToInline;
if (!MemPool)
return FuncsToInline;
for (auto *U : MemPool->users())
{
if (!G.use_empty() &&
G.getType()->getAddressSpace() == ADDRESS_SPACE_LOCAL)
if (auto *CI = dyn_cast<CallInst>(U))
{
return true;
FuncsToInline.insert(CI->getFunction());
}
}
const char *BUILTIN_MEMPOOL = "__builtin_IB_AllocLocalMemPool";
if (auto F = M.getFunction(BUILTIN_MEMPOOL))
{
return !F->use_empty();
}
return false;
return FuncsToInline;
}
bool ProcessFuncAttributes::runOnModule(Module& M)
......@@ -187,7 +193,7 @@ bool ProcessFuncAttributes::runOnModule(Module& M)
MetaDataUtilsWrapper &mduw = getAnalysis<MetaDataUtilsWrapper>();
MetaDataUtils *pMdUtils = mduw.getMetaDataUtils();
ModuleMetaData *modMD = mduw.getModuleMetaData();
bool containsSLM = false; // hasSLMUsage(M);
auto MemPoolFuncs = collectMemPoolUsage(M);
std::set<llvm::Function *> fastMathFunct;
GlobalVariable *gv_fastMath = M.getGlobalVariable("__FastRelaxedMath", true);
......@@ -274,7 +280,7 @@ bool ProcessFuncAttributes::runOnModule(Module& M)
// The following subroutine check is added to disable two-phase-inlining
// when we do not enable subroutines.
bool keepAlwaysInline = containsSLM;
bool keepAlwaysInline = (MemPoolFuncs.count(F) != 0);
if (IGC_GET_FLAG_VALUE(FunctionControl) != FLAG_FCALL_FORCE_INLINE)
{
// keep inline if function pointers not enabled and there are uses
......@@ -474,11 +480,10 @@ bool ProcessBuiltinMetaData::runOnModule(Module& M)
void ProcessBuiltinMetaData::updateBuiltinFunctionMetaData(llvm::Function* pFunc)
{
IGCMD::FunctionInfoMetaDataHandle fHandle = IGCMD::FunctionInfoMetaDataHandle(IGCMD::FunctionInfoMetaData::get());
IGC::ModuleMetaData* modMD = getAnalysis<CodeGenContextWrapper>().getCodeGenContext()->getModuleMetaData();
FunctionMetaData *funcMD = &modMD->FuncMD[pFunc]; //okay to insert if not present
fHandle->setType(IGC::IGCMD::FunctionTypeEnum::OtherFunctionType);
funcMD->functionType = IGC::FunctionTypeMD::UserFunction;
fHandle->setType(FunctionTypeMD::UserFunction);
for (auto arg = pFunc->arg_begin(); arg != pFunc->arg_end(); ++arg)
{
std::string typeStr;
......
......@@ -146,6 +146,8 @@ enum E_SH_TYPE
SH_TYPE_OPENCL_DEV_DEBUG = 0xff000008, // Device debug
SH_TYPE_SPIRV = 0xff000009, // SPIRV
SH_TYPE_NON_COHERENT_DEV_BINARY = 0xff00000a, // Non-coherent Device binary
SH_TYPE_SPIRV_SC_IDS = 0xff00000b, // Specialization Constants IDs
SH_TYPE_SPIRV_SC_VALUES = 0xff00000c // Specialization Constants values
};
// E_SH_FLAG - List of section header flags.
......
......@@ -1427,6 +1427,7 @@ void DebugPatchList(
"\tBufferSize = %d\n",
pPatchItem->BufferSize);
}
break;
case iOpenCL::PATCH_TOKEN_GTPIN_INFO:
{
const iOpenCL::SPatchItemHeader* pPatchItem = pHeader;
......@@ -1437,6 +1438,38 @@ void DebugPatchList(
pPatchItem->Size);
}
break;
case iOpenCL::PATCH_TOKEN_FUNCTION_SYMBOL_TABLE:
{
const iOpenCL::SPatchFunctionTableInfo* pPatchItem =
(const iOpenCL::SPatchFunctionTableInfo*)pHeader;
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
"PATCH_TOKEN_FUNCTION_SYMBOL_TABLE (%08X) (size = %d)\n",
pPatchItem->Token,
pPatchItem->Size);
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
"\tNumEntries = %d\n",
pPatchItem->NumEntries);
}
break;
case iOpenCL::PATCH_TOKEN_FUNCTION_RELOCATION_TABLE:
{
const iOpenCL::SPatchFunctionTableInfo* pPatchItem =
(const iOpenCL::SPatchFunctionTableInfo*)pHeader;
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
"PATCH_TOKEN_FUNCTION_RELOCATION_TABLE (%08X) (size = %d)\n",
pPatchItem->Token,
pPatchItem->Size);
ICBE_DPF_STR(output, GFXDBG_HARDWARE,
"\tNumEntries = %d\n",
pPatchItem->NumEntries);
}
break;
default:
{
......
......@@ -2104,6 +2104,98 @@ RETVAL CGen8OpenCLStateProcessor::CreatePatchList(
}
}
// Patch for function symbol table
if (retValue.Success)
{
iOpenCL::SPatchFunctionTableInfo patch;
memset(&patch, 0, sizeof(patch));
patch.Token = PATCH_TOKEN_FUNCTION_SYMBOL_TABLE;
uint32_t size = 0;
uint32_t entries = 0;
void* buffer = nullptr;
const IGC::SKernelProgram* program = &(annotations.m_kernelProgram);
if (annotations.m_executionEnivronment.CompiledSIMDSize == 8)
{
buffer = program->simd8.m_funcSymbolTable;
size = program->simd8.m_funcSymbolTableSize;
entries = program->simd8.m_funcSymbolTableEntries;
}
else if (annotations.m_executionEnivronment.CompiledSIMDSize == 16)
{
buffer = program->simd16.m_funcSymbolTable;
size = program->simd16.m_funcSymbolTableSize;
entries = program->simd16.m_funcSymbolTableEntries;
}
else if (annotations.m_executionEnivronment.CompiledSIMDSize == 32)
{
buffer = program->simd32.m_funcSymbolTable;
size = program->simd32.m_funcSymbolTableSize;
entries = program->simd32.m_funcSymbolTableEntries;
}
if (size > 0)
{
patch.Size = sizeof(patch) + size;
patch.NumEntries = entries;
retValue = AddPatchItem(patch, membuf);
if (!membuf.Write((const char*)buffer, size))
{
retValue.Success = false;
return retValue;
}
free(buffer);
}
}
// Patch for function relocation table
if (retValue.Success)
{
iOpenCL::SPatchFunctionTableInfo patch;
memset(&patch, 0, sizeof(patch));
patch.Token = PATCH_TOKEN_FUNCTION_RELOCATION_TABLE;
uint32_t size = 0;
uint32_t entries = 0;
void* buffer = nullptr;
const IGC::SKernelProgram* program = &(annotations.m_kernelProgram);
if (annotations.m_executionEnivronment.CompiledSIMDSize == 8)
{
buffer = program->simd8.m_funcRelocationTable;
size = program->simd8.m_funcRelocationTableSize;
entries = program->simd8.m_funcRelocationTableEntries;
}
else if (annotations.m_executionEnivronment.CompiledSIMDSize == 16)
{
buffer = program->simd16.m_funcRelocationTable;
size = program->simd16.m_funcRelocationTableSize;
entries = program->simd16.m_funcRelocationTableEntries;
}
else if (annotations.m_executionEnivronment.CompiledSIMDSize == 32)
{
buffer = program->simd32.m_funcRelocationTable;
size = program->simd32.m_funcRelocationTableSize;
entries = program->simd32.m_funcRelocationTableEntries;
}
if (size > 0)
{
patch.Size = sizeof(patch) + size;
patch.NumEntries = entries;
retValue = AddPatchItem(patch, membuf);
if (!membuf.Write((const char*)buffer, size))
{
retValue.Success = false;
return retValue;
}
freeBlock(buffer);
}
}
return retValue;
}
......
......@@ -29,8 +29,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "../../../Compiler/CodeGenPublic.h"
#include "program_debug_data.h"
#include "../../../common/Types.hpp"
#include "../../../common/shaderOverride.hpp"
#include "../../../Compiler/CISACodeGen/OpenCLKernelCodeGen.hpp"
#include <iomanip>
#include <fstream>
namespace iOpenCL
{
......@@ -138,6 +142,75 @@ RETVAL CGen8OpenCLProgram::GetProgramDebugData(Util::BinaryStream& programDebugD
return retValue;
}
void dumpOCLKernelBinary(
const IGC::COpenCLKernel *Kernel,
const KernelData &data)
{
#if LLVM_VERSION_MAJOR >= 7
using namespace IGC;
using namespace IGC::Debug;
auto *Ctx = Kernel->GetContext();
auto &kernelName = Kernel->m_kernelInfo.m_kernelName;
auto name = DumpName(IGC::Debug::GetShaderOutputName())
.Hash(Ctx->hash)
.Type(ShaderType::OPENCL_SHADER)
.PostFix(kernelName)
.Extension("kernbin");
auto *KernBin = data.kernelBinary;
std::error_code EC;
llvm::raw_fd_ostream f(name.str(), EC);
if (!EC)
f.write(KernBin->GetLinearPointer(), (size_t)KernBin->Size());
#endif
}
void overrideOCLKernelBinary(
const IGC::COpenCLKernel *Kernel,
KernelData &data)
{
using namespace IGC;
using namespace IGC::Debug;
auto *Ctx = Kernel->GetContext();
auto &kernelName = Kernel->m_kernelInfo.m_kernelName;
auto name = DumpName(IGC::Debug::GetShaderOutputName())
.Hash(Ctx->hash)
.Type(ShaderType::OPENCL_SHADER)
.PostFix(kernelName)
.Extension("kernbin");
std::string Path = name.overridePath();
std::ifstream f(Path, std::ios::binary);
if (!f.is_open())
return;
appendToShaderOverrideLogFile(Path, "OVERRIDDEN: ");
f.seekg(0, f.end);
int newBinarySize = (int)f.tellg();
f.seekg(0, f.beg);
auto *&KernBin = data.kernelBinary;
delete KernBin;
KernBin = new Util::BinaryStream();
std::unique_ptr<char[]> Buf(new char[newBinarySize]);
f.read(Buf.get(), newBinarySize);
assert(f && "Not fully read!");
KernBin->Write(Buf.get(), newBinarySize);
}
void CGen8OpenCLProgram::CreateKernelBinaries()
{
auto isValidShader = [&](IGC::COpenCLKernel* shader)->bool
......@@ -191,6 +264,12 @@ void CGen8OpenCLProgram::CreateKernelBinaries()
m_pSystemThreadKernelOutput,
pOutput->m_unpaddedProgramSize);
if (IGC_IS_FLAG_ENABLED(ShaderDumpEnable))
dumpOCLKernelBinary(kernel, data);
if (IGC_IS_FLAG_ENABLED(ShaderOverride))
overrideOCLKernelBinary(kernel, data);
assert(data.kernelBinary && data.kernelBinary->Size() > 0);
// Create the debug data binary streams
......
......@@ -406,6 +406,8 @@ _SPIRV_OP(OpGenericCastToPtrExplicit)
// Ballot extension
_SPIRV_OP(OpSubgroupBallotKHR)
_SPIRV_OP(OpSubgroupFirstInvocationKHR)
// Shader clock extension
_SPIRV_OP(OpReadClockKHR)
#undef _SPIRV_OP
#define _SPIRV_OP(x, y) add(Op##y, #x);
......
......@@ -76,6 +76,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "libSPIRV/SPIRVFunction.h"
#include "libSPIRV/SPIRVInstruction.h"
#include "libSPIRV/SPIRVModule.h"
#include "SPIRVInternal.h"
#include "common/MDFrameWork.h"
#include "../../AdaptorCommon/TypesLegalizationPass.hpp"
......@@ -2102,14 +2103,21 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
// Translation of non-instruction values
switch(OC) {
case OpSpecConstant:
case OpConstant: {
SPIRVConstant *BConst = static_cast<SPIRVConstant *>(BV);
SPIRVType *BT = BV->getType();
Type *LT = transType(BT);
uint64_t V = BConst->getZExtIntValue();
if(BV->hasDecorate(DecorationSpecId)) {
spirv_assert(OC == OpSpecConstant && "Only SpecConstants can be specialized!");
SPIRVWord specid = *BV->getDecorate(DecorationSpecId).begin();
V = BM->getSpecConstant(specid);
}
switch(BT->getOpCode()) {
case OpTypeBool:
case OpTypeInt:
return mapValue(BV, ConstantInt::get(LT, BConst->getZExtIntValue(),
return mapValue(BV, ConstantInt::get(LT, V,
static_cast<SPIRVTypeInt*>(BT)->isSigned()));
case OpTypeFloat: {
const llvm::fltSemantics *FS = nullptr;
......@@ -2127,7 +2135,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
spirv_assert (0 && "invalid float type");
}
return mapValue(BV, ConstantFP::get(*Context, APFloat(*FS,
APInt(BT->getFloatBitWidth(), BConst->getZExtIntValue()))));
APInt(BT->getFloatBitWidth(), V))));
}
default:
llvm_unreachable("Not implemented");
......@@ -2136,9 +2144,29 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
}
break;
case OpSpecConstantTrue:
if (BV->hasDecorate(DecorationSpecId)) {
SPIRVWord specid = *BV->getDecorate(DecorationSpecId).begin();
if(BM->getSpecConstant(specid))
return mapValue(BV, ConstantInt::getTrue(*Context));
else
return mapValue(BV, ConstantInt::getFalse(*Context));
}
// intentional fall-through: if decoration was not specified, treat this
// as a OpConstantTrue (default spec constant value)
case OpConstantTrue:
return mapValue(BV, ConstantInt::getTrue(*Context));
case OpSpecConstantFalse:
if (BV->hasDecorate(DecorationSpecId)) {
SPIRVWord specid = *BV->getDecorate(DecorationSpecId).begin();
if (BM->getSpecConstant(specid))
return mapValue(BV, ConstantInt::getTrue(*Context));
else
return mapValue(BV, ConstantInt::getFalse(*Context));
}
// intentional fall-through: if decoration was not specified, treat this
// as a OpConstantFalse (default spec constant value)
case OpConstantFalse:
return mapValue(BV, ConstantInt::getFalse(*Context));
......@@ -2149,6 +2177,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
return mapValue(BV, ConstantAggregateZero::get(LT));
}
case OpSpecConstantComposite:
case OpConstantComposite: {
auto BCC = static_cast<SPIRVConstantComposite*>(BV);
std::vector<Constant *> CV;
......@@ -2349,6 +2378,13 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
break;
}
// During translation of OpSpecConstantOp we create an instruction
// corresponding to the Opcode operand and then translate this instruction.
// For such instruction BB and F should be nullptr, because it is a constant
// expression declared out of scope of any basic block or function.
// All other values require valid BB pointer.
assert(((isSpecConstantOpAllowedOp(OC) && !F && !BB) || BB) && "Invalid BB");
// Creation of place holder
if (CreatePlaceHolder) {
auto GV = new GlobalVariable(*M,
......@@ -3846,10 +3882,11 @@ static void dumpSPIRVBC(const char* fname, const char* data, unsigned int size)
bool ReadSPIRV(LLVMContext &C, std::istream &IS, Module *&M,
StringRef options,
std::string &ErrMsg) {
std::string &ErrMsg,
std::unordered_map<uint32_t, uint64_t> *specConstants) {
std::unique_ptr<SPIRVModule> BM( SPIRVModule::createSPIRVModule() );
BM->setCompileFlag( options );
BM->setSpecConstantMap(specConstants);
IS >> *BM;
BM->resolveUnknownStructFields();
M = new Module( "",C );
......
......@@ -40,12 +40,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "llvm/IR/Module.h"
#include <unordered_map>
namespace spv{
// Loads SPIRV from istream and translate to LLVM module.
// Returns true if succeeds.
bool ReadSPIRV(llvm::LLVMContext &C, std::istream &IS, llvm::Module *&M,
llvm::StringRef options,
std::string &ErrMsg);
std::string &ErrMsg,
std::unordered_map<uint32_t, uint64_t> *specConstants);
}
#endif
......@@ -663,10 +663,6 @@ _SPIRV_OP(SourceContinued)
_SPIRV_OP(TypeMatrix)
_SPIRV_OP(TypeRuntimeArray)
_SPIRV_OP(TypeForwardPointer)
_SPIRV_OP(SpecConstantTrue)
_SPIRV_OP(SpecConstantFalse)
_SPIRV_OP(SpecConstant)
_SPIRV_OP(SpecConstantComposite)
_SPIRV_OP(ImageTexelPointer)
_SPIRV_OP(ImageSampleDrefImplicitLod)
_SPIRV_OP(ImageSampleDrefExplicitLod)
......
......@@ -1726,6 +1726,7 @@ _SPIRV_OP(LifetimeStart, false, 3)
_SPIRV_OP(LifetimeStop, false, 3)
_SPIRV_OP(SelectionMerge, false, 3)
_SPIRV_OP(VectorTimesScalar, true, 5)
_SPIRV_OP(ReadClockKHR, true, 4)
#undef _SPIRV_OP
class SPIRVBallotInstBase : public SPIRVInstTemplateBase
......
......@@ -87,7 +87,8 @@ public:
InstSchema(SPIRVISCH_Default),
SrcLang(SpvSourceLanguageOpenCL_C),
SrcLangVer(12),
MemoryModel(SPIRVMemoryModelKind::MemoryModelOpenCL){
MemoryModel(SPIRVMemoryModelKind::MemoryModelOpenCL),
SCMap(nullptr) {
AddrModel = sizeof(size_t) == 32 ? AddressingModelPhysical32 : AddressingModelPhysical64;
};
virtual ~SPIRVModuleImpl();
......@@ -116,6 +117,17 @@ public:
const std::string &getCompileFlag() const { return CompileFlag;}
std::string &getCompileFlag() { return CompileFlag;}
void setCompileFlag(const std::string &options) { CompileFlag = options; }
bool isSpecConstant(SPIRVWord spec_id) const {
if(SCMap)
return SCMap->find(spec_id) != SCMap->end();
else
return false;
}
uint64_t getSpecConstant(SPIRVWord spec_id) {
spirv_assert(isSpecConstant(spec_id) && "Specialization constant was not specialized!");
return SCMap->at(spec_id);
}
void setSpecConstantMap(SPIRVSpecConstantMap *specConstants) { SCMap = specConstants; }
std::set<std::string> &getExtension() { return SPIRVExt;}
SPIRVFunction *getFunction(unsigned I) const { return FuncVec[I];}
SPIRVVariable *getVariable(unsigned I) const { return VariableVec[I];}
......@@ -245,6 +257,25 @@ public:
return globalVars;
}
virtual std::vector<SPIRVValue*> parseSpecConstants()
{
std::vector<SPIRVValue*> specConstants;
for (auto& item : IdEntryMap)
{
Op opcode = item.second->getOpCode();
if (opcode == spv::Op::OpSpecConstant ||
opcode == spv::Op::OpSpecConstantTrue ||
opcode == spv::Op::OpSpecConstantFalse)
{
auto specConstant = static_cast<SPIRVValue*>(item.second);
specConstants.push_back(specConstant);
}
}
return specConstants;
}
// I/O functions
friend std::istream & operator>>(std::istream &I, SPIRVModule& M);
......@@ -296,6 +327,7 @@ private:
SPIRVExecModelIdVecMap EntryPointVec;
SPIRVStringMap StrMap;
SPIRVCapSet CapSet;
SPIRVSpecConstantMap *SCMap;
std::map<unsigned, SPIRVTypeInt*> IntTypeMap;
std::map<unsigned, SPIRVConstant*> LiteralMap;
......
......@@ -78,7 +78,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace spv{
class SPIRVBasicBlock;
class SPIRVConstant;
class SPIRVEntry;
class SPIRVFunction;
class SPIRVInstruction;
......@@ -110,6 +109,11 @@ class SPIRVInstTemplateBase;
typedef SPIRVBasicBlock SPIRVLabel;
struct SPIRVTypeImageDescriptor;
template <Op OP> class SPIRVConstantBase;
typedef SPIRVConstantBase<OpConstant> SPIRVConstant;
typedef std::unordered_map<uint32_t, uint64_t> SPIRVSpecConstantMap;
class SPIRVModule
{
public:
......@@ -141,6 +145,9 @@ public:
virtual SPIRVExtInstSetKind getBuiltinSet(SPIRVId) const = 0;
virtual std::string &getCompileFlag() = 0;
virtual void setCompileFlag(const std::string &options) = 0;
virtual bool isSpecConstant(SPIRVWord) const = 0;
virtual uint64_t getSpecConstant(SPIRVWord) = 0;
virtual void setSpecConstantMap(SPIRVSpecConstantMap *) = 0;
virtual const std::string &getCompileFlag() const = 0;
virtual SPIRVFunction *getEntryPoint(SPIRVExecutionModelKind, unsigned) const = 0;
virtual std::set<std::string> &getExtension() = 0;
......@@ -214,6 +221,7 @@ public:
virtual SPIRVExtInst* getCompilationUnit() const = 0;
virtual std::vector<SPIRVExtInst*> getGlobalVars() = 0;
virtual std::vector<SPIRVValue*> parseSpecConstants() = 0;
// I/O functions
friend std::istream & operator>>(std::istream &I, SPIRVModule& M);
......
......@@ -329,6 +329,8 @@ _SPIRV_OP(ModuleProcessed, 330)
//Ballot extension
_SPIRV_OP(SubgroupBallotKHR, 4421)
_SPIRV_OP(SubgroupFirstInvocationKHR, 4422)
// Shader clock extension
_SPIRV_OP(ReadClockKHR, 5055)
_SPIRV_OP(Forward, 1024) // Internal only
_SPIRV_OP(SubgroupShuffleINTEL, 5571)
_SPIRV_OP(SubgroupShuffleDownINTEL, 5572)
......
......@@ -274,7 +274,6 @@ private:
SPIRVWord CompCount; // Component Count
};
class SPIRVConstant;
class SPIRVTypeArray:public SPIRVType {
public:
// Complete constructor
......
......@@ -162,32 +162,33 @@ protected:
SPIRVType *Type; // Value Type
};
class SPIRVConstant: public SPIRVValue {
template<Op OC>
class SPIRVConstantBase: public SPIRVValue {
public:
// Complete constructor for integer constant
SPIRVConstant(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId,
SPIRVConstantBase(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId,
uint64_t TheValue)
:SPIRVValue(M, 0, OpConstant, TheType, TheId){
:SPIRVValue(M, 0, OC, TheType, TheId){
Union.UInt64Val = TheValue;
recalculateWordCount();
validate();
}
// Complete constructor for float constant
SPIRVConstant(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId, float TheValue)
:SPIRVValue(M, 0, OpConstant, TheType, TheId){
SPIRVConstantBase(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId, float TheValue)
:SPIRVValue(M, 0, OC, TheType, TheId){
Union.FloatVal = TheValue;
recalculateWordCount();
validate();
}
// Complete constructor for double constant
SPIRVConstant(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId, double TheValue)
:SPIRVValue(M, 0, OpConstant, TheType, TheId){
SPIRVConstantBase(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId, double TheValue)
:SPIRVValue(M, 0, OC, TheType, TheId){
Union.DoubleVal = TheValue;
recalculateWordCount();
validate();
}
// Incomplete constructor
SPIRVConstant():SPIRVValue(OpConstant), NumWords(0){}
SPIRVConstantBase():SPIRVValue(OC), NumWords(0){}
uint64_t getZExtIntValue() const { return Union.UInt64Val;}
float getFloatValue() const { return Union.FloatVal;}
double getDoubleValue() const { return Union.DoubleVal;}
......@@ -225,6 +226,9 @@ protected:
} Union;
};
typedef SPIRVConstantBase<OpConstant> SPIRVConstant;
typedef SPIRVConstantBase<OpSpecConstant> SPIRVSpecConstant;
template<Op OC>
class SPIRVConstantEmpty: public SPIRVValue {
public:
......@@ -260,6 +264,9 @@ protected:
typedef SPIRVConstantBool<OpConstantTrue> SPIRVConstantTrue;
typedef SPIRVConstantBool<OpConstantFalse> SPIRVConstantFalse;
typedef SPIRVConstantBool<OpSpecConstantTrue> SPIRVSpecConstantTrue;
typedef SPIRVConstantBool<OpSpecConstantFalse> SPIRVSpecConstantFalse;
class SPIRVConstantNull : public SPIRVConstantEmpty<OpConstantNull>
{
public:
......@@ -293,18 +300,18 @@ protected:
}
};
class SPIRVConstantComposite: public SPIRVValue {
template<Op OC>
class SPIRVConstantCompositeBase: public SPIRVValue {
public:
// Complete constructor for composite constant
SPIRVConstantComposite(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId,
SPIRVConstantCompositeBase(SPIRVModule *M, SPIRVType *TheType, SPIRVId TheId,
const std::vector<SPIRVValue *> TheElements)
:SPIRVValue(M, TheElements.size()+3, OpConstantComposite, TheType,
TheId){
:SPIRVValue(M, TheElements.size()+3, OC, TheType, TheId){
Elements = getIds(TheElements);
validate();
}
// Incomplete constructor
SPIRVConstantComposite():SPIRVValue(OpConstantComposite){}
SPIRVConstantCompositeBase():SPIRVValue(OC){}
std::vector<SPIRVValue*> getElements()const {
return getValues(Elements);
}
......@@ -322,6 +329,9 @@ protected:
std::vector<SPIRVId> Elements;
};
typedef SPIRVConstantCompositeBase<OpConstantComposite> SPIRVConstantComposite;
typedef SPIRVConstantCompositeBase<OpSpecConstantComposite> SPIRVSpecConstantComposite;
class SPIRVConstantSampler: public SPIRVValue {
public:
const static Op OC = OpConstantSampler;
......
......@@ -186,6 +186,9 @@ struct STB_TranslateInputArgs
uint32_t TracingOptionsCount; // number of instrumentation options
void* GTPinInput; // input structure for GTPin requests
bool CompileTimeStatisticsEnable;
const uint32_t* pSpecConstantsIds; // user-defined spec constants ids
const uint64_t* pSpecConstantsValues; // spec constants values to be translated
uint32_t SpecConstantsSize; // number of specialization constants
STB_TranslateInputArgs()
{
......@@ -199,6 +202,9 @@ struct STB_TranslateInputArgs
TracingOptionsCount = 0;
GTPinInput = NULL;
CompileTimeStatisticsEnable = false;
pSpecConstantsIds = NULL;
pSpecConstantsValues = NULL;
SpecConstantsSize = 0;
}
};
......
......@@ -105,7 +105,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "Compiler/SPIRMetaDataTranslation.h"
#include "Compiler/Optimizer/OpenCLPasses/ErrorCheckPass.h"
#include "AdaptorCommon/AddCopyIntrinsic.hpp"
#include "Compiler/MetaDataApi/IGCMetaDataDefs.h"
#include "Compiler/MetaDataApi/IGCMetaDataHelper.h"
#include "Compiler/CodeGenContextWrapper.hpp"
#include "Compiler/FixResourcePtr.hpp"
......
......@@ -31,7 +31,7 @@ ENDIF()
SET(ThirdPartyDir "third_party")
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
IF(NOT MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
......
This diff is collapsed.
......@@ -5,6 +5,6 @@ libdir=${exec_prefix}/lib
Name: igc-opencl
Description: Intel(R) Graphics Compiler for OpenCL(TM)
Version: @MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@
Version: @IGC_API_MAJOR_VERSION@.@IGC_API_MINOR_VERSION@.@IGC_API_PATCH_VERSION@
Cflags: -I${includedir} -I${includedir}/cif -I${includedir}/ocl_igc_shared/executable_format -I${includedir}/ocl_igc_shared/device_enqueue
Libs:
......@@ -30,8 +30,8 @@
#cmakedefine IGC_LIBRARY_NAME "${IGC_LIBRARY_NAME}32.dll"
#cmakedefine FCL_LIBRARY_NAME "${FCL_LIBRARY_NAME}32.dll"
#else
#cmakedefine IGC_LIBRARY_NAME "lib${IGC_LIBRARY_NAME}.so"
#cmakedefine FCL_LIBRARY_NAME "lib${FCL_LIBRARY_NAME}.so"
#cmakedefine IGC_LIBRARY_NAME "lib${IGC_LIBRARY_NAME}.so.${IGC_API_MAJOR_VERSION}"
#cmakedefine FCL_LIBRARY_NAME "lib${FCL_LIBRARY_NAME}.so.${IGC_API_MAJOR_VERSION}"
#endif
#endif /* IGC_OPENCL_H */
#ifndef _IGCMC_H_
#define _IGCMC_H_
#include <stdint.h>
#ifndef DLL_EXPORT
#ifdef _WIN32
#define __EXPORT__ __declspec(dllexport)
#else
#define __EXPORT__ __attribute__((visibility("default")))
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum _cmc_error_t {
CMC_SUCCESS = 0,
CMC_ERROR = 1,
CMC_ERROR_READING_SPIRV = 2,
CMC_ERROR_BROKEN_INPUT_IR = 3,
CMC_ERROR_IN_LOADING_TARGET = 4,
CMC_ERROR_IN_COMPILING_IR = 5
} cmc_error_t;
typedef struct _cmc_kernel_info {
/// The kernel name.
const char *name;
/// The number of kernel arguments with descriptors.
unsigned num_arg_desc;
/// The kernel argument descriptors.
const char **arg_desc;
} cmc_kernel_info;
typedef struct _cmc_jit_info {
/// The vISA binary size in bytes.
size_t binary_size;
/// The vISA binary data.
void *binary;
/// The vISA major version.
unsigned visa_major_version;
/// The vISA minor version.
unsigned visa_minor_version;
/// The number of kernels in this binary.
unsigned num_kernels;
/// The kernel infomation for each kernel.
cmc_kernel_info *kernel_info;
/// The context for this compilation. This opaque data holds all memory
/// allocations that will be freed in the end.
void *context;
} cmc_jit_info;
__EXPORT__ cmc_error_t cmc_load_and_compile(const char *input,
size_t input_size,
const char *const options,
cmc_jit_info **output);
__EXPORT__ const char *cmc_get_error_string(cmc_error_t err);
__EXPORT__ cmc_error_t cmc_free_jit_info(cmc_jit_info *output);
#ifdef __cplusplus
}
#endif
#endif // _IGCMC_H_
......@@ -93,9 +93,44 @@ protected:
void *gtPinInput);
};
CIF_DEFINE_INTERFACE_VER_WITH_COMPATIBILITY(IgcOclTranslationCtx, 3, 2) {
using IgcOclTranslationCtx<2>::TranslateImpl;
using IgcOclTranslationCtx<2>::Translate;
CIF_INHERIT_CONSTRUCTOR();
template <typename OclTranslationOutputInterface = OclTranslationOutputTagOCL>
CIF::RAII::UPtr_t<OclTranslationOutputInterface> Translate(CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *specConstantsIds,
CIF::Builtins::BufferSimple *specConstantsValues,
CIF::Builtins::BufferSimple *options,
CIF::Builtins::BufferSimple *internalOptions,
CIF::Builtins::BufferSimple *tracingOptions,
uint32_t tracingOptionsCount,
void *gtPinInput) {
auto p = TranslateImpl(OclTranslationOutputInterface::GetVersion(), src, options, internalOptions, tracingOptions, tracingOptionsCount, gtPinInput, specConstantsIds, specConstantsValues);
return CIF::RAII::Pack<OclTranslationOutputInterface>(p);
}
bool GetSpecConstantsInfoImpl(CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *outSpecConstantsIds,
CIF::Builtins::BufferSimple *outSpecConstantsSizes);
protected:
virtual OclTranslationOutputBase *TranslateImpl(CIF::Version_t outVersion,
CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *specConstantsIds,
CIF::Builtins::BufferSimple *specConstantsValues,
CIF::Builtins::BufferSimple *options,
CIF::Builtins::BufferSimple *internalOptions,
CIF::Builtins::BufferSimple *tracingOptions,
uint32_t tracingOptionsCount,
void *gtPinInput);
};
CIF_GENERATE_VERSIONS_LIST_AND_DECLARE_INTERFACE_DEPENDENCIES(IgcOclTranslationCtx, IGC::OclTranslationOutput, CIF::Builtins::Buffer);
CIF_MARK_LATEST_VERSION(IgcOclTranslationCtxLatest, IgcOclTranslationCtx);
using IgcOclTranslationCtxTagOCL = IgcOclTranslationCtxLatest; // Note : can tag with different version for
using IgcOclTranslationCtxTagOCL = IgcOclTranslationCtx<2>; // Note : can tag with different version for
// transition periods
}
......
......@@ -38,7 +38,7 @@ OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 1)::Tran
CIF::Builtins::BufferSimple *internalOptions,
CIF::Builtins::BufferSimple *tracingOptions,
uint32_t tracingOptionsCount) {
return CIF_GET_PIMPL()->Translate(outVersion, src, options, internalOptions, tracingOptions, tracingOptionsCount, nullptr);
return CIF_GET_PIMPL()->Translate(outVersion, src, nullptr, nullptr, options, internalOptions, tracingOptions, tracingOptionsCount, nullptr);
}
OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 2)::TranslateImpl(
......@@ -49,7 +49,27 @@ OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 2)::Tran
CIF::Builtins::BufferSimple *tracingOptions,
uint32_t tracingOptionsCount,
void *gtPinInput) {
return CIF_GET_PIMPL()->Translate(outVersion, src, options, internalOptions, tracingOptions, tracingOptionsCount, gtPinInput);
return CIF_GET_PIMPL()->Translate(outVersion, src, nullptr, nullptr, options, internalOptions, tracingOptions, tracingOptionsCount, gtPinInput);
}
bool CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 3)::GetSpecConstantsInfoImpl(
CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *outSpecConstantsIds,
CIF::Builtins::BufferSimple *outSpecConstantsSizes) {
return CIF_GET_PIMPL()->GetSpecConstantsInfo(src, outSpecConstantsIds, outSpecConstantsSizes);
}
OclTranslationOutputBase *CIF_GET_INTERFACE_CLASS(IgcOclTranslationCtx, 3)::TranslateImpl(
CIF::Version_t outVersion,
CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *specConstantsIds,
CIF::Builtins::BufferSimple *specConstantsValues,
CIF::Builtins::BufferSimple *options,
CIF::Builtins::BufferSimple *internalOptions,
CIF::Builtins::BufferSimple *tracingOptions,
uint32_t tracingOptionsCount,
void *gtPinInput) {
return CIF_GET_PIMPL()->Translate(outVersion, src, specConstantsIds, specConstantsValues, options, internalOptions, tracingOptions, tracingOptionsCount, gtPinInput);
}
}
......
......@@ -65,6 +65,10 @@ bool TranslateBuild(
const IGC::CPlatform &platform,
float profilingTimerResolution);
bool ReadSpecConstantsFromSPIRV(
std::istream &IS,
std::vector<std::pair<uint32_t, uint32_t>> &OutSCInfo);
}
bool enableSrcLine(void*);
......@@ -109,14 +113,49 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
return false;
}
bool GetSpecConstantsInfo(CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *outSpecConstantsIds,
CIF::Builtins::BufferSimple *outSpecConstantsSizes)
{
bool success = false;
const char* pInput = src->GetMemory<char>();
uint32_t inputSize = static_cast<uint32_t>(src->GetSizeRaw());
if(this->inType == CodeType::spirV){
llvm::StringRef strInput = llvm::StringRef(pInput, inputSize);
std::istringstream IS(strInput);
// vector of pairs [spec_id, spec_size]
std::vector<std::pair<uint32_t, uint32_t>> SCInfo;
success = TC::ReadSpecConstantsFromSPIRV(IS, SCInfo);
outSpecConstantsIds->Resize(sizeof(uint32_t) * SCInfo.size());
outSpecConstantsSizes->Resize(sizeof(uint32_t) * SCInfo.size());
uint32_t* specConstantsIds = outSpecConstantsIds->GetMemoryWriteable<uint32_t>();
uint32_t* specConstantsSizes = outSpecConstantsSizes->GetMemoryWriteable<uint32_t>();
for(uint32_t i = 0; i < SCInfo.size(); ++i){
specConstantsIds[i] = SCInfo.at(i).first;
specConstantsSizes[i] = SCInfo.at(i).second;
}
}
else{
success = false;
}
return success;
}
OclTranslationOutputBase *Translate(CIF::Version_t outVersion,
CIF::Builtins::BufferSimple *src,
CIF::Builtins::BufferSimple *specConstantsIds,
CIF::Builtins::BufferSimple *specConstantsValues,
CIF::Builtins::BufferSimple *options,
CIF::Builtins::BufferSimple *internalOptions,
CIF::Builtins::BufferSimple *tracingOptions,
uint32_t tracingOptionsCount,
void *gtPinInput
) const{
void *gtPinInput) const{
// Create interface for return data
auto outputInterface = CIF::RAII::UPtr(CIF::InterfaceCreator<OclTranslationOutput>::CreateInterfaceVer(outVersion, this->outType));
if(outputInterface == nullptr){
......@@ -149,6 +188,11 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase
inputArgs.pTracingOptions = tracingOptions->GetMemoryRawWriteable();
}
inputArgs.TracingOptionsCount = tracingOptionsCount;
if(specConstantsIds != nullptr && specConstantsValues != nullptr){
inputArgs.pSpecConstantsIds = specConstantsIds->GetMemory<uint32_t>();
inputArgs.SpecConstantsSize = static_cast<uint32_t>(specConstantsIds->GetSizeRaw() / sizeof(uint32_t));
inputArgs.pSpecConstantsValues = specConstantsValues->GetMemory<uint64_t>();
}
inputArgs.GTPinInput = gtPinInput;
IGC::CPlatform igcPlatform = this->globalState.GetIgcCPlatform();
......
......@@ -34,7 +34,7 @@ Abstract: Contains common patch structure definitions
namespace iOpenCL
{
const uint32_t CURRENT_ICBE_VERSION = 1057;
const uint32_t CURRENT_ICBE_VERSION = 1058;
const uint32_t MAGIC_CL = 0x494E5443; // 'I', 'N', 'T', 'C'
const uint32_t INVALID_INDEX = 0xFFFFFFFF;
......@@ -147,13 +147,15 @@ enum PATCH_TOKEN
PATCH_TOKEN_CONSTRUCTOR_DESTRUCTOR_KERNEL_PROGRAM_BINARY_INFO, // 49 - (Unused)
PATCH_TOKEN_INLINE_VME_SAMPLER_INFO, // 50 - (Unused)
PATCH_TOKEN_GTPIN_FREE_GRF_INFO, // 51 @SPatchGtpinFreeGRFInfo@
PATCH_TOKEN_GTPIN_INFO,
PATCH_TOKEN_GTPIN_INFO, // 52 @SPatchItemHeader@
PATCH_TOKEN_FUNCTION_SYMBOL_TABLE, // 53 @SPatchFunctionTableInfo@
PATCH_TOKEN_FUNCTION_RELOCATION_TABLE, // 54 @SPatchFunctionTableInfo@
NUM_PATCH_TOKENS
};
// Update CURRENT_ICBE_VERSION when modifying the patch list
static_assert( NUM_PATCH_TOKENS == 53, "NUM_PATCH_TOKENS has invalid value");
static_assert( NUM_PATCH_TOKENS == 55, "NUM_PATCH_TOKENS has invalid value");
/*****************************************************************************\
ENUM: IMAGE_MEMORY_OBJECT_TYPE
......
......@@ -540,6 +540,18 @@ struct SPatchGtpinFreeGRFInfo :
// Update CURRENT_ICBE_VERSION when modifying the patch list
static_assert(sizeof(SPatchGtpinFreeGRFInfo) == (4 + sizeof(SPatchItemHeader)), "The size of SPatchGtpinFreeGRFInfo is not what is expected");
/*****************************************************************************\
STRUCT: SPatchFunctionTableInfo
\*****************************************************************************/
struct SPatchFunctionTableInfo :
SPatchItemHeader
{
uint32_t NumEntries;
};
// Update CURRENT_ICBE_VERSION when modifying the patch list
static_assert(sizeof(SPatchFunctionTableInfo) == (4 + sizeof(SPatchItemHeader)), "The size of SPatchFunctionTableInfo is not what is expected");
} // namespace
#pragma pack( pop )
......@@ -33,21 +33,12 @@
# In new Clang versions VME types are built-in. Keep this flag until all OS's update Clang version to 8
if(NOT DEFINED VME_TYPES_DEFINED)
set(VME_TYPES_DEFINED FALSE)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(VME_TYPES_DEFINED TRUE)
endif()
endif()
set(CLANG_EXE_VERSION_GE_7 FALSE)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
set(CLANG_EXE_VERSION_GE_7 TRUE)
endif()
set(CCLANG_BUILD_INTREE_LLVM FALSE)
if(EXISTS ${LLVM_SOURCE_DIR}/projects/opencl-clang)
set(CCLANG_BUILD_INTREE_LLVM TRUE)
set(VME_TYPES_DEFINED TRUE)
set(CLANG_SOURCE_DIR ${LLVM_SOURCE_DIR}/tools/clang)
endif()
......@@ -131,22 +122,6 @@ endif()
get_property(_clang7zLocation TARGET CLANG_7Z PROPERTY IMPORTED_LOCATION_RELEASE)
if(NOT DEFINED COMMON_CLANG_LIBRARY_NAME AND
EXISTS ${_clang7zLocation}
)
if(WIN32)
set(COMMON_CLANG_LIBRARY_NAME common_clang${_cpuSuffix})
else()
set(COMMON_CLANG_LIBRARY_NAME opencl_clang)
endif()
endif()
if(WIN32)
set(COMMON_CLANG_LIB_FULL_NAME "${COMMON_CLANG_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
else()
set(COMMON_CLANG_LIB_FULL_NAME "lib${COMMON_CLANG_LIBRARY_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
if(NOT ${CCLANG_BUILD_INTREE_LLVM})
# Add step to preform the extraction
add_custom_command(
......@@ -169,11 +144,12 @@ endif()
set(CL_OPTIONS "")
add_custom_target(GetClang)
add_library(common_clang_dll UNKNOWN IMPORTED GLOBAL)
add_library(common_clang_dll SHARED IMPORTED GLOBAL)
if(EXISTS ${_clang7zLocation} AND NOT ${CCLANG_BUILD_INTREE_LLVM})
# Use precompiled common clang bundle.
message(STATUS "Use precompiled common clang from ${_clang7zLocation}")
set(SYSTEM_COMMON_CLANG OFF)
add_dependencies(GetClang UnzipClang)
......@@ -186,38 +162,15 @@ endif()
set(IGC_CCLANG_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/clang_build)
if(${CCLANG_BUILD_INTREE_LLVM})
message("Common clang build-in-tree")
set(CCLANG_INSTALL_ARTIFACTS_DIR ${IGC_TARGET__TOOLS_CLANG_DIR})
if(NOT CCLANG_OCL_HEADERS_DIR)
if (EXISTS "${IGC_BUILD__GFX_DEV_SRC_DIR}/third_party/opencl_headers")
set(CCLANG_OCL_HEADERS_DIR "${IGC_BUILD__GFX_DEV_SRC_DIR}/third_party/opencl_headers")
else()
get_filename_component(CCLANG_OCL_HEADERS_DIR "${IGC_BUILD__GFX_DEV_SRC_DIR}/../opencl_headers" ABSOLUTE)
endif()
endif(NOT CCLANG_OCL_HEADERS_DIR)
set(clang_filename "clang${CMAKE_EXECUTABLE_SUFFIX}")
add_custom_command(
OUTPUT "${IGC_TARGET__TOOLS_CLANG_DIR}/${clang_filename}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:clang>" "${IGC_TARGET__TOOLS_CLANG_DIR}/${clang_filename}"
DEPENDS clang
)
add_custom_command(
OUTPUT "${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${COMMON_CLANG_LIBRARY_NAME}>" "${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME}"
DEPENDS ${COMMON_CLANG_LIBRARY_NAME}
)
set(cclang_header_filename "opencl-c.h")
add_custom_command(
OUTPUT "${IGC_TARGET__TOOLS_CLANG_DIR}/${cclang_header_filename}"
COMMAND ${CMAKE_COMMAND} -E copy "${CLANG_SOURCE_DIR}/lib/Headers/${cclang_header_filename}" "${IGC_TARGET__TOOLS_CLANG_DIR}/${cclang_header_filename}"
DEPENDS cl_headers
)
set(SYSTEM_COMMON_CLANG OFF)
add_custom_target(copy_cclang_files ALL
DEPENDS ${IGC_TARGET__TOOLS_CLANG_DIR}/${clang_filename} ${IGC_TARGET__TOOLS_CLANG_DIR}/${COMMON_CLANG_LIB_FULL_NAME} ${IGC_TARGET__TOOLS_CLANG_DIR}/${cclang_header_filename}
COMMAND ${CMAKE_COMMAND} -E make_directory "${IGC_TARGET__TOOLS_CLANG_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy "${CLANG_SOURCE_DIR}/lib/Headers/opencl-c.h" "${IGC_TARGET__TOOLS_CLANG_DIR}/"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:clang>" "${IGC_TARGET__TOOLS_CLANG_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_LINKER_FILE:${COMMON_CLANG_LIBRARY_NAME}>" "${IGC_TARGET__TOOLS_CLANG_DIR}/"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_SONAME_FILE:${COMMON_CLANG_LIBRARY_NAME}>" "${IGC_TARGET__TOOLS_CLANG_DIR}/"
DEPENDS clang cl_headers ${COMMON_CLANG_LIBRARY_NAME}
)
add_dependencies(GetClang copy_cclang_files)
......@@ -252,9 +205,9 @@ endif()
endif()
add_dependencies(common_clang_dll GetClang)
if(UNIX)
install(FILES $<TARGET_FILE:common_clang_dll> DESTINATION ${IGC_INSTALL_TIME_ROOT_DIR}/lib COMPONENT igc-opencl)