From 48203ea02250ba517f749a222092f091d9bef15e Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Fri, 9 May 2025 23:26:43 -0400 Subject: Fix SPIRV unsigned to signed widening casts (#7051) * Fix unsigned to signed casts for SPIRV * Add test * Fix ICE crash --- source/slang/slang-ir.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index a99eddebb..98c0fa471 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -7811,6 +7811,37 @@ IROp getIntTypeOpFromInfo(const IntInfo info) } } +IROp getOppositeSignIntTypeOp(IROp op) +{ + switch (op) + { + case kIROp_UInt8Type: + return kIROp_Int8Type; + case kIROp_UInt16Type: + return kIROp_Int16Type; + case kIROp_UIntType: + return kIROp_IntType; + case kIROp_UInt64Type: + return kIROp_Int64Type; + case kIROp_UIntPtrType: + return kIROp_IntPtrType; + + case kIROp_Int8Type: + return kIROp_UInt8Type; + case kIROp_Int16Type: + return kIROp_UInt16Type; + case kIROp_IntType: + return kIROp_UIntType; + case kIROp_Int64Type: + return kIROp_UInt64Type; + case kIROp_IntPtrType: + return kIROp_UIntPtrType; + + default: + SLANG_UNEXPECTED("Unhandled type passed to getOppositeSignIntTypeOp"); + } +} + FloatInfo getFloatingTypeInfo(const IRType* floatType) { switch (floatType->getOp()) -- cgit v1.2.3