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-cpp.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/slang/slang-emit-cpp.cpp') diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 9c1573bf8..bc145dca1 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -97,6 +97,8 @@ static IROp _getTypeStyle(IROp op) case kIROp_UIntType: case kIROp_Int64Type: case kIROp_UInt64Type: + case kIROp_IntPtrType: + case kIROp_UIntPtrType: { // All int like return kIROp_IntType; @@ -131,6 +133,11 @@ static IROp _getCType(IROp op) // Promote all these to Int return kIROp_IntType; } + case kIROp_IntPtrType: + case kIROp_UIntPtrType: + { + return kIROp_IntPtrType; + } case kIROp_Int64Type: case kIROp_UInt64Type: { @@ -165,6 +172,8 @@ static UnownedStringSlice _getCTypeVecPostFix(IROp op) case kIROp_FloatType: return UnownedStringSlice::fromLiteral("F"); case kIROp_Int64Type: return UnownedStringSlice::fromLiteral("I64"); case kIROp_DoubleType: return UnownedStringSlice::fromLiteral("F64"); + case kIROp_IntPtrType: return UnownedStringSlice::fromLiteral(""); + case kIROp_UIntPtrType: return UnownedStringSlice::fromLiteral(""); default: return UnownedStringSlice::fromLiteral("?"); } } @@ -207,11 +216,13 @@ static bool _isCppOrCudaTarget(CodeGenTarget target) case kIROp_Int16Type: return UnownedStringSlice("int16_t"); case kIROp_IntType: return UnownedStringSlice("int32_t"); case kIROp_Int64Type: return UnownedStringSlice("int64_t"); + case kIROp_IntPtrType: return UnownedStringSlice("intptr_t"); case kIROp_UInt8Type: return UnownedStringSlice("uint8_t"); case kIROp_UInt16Type: return UnownedStringSlice("uint16_t"); case kIROp_UIntType: return UnownedStringSlice("uint32_t"); case kIROp_UInt64Type: return UnownedStringSlice("uint64_t"); + case kIROp_UIntPtrType: return UnownedStringSlice("uintptr_t"); // Not clear just yet how we should handle half... we want all processing as float probly, but when reading/writing to memory converting -- cgit v1.2.3