mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Program refactor
* Decouple binary program handling from Program object * Add binary formats multiplexer * Improve Elf format support Change-Id: Ic22aff40173532e14825d70b82ec53fcc5fa9fdf
This commit is contained in:
@@ -13,6 +13,7 @@ set(NEO_COMPILER_INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/create_main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/intermediate_representations.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linker.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linker.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options/compiler_options_base.h
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -106,8 +106,9 @@ class CompilerInterface {
|
||||
CompilerInterface &operator=(CompilerInterface &&) = delete;
|
||||
virtual ~CompilerInterface();
|
||||
|
||||
static CompilerInterface *createInstance(std::unique_ptr<CompilerCache> cache, bool requireFcl) {
|
||||
auto instance = new CompilerInterface();
|
||||
template <typename CompilerInterfaceT = CompilerInterface>
|
||||
static CompilerInterfaceT *createInstance(std::unique_ptr<CompilerCache> cache, bool requireFcl) {
|
||||
auto instance = new CompilerInterfaceT();
|
||||
if (!instance->initialize(std::move(cache), requireFcl)) {
|
||||
delete instance;
|
||||
instance = nullptr;
|
||||
@@ -137,7 +138,7 @@ class CompilerInterface {
|
||||
MOCKABLE_VIRTUAL TranslationOutput::ErrorCode getSipKernelBinary(NEO::Device &device, SipKernelType type, std::vector<char> &retBinary);
|
||||
|
||||
protected:
|
||||
bool initialize(std::unique_ptr<CompilerCache> cache, bool requireFcl);
|
||||
MOCKABLE_VIRTUAL bool initialize(std::unique_ptr<CompilerCache> cache, bool requireFcl);
|
||||
MOCKABLE_VIRTUAL bool loadFcl();
|
||||
MOCKABLE_VIRTUAL bool loadIgc();
|
||||
|
||||
|
||||
36
core/compiler_interface/intermediate_representations.h
Normal file
36
core/compiler_interface/intermediate_representations.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/utilities/arrayref.h"
|
||||
#include "core/utilities/const_stringref.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
static constexpr ConstStringRef llvmBcMagic = "BC\xc0\xde";
|
||||
static constexpr ConstStringRef spirvMagic = "\x07\x23\x02\x03";
|
||||
static constexpr ConstStringRef spirvMagicInv = "\x03\x02\x23\x07";
|
||||
|
||||
inline bool hasSameMagic(ConstStringRef expectedMagic, ArrayRef<const uint8_t> binary) {
|
||||
auto binaryMagicLen = std::min(expectedMagic.size(), binary.size());
|
||||
ConstStringRef binaryMagic(reinterpret_cast<const char *>(binary.begin()), binaryMagicLen);
|
||||
return expectedMagic == binaryMagic;
|
||||
}
|
||||
|
||||
inline bool isLlvmBitcode(ArrayRef<const uint8_t> binary) {
|
||||
return hasSameMagic(llvmBcMagic, binary);
|
||||
}
|
||||
|
||||
inline bool isSpirVBitcode(ArrayRef<const uint8_t> binary) {
|
||||
return hasSameMagic(spirvMagic, binary) || hasSameMagic(spirvMagicInv, binary);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user