#include "spirv-tools/linker.hpp"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <memory>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "source/assembly_grammar.h"
#include "source/diagnostic.h"
#include "source/opt/build_module.h"
#include "source/opt/compact_ids_pass.h"
#include "source/opt/decoration_manager.h"
#include "source/opt/ir_builder.h"
#include "source/opt/ir_loader.h"
#include "source/opt/pass_manager.h"
#include "source/opt/remove_duplicates_pass.h"
#include "source/opt/remove_unused_interface_variables_pass.h"
#include "source/opt/type_manager.h"
#include "source/spirv_constant.h"
#include "source/spirv_target_env.h"
#include "source/util/make_unique.h"
#include "source/util/string_utils.h"
#include "spirv-tools/libspirv.hpp"
namespace spvtools {
namespace {
Instruction;
InstructionBuilder;
IRContext;
Module;
PassManager;
RemoveDuplicatesPass;
DecorationManager;
DefUseManager;
Function;
Type;
TypeManager;
struct LinkageSymbolInfo { … };
struct LinkageEntry { … };
LinkageTable;
spv_result_t ShiftIdsInModules(const MessageConsumer& consumer,
std::vector<opt::Module*>* modules,
uint32_t* max_id_bound);
spv_result_t GenerateHeader(const MessageConsumer& consumer,
const std::vector<opt::Module*>& modules,
uint32_t max_id_bound, opt::ModuleHeader* header,
const LinkerOptions& options);
spv_result_t MergeModules(const MessageConsumer& consumer,
const std::vector<Module*>& in_modules,
const AssemblyGrammar& grammar,
IRContext* linked_context);
spv_result_t GetImportExportPairs(const MessageConsumer& consumer,
const opt::IRContext& linked_context,
const DefUseManager& def_use_manager,
const DecorationManager& decoration_manager,
bool allow_partial_linkage,
LinkageTable* linkings_to_do);
spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer,
const LinkageTable& linkings_to_do,
bool allow_ptr_type_mismatch,
opt::IRContext* context);
spv_result_t RemoveLinkageSpecificInstructions(
const MessageConsumer& consumer, const LinkerOptions& options,
const LinkageTable& linkings_to_do, DecorationManager* decoration_manager,
opt::IRContext* linked_context);
spv_result_t VerifyIds(const MessageConsumer& consumer,
opt::IRContext* linked_context);
spv_result_t VerifyLimits(const MessageConsumer& consumer,
const opt::IRContext& linked_context);
spv_result_t ShiftIdsInModules(const MessageConsumer& consumer,
std::vector<opt::Module*>* modules,
uint32_t* max_id_bound) { … }
spv_result_t GenerateHeader(const MessageConsumer& consumer,
const std::vector<opt::Module*>& modules,
uint32_t max_id_bound, opt::ModuleHeader* header,
const LinkerOptions& options) { … }
spv_result_t MergeModules(const MessageConsumer& consumer,
const std::vector<Module*>& input_modules,
const AssemblyGrammar& grammar,
IRContext* linked_context) { … }
spv_result_t GetImportExportPairs(const MessageConsumer& consumer,
const opt::IRContext& linked_context,
const DefUseManager& def_use_manager,
const DecorationManager& decoration_manager,
bool allow_partial_linkage,
LinkageTable* linkings_to_do) { … }
spv_result_t CheckImportExportCompatibility(const MessageConsumer& consumer,
const LinkageTable& linkings_to_do,
bool allow_ptr_type_mismatch,
opt::IRContext* context) { … }
spv_result_t RemoveLinkageSpecificInstructions(
const MessageConsumer& consumer, const LinkerOptions& options,
const LinkageTable& linkings_to_do, DecorationManager* decoration_manager,
opt::IRContext* linked_context) { … }
spv_result_t VerifyIds(const MessageConsumer& consumer,
opt::IRContext* linked_context) { … }
spv_result_t VerifyLimits(const MessageConsumer& consumer,
const opt::IRContext& linked_context) { … }
spv_result_t FixFunctionCallTypes(opt::IRContext& context,
const LinkageTable& linkings) { … }
}
spv_result_t Link(const Context& context,
const std::vector<std::vector<uint32_t>>& binaries,
std::vector<uint32_t>* linked_binary,
const LinkerOptions& options) { … }
spv_result_t Link(const Context& context, const uint32_t* const* binaries,
const size_t* binary_sizes, size_t num_binaries,
std::vector<uint32_t>* linked_binary,
const LinkerOptions& options) { … }
}