1 /* Copyright (C) 2022-2023 Free Software Foundation, Inc.
3 This file is part of the GNU Atomic Library (libatomic).
5 Libatomic is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
30 .type name,%function; \
73 ENTRY (libat_load_16_i1)
87 END (libat_load_16_i1)
90 ENTRY (libat_store_16_i1)
103 END (libat_store_16_i1)
106 ENTRY (libat_exchange_16_i1)
110 ldxp res0, res1, [x5]
111 stxp w4, in0, in1, [x5]
118 ldaxp res0, res1, [x5]
119 stxp w4, in0, in1, [x5]
126 ldxp res0, res1, [x5]
127 stlxp w4, in0, in1, [x5]
131 ldaxp res0, res1, [x5]
132 stlxp w4, in0, in1, [x5]
135 END (libat_exchange_16_i1)
138 ENTRY (libat_compare_exchange_16_i1)
145 caspa exp0, exp1, in0, in1, [x0]
148 ccmp exp1, tmp1, 0, eq
157 casp exp0, exp1, in0, in1, [x0]
161 caspl exp0, exp1, in0, in1, [x0]
164 caspal exp0, exp1, in0, in1, [x0]
166 END (libat_compare_exchange_16_i1)
169 ENTRY (libat_fetch_add_16_i1)
173 ldxp res0, res1, [x5]
174 adds tmplo, reslo, inlo
175 adc tmphi, reshi, inhi
176 stxp w4, tmp0, tmp1, [x5]
180 ldaxp res0, res1, [x5]
181 adds tmplo, reslo, inlo
182 adc tmphi, reshi, inhi
183 stlxp w4, tmp0, tmp1, [x5]
186 END (libat_fetch_add_16_i1)
189 ENTRY (libat_add_fetch_16_i1)
193 ldxp res0, res1, [x5]
194 adds reslo, reslo, inlo
195 adc reshi, reshi, inhi
196 stxp w4, res0, res1, [x5]
200 ldaxp res0, res1, [x5]
201 adds reslo, reslo, inlo
202 adc reshi, reshi, inhi
203 stlxp w4, res0, res1, [x5]
206 END (libat_add_fetch_16_i1)
209 ENTRY (libat_fetch_sub_16_i1)
213 ldxp res0, res1, [x5]
214 subs tmplo, reslo, inlo
215 sbc tmphi, reshi, inhi
216 stxp w4, tmp0, tmp1, [x5]
220 ldaxp res0, res1, [x5]
221 subs tmplo, reslo, inlo
222 sbc tmphi, reshi, inhi
223 stlxp w4, tmp0, tmp1, [x5]
226 END (libat_fetch_sub_16_i1)
229 ENTRY (libat_sub_fetch_16_i1)
233 ldxp res0, res1, [x5]
234 subs reslo, reslo, inlo
235 sbc reshi, reshi, inhi
236 stxp w4, res0, res1, [x5]
240 ldaxp res0, res1, [x5]
241 subs reslo, reslo, inlo
242 sbc reshi, reshi, inhi
243 stlxp w4, res0, res1, [x5]
246 END (libat_sub_fetch_16_i1)
249 ENTRY (libat_fetch_or_16_i1)
253 ldxp res0, res1, [x5]
256 stxp w4, tmp0, tmp1, [x5]
260 ldaxp res0, res1, [x5]
263 stlxp w4, tmp0, tmp1, [x5]
266 END (libat_fetch_or_16_i1)
269 ENTRY (libat_or_fetch_16_i1)
273 ldxp res0, res1, [x5]
276 stxp w4, res0, res1, [x5]
280 ldaxp res0, res1, [x5]
283 stlxp w4, res0, res1, [x5]
286 END (libat_or_fetch_16_i1)
289 ENTRY (libat_fetch_and_16_i1)
293 ldxp res0, res1, [x5]
296 stxp w4, tmp0, tmp1, [x5]
300 ldaxp res0, res1, [x5]
303 stlxp w4, tmp0, tmp1, [x5]
306 END (libat_fetch_and_16_i1)
309 ENTRY (libat_and_fetch_16_i1)
313 ldxp res0, res1, [x5]
316 stxp w4, res0, res1, [x5]
320 ldaxp res0, res1, [x5]
323 stlxp w4, res0, res1, [x5]
326 END (libat_and_fetch_16_i1)
329 ENTRY (libat_fetch_xor_16_i1)
333 ldxp res0, res1, [x5]
336 stxp w4, tmp0, tmp1, [x5]
340 ldaxp res0, res1, [x5]
343 stlxp w4, tmp0, tmp1, [x5]
346 END (libat_fetch_xor_16_i1)
349 ENTRY (libat_xor_fetch_16_i1)
353 ldxp res0, res1, [x5]
356 stxp w4, res0, res1, [x5]
360 ldaxp res0, res1, [x5]
363 stlxp w4, res0, res1, [x5]
366 END (libat_xor_fetch_16_i1)
369 ENTRY (libat_fetch_nand_16_i1)
375 ldxp res0, res1, [x5]
378 stxp w4, tmp0, tmp1, [x5]
382 ldaxp res0, res1, [x5]
385 stlxp w4, tmp0, tmp1, [x5]
388 END (libat_fetch_nand_16_i1)
391 ENTRY (libat_nand_fetch_16_i1)
397 ldxp res0, res1, [x5]
400 stxp w4, res0, res1, [x5]
404 ldaxp res0, res1, [x5]
407 stlxp w4, res0, res1, [x5]
410 END (libat_nand_fetch_16_i1)
413 ENTRY (libat_test_and_set_16_i1)
419 2: swpalb w0, w2, [x0]
421 END (libat_test_and_set_16_i1)
424 /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
425 #define FEATURE_1_AND 0xc0000000
426 #define FEATURE_1_BTI 1
427 #define FEATURE_1_PAC 2
429 /* Supported features based on the code generation options. */
430 #if defined(__ARM_FEATURE_BTI_DEFAULT)
431 # define BTI_FLAG FEATURE_1_BTI
436 #if __ARM_FEATURE_PAC_DEFAULT & 3
437 # define PAC_FLAG FEATURE_1_PAC
442 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
443 #define GNU_PROPERTY(type, value) \
444 .section .note.gnu.property, "a"; \
455 #if defined(__linux__) || defined(__FreeBSD__)
456 .section .note.GNU-stack, "", %progbits
458 /* Add GNU property note if built with branch protection. */
459 # if (BTI_FLAG|PAC_FLAG) != 0
460 GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)