1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/*
* 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 <cstddef>
#include <memory>
#include <string>
#include <utility>
#include <vector>
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<char[]> bytes, size_t size, IGC::CodeType::CodeType_t codeType)
: bytes{std::move(bytes)}, size{size}, codeType{codeType} {}
std::unique_ptr<char[]> bytes{};
size_t size{};
IGC::CodeType::CodeType_t codeType{};
};
public:
static std::unique_ptr<OfflineLinker> create(size_t argsCount, const std::vector<std::string> &args, int &errorCode, OclocArgHelper *argHelper);
MOCKABLE_VIRTUAL ~OfflineLinker();
int execute();
std::string getBuildLog() const;
protected:
explicit OfflineLinker(OclocArgHelper *argHelper, std::unique_ptr<OclocIgcFacade> igcFacade);
int initialize(size_t argsCount, const std::vector<std::string> &args);
int parseCommand(size_t argsCount, const std::vector<std::string> &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<uint8_t> createSingleInputFile() const;
std::pair<int, std::vector<uint8_t>> translateToOutputFormat(const std::vector<uint8_t> &elfInput);
void tryToStoreBuildLog(const char *buildLogRaw, size_t size);
MOCKABLE_VIRTUAL ArrayRef<const HardwareInfo *> getHardwareInfoTable() const;
OclocArgHelper *argHelper{};
OperationMode operationMode{};
std::vector<std::string> inputFilenames{};
std::vector<InputFileContent> inputFilesContent{};
std::string outputFilename{};
IGC::CodeType::CodeType_t outputFormat{};
std::string options{};
std::string internalOptions{};
std::unique_ptr<OclocIgcFacade> igcFacade;
HardwareInfo hwInfo{};
std::string buildLog{};
};
} // namespace NEO
|