From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- source/slang/slang-ir-specialize-matrix-layout.cpp | 58 ++++++++++++---------- 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'source/slang/slang-ir-specialize-matrix-layout.cpp') diff --git a/source/slang/slang-ir-specialize-matrix-layout.cpp b/source/slang/slang-ir-specialize-matrix-layout.cpp index 8f6ca1b12..d1c768ea0 100644 --- a/source/slang/slang-ir-specialize-matrix-layout.cpp +++ b/source/slang/slang-ir-specialize-matrix-layout.cpp @@ -1,46 +1,50 @@ #include "slang-ir-specialize-matrix-layout.h" -#include "slang-ir.h" -#include "slang-ir-insts.h" + #include "slang-compiler.h" +#include "slang-ir-insts.h" +#include "slang-ir.h" namespace Slang { - void visitParent(List& typeWorkList, IRInst* parent) +void visitParent(List& typeWorkList, IRInst* parent) +{ + for (auto child : parent->getChildren()) { - for (auto child : parent->getChildren()) + if (auto matrixType = as(child)) { - if (auto matrixType = as(child)) + if (auto constLayout = as(matrixType->getLayout())) { - if (auto constLayout = as(matrixType->getLayout())) + if (constLayout->getValue() == SLANG_MATRIX_LAYOUT_MODE_UNKNOWN) { - if (constLayout->getValue() == SLANG_MATRIX_LAYOUT_MODE_UNKNOWN) - { - typeWorkList.add(matrixType); - } + typeWorkList.add(matrixType); } } - visitParent(typeWorkList, child); } + visitParent(typeWorkList, child); } +} - void specializeMatrixLayout(TargetProgram* target, IRModule* module) - { - List typeWorkList; - visitParent(typeWorkList, module->getModuleInst()); +void specializeMatrixLayout(TargetProgram* target, IRModule* module) +{ + List typeWorkList; + visitParent(typeWorkList, module->getModuleInst()); - IRIntegerValue defaultLayout = target->getOptionSet().getMatrixLayoutMode(); - if (defaultLayout == SLANG_MATRIX_LAYOUT_MODE_UNKNOWN) - defaultLayout = SLANG_MATRIX_LAYOUT_ROW_MAJOR; + IRIntegerValue defaultLayout = target->getOptionSet().getMatrixLayoutMode(); + if (defaultLayout == SLANG_MATRIX_LAYOUT_MODE_UNKNOWN) + defaultLayout = SLANG_MATRIX_LAYOUT_ROW_MAJOR; - IRBuilder builder(module); - for (auto matrixType : typeWorkList) - { - builder.setInsertBefore(matrixType); - auto replacementMatrixType = builder.getMatrixType(matrixType->getElementType(), matrixType->getRowCount(), matrixType->getColumnCount(), - builder.getIntValue(builder.getIntType(), defaultLayout)); - matrixType->replaceUsesWith(replacementMatrixType); - } + IRBuilder builder(module); + for (auto matrixType : typeWorkList) + { + builder.setInsertBefore(matrixType); + auto replacementMatrixType = builder.getMatrixType( + matrixType->getElementType(), + matrixType->getRowCount(), + matrixType->getColumnCount(), + builder.getIntValue(builder.getIntType(), defaultLayout)); + matrixType->replaceUsesWith(replacementMatrixType); } - } + +} // namespace Slang -- cgit v1.2.3