summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-cpp.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-09-15 14:22:59 -0700
committerGitHub <noreply@github.com>2022-09-15 14:22:59 -0700
commita6032446c6bf7f64d1e201bf438a4c7605a3dbb4 (patch)
treea95267c52155e13699ff9aab38ab68353d76939e /source/slang/slang-emit-cpp.cpp
parent05f9aaf6a4ef246dcf89b00000a8e59e90c47662 (diff)
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 <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
-rw-r--r--source/slang/slang-emit-cpp.cpp11
1 files changed, 11 insertions, 0 deletions
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