From 73595f45889f7bb7adfa6bd946eadc7348f31f4b Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 11 Mar 2019 03:26:21 -0300 Subject: [PATCH] Change clang-format settings --- .clang-format | 90 +++++++++++++++++++++- include/sirit/sirit.h | 127 ++++++++++++-------------------- src/instructions/annotation.cpp | 10 +-- src/instructions/arithmetic.cpp | 40 +++++----- src/instructions/bit.cpp | 11 +-- src/instructions/constant.cpp | 26 +++---- src/instructions/conversion.cpp | 12 +-- src/instructions/debug.cpp | 4 +- src/instructions/extension.cpp | 28 +++---- src/instructions/flow.cpp | 25 ++++--- src/instructions/function.cpp | 13 ++-- src/instructions/image.cpp | 115 ++++++++++++++--------------- src/instructions/logical.cpp | 39 +++++----- src/instructions/memory.cpp | 26 +++---- src/instructions/misc.cpp | 2 +- src/instructions/type.cpp | 8 +- src/literal_number.cpp | 6 +- src/literal_number.h | 11 +-- src/literal_string.cpp | 4 +- src/literal_string.h | 6 +- src/op.cpp | 16 +++- src/op.h | 9 +-- src/operand.cpp | 10 ++- src/operand.h | 4 +- src/sirit.cpp | 24 +++--- src/stream.cpp | 4 +- src/stream.h | 6 +- 27 files changed, 356 insertions(+), 320 deletions(-) diff --git a/.clang-format b/.clang-format index 922a91a..1c6b71b 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,88 @@ -BasedOnStyle: LLVM -IndentWidth: 4 - -Language: Cpp +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true DerivePointerAlignment: false +DisableFormat: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^\<[^Q][^/.>]*\>' + Priority: -2 + - Regex: '^\<' + Priority: -1 + - Regex: '^\"' + Priority: 0 +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 150 PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 4119a5f..abaa9ca 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -10,10 +10,10 @@ #include #include #include -#include #include #include #include +#include namespace Sirit { @@ -22,12 +22,12 @@ constexpr std::uint32_t GENERATOR_MAGIC_NUMBER = 0; class Op; class Operand; -using Literal = std::variant; +using Literal = + std::variant; using Id = const Op*; class Module { - public: +public: explicit Module(std::uint32_t version = spv::Version); ~Module(); @@ -46,12 +46,10 @@ class Module { void AddCapability(spv::Capability capability); /// Sets module memory model. - void SetMemoryModel(spv::AddressingModel addressing_model, - spv::MemoryModel memory_model); + void SetMemoryModel(spv::AddressingModel addressing_model, spv::MemoryModel memory_model); /// Adds an entry point. - void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, - const std::string& name, + void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, const std::string& name, const std::vector& interfaces = {}); /// Declare an execution mode for an entry point. @@ -94,8 +92,8 @@ class Module { Id OpTypeMatrix(Id column_type, int column_count); /// Returns type image. - Id OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, - bool ms, int sampled, spv::ImageFormat image_format, + Id OpTypeImage(Id sampled_type, spv::Dim dim, int depth, bool arrayed, bool ms, int sampled, + spv::ImageFormat image_format, std::optional access_qualifier = {}); /// Returns type sampler. @@ -152,9 +150,8 @@ class Module { Id ConstantComposite(Id result_type, const std::vector& constituents); /// Returns a sampler constant. - Id ConstantSampler(Id result_type, - spv::SamplerAddressingMode addressing_mode, - bool normalized, spv::SamplerFilterMode filter_mode); + Id ConstantSampler(Id result_type, spv::SamplerAddressingMode addressing_mode, bool normalized, + spv::SamplerFilterMode filter_mode); /// Returns a null constant value. Id ConstantNull(Id result_type); @@ -162,26 +159,22 @@ class Module { // Function /// Declares a function. - Id OpFunction(Id result_type, spv::FunctionControlMask function_control, - Id function_type); + Id OpFunction(Id result_type, spv::FunctionControlMask function_control, Id function_type); /// Ends a function. Id OpFunctionEnd(); /// Call a function. - Id OpFunctionCall(Id result_type, Id function, - const std::vector& arguments = {}); + Id OpFunctionCall(Id result_type, Id function, const std::vector& arguments = {}); // Flow /// Declare a structured loop. - Id OpLoopMerge(Id merge_block, Id continue_target, - spv::LoopControlMask loop_control, + Id OpLoopMerge(Id merge_block, Id continue_target, spv::LoopControlMask loop_control, const std::vector& literals = {}); /// Declare a structured selection. - Id OpSelectionMerge(Id merge_block, - spv::SelectionControlMask selection_control); + Id OpSelectionMerge(Id merge_block, spv::SelectionControlMask selection_control); /// The block label instruction: Any reference to a block is through this /// ref. @@ -193,12 +186,10 @@ class Module { /// If condition is true branch to true_label, otherwise branch to /// false_label. Id OpBranchConditional(Id condition, Id true_label, Id false_label, - std::uint32_t true_weight = 0, - std::uint32_t false_weight = 0); + std::uint32_t true_weight = 0, std::uint32_t false_weight = 0); /// Multi-way branch to one of the operand label. - Id OpSwitch(Id selector, Id default_label, - const std::vector& literals, + Id OpSwitch(Id selector, Id default_label, const std::vector& literals, const std::vector& labels); /// Returns with no value from a function with void return type. @@ -229,29 +220,24 @@ class Module { // Memory /// Allocate an object in memory, resulting in a copy to it. - Id OpVariable(Id result_type, spv::StorageClass storage_class, - Id initializer = nullptr); + Id OpVariable(Id result_type, spv::StorageClass storage_class, Id initializer = nullptr); /// Load through a pointer. - Id OpLoad(Id result_type, Id pointer, - std::optional memory_access = {}); + Id OpLoad(Id result_type, Id pointer, std::optional memory_access = {}); /// Store through a pointer. - Id OpStore(Id pointer, Id object, - std::optional memory_access = {}); + Id OpStore(Id pointer, Id object, std::optional memory_access = {}); /// Create a pointer into a composite object that can be used with OpLoad /// and OpStore. - Id OpAccessChain(Id result_type, Id base, - const std::vector& indexes = {}); + Id OpAccessChain(Id result_type, Id base, const std::vector& indexes = {}); /// Make a copy of a composite object, while modifying one part of it. Id OpCompositeInsert(Id result_type, Id object, Id composite, const std::vector& indexes = {}); /// Extract a part of a composite object. - Id OpCompositeExtract(Id result_type, Id composite, - const std::vector& indexes = {}); + Id OpCompositeExtract(Id result_type, Id composite, const std::vector& indexes = {}); /// Construct a new composite object from a set of constituent objects that /// will fully form it. @@ -260,11 +246,9 @@ class Module { // Annotation /// Add a decoration to target. - Id Decorate(Id target, spv::Decoration decoration, - const std::vector& literals = {}); + Id Decorate(Id target, spv::Decoration decoration, const std::vector& literals = {}); - Id MemberDecorate(Id structure_type, Literal member, - spv::Decoration decoration, + Id MemberDecorate(Id structure_type, Literal member, spv::Decoration decoration, const std::vector& literals = {}); // Misc @@ -383,8 +367,7 @@ class Module { /// Does a bitwise Not on the operand. Id OpNot(Id result_type, Id operand); - Id OpBitFieldInsert(Id result_type, Id base, Id insert, Id offset, - Id count); + Id OpBitFieldInsert(Id result_type, Id base, Id insert, Id offset, Id count); Id OpBitFieldSExtract(Id result_type, Id base, Id offset, Id count); @@ -533,61 +516,49 @@ class Module { Id OpSampledImage(Id result_type, Id image, Id sampler); - Id OpImageSampleImplicitLod( - Id result_type, Id sampled_image, Id coordinate, - std::optional image_operands = {}, - const std::vector& operands = {}); + Id OpImageSampleImplicitLod(Id result_type, Id sampled_image, Id coordinate, + std::optional image_operands = {}, + const std::vector& operands = {}); Id OpImageSampleExplicitLod(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Id lod, const std::vector& operands = {}); - Id OpImageSampleDrefImplicitLod( - Id result_type, Id sampled_image, Id coordinate, Id dref, - std::optional image_operands = {}, - const std::vector& operands = {}); - - Id OpImageSampleDrefExplicitLod(Id result_type, Id sampled_image, - Id coordinate, Id dref, - spv::ImageOperandsMask image_operands, - Id lod, + Id OpImageSampleDrefImplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, + std::optional image_operands = {}, const std::vector& operands = {}); - Id OpImageSampleProjImplicitLod( - Id result_type, Id sampled_image, Id coordinate, - std::optional image_operands = {}, - const std::vector& operands = {}); - - Id OpImageSampleProjExplicitLod(Id result_type, Id sampled_image, - Id coordinate, - spv::ImageOperandsMask image_operands, - Id lod, + Id OpImageSampleDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, + spv::ImageOperandsMask image_operands, Id lod, const std::vector& operands = {}); - Id OpImageSampleProjDrefImplicitLod( - Id result_type, Id sampled_image, Id coordinate, Id dref, - std::optional image_operands = {}, - const std::vector& operands = {}); + Id OpImageSampleProjImplicitLod(Id result_type, Id sampled_image, Id coordinate, + std::optional image_operands = {}, + const std::vector& operands = {}); - Id OpImageSampleProjDrefExplicitLod(Id result_type, Id sampled_image, - Id coordinate, Id dref, - spv::ImageOperandsMask image_operands, - Id lod, + Id OpImageSampleProjExplicitLod(Id result_type, Id sampled_image, Id coordinate, + spv::ImageOperandsMask image_operands, Id lod, + const std::vector& operands = {}); + + Id OpImageSampleProjDrefImplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, + std::optional image_operands = {}, + const std::vector& operands = {}); + + Id OpImageSampleProjDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, + spv::ImageOperandsMask image_operands, Id lod, const std::vector& operands = {}); Id OpImageFetch(Id result_type, Id sampled_image, Id coordinate, std::optional image_operands = {}, const std::vector& operands = {}); - Id OpImageGather(Id result_type, Id sampled_image, Id coordinate, - Id component, + Id OpImageGather(Id result_type, Id sampled_image, Id coordinate, Id component, std::optional image_operands = {}, const std::vector& operands = {}); - Id - OpImageDrefGather(Id result_type, Id sampled_image, Id coordinate, Id dref, - std::optional image_operands = {}, - const std::vector& operands = {}); + Id OpImageDrefGather(Id result_type, Id sampled_image, Id coordinate, Id dref, + std::optional image_operands = {}, + const std::vector& operands = {}); Id OpImageRead(Id result_type, Id sampled_image, Id coordinate, std::optional image_operands = {}, @@ -609,7 +580,7 @@ class Module { Id OpImageQuerySamples(Id result_type, Id image); - private: +private: Id AddCode(std::unique_ptr op); Id AddCode(spv::Op opcode, std::optional id = {}); diff --git a/src/instructions/annotation.cpp b/src/instructions/annotation.cpp index 821b349..d86da31 100644 --- a/src/instructions/annotation.cpp +++ b/src/instructions/annotation.cpp @@ -4,16 +4,15 @@ * Lesser General Public License version 3 or any later version. */ +#include +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include -#include namespace Sirit { -Id Module::Decorate(Id target, spv::Decoration decoration, - const std::vector& literals) { +Id Module::Decorate(Id target, spv::Decoration decoration, const std::vector& literals) { auto op{std::make_unique(spv::Op::OpDecorate)}; op->Add(target); op->Add(static_cast(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& literals) { auto op{std::make_unique(spv::Op::OpMemberDecorate)}; op->Add(structure_type); diff --git a/src/instructions/arithmetic.cpp b/src/instructions/arithmetic.cpp index f1423c6..a95dfba 100644 --- a/src/instructions/arithmetic.cpp +++ b/src/instructions/arithmetic.cpp @@ -4,36 +4,35 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include namespace Sirit { -#define DEFINE_UNARY(funcname, opcode) \ - Id Module::funcname(Id result_type, Id operand) { \ - auto op{std::make_unique(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(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(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(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(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(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 diff --git a/src/instructions/bit.cpp b/src/instructions/bit.cpp index 3afc0d5..6378760 100644 --- a/src/instructions/bit.cpp +++ b/src/instructions/bit.cpp @@ -4,32 +4,29 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include namespace Sirit { Id Module::OpShiftRightLogical(Id result_type, Id base, Id shift) { - auto op{std::make_unique(spv::Op::OpShiftRightLogical, bound++, - result_type)}; + auto op{std::make_unique(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(spv::Op::OpShiftRightArithmetic, bound++, - result_type)}; + auto op{std::make_unique(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(spv::Op::OpShiftLeftLogical, bound++, - result_type)}; + auto op{std::make_unique(spv::Op::OpShiftLeftLogical, bound++, result_type)}; op->Add(base); op->Add(shift); return AddCode(std::move(op)); diff --git a/src/instructions/constant.cpp b/src/instructions/constant.cpp index f0c21dc..9522f2d 100644 --- a/src/instructions/constant.cpp +++ b/src/instructions/constant.cpp @@ -4,20 +4,18 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "op.h" #include "sirit/sirit.h" -#include namespace Sirit { Id Module::ConstantTrue(Id result_type) { - return AddDeclaration( - std::make_unique(spv::Op::OpConstantTrue, bound, result_type)); + return AddDeclaration(std::make_unique(spv::Op::OpConstantTrue, bound, result_type)); } Id Module::ConstantFalse(Id result_type) { - return AddDeclaration( - std::make_unique(spv::Op::OpConstantFalse, bound, result_type)); + return AddDeclaration(std::make_unique(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& constituents) { - auto op{ - std::make_unique(spv::Op::OpConstantComposite, bound, result_type)}; +Id Module::ConstantComposite(Id result_type, const std::vector& constituents) { + auto op{std::make_unique(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(spv::Op::OpConstantSampler, bound, result_type)}; + auto op{std::make_unique(spv::Op::OpConstantSampler, bound, result_type)}; op->Add(static_cast(addressing_mode)); op->Add(normalized ? 1 : 0); op->Add(static_cast(filter_mode)); @@ -49,8 +42,7 @@ Id Module::ConstantSampler(Id result_type, } Id Module::ConstantNull(Id result_type) { - return AddDeclaration( - std::make_unique(spv::Op::OpConstantNull, bound, result_type)); + return AddDeclaration(std::make_unique(spv::Op::OpConstantNull, bound, result_type)); } } // namespace Sirit diff --git a/src/instructions/conversion.cpp b/src/instructions/conversion.cpp index 3897742..fa80904 100644 --- a/src/instructions/conversion.cpp +++ b/src/instructions/conversion.cpp @@ -4,18 +4,18 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include namespace Sirit { -#define DEFINE_UNARY(opcode) \ - Id Module::opcode(Id result_type, Id operand) { \ - auto op{std::make_unique(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(spv::Op::opcode, bound++, result_type)}; \ + op->Add(operand); \ + return AddCode(std::move(op)); \ } DEFINE_UNARY(OpConvertFToU) diff --git a/src/instructions/debug.cpp b/src/instructions/debug.cpp index dba8a95..a2cc1c3 100644 --- a/src/instructions/debug.cpp +++ b/src/instructions/debug.cpp @@ -4,10 +4,10 @@ * Lesser General Public License version 3 or any later version. */ -#include "op.h" -#include "sirit/sirit.h" #include #include +#include "op.h" +#include "sirit/sirit.h" namespace Sirit { diff --git a/src/instructions/extension.cpp b/src/instructions/extension.cpp index 30b4bce..56d417b 100644 --- a/src/instructions/extension.cpp +++ b/src/instructions/extension.cpp @@ -4,16 +4,15 @@ * Lesser General Public License version 3 or any later version. */ +#include +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include -#include namespace Sirit { -Id Module::OpExtInst(Id result_type, Id set, u32 instruction, - const std::vector& operands) { +Id Module::OpExtInst(Id result_type, Id set, u32 instruction, const std::vector& operands) { auto op{std::make_unique(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) diff --git a/src/instructions/flow.cpp b/src/instructions/flow.cpp index 4c0036f..bdd0991 100644 --- a/src/instructions/flow.cpp +++ b/src/instructions/flow.cpp @@ -4,16 +4,15 @@ * Lesser General Public License version 3 or any later version. */ +#include +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include -#include 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& literals) { auto op{std::make_unique(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(spv::Op::OpSelectionMerge)}; op->Add(merge_block); op->Add(static_cast(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(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(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& literals, +Id Module::OpSwitch(Id selector, Id default_label, const std::vector& literals, const std::vector& 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(spv::Op::OpReturnValue)}; diff --git a/src/instructions/function.cpp b/src/instructions/function.cpp index 88974cc..c88f82f 100644 --- a/src/instructions/function.cpp +++ b/src/instructions/function.cpp @@ -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(spv::Op::OpFunction, bound++, result_type)}; op->Add(static_cast(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& arguments) { - auto op{ - std::make_unique(spv::Op::OpFunctionCall, bound++, result_type)}; +Id Module::OpFunctionCall(Id result_type, Id function, const std::vector& arguments) { + auto op{std::make_unique(spv::Op::OpFunctionCall, bound++, result_type)}; op->Add(function); op->Add(arguments); return AddCode(std::move(op)); diff --git a/src/instructions/image.cpp b/src/instructions/image.cpp index 1949d58..2b1d714 100644 --- a/src/instructions/image.cpp +++ b/src/instructions/image.cpp @@ -10,79 +10,77 @@ namespace Sirit { -static void -AddImageOperands(Op* op, std::optional image_operands, - const std::vector& operands) { +static void AddImageOperands(Op* op, std::optional image_operands, + const std::vector& operands) { if (!image_operands) return; op->Add(static_cast(*image_operands)); op->Add(operands); } -#define DEFINE_IMAGE_OP(opcode) \ - Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \ - std::optional image_operands, \ - const std::vector& operands) { \ - auto op{std::make_unique(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 image_operands, \ + const std::vector& operands) { \ + auto op{std::make_unique(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& operands) { \ - auto op{std::make_unique(spv::Op::opcode, bound++, result_type)}; \ - op->Add(sampled_image); \ - op->Add(coordinate); \ - op->Add(static_cast(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& operands) { \ + auto op{std::make_unique(spv::Op::opcode, bound++, result_type)}; \ + op->Add(sampled_image); \ + op->Add(coordinate); \ + op->Add(static_cast(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 image_operands, \ - const std::vector& operands) { \ - auto op{std::make_unique(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 image_operands, \ + const std::vector& operands) { \ + auto op{std::make_unique(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& operands) { \ - auto op{std::make_unique(spv::Op::opcode, bound++, result_type)}; \ - op->Add(sampled_image); \ - op->Add(coordinate); \ - op->Add(extra); \ - op->Add(static_cast(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& operands) { \ + auto op{std::make_unique(spv::Op::opcode, bound++, result_type)}; \ + op->Add(sampled_image); \ + op->Add(coordinate); \ + op->Add(extra); \ + op->Add(static_cast(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(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(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(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(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(spv::Op::OpSampledImage, bound++, result_type)}; + auto op{std::make_unique(spv::Op::OpSampledImage, bound++, result_type)}; op->Add(image); op->Add(sampler); return AddCode(std::move(op)); diff --git a/src/instructions/logical.cpp b/src/instructions/logical.cpp index 91c231f..4eb7e02 100644 --- a/src/instructions/logical.cpp +++ b/src/instructions/logical.cpp @@ -4,36 +4,35 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "common_types.h" #include "op.h" #include "sirit/sirit.h" -#include namespace Sirit { -#define DEFINE_UNARY(funcname, opcode) \ - Id Module::funcname(Id result_type, Id operand) { \ - auto op{std::make_unique(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(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(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(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(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(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) diff --git a/src/instructions/memory.cpp b/src/instructions/memory.cpp index c4a9201..f9eb9bb 100644 --- a/src/instructions/memory.cpp +++ b/src/instructions/memory.cpp @@ -4,14 +4,13 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "op.h" #include "sirit/sirit.h" -#include 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(spv::Op::OpVariable, bound++, result_type)}; op->Add(static_cast(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 memory_access) { +Id Module::OpLoad(Id result_type, Id pointer, std::optional memory_access) { auto op{std::make_unique(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 memory_access) { +Id Module::OpStore(Id pointer, Id object, std::optional memory_access) { auto op{std::make_unique(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& indexes) { +Id Module::OpAccessChain(Id result_type, Id base, const std::vector& indexes) { assert(indexes.size() > 0); auto op{std::make_unique(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& indexes) { - auto op{ - std::make_unique(spv::Op::OpCompositeInsert, bound++, result_type)}; + auto op{std::make_unique(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& indexes) { - auto op{std::make_unique(spv::Op::OpCompositeExtract, bound++, - result_type)}; +Id Module::OpCompositeExtract(Id result_type, Id composite, const std::vector& indexes) { + auto op{std::make_unique(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& ids) { assert(ids.size() >= 1); - auto op{std::make_unique(spv::Op::OpCompositeConstruct, bound++, - result_type)}; + auto op{std::make_unique(spv::Op::OpCompositeConstruct, bound++, result_type)}; op->Add(ids); return AddCode(std::move(op)); } diff --git a/src/instructions/misc.cpp b/src/instructions/misc.cpp index 81646cc..84defb3 100644 --- a/src/instructions/misc.cpp +++ b/src/instructions/misc.cpp @@ -4,9 +4,9 @@ * Lesser General Public License version 3 or any later version. */ +#include #include "op.h" #include "sirit/sirit.h" -#include namespace Sirit { diff --git a/src/instructions/type.cpp b/src/instructions/type.cpp index d769f0d..6cf76ca 100644 --- a/src/instructions/type.cpp +++ b/src/instructions/type.cpp @@ -4,8 +4,8 @@ * Lesser General Public License version 3 or any later version. */ -#include #include +#include #include #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 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 access_qualifier) { switch (dim) { case spv::Dim::Dim1D: AddCapability(spv::Capability::Sampled1D); diff --git a/src/literal_number.cpp b/src/literal_number.cpp index 689c01d..9a1b4c7 100644 --- a/src/literal_number.cpp +++ b/src/literal_number.cpp @@ -4,8 +4,8 @@ * Lesser General Public License version 3 or any later version. */ -#include "literal_number.h" #include +#include "literal_number.h" namespace Sirit { @@ -23,7 +23,9 @@ void LiteralNumber::Fetch(Stream& stream) const { } } -u16 LiteralNumber::GetWordCount() const { return is_32 ? 1 : 2; } +u16 LiteralNumber::GetWordCount() const { + return is_32 ? 1 : 2; +} bool LiteralNumber::operator==(const Operand& other) const { if (operand_type == other.GetType()) { diff --git a/src/literal_number.h b/src/literal_number.h index 5258f00..ba4a51a 100644 --- a/src/literal_number.h +++ b/src/literal_number.h @@ -6,15 +6,15 @@ #pragma once -#include "operand.h" -#include "stream.h" #include #include +#include "operand.h" +#include "stream.h" namespace Sirit { class LiteralNumber : public Operand { - public: +public: LiteralNumber(std::type_index type); ~LiteralNumber(); @@ -23,7 +23,8 @@ class LiteralNumber : public Operand { virtual bool operator==(const Operand& other) const; - template static LiteralNumber* Create(T value) { + template + static LiteralNumber* Create(T value) { static_assert(sizeof(T) == 4 || sizeof(T) == 8); LiteralNumber* number = new LiteralNumber(std::type_index(typeid(T))); @@ -32,7 +33,7 @@ class LiteralNumber : public Operand { return number; } - private: +private: std::type_index type; bool is_32{}; u64 raw{}; diff --git a/src/literal_string.cpp b/src/literal_string.cpp index 2ecb45c..3811697 100644 --- a/src/literal_string.cpp +++ b/src/literal_string.cpp @@ -4,9 +4,9 @@ * Lesser General Public License version 3 or any later version. */ -#include "literal_string.h" -#include "common_types.h" #include +#include "common_types.h" +#include "literal_string.h" namespace Sirit { diff --git a/src/literal_string.h b/src/literal_string.h index 9c9c69a..f922f5d 100644 --- a/src/literal_string.h +++ b/src/literal_string.h @@ -6,14 +6,14 @@ #pragma once +#include #include "operand.h" #include "stream.h" -#include namespace Sirit { class LiteralString : public Operand { - public: +public: LiteralString(const std::string& string); ~LiteralString(); @@ -22,7 +22,7 @@ class LiteralString : public Operand { virtual bool operator==(const Operand& other) const; - private: +private: const std::string string; }; diff --git a/src/op.cpp b/src/op.cpp index ca31710..ee383fe 100644 --- a/src/op.cpp +++ b/src/op.cpp @@ -26,7 +26,9 @@ void Op::Fetch(Stream& stream) const { stream.Write(id.value()); } -u16 Op::GetWordCount() const { return 1; } +u16 Op::GetWordCount() const { + return 1; +} bool Op::operator==(const Operand& other) const { if (operand_type != other.GetType()) { @@ -100,11 +102,17 @@ void Op::Add(const std::vector& literals) { } } -void Op::Add(const Operand* operand) { operands.push_back(operand); } +void Op::Add(const Operand* operand) { + operands.push_back(operand); +} -void Op::Add(u32 integer) { Sink(LiteralNumber::Create(integer)); } +void Op::Add(u32 integer) { + Sink(LiteralNumber::Create(integer)); +} -void Op::Add(const std::string& string) { Sink(new LiteralString(string)); } +void Op::Add(const std::string& string) { + Sink(new LiteralString(string)); +} void Op::Add(const std::vector& ids) { for (Id op : ids) { diff --git a/src/op.h b/src/op.h index 95f575b..246f82c 100644 --- a/src/op.h +++ b/src/op.h @@ -6,18 +6,17 @@ #pragma once +#include #include "common_types.h" #include "operand.h" #include "sirit/sirit.h" #include "stream.h" -#include namespace Sirit { class Op : public Operand { - public: - explicit Op(spv::Op opcode, std::optional id = {}, - Id result_type = nullptr); +public: + explicit Op(spv::Op opcode, std::optional id = {}, Id result_type = nullptr); ~Op(); virtual void Fetch(Stream& stream) const; @@ -43,7 +42,7 @@ class Op : public Operand { void Add(const std::vector& ids); - private: +private: u16 WordCount() const; spv::Op opcode; diff --git a/src/operand.cpp b/src/operand.cpp index 8a00e4e..127ae8e 100644 --- a/src/operand.cpp +++ b/src/operand.cpp @@ -4,8 +4,8 @@ * Lesser General Public License version 3 or any later version. */ -#include "operand.h" #include +#include "operand.h" namespace Sirit { @@ -22,12 +22,16 @@ u16 Operand::GetWordCount() const { return 0; } -bool Operand::operator==(const Operand& other) const { return false; } +bool Operand::operator==(const Operand& other) const { + return false; +} bool Operand::operator!=(const Operand& other) const { return !(*this == other); } -OperandType Operand::GetType() const { return operand_type; } +OperandType Operand::GetType() const { + return operand_type; +} } // namespace Sirit diff --git a/src/operand.h b/src/operand.h index ee84373..70ba810 100644 --- a/src/operand.h +++ b/src/operand.h @@ -13,7 +13,7 @@ namespace Sirit { enum class OperandType { Invalid, Op, Number, String }; class Operand { - public: +public: Operand(); virtual ~Operand(); @@ -25,7 +25,7 @@ class Operand { OperandType GetType() const; - protected: +protected: OperandType operand_type{}; }; diff --git a/src/sirit.cpp b/src/sirit.cpp index 9112a80..84e752b 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -4,16 +4,17 @@ * Lesser General Public License version 3 or any later version. */ -#include "sirit/sirit.h" -#include "common_types.h" -#include "op.h" -#include "stream.h" #include #include +#include "common_types.h" +#include "op.h" +#include "sirit/sirit.h" +#include "stream.h" namespace Sirit { -template static void WriteSet(Stream& stream, const T& set) { +template +static void WriteSet(Stream& stream, const T& set) { for (const auto& item : set) { item->Write(stream); } @@ -73,15 +74,13 @@ void Module::AddCapability(spv::Capability capability) { capabilities.insert(capability); } -void Module::SetMemoryModel(spv::AddressingModel addressing_model, - spv::MemoryModel memory_model) { +void Module::SetMemoryModel(spv::AddressingModel addressing_model, spv::MemoryModel memory_model) { this->addressing_model = addressing_model; this->memory_model = memory_model; } void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, - const std::string& name, - const std::vector& interfaces) { + const std::string& name, const std::vector& interfaces) { auto op{std::make_unique(spv::Op::OpEntryPoint)}; op->Add(static_cast(execution_model)); op->Add(entry_point); @@ -91,7 +90,7 @@ void Module::AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, } void Module::AddExecutionMode(Id entry_point, spv::ExecutionMode mode, - const std::vector& literals) { + const std::vector& literals) { auto op{std::make_unique(spv::Op::OpExecutionMode)}; op->Add(entry_point); op->Add(static_cast(mode)); @@ -121,9 +120,8 @@ Id Module::AddCode(spv::Op opcode, std::optional id) { } Id Module::AddDeclaration(std::unique_ptr op) { - const auto& found{ - std::find_if(declarations.begin(), declarations.end(), - [&op](const auto& other) { return *other == *op; })}; + const auto& found{std::find_if(declarations.begin(), declarations.end(), + [&op](const auto& other) { return *other == *op; })}; if (found != declarations.end()) { return found->get(); } diff --git a/src/stream.cpp b/src/stream.cpp index 6e4ac7e..aae5a9e 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -41,6 +41,8 @@ void Stream::Write(u16 value) { Write(mem[1]); } -void Stream::Write(u8 value) { bytes.push_back(value); } +void Stream::Write(u8 value) { + bytes.push_back(value); +} } // namespace Sirit diff --git a/src/stream.h b/src/stream.h index 4141033..20aa064 100644 --- a/src/stream.h +++ b/src/stream.h @@ -6,14 +6,14 @@ #pragma once -#include "common_types.h" #include #include +#include "common_types.h" namespace Sirit { class Stream { - public: +public: explicit Stream(std::vector& bytes); ~Stream(); @@ -27,7 +27,7 @@ class Stream { void Write(u8 value); - private: +private: std::vector& bytes; };