From 029672ee08f5ecb710e84cf1ccc625e826ff9a29 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Sat, 10 May 2025 01:50:14 +0300 Subject: 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 --- prelude/slang-cpp-host-prelude.h | 7 +++++++ prelude/slang-cpp-prelude.h | 7 +++++++ prelude/slang-cpp-types-core.h | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) (limited to 'prelude') diff --git a/prelude/slang-cpp-host-prelude.h b/prelude/slang-cpp-host-prelude.h index 8bc0f5cad..66f74052c 100644 --- a/prelude/slang-cpp-host-prelude.h +++ b/prelude/slang-cpp-host-prelude.h @@ -28,6 +28,13 @@ #include #endif // SLANG_LLVM +// Is intptr_t not equal to equal-width sized integer type? +#if defined(__APPLE__) +#define SLANG_INTPTR_TYPE_IS_DISTINCT 1 +#else +#define SLANG_INTPTR_TYPE_IS_DISTINCT 0 +#endif + #if defined(_MSC_VER) #define SLANG_PRELUDE_SHARED_LIB_EXPORT __declspec(dllexport) #else diff --git a/prelude/slang-cpp-prelude.h b/prelude/slang-cpp-prelude.h index 4dacac9c5..6530654c1 100644 --- a/prelude/slang-cpp-prelude.h +++ b/prelude/slang-cpp-prelude.h @@ -22,6 +22,13 @@ #include #endif // SLANG_LLVM +// Is intptr_t not equal to equal-width sized integer type? +#if defined(__APPLE__) +#define SLANG_INTPTR_TYPE_IS_DISTINCT 1 +#else +#define SLANG_INTPTR_TYPE_IS_DISTINCT 0 +#endif + #if defined(_MSC_VER) #define SLANG_PRELUDE_SHARED_LIB_EXPORT __declspec(dllexport) #else diff --git a/prelude/slang-cpp-types-core.h b/prelude/slang-cpp-types-core.h index 82674fefb..5f2024ac7 100644 --- a/prelude/slang-cpp-types-core.h +++ b/prelude/slang-cpp-types-core.h @@ -346,6 +346,10 @@ SLANG_INT_VECTOR_OPS(uint) SLANG_INT_VECTOR_OPS(uint8_t) SLANG_INT_VECTOR_OPS(uint16_t) SLANG_INT_VECTOR_OPS(uint64_t) +#if SLANG_INTPTR_TYPE_IS_DISTINCT +SLANG_INT_VECTOR_OPS(intptr_t) +SLANG_INT_VECTOR_OPS(uintptr_t) +#endif SLANG_FLOAT_VECTOR_OPS(float) SLANG_FLOAT_VECTOR_OPS(double) @@ -367,6 +371,10 @@ SLANG_VECTOR_INT_NEG_OP(uint) SLANG_VECTOR_INT_NEG_OP(uint8_t) SLANG_VECTOR_INT_NEG_OP(uint16_t) SLANG_VECTOR_INT_NEG_OP(uint64_t) +#if SLANG_INTPTR_TYPE_IS_DISTINCT +SLANG_VECTOR_INT_NEG_OP(intptr_t) +SLANG_VECTOR_INT_NEG_OP(uintptr_t) +#endif #define SLANG_FLOAT_VECTOR_MOD(T) \ template \ @@ -643,6 +651,10 @@ SLANG_INT_MATRIX_OPS(uint) SLANG_INT_MATRIX_OPS(uint8_t) SLANG_INT_MATRIX_OPS(uint16_t) SLANG_INT_MATRIX_OPS(uint64_t) +#if SLANG_INTPTR_TYPE_IS_DISTINCT +SLANG_INT_MATRIX_OPS(intptr_t) +SLANG_INT_MATRIX_OPS(uintptr_t) +#endif SLANG_FLOAT_MATRIX_OPS(float) SLANG_FLOAT_MATRIX_OPS(double) @@ -665,6 +677,10 @@ SLANG_MATRIX_INT_NEG_OP(uint) SLANG_MATRIX_INT_NEG_OP(uint8_t) SLANG_MATRIX_INT_NEG_OP(uint16_t) SLANG_MATRIX_INT_NEG_OP(uint64_t) +#if SLANG_INTPTR_TYPE_IS_DISTINCT +SLANG_MATRIX_INT_NEG_OP(intptr_t) +SLANG_MATRIX_INT_NEG_OP(uintptr_t) +#endif #define SLANG_FLOAT_MATRIX_MOD(T) \ template \ -- cgit v1.2.3