summaryrefslogtreecommitdiff
path: root/0001-compiler-rt-Support-HARDCODE_NO_LSE-to-disable-lse-a.patch
blob: baac454cd290f1955d1a6e9019447e3d633f9c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
From 8ed31fc5c8722d5f94a90e28cdc8d99fd66f943e Mon Sep 17 00:00:00 2001
From: eshiner <zengfuliangjx@sina.cn>
Date: Tue, 23 Sep 2025 17:27:15 +0800
Subject: [PATCH] [compiler-rt] Support HARDCODE_NO_LSE to disable lse atomic

Currently in compiler-rt, using dynamic detect for LSE support.
But for some soc/ship, there was something wrong with LSE atomic
instructions, so we need DISBALE it by HARDCODE.

Signed-off-by: eshiner <zengfuliangjx@sina.cn>
---
 .../compiler-rt/lib/builtins/aarch64/lse.S      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S b/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S
index 1fe18f4..31577a4 100644
--- a/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S
+++ b/src/llvm-project/compiler-rt/lib/builtins/aarch64/lse.S
@@ -129,6 +129,7 @@ HIDDEN(___aarch64_have_lse_atomics)
 #define tmp1 17
 #define tmp2 15
 
+#ifndef HARDCODED_NO_LSE
 // Macro for branch to label if no LSE available
 .macro JUMP_IF_NOT_LSE label
 #if !defined(__APPLE__)
@@ -140,11 +141,15 @@ HIDDEN(___aarch64_have_lse_atomics)
 #endif
         cbz     w(tmp0), \label
 .endm
+#endif // HARDCODED_NO_LSE
 
 #ifdef L_cas
 DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
+#ifndef HARDCODED_NO_LSE
         JUMP_IF_NOT_LSE 8f
+#endif // HARDCODED_NO_LSE
 #if SIZE < 16
+#ifndef HARDCODED_NO_LSE
 #ifdef HAS_ASM_LSE
 #define CAS GLUE4(cas, A, L, S) s(0), s(1), [x2]
 #else
@@ -153,6 +158,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
         CAS    // s(0), s(1), [x2]
         ret
 8:
+#endif // HARDCODED_NO_LSE
+        mov    s(tmp0), s(0)
         UXT    s(tmp0), s(0)
 0:
         LDXR   s(0), [x2]
@@ -171,6 +178,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
 #define LDXP GLUE3(ld, A, xp)
 #endif
 #define STXP GLUE3(st, L, xp)
+#ifndef HARDCODED_NO_LSE
 #ifdef HAS_ASM_LSE
 #define CASP GLUE3(casp, A, L)  x0, x1, x2, x3, [x4]
 #else
@@ -180,6 +188,7 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(cas))
         CASP   // x0, x1, x2, x3, [x4]
         ret
 8:
+#endif // HARDCODED_NO_LSE
         mov    x(tmp0), x0
         mov    x(tmp1), x1
 0:
@@ -197,16 +206,20 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(cas))
 #endif // L_cas
 
 #ifdef L_swp
+#ifndef HARDCODED_NO_LSE
 #ifdef HAS_ASM_LSE
 #define SWP GLUE4(swp, A, L, S)  s(0), s(0), [x1]
 #else
 #define SWP .inst 0x38208020 + B + N
 #endif
+#endif // HARDCODED_NO_LSE
 DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(swp))
+#ifndef HARDCODED_NO_LSE
         JUMP_IF_NOT_LSE 8f
         SWP    // s(0), s(0), [x1]
         ret
 8:
+#endif // HARDCODED_NO_LSE
         mov    s(tmp0), s(0)
 0:
         LDXR   s(0), [x1]
@@ -240,17 +253,21 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(swp))
 #error
 #endif
 
+#ifndef HARDCODED_NO_LSE
 #ifdef HAS_ASM_LSE
 #define LDOP GLUE4(LDNM, A, L, S) s(0), s(0), [x1]
 #else
 #define LDOP .inst 0x38200020 + OPN + B + N
 #endif
+#endif // HARDCODED_NO_LSE
 
 DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(NAME(LDNM))
+#ifndef HARDCODED_NO_LSE
         JUMP_IF_NOT_LSE 8f
         LDOP // s(0), s(0), [x1]
         ret
 8:
+#endif // HARDCODED_NO_LSE
         mov    s(tmp0), s(0)
 0:
         LDXR   s(0), [x1]
-- 
2.51.0.windows.1