diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-ir-specialize-matrix-layout.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-ir-specialize-matrix-layout.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize-matrix-layout.cpp | 58 |
1 files changed, 31 insertions, 27 deletions
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<IRMatrixType*>& typeWorkList, IRInst* parent) +void visitParent(List<IRMatrixType*>& typeWorkList, IRInst* parent) +{ + for (auto child : parent->getChildren()) { - for (auto child : parent->getChildren()) + if (auto matrixType = as<IRMatrixType>(child)) { - if (auto matrixType = as<IRMatrixType>(child)) + if (auto constLayout = as<IRIntLit>(matrixType->getLayout())) { - if (auto constLayout = as<IRIntLit>(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<IRMatrixType*> typeWorkList; - visitParent(typeWorkList, module->getModuleInst()); +void specializeMatrixLayout(TargetProgram* target, IRModule* module) +{ + List<IRMatrixType*> 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 |
