diff options
| author | Julius Ikkala <julius.ikkala@gmail.com> | 2025-05-10 01:50:14 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-09 18:50:14 -0400 |
| commit | 029672ee08f5ecb710e84cf1ccc625e826ff9a29 (patch) | |
| tree | e5d9c263c2e26455bc3daa652173a6c1ab21ebf2 /prelude | |
| parent | dbf05f8dca79d7bb166038652d968554d486c9fd (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 'prelude')
| -rw-r--r-- | prelude/slang-cpp-host-prelude.h | 7 | ||||
| -rw-r--r-- | prelude/slang-cpp-prelude.h | 7 | ||||
| -rw-r--r-- | prelude/slang-cpp-types-core.h | 16 |
3 files changed, 30 insertions, 0 deletions
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 <string.h> #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 <string.h> #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<int N> \ @@ -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<int R, int C> \ |
