[compiler-rt] [AArch64][compiler-rt] Add LSE support for Windows. (PR #116706)
Daniel Kiss via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 14:38:33 PST 2024
https://github.com/DanielKristofKiss created https://github.com/llvm/llvm-project/pull/116706
None
>From 3a11a86ff9fb42ce83ad8a8fc86aabbcf4b08baf Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Mon, 18 Nov 2024 22:05:39 +0000
Subject: [PATCH] [AArch64] Add LSE support for Windows.
Change-Id: Ic639af3d799163fca829d6f37f830ccec63ab453
---
compiler-rt/lib/builtins/cpu_model/aarch64.c | 2 ++
.../cpu_model/aarch64/lse_atomics/windows.inc | 12 ++++++++++++
2 files changed, 14 insertions(+)
create mode 100644 compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/windows.inc
diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64.c b/compiler-rt/lib/builtins/cpu_model/aarch64.c
index def11f88c4854d..74e5e01b66c547 100644
--- a/compiler-rt/lib/builtins/cpu_model/aarch64.c
+++ b/compiler-rt/lib/builtins/cpu_model/aarch64.c
@@ -48,6 +48,8 @@ _Bool __aarch64_have_lse_atomics
#elif defined(__linux__) && __has_include(<sys/auxv.h>)
#include "aarch64/hwcap.inc"
#include "aarch64/lse_atomics/getauxval.inc"
+#elif defined(_WIN32)
+#include "aarch64/lse_atomics/windows.inc"
#else
// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false.
#endif
diff --git a/compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/windows.inc b/compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/windows.inc
new file mode 100644
index 00000000000000..da2e10d371b218
--- /dev/null
+++ b/compiler-rt/lib/builtins/cpu_model/aarch64/lse_atomics/windows.inc
@@ -0,0 +1,12 @@
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <processthreadsapi.h>
+
+#ifndef PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE
+#define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
+#endif
+
+static void CONSTRUCTOR_ATTRIBUTE init_have_lse_atomics(void) {
+ if(IsProcessorFeaturePresent(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE))
+ __aarch64_have_lse_atomics = true;
+}
More information about the llvm-commits
mailing list