Add LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T

This commit is contained in:
Matt Arsenault 2025-08-05 02:13:23 +09:00 committed by Matt Arsenault
parent 985a510a8c
commit 49f4496de2
3 changed files with 25 additions and 3 deletions

View File

@ -537,18 +537,24 @@ if( LLVM_NATIVE_ARCH STREQUAL "host" )
string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOST_TRIPLE}) string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOST_TRIPLE})
endif () endif ()
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 8)
if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86") if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86")
set(LLVM_NATIVE_ARCH X86) set(LLVM_NATIVE_ARCH X86)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH STREQUAL "x86") elseif (LLVM_NATIVE_ARCH STREQUAL "x86")
set(LLVM_NATIVE_ARCH X86) set(LLVM_NATIVE_ARCH X86)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH STREQUAL "amd64") elseif (LLVM_NATIVE_ARCH STREQUAL "amd64")
set(LLVM_NATIVE_ARCH X86) set(LLVM_NATIVE_ARCH X86)
elseif (LLVM_NATIVE_ARCH STREQUAL "x86_64") elseif (LLVM_NATIVE_ARCH STREQUAL "x86_64")
set(LLVM_NATIVE_ARCH X86) set(LLVM_NATIVE_ARCH X86)
elseif (LLVM_NATIVE_ARCH MATCHES "sparc") elseif (LLVM_NATIVE_ARCH MATCHES "sparc")
set(LLVM_NATIVE_ARCH Sparc) set(LLVM_NATIVE_ARCH Sparc)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "powerpc") elseif (LLVM_NATIVE_ARCH MATCHES "powerpc")
set(LLVM_NATIVE_ARCH PowerPC) set(LLVM_NATIVE_ARCH PowerPC)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "ppc64le") elseif (LLVM_NATIVE_ARCH MATCHES "ppc64le")
set(LLVM_NATIVE_ARCH PowerPC) set(LLVM_NATIVE_ARCH PowerPC)
elseif (LLVM_NATIVE_ARCH MATCHES "aarch64") elseif (LLVM_NATIVE_ARCH MATCHES "aarch64")
@ -557,29 +563,41 @@ elseif (LLVM_NATIVE_ARCH MATCHES "arm64")
set(LLVM_NATIVE_ARCH AArch64) set(LLVM_NATIVE_ARCH AArch64)
elseif (LLVM_NATIVE_ARCH MATCHES "arm") elseif (LLVM_NATIVE_ARCH MATCHES "arm")
set(LLVM_NATIVE_ARCH ARM) set(LLVM_NATIVE_ARCH ARM)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "avr") elseif (LLVM_NATIVE_ARCH MATCHES "avr")
set(LLVM_NATIVE_ARCH AVR) set(LLVM_NATIVE_ARCH AVR)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 2)
elseif (LLVM_NATIVE_ARCH MATCHES "mips") elseif (LLVM_NATIVE_ARCH MATCHES "mips")
set(LLVM_NATIVE_ARCH Mips) set(LLVM_NATIVE_ARCH Mips)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "xcore") elseif (LLVM_NATIVE_ARCH MATCHES "xcore")
set(LLVM_NATIVE_ARCH XCore) set(LLVM_NATIVE_ARCH XCore)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "msp430") elseif (LLVM_NATIVE_ARCH MATCHES "msp430")
set(LLVM_NATIVE_ARCH MSP430) set(LLVM_NATIVE_ARCH MSP430)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 2)
elseif (LLVM_NATIVE_ARCH MATCHES "hexagon") elseif (LLVM_NATIVE_ARCH MATCHES "hexagon")
set(LLVM_NATIVE_ARCH Hexagon) set(LLVM_NATIVE_ARCH Hexagon)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "s390x") elseif (LLVM_NATIVE_ARCH MATCHES "s390x")
set(LLVM_NATIVE_ARCH SystemZ) set(LLVM_NATIVE_ARCH SystemZ)
elseif (LLVM_NATIVE_ARCH MATCHES "wasm32") elseif (LLVM_NATIVE_ARCH MATCHES "wasm32")
set(LLVM_NATIVE_ARCH WebAssembly) set(LLVM_NATIVE_ARCH WebAssembly)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "wasm64") elseif (LLVM_NATIVE_ARCH MATCHES "wasm64")
set(LLVM_NATIVE_ARCH WebAssembly) set(LLVM_NATIVE_ARCH WebAssembly)
elseif (LLVM_NATIVE_ARCH MATCHES "riscv32") elseif (LLVM_NATIVE_ARCH MATCHES "riscv32")
set(LLVM_NATIVE_ARCH RISCV) set(LLVM_NATIVE_ARCH RISCV)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "riscv64") elseif (LLVM_NATIVE_ARCH MATCHES "riscv64")
set(LLVM_NATIVE_ARCH RISCV) set(LLVM_NATIVE_ARCH RISCV)
elseif (LLVM_NATIVE_ARCH STREQUAL "m68k") elseif (LLVM_NATIVE_ARCH STREQUAL "m68k")
set(LLVM_NATIVE_ARCH M68k) set(LLVM_NATIVE_ARCH M68k)
elseif (LLVM_NATIVE_ARCH MATCHES "loongarch") set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "loongarch32")
set(LLVM_NATIVE_ARCH LoongArch)
set(LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T 4)
elseif (LLVM_NATIVE_ARCH MATCHES "loongarch64")
set(LLVM_NATIVE_ARCH LoongArch) set(LLVM_NATIVE_ARCH LoongArch)
else () else ()
message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}") message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}")

View File

@ -33,6 +33,9 @@
/* LLVM architecture name for the native architecture, if available */ /* LLVM architecture name for the native architecture, if available */
#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} #cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}
/* sizeof(uintptr_t) name for the native architecture, if available */
#cmakedefine LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T ${LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T}
/* LLVM name for the native AsmParser init function, if available */ /* LLVM name for the native AsmParser init function, if available */
#cmakedefine LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser #cmakedefine LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser

View File

@ -606,7 +606,8 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
PredicateSorter.insert( PredicateSorter.insert(
PredicateWithCC()); // No predicate or CC override first. PredicateWithCC()); // No predicate or CC override first.
constexpr unsigned BitsPerStorageElt = sizeof(uintptr_t) * CHAR_BIT; constexpr unsigned BitsPerStorageElt =
LLVM_NATIVE_ARCH_SIZEOF_UINTPTR_T * CHAR_BIT;
DenseMap<PredicateWithCC, LibcallsWithCC> Pred2Funcs; DenseMap<PredicateWithCC, LibcallsWithCC> Pred2Funcs;
@ -622,7 +623,7 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
} }
size_t BitIdx = LibCallImpl->getEnumVal(); size_t BitIdx = LibCallImpl->getEnumVal();
uintptr_t BitmaskVal = uintptr_t(1) << (BitIdx % BitsPerStorageElt); uint64_t BitmaskVal = uint64_t(1) << (BitIdx % BitsPerStorageElt);
size_t BitsetIdx = BitIdx / BitsPerStorageElt; size_t BitsetIdx = BitIdx / BitsPerStorageElt;
auto It = Func2Preds.find(LibCallImpl); auto It = Func2Preds.find(LibCallImpl);