···
1
+
From 4fe3f21bf8b20c766877d2251d61118d0ff36688 Mon Sep 17 00:00:00 2001
2
+
From: Ben Wolsieffer <benwolsieffer@gmail.com>
3
+
Date: Wed, 7 Dec 2022 14:56:51 -0500
4
+
Subject: [PATCH] [compiler-rt][builtins] Do not use ldrexd or strexd on ARMv6
6
+
The ldrexd and strexd instructions are not available on base ARMv6, and were
7
+
only added in ARMv6K (see [1]). This patch solves this problem once and for all
8
+
using the __ARM_FEATURE_LDREX macro (see [2]) defined in the ARM C Language
9
+
Extensions (ACLE). Although this macro is technically deprecated in the ACLE,
10
+
it allows compiler-rt to reliably detect whether ldrexd and strexd are supported
11
+
without complicated conditionals to detect different ARM architecture variants.
13
+
[1] https://developer.arm.com/documentation/dht0008/a/ch01s02s01
14
+
[2] https://arm-software.github.io/acle/main/acle.html#ldrexstrex
16
+
Differential Revision: https://reviews.llvm.org/D139585
18
+
compiler-rt/lib/builtins/arm/sync_fetch_and_add_8.S | 2 +-
19
+
compiler-rt/lib/builtins/arm/sync_fetch_and_and_8.S | 2 +-
20
+
compiler-rt/lib/builtins/arm/sync_fetch_and_max_8.S | 2 +-
21
+
compiler-rt/lib/builtins/arm/sync_fetch_and_min_8.S | 2 +-
22
+
compiler-rt/lib/builtins/arm/sync_fetch_and_nand_8.S | 2 +-
23
+
compiler-rt/lib/builtins/arm/sync_fetch_and_or_8.S | 2 +-
24
+
compiler-rt/lib/builtins/arm/sync_fetch_and_sub_8.S | 2 +-
25
+
compiler-rt/lib/builtins/arm/sync_fetch_and_umax_8.S | 2 +-
26
+
compiler-rt/lib/builtins/arm/sync_fetch_and_umin_8.S | 2 +-
27
+
compiler-rt/lib/builtins/arm/sync_fetch_and_xor_8.S | 2 +-
28
+
10 files changed, 10 insertions(+), 10 deletions(-)
30
+
diff --git a/lib/builtins/arm/sync_fetch_and_add_8.S b/lib/builtins/arm/sync_fetch_and_add_8.S
31
+
index 18bdd875b8b7..bee6f7ba0f34 100644
32
+
--- a/lib/builtins/arm/sync_fetch_and_add_8.S
33
+
+++ b/lib/builtins/arm/sync_fetch_and_add_8.S
36
+
#include "sync-ops.h"
38
+
-#if __ARM_ARCH_PROFILE != 'M'
39
+
+#if __ARM_FEATURE_LDREX & 8
40
+
#define add_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
41
+
adds rD_LO, rN_LO, rM_LO ; \
42
+
adc rD_HI, rN_HI, rM_HI
43
+
diff --git a/lib/builtins/arm/sync_fetch_and_and_8.S b/lib/builtins/arm/sync_fetch_and_and_8.S
44
+
index 3716eff809d5..b4e77a54edf6 100644
45
+
--- a/lib/builtins/arm/sync_fetch_and_and_8.S
46
+
+++ b/lib/builtins/arm/sync_fetch_and_and_8.S
49
+
#include "sync-ops.h"
51
+
-#if __ARM_ARCH_PROFILE != 'M'
52
+
+#if __ARM_FEATURE_LDREX & 8
53
+
#define and_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
54
+
and rD_LO, rN_LO, rM_LO ; \
55
+
and rD_HI, rN_HI, rM_HI
56
+
diff --git a/lib/builtins/arm/sync_fetch_and_max_8.S b/lib/builtins/arm/sync_fetch_and_max_8.S
57
+
index 06115ab55246..1813274cc649 100644
58
+
--- a/lib/builtins/arm/sync_fetch_and_max_8.S
59
+
+++ b/lib/builtins/arm/sync_fetch_and_max_8.S
62
+
#include "sync-ops.h"
64
+
-#if __ARM_ARCH_PROFILE != 'M'
65
+
+#if __ARM_FEATURE_LDREX & 8
66
+
#define max_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, gt)
69
+
diff --git a/lib/builtins/arm/sync_fetch_and_min_8.S b/lib/builtins/arm/sync_fetch_and_min_8.S
70
+
index 4f3e299d95cc..fa8f3477757b 100644
71
+
--- a/lib/builtins/arm/sync_fetch_and_min_8.S
72
+
+++ b/lib/builtins/arm/sync_fetch_and_min_8.S
75
+
#include "sync-ops.h"
77
+
-#if __ARM_ARCH_PROFILE != 'M'
78
+
+#if __ARM_FEATURE_LDREX & 8
79
+
#define min_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, lt)
82
+
diff --git a/lib/builtins/arm/sync_fetch_and_nand_8.S b/lib/builtins/arm/sync_fetch_and_nand_8.S
83
+
index 425c94474af7..fb27219ee200 100644
84
+
--- a/lib/builtins/arm/sync_fetch_and_nand_8.S
85
+
+++ b/lib/builtins/arm/sync_fetch_and_nand_8.S
88
+
#include "sync-ops.h"
90
+
-#if __ARM_ARCH_PROFILE != 'M'
91
+
+#if __ARM_FEATURE_LDREX & 8
92
+
#define nand_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
93
+
bic rD_LO, rN_LO, rM_LO ; \
94
+
bic rD_HI, rN_HI, rM_HI
95
+
diff --git a/lib/builtins/arm/sync_fetch_and_or_8.S b/lib/builtins/arm/sync_fetch_and_or_8.S
96
+
index 4f18dcf84df9..3b077c8737b1 100644
97
+
--- a/lib/builtins/arm/sync_fetch_and_or_8.S
98
+
+++ b/lib/builtins/arm/sync_fetch_and_or_8.S
101
+
#include "sync-ops.h"
103
+
-#if __ARM_ARCH_PROFILE != 'M'
104
+
+#if __ARM_FEATURE_LDREX & 8
105
+
#define or_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
106
+
orr rD_LO, rN_LO, rM_LO ; \
107
+
orr rD_HI, rN_HI, rM_HI
108
+
diff --git a/lib/builtins/arm/sync_fetch_and_sub_8.S b/lib/builtins/arm/sync_fetch_and_sub_8.S
109
+
index 25a4a1076555..c171607eabd8 100644
110
+
--- a/lib/builtins/arm/sync_fetch_and_sub_8.S
111
+
+++ b/lib/builtins/arm/sync_fetch_and_sub_8.S
114
+
#include "sync-ops.h"
116
+
-#if __ARM_ARCH_PROFILE != 'M'
117
+
+#if __ARM_FEATURE_LDREX & 8
118
+
#define sub_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
119
+
subs rD_LO, rN_LO, rM_LO ; \
120
+
sbc rD_HI, rN_HI, rM_HI
121
+
diff --git a/lib/builtins/arm/sync_fetch_and_umax_8.S b/lib/builtins/arm/sync_fetch_and_umax_8.S
122
+
index aa5213ff1def..d1224f758049 100644
123
+
--- a/lib/builtins/arm/sync_fetch_and_umax_8.S
124
+
+++ b/lib/builtins/arm/sync_fetch_and_umax_8.S
127
+
#include "sync-ops.h"
129
+
-#if __ARM_ARCH_PROFILE != 'M'
130
+
+#if __ARM_FEATURE_LDREX & 8
131
+
#define umax_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, hi)
134
+
diff --git a/lib/builtins/arm/sync_fetch_and_umin_8.S b/lib/builtins/arm/sync_fetch_and_umin_8.S
135
+
index 8b40541ab47d..595444e6d053 100644
136
+
--- a/lib/builtins/arm/sync_fetch_and_umin_8.S
137
+
+++ b/lib/builtins/arm/sync_fetch_and_umin_8.S
140
+
#include "sync-ops.h"
142
+
-#if __ARM_ARCH_PROFILE != 'M'
143
+
+#if __ARM_FEATURE_LDREX & 8
144
+
#define umin_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, lo)
147
+
diff --git a/lib/builtins/arm/sync_fetch_and_xor_8.S b/lib/builtins/arm/sync_fetch_and_xor_8.S
148
+
index 7436eb1d4cae..9fc3d85cef75 100644
149
+
--- a/lib/builtins/arm/sync_fetch_and_xor_8.S
150
+
+++ b/lib/builtins/arm/sync_fetch_and_xor_8.S
153
+
#include "sync-ops.h"
155
+
-#if __ARM_ARCH_PROFILE != 'M'
156
+
+#if __ARM_FEATURE_LDREX & 8
157
+
#define xor_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \
158
+
eor rD_LO, rN_LO, rM_LO ; \
159
+
eor rD_HI, rN_HI, rM_HI