/* * Copyright (C) 2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/helpers/hw_info.h" #include "shared/source/utilities/arrayref.h" #include "cif/common/cif_main.h" #include "cif/import/library_api.h" #include "ocl_igc_interface/code_type.h" #include "ocl_igc_interface/igc_ocl_device_ctx.h" #include #include #include #include #include class OclocArgHelper; namespace NEO { class OsLibrary; class OfflineLinker { protected: enum class OperationMode { SKIP_EXECUTION = 0, SHOW_HELP = 1, LINK_FILES = 2, }; struct InputFileContent { InputFileContent(std::unique_ptr bytes, size_t size, IGC::CodeType::CodeType_t codeType) : bytes{std::move(bytes)}, size{size}, codeType{codeType} {} std::unique_ptr bytes{}; size_t size{}; IGC::CodeType::CodeType_t codeType{}; }; public: static std::unique_ptr create(size_t argsCount, const std::vector &args, int &errorCode, OclocArgHelper *argHelper); MOCKABLE_VIRTUAL ~OfflineLinker(); int execute(); std::string getBuildLog() const; protected: explicit OfflineLinker(OclocArgHelper *argHelper); int initialize(size_t argsCount, const std::vector &args); int parseCommand(size_t argsCount, const std::vector &args); IGC::CodeType::CodeType_t parseOutputFormat(const std::string &outputFormatName); int verifyLinkerCommand(); int loadInputFilesContent(); IGC::CodeType::CodeType_t detectCodeType(char *bytes, size_t size) const; int initHardwareInfo(); int prepareIgc(); int link(); int showHelp(); std::vector createSingleInputFile() const; std::pair> translateToOutputFormat(const std::vector &elfInput); void tryToStoreBuildLog(const char *buildLogRaw, size_t size); MOCKABLE_VIRTUAL ArrayRef getHardwareInfoTable() const; MOCKABLE_VIRTUAL std::unique_ptr loadIgcLibrary() const; MOCKABLE_VIRTUAL CIF::CreateCIFMainFunc_t loadCreateIgcMainFunction() const; MOCKABLE_VIRTUAL CIF::RAII::UPtr_t createIgcMain(CIF::CreateCIFMainFunc_t createMainFunction) const; MOCKABLE_VIRTUAL CIF::RAII::UPtr_t createIgcDeviceContext() const; MOCKABLE_VIRTUAL CIF::RAII::UPtr_t getIgcPlatformHandle() const; MOCKABLE_VIRTUAL CIF::RAII::UPtr_t getGTSystemInfoHandle() const; OclocArgHelper *argHelper{}; OperationMode operationMode{}; std::vector inputFilenames{}; std::vector inputFilesContent{}; std::string outputFilename{}; IGC::CodeType::CodeType_t outputFormat{}; std::string options{}; std::string internalOptions{}; std::unique_ptr igcLib{}; CIF::RAII::UPtr_t igcMain{}; CIF::RAII::UPtr_t igcDeviceCtx{}; HardwareInfo hwInfo{}; std::string buildLog{}; }; } // namespace NEO