Change clang-format settings

This commit is contained in:
ReinUsesLisp 2019-03-11 03:26:21 -03:00
parent 38838c9a9d
commit 73595f4588
27 changed files with 356 additions and 320 deletions

View file

@ -4,16 +4,15 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include <vector>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
#include <vector>
namespace Sirit {
Id Module::Decorate(Id target, spv::Decoration decoration,
const std::vector<Literal>& literals) {
Id Module::Decorate(Id target, spv::Decoration decoration, const std::vector<Literal>& literals) {
auto op{std::make_unique<Op>(spv::Op::OpDecorate)};
op->Add(target);
op->Add(static_cast<u32>(decoration));
@ -22,8 +21,7 @@ Id Module::Decorate(Id target, spv::Decoration decoration,
return target;
}
Id Module::MemberDecorate(Id structure_type, Literal member,
spv::Decoration decoration,
Id Module::MemberDecorate(Id structure_type, Literal member, spv::Decoration decoration,
const std::vector<Literal>& literals) {
auto op{std::make_unique<Op>(spv::Op::OpMemberDecorate)};
op->Add(structure_type);

View file

@ -4,36 +4,35 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
namespace Sirit {
#define DEFINE_UNARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
#define DEFINE_UNARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
}
#define DEFINE_BINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
return AddCode(std::move(op)); \
#define DEFINE_BINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
return AddCode(std::move(op)); \
}
#define DEFINE_TRINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, \
Id operand_3) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
op->Add(operand_3); \
return AddCode(std::move(op)); \
#define DEFINE_TRINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, Id operand_3) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
op->Add(operand_3); \
return AddCode(std::move(op)); \
}
DEFINE_UNARY(OpSNegate, spv::Op::OpSNegate)
@ -54,5 +53,4 @@ DEFINE_BINARY(OpFMod, spv::Op::OpFMod)
DEFINE_BINARY(OpSRem, spv::Op::OpSRem)
DEFINE_BINARY(OpFRem, spv::Op::OpFRem)
} // namespace Sirit

View file

@ -4,32 +4,29 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
namespace Sirit {
Id Module::OpShiftRightLogical(Id result_type, Id base, Id shift) {
auto op{std::make_unique<Op>(spv::Op::OpShiftRightLogical, bound++,
result_type)};
auto op{std::make_unique<Op>(spv::Op::OpShiftRightLogical, bound++, result_type)};
op->Add(base);
op->Add(shift);
return AddCode(std::move(op));
}
Id Module::OpShiftRightArithmetic(Id result_type, Id base, Id shift) {
auto op{std::make_unique<Op>(spv::Op::OpShiftRightArithmetic, bound++,
result_type)};
auto op{std::make_unique<Op>(spv::Op::OpShiftRightArithmetic, bound++, result_type)};
op->Add(base);
op->Add(shift);
return AddCode(std::move(op));
}
Id Module::OpShiftLeftLogical(Id result_type, Id base, Id shift) {
auto op{std::make_unique<Op>(spv::Op::OpShiftLeftLogical, bound++,
result_type)};
auto op{std::make_unique<Op>(spv::Op::OpShiftLeftLogical, bound++, result_type)};
op->Add(base);
op->Add(shift);
return AddCode(std::move(op));

View file

@ -4,20 +4,18 @@
* Lesser General Public License version 3 or any later version.
*/
#include <cassert>
#include "op.h"
#include "sirit/sirit.h"
#include <cassert>
namespace Sirit {
Id Module::ConstantTrue(Id result_type) {
return AddDeclaration(
std::make_unique<Op>(spv::Op::OpConstantTrue, bound, result_type));
return AddDeclaration(std::make_unique<Op>(spv::Op::OpConstantTrue, bound, result_type));
}
Id Module::ConstantFalse(Id result_type) {
return AddDeclaration(
std::make_unique<Op>(spv::Op::OpConstantFalse, bound, result_type));
return AddDeclaration(std::make_unique<Op>(spv::Op::OpConstantFalse, bound, result_type));
}
Id Module::Constant(Id result_type, const Literal& literal) {
@ -26,22 +24,17 @@ Id Module::Constant(Id result_type, const Literal& literal) {
return AddDeclaration(std::move(op));
}
Id Module::ConstantComposite(Id result_type,
const std::vector<Id>& constituents) {
auto op{
std::make_unique<Op>(spv::Op::OpConstantComposite, bound, result_type)};
Id Module::ConstantComposite(Id result_type, const std::vector<Id>& constituents) {
auto op{std::make_unique<Op>(spv::Op::OpConstantComposite, bound, result_type)};
op->Add(constituents);
return AddDeclaration(std::move(op));
}
Id Module::ConstantSampler(Id result_type,
spv::SamplerAddressingMode addressing_mode,
bool normalized,
spv::SamplerFilterMode filter_mode) {
Id Module::ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode,
bool normalized, spv::SamplerFilterMode filter_mode) {
AddCapability(spv::Capability::LiteralSampler);
AddCapability(spv::Capability::Kernel);
auto op{
std::make_unique<Op>(spv::Op::OpConstantSampler, bound, result_type)};
auto op{std::make_unique<Op>(spv::Op::OpConstantSampler, bound, result_type)};
op->Add(static_cast<u32>(addressing_mode));
op->Add(normalized ? 1 : 0);
op->Add(static_cast<u32>(filter_mode));
@ -49,8 +42,7 @@ Id Module::ConstantSampler(Id result_type,
}
Id Module::ConstantNull(Id result_type) {
return AddDeclaration(
std::make_unique<Op>(spv::Op::OpConstantNull, bound, result_type));
return AddDeclaration(std::make_unique<Op>(spv::Op::OpConstantNull, bound, result_type));
}
} // namespace Sirit

View file

@ -4,18 +4,18 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
namespace Sirit {
#define DEFINE_UNARY(opcode) \
Id Module::opcode(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
#define DEFINE_UNARY(opcode) \
Id Module::opcode(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
}
DEFINE_UNARY(OpConvertFToU)

View file

@ -4,10 +4,10 @@
* Lesser General Public License version 3 or any later version.
*/
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
#include <string>
#include "op.h"
#include "sirit/sirit.h"
namespace Sirit {

View file

@ -4,16 +4,15 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include <spirv/unified1/GLSL.std.450.h>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
#include <spirv/unified1/GLSL.std.450.h>
namespace Sirit {
Id Module::OpExtInst(Id result_type, Id set, u32 instruction,
const std::vector<Id>& operands) {
Id Module::OpExtInst(Id result_type, Id set, u32 instruction, const std::vector<Id>& operands) {
auto op{std::make_unique<Op>(spv::Op::OpExtInst, bound++, result_type)};
op->Add(set);
op->Add(instruction);
@ -21,22 +20,19 @@ Id Module::OpExtInst(Id result_type, Id set, u32 instruction,
return AddCode(std::move(op));
}
#define DEFINE_UNARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand) { \
return OpExtInst(result_type, GetGLSLstd450(), opcode, {operand}); \
#define DEFINE_UNARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand) { \
return OpExtInst(result_type, GetGLSLstd450(), opcode, {operand}); \
}
#define DEFINE_BINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
return OpExtInst(result_type, GetGLSLstd450(), opcode, \
{operand_1, operand_2}); \
#define DEFINE_BINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
return OpExtInst(result_type, GetGLSLstd450(), opcode, {operand_1, operand_2}); \
}
#define DEFINE_TRINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, \
Id operand_3) { \
return OpExtInst(result_type, GetGLSLstd450(), opcode, \
{operand_1, operand_2, operand_3}); \
#define DEFINE_TRINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, Id operand_3) { \
return OpExtInst(result_type, GetGLSLstd450(), opcode, {operand_1, operand_2, operand_3}); \
}
DEFINE_UNARY(OpFAbs, GLSLstd450FAbs)

View file

@ -4,16 +4,15 @@
* Lesser General Public License version 3 or any later version.
*/
#include <cassert>
#include <vector>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <cassert>
#include <vector>
namespace Sirit {
Id Module::OpLoopMerge(Id merge_block, Id continue_target,
spv::LoopControlMask loop_control,
Id Module::OpLoopMerge(Id merge_block, Id continue_target, spv::LoopControlMask loop_control,
const std::vector<Id>& literals) {
auto op{std::make_unique<Op>(spv::Op::OpLoopMerge)};
op->Add(merge_block);
@ -23,15 +22,16 @@ Id Module::OpLoopMerge(Id merge_block, Id continue_target,
return AddCode(std::move(op));
}
Id Module::OpSelectionMerge(Id merge_block,
spv::SelectionControlMask selection_control) {
Id Module::OpSelectionMerge(Id merge_block, spv::SelectionControlMask selection_control) {
auto op{std::make_unique<Op>(spv::Op::OpSelectionMerge)};
op->Add(merge_block);
op->Add(static_cast<u32>(selection_control));
return AddCode(std::move(op));
}
Id Module::OpLabel() { return AddCode(spv::Op::OpLabel, bound++); }
Id Module::OpLabel() {
return AddCode(spv::Op::OpLabel, bound++);
}
Id Module::OpBranch(Id target_label) {
auto op{std::make_unique<Op>(spv::Op::OpBranch)};
@ -39,8 +39,8 @@ Id Module::OpBranch(Id target_label) {
return AddCode(std::move(op));
}
Id Module::OpBranchConditional(Id condition, Id true_label, Id false_label,
u32 true_weight, u32 false_weight) {
Id Module::OpBranchConditional(Id condition, Id true_label, Id false_label, u32 true_weight,
u32 false_weight) {
auto op{std::make_unique<Op>(spv::Op::OpBranchConditional)};
op->Add(condition);
op->Add(true_label);
@ -52,8 +52,7 @@ Id Module::OpBranchConditional(Id condition, Id true_label, Id false_label,
return AddCode(std::move(op));
}
Id Module::OpSwitch(Id selector, Id default_label,
const std::vector<Literal>& literals,
Id Module::OpSwitch(Id selector, Id default_label, const std::vector<Literal>& literals,
const std::vector<Id>& labels) {
const std::size_t size = literals.size();
assert(literals.size() == labels.size());
@ -67,7 +66,9 @@ Id Module::OpSwitch(Id selector, Id default_label,
return AddCode(std::move(op));
}
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)};

View file

@ -10,20 +10,19 @@
namespace Sirit {
Id Module::OpFunction(Id result_type, spv::FunctionControlMask function_control,
Id function_type) {
Id Module::OpFunction(Id result_type, spv::FunctionControlMask function_control, Id function_type) {
auto op{std::make_unique<Op>(spv::Op::OpFunction, bound++, result_type)};
op->Add(static_cast<u32>(function_control));
op->Add(function_type);
return AddCode(std::move(op));
}
Id Module::OpFunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); }
Id Module::OpFunctionEnd() {
return AddCode(spv::Op::OpFunctionEnd);
}
Id Module::OpFunctionCall(Id result_type, Id function,
const std::vector<Id>& arguments) {
auto op{
std::make_unique<Op>(spv::Op::OpFunctionCall, bound++, result_type)};
Id Module::OpFunctionCall(Id result_type, Id function, const std::vector<Id>& arguments) {
auto op{std::make_unique<Op>(spv::Op::OpFunctionCall, bound++, result_type)};
op->Add(function);
op->Add(arguments);
return AddCode(std::move(op));

View file

@ -10,79 +10,77 @@
namespace Sirit {
static void
AddImageOperands(Op* op, std::optional<spv::ImageOperandsMask> image_operands,
const std::vector<Id>& operands) {
static void AddImageOperands(Op* op, std::optional<spv::ImageOperandsMask> image_operands,
const std::vector<Id>& operands) {
if (!image_operands)
return;
op->Add(static_cast<u32>(*image_operands));
op->Add(operands);
}
#define DEFINE_IMAGE_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \
std::optional<spv::ImageOperandsMask> image_operands, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
AddImageOperands(op.get(), image_operands, operands); \
return AddCode(std::move(op)); \
#define DEFINE_IMAGE_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \
std::optional<spv::ImageOperandsMask> image_operands, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
AddImageOperands(op.get(), image_operands, operands); \
return AddCode(std::move(op)); \
}
#define DEFINE_IMAGE_EXP_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \
spv::ImageOperandsMask image_operands, Id lod, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(static_cast<u32>(image_operands)); \
op->Add(lod); \
op->Add(operands); \
return AddCode(std::move(op)); \
#define DEFINE_IMAGE_EXP_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \
spv::ImageOperandsMask image_operands, Id lod, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(static_cast<u32>(image_operands)); \
op->Add(lod); \
op->Add(operands); \
return AddCode(std::move(op)); \
}
#define DEFINE_IMAGE_EXTRA_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \
Id extra, \
std::optional<spv::ImageOperandsMask> image_operands, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(extra); \
AddImageOperands(op.get(), image_operands, operands); \
return AddCode(std::move(op)); \
#define DEFINE_IMAGE_EXTRA_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, Id extra, \
std::optional<spv::ImageOperandsMask> image_operands, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(extra); \
AddImageOperands(op.get(), image_operands, operands); \
return AddCode(std::move(op)); \
}
#define DEFINE_IMAGE_EXTRA_EXP_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \
Id extra, spv::ImageOperandsMask image_operands, Id lod, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(extra); \
op->Add(static_cast<u32>(image_operands)); \
op->Add(lod); \
op->Add(operands); \
return AddCode(std::move(op)); \
#define DEFINE_IMAGE_EXTRA_EXP_OP(opcode) \
Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, Id extra, \
spv::ImageOperandsMask image_operands, Id lod, \
const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(extra); \
op->Add(static_cast<u32>(image_operands)); \
op->Add(lod); \
op->Add(operands); \
return AddCode(std::move(op)); \
}
#define DEFINE_IMAGE_QUERY_OP(opcode) \
Id Module::opcode(Id result_type, Id image) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(image); \
return AddCode(std::move(op)); \
#define DEFINE_IMAGE_QUERY_OP(opcode) \
Id Module::opcode(Id result_type, Id image) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(image); \
return AddCode(std::move(op)); \
}
#define DEFINE_IMAGE_QUERY_BIN_OP(opcode) \
Id Module::opcode(Id result_type, Id image, Id extra) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(image); \
op->Add(extra); \
return AddCode(std::move(op)); \
#define DEFINE_IMAGE_QUERY_BIN_OP(opcode) \
Id Module::opcode(Id result_type, Id image, Id extra) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(image); \
op->Add(extra); \
return AddCode(std::move(op)); \
}
DEFINE_IMAGE_OP(OpImageSampleImplicitLod)
@ -104,8 +102,7 @@ DEFINE_IMAGE_QUERY_OP(OpImageQueryLevels)
DEFINE_IMAGE_QUERY_OP(OpImageQuerySamples)
Id Module::OpSampledImage(Id result_type, Id image, Id sampler) {
auto op{
std::make_unique<Op>(spv::Op::OpSampledImage, bound++, result_type)};
auto op{std::make_unique<Op>(spv::Op::OpSampledImage, bound++, result_type)};
op->Add(image);
op->Add(sampler);
return AddCode(std::move(op));

View file

@ -4,36 +4,35 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include "common_types.h"
#include "op.h"
#include "sirit/sirit.h"
#include <memory>
namespace Sirit {
#define DEFINE_UNARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
#define DEFINE_UNARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand); \
return AddCode(std::move(op)); \
}
#define DEFINE_BINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
return AddCode(std::move(op)); \
#define DEFINE_BINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
return AddCode(std::move(op)); \
}
#define DEFINE_TRINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, \
Id operand_3) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
op->Add(operand_3); \
return AddCode(std::move(op)); \
#define DEFINE_TRINARY(funcname, opcode) \
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, Id operand_3) { \
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
op->Add(operand_1); \
op->Add(operand_2); \
op->Add(operand_3); \
return AddCode(std::move(op)); \
}
DEFINE_UNARY(OpIsNan, spv::Op::OpIsNan)

View file

@ -4,14 +4,13 @@
* Lesser General Public License version 3 or any later version.
*/
#include <cassert>
#include "op.h"
#include "sirit/sirit.h"
#include <cassert>
namespace Sirit {
Id Module::OpVariable(Id result_type, spv::StorageClass storage_class,
Id initializer) {
Id Module::OpVariable(Id result_type, spv::StorageClass storage_class, Id initializer) {
auto op{std::make_unique<Op>(spv::Op::OpVariable, bound++, result_type)};
op->Add(static_cast<u32>(storage_class));
if (initializer) {
@ -20,8 +19,7 @@ Id Module::OpVariable(Id result_type, spv::StorageClass storage_class,
return AddCode(std::move(op));
}
Id Module::OpLoad(Id result_type, Id pointer,
std::optional<spv::MemoryAccessMask> memory_access) {
Id Module::OpLoad(Id result_type, Id pointer, std::optional<spv::MemoryAccessMask> memory_access) {
auto op{std::make_unique<Op>(spv::Op::OpLoad, bound++, result_type)};
op->Add(pointer);
if (memory_access) {
@ -30,8 +28,7 @@ Id Module::OpLoad(Id result_type, Id pointer,
return AddCode(std::move(op));
}
Id Module::OpStore(Id pointer, Id object,
std::optional<spv::MemoryAccessMask> memory_access) {
Id Module::OpStore(Id pointer, Id object, std::optional<spv::MemoryAccessMask> memory_access) {
auto op{std::make_unique<Op>(spv::Op::OpStore)};
op->Add(pointer);
op->Add(object);
@ -41,8 +38,7 @@ Id Module::OpStore(Id pointer, Id object,
return AddCode(std::move(op));
}
Id Module::OpAccessChain(Id result_type, Id base,
const std::vector<Id>& indexes) {
Id Module::OpAccessChain(Id result_type, Id base, const std::vector<Id>& indexes) {
assert(indexes.size() > 0);
auto op{std::make_unique<Op>(spv::Op::OpAccessChain, bound++, result_type)};
op->Add(base);
@ -52,18 +48,15 @@ Id Module::OpAccessChain(Id result_type, Id base,
Id Module::OpCompositeInsert(Id result_type, Id object, Id composite,
const std::vector<Literal>& indexes) {
auto op{
std::make_unique<Op>(spv::Op::OpCompositeInsert, bound++, result_type)};
auto op{std::make_unique<Op>(spv::Op::OpCompositeInsert, bound++, result_type)};
op->Add(object);
op->Add(composite);
op->Add(indexes);
return AddCode(std::move(op));
}
Id Module::OpCompositeExtract(Id result_type, Id composite,
const std::vector<Literal>& indexes) {
auto op{std::make_unique<Op>(spv::Op::OpCompositeExtract, bound++,
result_type)};
Id Module::OpCompositeExtract(Id result_type, Id composite, const std::vector<Literal>& indexes) {
auto op{std::make_unique<Op>(spv::Op::OpCompositeExtract, bound++, result_type)};
op->Add(composite);
op->Add(indexes);
return AddCode(std::move(op));
@ -71,8 +64,7 @@ Id Module::OpCompositeExtract(Id result_type, Id composite,
Id Module::OpCompositeConstruct(Id result_type, const std::vector<Id>& ids) {
assert(ids.size() >= 1);
auto op{std::make_unique<Op>(spv::Op::OpCompositeConstruct, bound++,
result_type)};
auto op{std::make_unique<Op>(spv::Op::OpCompositeConstruct, bound++, result_type)};
op->Add(ids);
return AddCode(std::move(op));
}

View file

@ -4,9 +4,9 @@
* Lesser General Public License version 3 or any later version.
*/
#include <cassert>
#include "op.h"
#include "sirit/sirit.h"
#include <cassert>
namespace Sirit {

View file

@ -4,8 +4,8 @@
* Lesser General Public License version 3 or any later version.
*/
#include <memory>
#include <cassert>
#include <memory>
#include <optional>
#include "op.h"
@ -63,9 +63,9 @@ Id Module::OpTypeMatrix(Id column_type, int column_count) {
return AddDeclaration(std::move(op));
}
Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed,
bool ms, int sampled, spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier) {
Id Module::OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled,
spv::ImageFormat image_format,
std::optional<spv::AccessQualifier> access_qualifier) {
switch (dim) {
case spv::Dim::Dim1D:
AddCapability(spv::Capability::Sampled1D);