From a2401a6ae6c50aeb6ffc196144569bb5253cdf95 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 12 Feb 2021 12:20:17 -0800 Subject: Support `bit_cast` between complex types. (#1702) * Support `bit_cast` between complex types. * Fix vs project file * Fix clang build error * fix * fix * Fix * FIx * Fix * Fix * Fix * Fix * Fix linux compile error Co-authored-by: Tim Foley --- source/slang/slang-ir-layout.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source/slang/slang-ir-layout.cpp') diff --git a/source/slang/slang-ir-layout.cpp b/source/slang/slang-ir-layout.cpp index 41b004372..ed3fff2c0 100644 --- a/source/slang/slang-ir-layout.cpp +++ b/source/slang/slang-ir-layout.cpp @@ -77,6 +77,12 @@ static Result _calcNaturalArraySizeAndAlignment( return SLANG_OK; } +IRIntegerValue getIntegerValueFromInst(IRInst* inst) +{ + SLANG_ASSERT(inst->op == kIROp_IntLit); + return as(inst)->value.intVal; +} + static Result _calcNaturalSizeAndAlignment( TargetRequest* target, IRType* type, @@ -192,6 +198,24 @@ static Result _calcNaturalSizeAndAlignment( } break; + case kIROp_MatrixType: + { + auto matType = cast(type); + auto rowCount = getIntegerValueFromInst(matType->getRowCount()); + auto colCount = getIntegerValueFromInst(matType->getColumnCount()); + SharedIRBuilder sharedBuilder; + sharedBuilder.module = type->getModule(); + sharedBuilder.session = sharedBuilder.module->getSession(); + + IRBuilder builder; + builder.sharedBuilder = &sharedBuilder; + + return _calcNaturalArraySizeAndAlignment( + target, matType->getElementType(), + builder.getIntValue(builder.getUIntType(), rowCount * colCount), + outSizeAndAlignment); + } + break; default: break; } -- cgit v1.2.3