Skip to content

Commit

Permalink
address merge conflict (accept all upstream changes)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Gutekanst <[email protected]>
  • Loading branch information
emidoots committed Dec 30, 2024
1 parent 5e6cd9a commit e16e8b6
Show file tree
Hide file tree
Showing 518 changed files with 7,846 additions and 62,086 deletions.
156 changes: 0 additions & 156 deletions include/spirv-tools/instrument.hpp

This file was deleted.

34 changes: 34 additions & 0 deletions include/spirv-tools/libspirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ extern "C" {
#else
#define SPIRV_TOOLS_EXPORT __declspec(dllimport)
#endif
#define SPIRV_TOOLS_LOCAL
#else
#if defined(SPIRV_TOOLS_IMPLEMENTATION)
#define SPIRV_TOOLS_EXPORT __attribute__((visibility("default")))
#define SPIRV_TOOLS_LOCAL __attribute__((visibility("hidden")))
#else
#define SPIRV_TOOLS_EXPORT
#define SPIRV_TOOLS_LOCAL
#endif
#endif
#else
#define SPIRV_TOOLS_EXPORT
#define SPIRV_TOOLS_LOCAL
#endif

// Helpers
Expand Down Expand Up @@ -171,6 +175,7 @@ typedef enum spv_operand_type_t {
SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS, // SPIR-V Sec 3.29
SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO, // SPIR-V Sec 3.30
SPV_OPERAND_TYPE_CAPABILITY, // SPIR-V Sec 3.31
SPV_OPERAND_TYPE_FPENCODING, // SPIR-V Sec 3.51

// NOTE: New concrete enum values should be added at the end.

Expand Down Expand Up @@ -232,6 +237,8 @@ typedef enum spv_operand_type_t {
// assemble regardless of where they occur -- literals, IDs, immediate
// integers, etc.
SPV_OPERAND_TYPE_OPTIONAL_CIV,
// An optional floating point encoding enum
SPV_OPERAND_TYPE_OPTIONAL_FPENCODING,

// A variable operand represents zero or more logical operands.
// In an instruction definition, this may only appear at the end of the
Expand Down Expand Up @@ -301,6 +308,18 @@ typedef enum spv_operand_type_t {
SPV_OPERAND_TYPE_LOAD_CACHE_CONTROL,
// Enum type from SPV_INTEL_cache_controls
SPV_OPERAND_TYPE_STORE_CACHE_CONTROL,
// Enum type from SPV_INTEL_maximum_registers
SPV_OPERAND_TYPE_NAMED_MAXIMUM_NUMBER_OF_REGISTERS,
// Enum type from SPV_NV_raw_access_chains
SPV_OPERAND_TYPE_RAW_ACCESS_CHAIN_OPERANDS,
// Optional enum type from SPV_NV_raw_access_chains
SPV_OPERAND_TYPE_OPTIONAL_RAW_ACCESS_CHAIN_OPERANDS,
// Enum type from SPV_NV_tensor_addressing
SPV_OPERAND_TYPE_TENSOR_CLAMP_MODE,
// Enum type from SPV_NV_cooperative_matrix2
SPV_OPERAND_TYPE_COOPERATIVE_MATRIX_REDUCE,
// Enum type from SPV_NV_cooperative_matrix2
SPV_OPERAND_TYPE_TENSOR_ADDRESSING_OPERANDS,

// This is a sentinel value, and does not represent an operand type.
// It should come last.
Expand All @@ -327,6 +346,7 @@ typedef enum spv_ext_inst_type_t {
SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100,
SPV_EXT_INST_TYPE_NONSEMANTIC_CLSPVREFLECTION,
SPV_EXT_INST_TYPE_NONSEMANTIC_SHADER_DEBUGINFO_100,
SPV_EXT_INST_TYPE_NONSEMANTIC_VKSPREFLECTION,

// Multiple distinct extended instruction set types could return this
// value, if they are prefixed with NonSemantic. and are otherwise
Expand Down Expand Up @@ -371,6 +391,11 @@ typedef enum spv_binary_to_text_options_t {
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES = SPV_BIT(6),
// Add some comments to the generated assembly
SPV_BINARY_TO_TEXT_OPTION_COMMENT = SPV_BIT(7),
// Use nested indentation for more readable SPIR-V
SPV_BINARY_TO_TEXT_OPTION_NESTED_INDENT = SPV_BIT(8),
// Reorder blocks to match the structured control flow of SPIR-V to increase
// readability.
SPV_BINARY_TO_TEXT_OPTION_REORDER_BLOCKS = SPV_BIT(9),
SPV_FORCE_32_BIT_ENUM(spv_binary_to_text_options_t)
} spv_binary_to_text_options_t;

Expand Down Expand Up @@ -515,6 +540,7 @@ SPIRV_TOOLS_EXPORT const char* spvSoftwareVersionDetailsString(void);
// SPV_ENV_VULKAN_1_1_SPIRV_1_4 -> SPIR-V 1.4
// SPV_ENV_VULKAN_1_2 -> SPIR-V 1.5
// SPV_ENV_VULKAN_1_3 -> SPIR-V 1.6
// SPV_ENV_VULKAN_1_4 -> SPIR-V 1.6
// Consult the description of API entry points for specific rules.
typedef enum {
SPV_ENV_UNIVERSAL_1_0, // SPIR-V 1.0 latest revision, no other restrictions.
Expand Down Expand Up @@ -552,6 +578,7 @@ typedef enum {

SPV_ENV_UNIVERSAL_1_6, // SPIR-V 1.6 latest revision, no other restrictions.
SPV_ENV_VULKAN_1_3, // Vulkan 1.3 latest revision.
SPV_ENV_VULKAN_1_4, // Vulkan 1.4 latest revision.

SPV_ENV_MAX // Keep this as the last enum value.
} spv_target_env;
Expand Down Expand Up @@ -966,9 +993,16 @@ SPIRV_TOOLS_EXPORT bool spvOptimizerRegisterPassFromFlag(
spv_optimizer_t* optimizer, const char* flag);

// Registers passes specified by length number of flags in an optimizer object.
// Passes may remove interface variables that are unused.
SPIRV_TOOLS_EXPORT bool spvOptimizerRegisterPassesFromFlags(
spv_optimizer_t* optimizer, const char** flags, const size_t flag_count);

// Registers passes specified by length number of flags in an optimizer object.
// Passes will not remove interface variables.
SPIRV_TOOLS_EXPORT bool
spvOptimizerRegisterPassesFromFlagsWhilePreservingTheInterface(
spv_optimizer_t* optimizer, const char** flags, const size_t flag_count);

// Optimizes the SPIR-V code of size |word_count| pointed to by |binary| and
// returns an optimized spv_binary in |optimized_binary|.
//
Expand Down
17 changes: 9 additions & 8 deletions include/spirv-tools/libspirv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <string>
#include <vector>

#include "spirv-tools/libspirv.h"
#include "libspirv.h"

namespace spvtools {

Expand All @@ -37,7 +37,7 @@ using InstructionParser =
std::function<spv_result_t(const spv_parsed_instruction_t& instruction)>;

// C++ RAII wrapper around the C context object spv_context.
class Context {
class SPIRV_TOOLS_EXPORT Context {
public:
// Constructs a context targeting the given environment |env|.
//
Expand Down Expand Up @@ -73,7 +73,7 @@ class Context {
};

// A RAII wrapper around a validator options object.
class ValidatorOptions {
class SPIRV_TOOLS_EXPORT ValidatorOptions {
public:
ValidatorOptions() : options_(spvValidatorOptionsCreate()) {}
~ValidatorOptions() { spvValidatorOptionsDestroy(options_); }
Expand Down Expand Up @@ -163,7 +163,7 @@ class ValidatorOptions {
};

// A C++ wrapper around an optimization options object.
class OptimizerOptions {
class SPIRV_TOOLS_EXPORT OptimizerOptions {
public:
OptimizerOptions() : options_(spvOptimizerOptionsCreate()) {}
~OptimizerOptions() { spvOptimizerOptionsDestroy(options_); }
Expand Down Expand Up @@ -205,7 +205,7 @@ class OptimizerOptions {
};

// A C++ wrapper around a reducer options object.
class ReducerOptions {
class SPIRV_TOOLS_EXPORT ReducerOptions {
public:
ReducerOptions() : options_(spvReducerOptionsCreate()) {}
~ReducerOptions() { spvReducerOptionsDestroy(options_); }
Expand Down Expand Up @@ -236,7 +236,7 @@ class ReducerOptions {
};

// A C++ wrapper around a fuzzer options object.
class FuzzerOptions {
class SPIRV_TOOLS_EXPORT FuzzerOptions {
public:
FuzzerOptions() : options_(spvFuzzerOptionsCreate()) {}
~FuzzerOptions() { spvFuzzerOptionsDestroy(options_); }
Expand Down Expand Up @@ -283,7 +283,7 @@ class FuzzerOptions {
// provides methods for assembling, disassembling, and validating.
//
// Instances of this class provide basic thread-safety guarantee.
class SpirvTools {
class SPIRV_TOOLS_EXPORT SpirvTools {
public:
enum {
// Default assembling option used by assemble():
Expand Down Expand Up @@ -388,7 +388,8 @@ class SpirvTools {
bool IsValid() const;

private:
struct Impl; // Opaque struct for holding the data fields used by this class.
struct SPIRV_TOOLS_LOCAL
Impl; // Opaque struct for holding the data fields used by this class.
std::unique_ptr<Impl> impl_; // Unique pointer to implementation data.
};

Expand Down
26 changes: 16 additions & 10 deletions include/spirv-tools/linker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
#define INCLUDE_SPIRV_TOOLS_LINKER_HPP_

#include <cstdint>

#include <memory>
#include <vector>

#include "libspirv.hpp"

namespace spvtools {

class LinkerOptions {
class SPIRV_TOOLS_EXPORT LinkerOptions {
public:
// Returns whether a library or an executable should be produced by the
// linking phase.
Expand Down Expand Up @@ -63,11 +62,17 @@ class LinkerOptions {
use_highest_version_ = use_highest_vers;
}

bool GetAllowPtrTypeMismatch() const { return allow_ptr_type_mismatch_; }
void SetAllowPtrTypeMismatch(bool allow_ptr_type_mismatch) {
allow_ptr_type_mismatch_ = allow_ptr_type_mismatch;
}

private:
bool create_library_{false};
bool verify_ids_{false};
bool allow_partial_linkage_{false};
bool use_highest_version_{false};
bool allow_ptr_type_mismatch_{false};
};

// Links one or more SPIR-V modules into a new SPIR-V module. That is, combine
Expand All @@ -84,14 +89,15 @@ class LinkerOptions {
// * Some entry points were defined multiple times;
// * Some imported symbols did not have an exported counterpart;
// * Possibly other reasons.
spv_result_t Link(const Context& context,
const std::vector<std::vector<uint32_t>>& binaries,
std::vector<uint32_t>* linked_binary,
const LinkerOptions& options = LinkerOptions());
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 = LinkerOptions());
SPIRV_TOOLS_EXPORT spv_result_t
Link(const Context& context, const std::vector<std::vector<uint32_t>>& binaries,
std::vector<uint32_t>* linked_binary,
const LinkerOptions& options = LinkerOptions());
SPIRV_TOOLS_EXPORT 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 = LinkerOptions());

} // namespace spvtools

Expand Down
Loading

0 comments on commit e16e8b6

Please sign in to comment.