From a6032446c6bf7f64d1e201bf438a4c7605a3dbb4 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 15 Sep 2022 14:22:59 -0700 Subject: Language feature: pointer sized int types. (#2401) * Language feature: pointer sized int types. * Fix. * small change to test. * Fix stdlib. * Fix. * Fix. * Add typedef for `size_t` in stdlib. * Fix test. * Add `intptr_t::size` constant. Co-authored-by: Yong He --- source/slang/slang-emit-spirv.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index fa0d92512..96ba89c55 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -708,7 +708,14 @@ struct SPIRVEmitContext return result; SpvWord valWord; memcpy(&valWord, &val, sizeof(SpvWord)); - if (type->getOp() == kIROp_Int64Type || type->getOp() == kIROp_UInt64Type) + switch (type->getOp()) + { + case kIROp_Int64Type: + case kIROp_UInt64Type: +#if SLANG_PTR_IS_64 + case kIROp_PtrType: + case kIROp_UIntPtrType: +#endif { SpvWord valHighWord; memcpy(&valHighWord, (char*)(&val) + 4, sizeof(SpvWord)); @@ -720,8 +727,9 @@ struct SPIRVEmitContext kResultID, valWord, valHighWord); + break; } - else + default: { result = emitInst( getSection(SpvLogicalSectionID::Constants), @@ -730,6 +738,8 @@ struct SPIRVEmitContext type, kResultID, valWord); + break; + } } m_spvIntConstants[key] = result; return result; @@ -1722,6 +1732,8 @@ struct SPIRVEmitContext { case BaseType::Int64: case BaseType::UInt64: + case BaseType::IntPtr: + case BaseType::UIntPtr: return emitInst( getSection(SpvLogicalSectionID::Constants), inst, -- cgit v1.2.3