summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorJulius Ikkala <julius.ikkala@gmail.com>2025-05-10 01:50:14 +0300
committerGitHub <noreply@github.com>2025-05-09 18:50:14 -0400
commit029672ee08f5ecb710e84cf1ccc625e826ff9a29 (patch)
treee5d9c263c2e26455bc3daa652173a6c1ab21ebf2 /source/slang
parentdbf05f8dca79d7bb166038652d968554d486c9fd (diff)
Fix various intptr_t issues by defining its width in `getIntTypeInfo` (#6786)
* Define a bit size for the intptr types * Fix intptr_t sign * Extend intptr test to check for previously broken operations * Fix intptr vector test on CUDA * Handle intptr size in getAnyValueSize * Fix formatting * Try with __ARM_ARCH_ISA_64 * On macs, int64_t != intptr_t Yikes * Move define to prelude header * Also check apple in host-prelude * Fix define location
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-emit-cuda.cpp12
-rw-r--r--source/slang/slang-ir-any-value-marshalling.cpp8
-rw-r--r--source/slang/slang-ir.cpp15
3 files changed, 32 insertions, 3 deletions
diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp
index 8657b3707..bb6941907 100644
--- a/source/slang/slang-emit-cuda.cpp
+++ b/source/slang/slang-emit-cuda.cpp
@@ -123,6 +123,18 @@ UnownedStringSlice CUDASourceEmitter::getVectorPrefix(IROp op)
case kIROp_UInt64Type:
return UnownedStringSlice("ulonglong");
+#if SLANG_PTR_IS_64
+ case kIROp_IntPtrType:
+ return UnownedStringSlice("longlong");
+ case kIROp_UIntPtrType:
+ return UnownedStringSlice("ulonglong");
+#else
+ case kIROp_IntPtrType:
+ return UnownedStringSlice("int");
+ case kIROp_UIntPtrType:
+ return UnownedStringSlice("uint");
+#endif
+
case kIROp_HalfType:
return UnownedStringSlice("__half");
diff --git a/source/slang/slang-ir-any-value-marshalling.cpp b/source/slang/slang-ir-any-value-marshalling.cpp
index b3bcf3316..9fb414db1 100644
--- a/source/slang/slang-ir-any-value-marshalling.cpp
+++ b/source/slang/slang-ir-any-value-marshalling.cpp
@@ -862,11 +862,19 @@ SlangInt _getAnyValueSizeRaw(IRType* type, SlangInt offset)
case kIROp_FloatType:
case kIROp_UIntType:
case kIROp_BoolType:
+#if SLANG_PTR_IS_32
+ case kIROp_IntPtrType:
+ case kIROp_UIntPtrType:
+#endif
return alignUp(offset, 4) + 4;
case kIROp_UInt64Type:
case kIROp_Int64Type:
case kIROp_DoubleType:
case kIROp_PtrType:
+#if SLANG_PTR_IS_64
+ case kIROp_IntPtrType:
+ case kIROp_UIntPtrType:
+#endif
return alignUp(offset, 8) + 8;
case kIROp_Int16Type:
case kIROp_UInt16Type:
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index c1cec36fe..a99eddebb 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -7769,6 +7769,12 @@ IntInfo getIntTypeInfo(const IRType* intType)
return {32, false};
case kIROp_UInt64Type:
return {64, false};
+ case kIROp_UIntPtrType:
+#if SLANG_PTR_IS_32
+ return {32, false};
+#else
+ return {64, false};
+#endif
case kIROp_Int8Type:
return {8, true};
case kIROp_Int16Type:
@@ -7777,9 +7783,12 @@ IntInfo getIntTypeInfo(const IRType* intType)
return {32, true};
case kIROp_Int64Type:
return {64, true};
-
- case kIROp_IntPtrType: // target platform dependent
- case kIROp_UIntPtrType: // target platform dependent
+ case kIROp_IntPtrType:
+#if SLANG_PTR_IS_32
+ return {32, true};
+#else
+ return {64, true};
+#endif
default:
SLANG_UNEXPECTED("Unhandled type passed to getIntTypeInfo");
}