Add OpReturnValue

This commit is contained in:
ReinUsesLisp 2018-11-01 01:12:52 -03:00
parent 91e0769db5
commit 798f8a5866
2 changed files with 28 additions and 20 deletions

View file

@ -87,8 +87,8 @@ class Module {
/// Returns type image. /// Returns type image.
Id OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, Id OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed,
bool ms, int sampled, spv::ImageFormat image_format, bool ms, int sampled, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier = {}); std::optional<spv::AccessQualifier> access_qualifier = {});
/// Returns type sampler. /// Returns type sampler.
Id OpTypeSampler(); Id OpTypeSampler();
@ -141,13 +141,12 @@ class Module {
Id OpConstant(Id result_type, const Literal& literal); Id OpConstant(Id result_type, const Literal& literal);
/// Returns a numeric scalar constant. /// Returns a numeric scalar constant.
Id OpConstantComposite(Id result_type, Id OpConstantComposite(Id result_type, const std::vector<Id>& constituents);
const std::vector<Id>& constituents);
/// Returns a sampler constant. /// Returns a sampler constant.
Id OpConstantSampler(Id result_type, Id OpConstantSampler(Id result_type,
spv::SamplerAddressingMode addressing_mode, spv::SamplerAddressingMode addressing_mode,
bool normalized, spv::SamplerFilterMode filter_mode); bool normalized, spv::SamplerFilterMode filter_mode);
/// Returns a null constant value. /// Returns a null constant value.
Id OpConstantNull(Id result_type); Id OpConstantNull(Id result_type);
@ -156,7 +155,7 @@ class Module {
/// Declares a function. /// Declares a function.
Id OpFunction(Id result_type, spv::FunctionControlMask function_control, Id OpFunction(Id result_type, spv::FunctionControlMask function_control,
Id function_type); Id function_type);
/// Ends a function. /// Ends a function.
Id OpFunctionEnd(); Id OpFunctionEnd();
@ -165,12 +164,12 @@ class Module {
/// Declare a structured loop. /// Declare a structured loop.
Id OpLoopMerge(Id merge_block, Id continue_target, Id OpLoopMerge(Id merge_block, Id continue_target,
spv::LoopControlMask loop_control, spv::LoopControlMask loop_control,
const std::vector<Id>& literals = {}); const std::vector<Id>& literals = {});
/// Declare a structured selection. /// Declare a structured selection.
Id OpSelectionMerge(Id merge_block, Id OpSelectionMerge(Id merge_block,
spv::SelectionControlMask selection_control); spv::SelectionControlMask selection_control);
/// The block label instruction: Any reference to a block is through this /// The block label instruction: Any reference to a block is through this
/// ref. /// ref.
@ -182,12 +181,15 @@ class Module {
/// If condition is true branch to true_label, otherwise branch to /// If condition is true branch to true_label, otherwise branch to
/// false_label. /// false_label.
Id OpBranchConditional(Id condition, Id true_label, Id false_label, Id OpBranchConditional(Id condition, Id true_label, Id false_label,
std::uint32_t true_weight = 0, std::uint32_t true_weight = 0,
std::uint32_t false_weight = 0); std::uint32_t false_weight = 0);
/// Returns with no value from a function with void return type. /// Returns with no value from a function with void return type.
Id OpReturn(); Id OpReturn();
/// Return a value from a function.
Id OpReturnValue(Id value);
// Debug // Debug
/// Assign a name string to a reference. /// Assign a name string to a reference.
@ -198,34 +200,34 @@ class Module {
/// Allocate an object in memory, resulting in a copy to it. /// Allocate an object in memory, resulting in a copy to it.
Id OpVariable(Id result_type, spv::StorageClass storage_class, Id OpVariable(Id result_type, spv::StorageClass storage_class,
Id initializer = nullptr); Id initializer = nullptr);
/// Load through a pointer. /// Load through a pointer.
Id OpLoad(Id result_type, Id pointer, Id OpLoad(Id result_type, Id pointer,
std::optional<spv::MemoryAccessMask> memory_access = {}); std::optional<spv::MemoryAccessMask> memory_access = {});
/// Store through a pointer. /// Store through a pointer.
Id OpStore(Id pointer, Id object, Id OpStore(Id pointer, Id object,
std::optional<spv::MemoryAccessMask> memory_access = {}); std::optional<spv::MemoryAccessMask> memory_access = {});
/// Create a pointer into a composite object that can be used with OpLoad /// Create a pointer into a composite object that can be used with OpLoad
/// and OpStore. /// and OpStore.
Id OpAccessChain(Id result_type, Id base, Id OpAccessChain(Id result_type, Id base,
const std::vector<Id>& indexes = {}); const std::vector<Id>& indexes = {});
/// Make a copy of a composite object, while modifying one part of it. /// Make a copy of a composite object, while modifying one part of it.
Id OpCompositeInsert(Id result_type, Id object, Id composite, Id OpCompositeInsert(Id result_type, Id object, Id composite,
const std::vector<Literal>& indexes = {}); const std::vector<Literal>& indexes = {});
// Annotation // Annotation
/// Add a decoration to target. /// Add a decoration to target.
Id Decorate(Id target, spv::Decoration decoration, Id Decorate(Id target, spv::Decoration decoration,
const std::vector<Literal>& literals = {}); const std::vector<Literal>& literals = {});
Id MemberDecorate(Id structure_type, Literal member, Id MemberDecorate(Id structure_type, Literal member,
spv::Decoration decoration, spv::Decoration decoration,
const std::vector<Literal>& literals = {}); const std::vector<Literal>& literals = {});
// Misc // Misc

View file

@ -53,4 +53,10 @@ Id Module::OpBranchConditional(Id condition, Id true_label, Id false_label,
Id Module::OpReturn() { return AddCode(spv::Op::OpReturn); } Id Module::OpReturn() { return AddCode(spv::Op::OpReturn); }
Id Module::OpReturnValue(Id value) {
auto op{std::make_unique<Op>(spv::Op::OpReturnValue)};
op->Add(value);
return AddCode(std::move(op));
}
} // namespace Sirit } // namespace Sirit