/* * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/helpers/hw_info.h" #include "shared/source/utilities/arrayref.h" #include "ocl_igc_interface/code_type.h" #include #include #include #include #include class OclocArgHelper; namespace NEO { class OsLibrary; class OclocIgcFacade; class OfflineLinker { protected: enum class OperationMode { skipExecution = 0, showHelp = 1, linkFiles = 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, std::unique_ptr igcFacade); 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 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; 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 igcFacade; HardwareInfo hwInfo{}; std::string buildLog{}; }; } // namespace NEO