Debian Codegraph @

libatomic/config/linux/aarch64/atomic_16.S

raw
1 /* Copyright (C) 2022-2025 Free Software Foundation, Inc.
2
3 This file is part of the GNU Atomic Library (libatomic).
4
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.
9
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
13 more details.
14
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.
18
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/>. */
23
24
25 /* AArch64 128-bit lock-free atomic implementation.
26
27 128-bit atomics are now lock-free for all AArch64 architecture versions.
28 This is backwards compatible with existing binaries (as we swap all uses
29 of 128-bit atomics via an ifunc) and gives better performance than locking
30 atomics.
31
32 128-bit atomic loads use a exclusive loop if LSE2 is not supported.
33 This results in an implicit store which is invisible to software as long
34 as the given address is writeable. Since all other atomics have explicit
35 writes, this will be true when using atomics in actual code.
36
37 The libat_<op>_16 entry points are ARMv8.0.
38 The libat_<op>_16_i1 entry points are used when LSE128 or LRCPC3 is available.
39 The libat_<op>_16_i2 entry points are used when LSE2 is available. */
40
41 #include "auto-config.h"
42
43 .arch armv8-a+lse
44
45 /* There is overlap in atomic instructions implemented in RCPC3 and LSE2.
46 Consequently, both _i1 and _i2 suffixes are needed for functions using these.
47 Elsewhere, all extension-specific implementations are mapped to _i1. */
48
49 #define LRCPC3(NAME) libat_##NAME##_i1
50 #define LSE128(NAME) libat_##NAME##_i1
51 #define LSE(NAME) libat_##NAME##_i1
52 #define LSE2(NAME) libat_##NAME##_i2
53 #define CORE(NAME) libat_##NAME
54 #define ATOMIC(NAME) __atomic_##NAME
55
56 /* Emit __atomic_* entrypoints if no ifuncs. */
57 #define ENTRY_ALIASED(NAME) ENTRY2 (CORE (NAME), ALIAS (NAME, ATOMIC, CORE))
58
59 #if HAVE_IFUNC
60 # define ENTRY(NAME) ENTRY2 (CORE (NAME), )
61 # define ENTRY_FEAT(NAME, FEAT) ENTRY2 (FEAT (NAME), )
62 # define END_FEAT(NAME, FEAT) END2 (FEAT (NAME))
63 #else
64 # define ENTRY(NAME) ENTRY_ALIASED (NAME)
65 #endif
66
67 #define END(NAME) END2 (CORE (NAME))
68
69 #define ENTRY2(NAME, ALIASES) \
70 .global NAME; \
71 .hidden NAME; \
72 .type NAME,%function; \
73 .p2align 4; \
74 ALIASES; \
75 NAME: \
76 .cfi_startproc; \
77 hint 34; // bti c
78
79 #define END2(NAME) \
80 .cfi_endproc; \
81 .size NAME, .-NAME;
82
83 #define ALIAS(NAME, FROM, TO) ALIAS1 (FROM (NAME), TO (NAME))
84
85 #define ALIAS1(ALIAS, NAME) \
86 .global ALIAS; \
87 .set ALIAS, NAME;
88
89 #define res0 x0
90 #define res1 x1
91 #define in0 x2
92 #define in1 x3
93 #define tmp0 x6
94 #define tmp1 x7
95 #define exp0 x8
96 #define exp1 x9
97
98 #ifdef __AARCH64EB__
99 # define reslo x1
100 # define reshi x0
101 # define inlo x3
102 # define inhi x2
103 # define tmplo x7
104 # define tmphi x6
105 #else
106 # define reslo x0
107 # define reshi x1
108 # define inlo x2
109 # define inhi x3
110 # define tmplo x6
111 # define tmphi x7
112 #endif
113
114 #define RELAXED 0
115 #define CONSUME 1
116 #define ACQUIRE 2
117 #define RELEASE 3
118 #define ACQ_REL 4
119 #define SEQ_CST 5
120
121
122 /* Core implementations: Not dependent on the presence of further architectural
123 extensions. */
124
125 ENTRY (load_16)
126 mov x5, x0
127 cbnz w1, 2f
128
129 /* RELAXED. */
130 1: ldxp res0, res1, [x5]
131 stxp w4, res0, res1, [x5]
132 cbnz w4, 1b
133 ret
134
135 /* ACQUIRE/CONSUME/SEQ_CST. */
136 2: ldaxp res0, res1, [x5]
137 stxp w4, res0, res1, [x5]
138 cbnz w4, 2b
139 ret
140 END (load_16)
141
142
143 ENTRY (store_16)
144 cbnz w4, 2f
145
146 /* RELAXED. */
147 1: ldxp xzr, tmp0, [x0]
148 stxp w4, in0, in1, [x0]
149 cbnz w4, 1b
150 ret
151
152 /* RELEASE/SEQ_CST. */
153 2: ldxp xzr, tmp0, [x0]
154 stlxp w4, in0, in1, [x0]
155 cbnz w4, 2b
156 ret
157 END (store_16)
158
159
160 ENTRY (exchange_16)
161 mov x5, x0
162 cbnz w4, 2f
163
164 /* RELAXED. */
165 1: ldxp res0, res1, [x5]
166 stxp w4, in0, in1, [x5]
167 cbnz w4, 1b
168 ret
169 2:
170 cmp w4, ACQUIRE
171 b.hi 4f
172
173 /* ACQUIRE/CONSUME. */
174 3: ldaxp res0, res1, [x5]
175 stxp w4, in0, in1, [x5]
176 cbnz w4, 3b
177 ret
178
179 /* RELEASE/ACQ_REL/SEQ_CST. */
180 4: ldaxp res0, res1, [x5]
181 stlxp w4, in0, in1, [x5]
182 cbnz w4, 4b
183 ret
184 END (exchange_16)
185
186
187 ENTRY (compare_exchange_16)
188 ldp exp0, exp1, [x1]
189 cbz w4, 3f
190 cmp w4, RELEASE
191 b.hs 5f
192
193 /* ACQUIRE/CONSUME. */
194 1: ldaxp tmp0, tmp1, [x0]
195 cmp tmp0, exp0
196 ccmp tmp1, exp1, 0, eq
197 csel tmp0, in0, tmp0, eq
198 csel tmp1, in1, tmp1, eq
199 stxp w4, tmp0, tmp1, [x0]
200 cbnz w4, 1b
201 beq 2f
202 stp tmp0, tmp1, [x1]
203 2: cset x0, eq
204 ret
205
206 /* RELAXED. */
207 3: ldxp tmp0, tmp1, [x0]
208 cmp tmp0, exp0
209 ccmp tmp1, exp1, 0, eq
210 csel tmp0, in0, tmp0, eq
211 csel tmp1, in1, tmp1, eq
212 stxp w4, tmp0, tmp1, [x0]
213 cbnz w4, 3b
214 beq 4f
215 stp tmp0, tmp1, [x1]
216 4: cset x0, eq
217 ret
218
219 /* RELEASE/ACQ_REL/SEQ_CST. */
220 5: ldaxp tmp0, tmp1, [x0]
221 cmp tmp0, exp0
222 ccmp tmp1, exp1, 0, eq
223 csel tmp0, in0, tmp0, eq
224 csel tmp1, in1, tmp1, eq
225 stlxp w4, tmp0, tmp1, [x0]
226 cbnz w4, 5b
227 beq 6f
228 stp tmp0, tmp1, [x1]
229 6: cset x0, eq
230 ret
231 END (compare_exchange_16)
232
233
234
235
236 ENTRY_ALIASED (fetch_add_16)
237 mov x5, x0
238 cbnz w4, 2f
239
240 /* RELAXED. */
241 1: ldxp res0, res1, [x5]
242 adds tmplo, reslo, inlo
243 adc tmphi, reshi, inhi
244 stxp w4, tmp0, tmp1, [x5]
245 cbnz w4, 1b
246 ret
247
248 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
249 2: ldaxp res0, res1, [x5]
250 adds tmplo, reslo, inlo
251 adc tmphi, reshi, inhi
252 stlxp w4, tmp0, tmp1, [x5]
253 cbnz w4, 2b
254 ret
255 END (fetch_add_16)
256
257
258 ENTRY_ALIASED (add_fetch_16)
259 mov x5, x0
260 cbnz w4, 2f
261
262 /* RELAXED. */
263 1: ldxp res0, res1, [x5]
264 adds reslo, reslo, inlo
265 adc reshi, reshi, inhi
266 stxp w4, res0, res1, [x5]
267 cbnz w4, 1b
268 ret
269
270 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
271 2: ldaxp res0, res1, [x5]
272 adds reslo, reslo, inlo
273 adc reshi, reshi, inhi
274 stlxp w4, res0, res1, [x5]
275 cbnz w4, 2b
276 ret
277 END (add_fetch_16)
278
279
280 ENTRY_ALIASED (fetch_sub_16)
281 mov x5, x0
282 cbnz w4, 2f
283
284 /* RELAXED. */
285 1: ldxp res0, res1, [x5]
286 subs tmplo, reslo, inlo
287 sbc tmphi, reshi, inhi
288 stxp w4, tmp0, tmp1, [x5]
289 cbnz w4, 1b
290 ret
291
292 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
293 2: ldaxp res0, res1, [x5]
294 subs tmplo, reslo, inlo
295 sbc tmphi, reshi, inhi
296 stlxp w4, tmp0, tmp1, [x5]
297 cbnz w4, 2b
298 ret
299 END (fetch_sub_16)
300
301
302 ENTRY_ALIASED (sub_fetch_16)
303 mov x5, x0
304 cbnz w4, 2f
305
306 /* RELAXED. */
307 1: ldxp res0, res1, [x5]
308 subs reslo, reslo, inlo
309 sbc reshi, reshi, inhi
310 stxp w4, res0, res1, [x5]
311 cbnz w4, 1b
312 ret
313
314 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
315 2: ldaxp res0, res1, [x5]
316 subs reslo, reslo, inlo
317 sbc reshi, reshi, inhi
318 stlxp w4, res0, res1, [x5]
319 cbnz w4, 2b
320 ret
321 END (sub_fetch_16)
322
323
324 ENTRY (fetch_or_16)
325 mov x5, x0
326 cbnz w4, 2f
327
328 /* RELAXED. */
329 1: ldxp res0, res1, [x5]
330 orr tmp0, res0, in0
331 orr tmp1, res1, in1
332 stxp w4, tmp0, tmp1, [x5]
333 cbnz w4, 1b
334 ret
335
336 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
337 2: ldaxp res0, res1, [x5]
338 orr tmp0, res0, in0
339 orr tmp1, res1, in1
340 stlxp w4, tmp0, tmp1, [x5]
341 cbnz w4, 2b
342 ret
343 END (fetch_or_16)
344
345
346 ENTRY (or_fetch_16)
347 mov x5, x0
348 cbnz w4, 2f
349
350 /* RELAXED. */
351 1: ldxp res0, res1, [x5]
352 orr res0, res0, in0
353 orr res1, res1, in1
354 stxp w4, res0, res1, [x5]
355 cbnz w4, 1b
356 ret
357
358 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
359 2: ldaxp res0, res1, [x5]
360 orr res0, res0, in0
361 orr res1, res1, in1
362 stlxp w4, res0, res1, [x5]
363 cbnz w4, 2b
364 ret
365 END (or_fetch_16)
366
367
368 ENTRY (fetch_and_16)
369 mov x5, x0
370 cbnz w4, 2f
371
372 /* RELAXED. */
373 1: ldxp res0, res1, [x5]
374 and tmp0, res0, in0
375 and tmp1, res1, in1
376 stxp w4, tmp0, tmp1, [x5]
377 cbnz w4, 1b
378 ret
379
380 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
381 2: ldaxp res0, res1, [x5]
382 and tmp0, res0, in0
383 and tmp1, res1, in1
384 stlxp w4, tmp0, tmp1, [x5]
385 cbnz w4, 2b
386 ret
387 END (fetch_and_16)
388
389
390 ENTRY (and_fetch_16)
391 mov x5, x0
392 cbnz w4, 2f
393
394 /* RELAXED. */
395 1: ldxp res0, res1, [x5]
396 and res0, res0, in0
397 and res1, res1, in1
398 stxp w4, res0, res1, [x5]
399 cbnz w4, 1b
400 ret
401
402 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
403 2: ldaxp res0, res1, [x5]
404 and res0, res0, in0
405 and res1, res1, in1
406 stlxp w4, res0, res1, [x5]
407 cbnz w4, 2b
408 ret
409 END (and_fetch_16)
410
411
412 ENTRY_ALIASED (fetch_xor_16)
413 mov x5, x0
414 cbnz w4, 2f
415
416 /* RELAXED. */
417 1: ldxp res0, res1, [x5]
418 eor tmp0, res0, in0
419 eor tmp1, res1, in1
420 stxp w4, tmp0, tmp1, [x5]
421 cbnz w4, 1b
422 ret
423
424 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
425 2: ldaxp res0, res1, [x5]
426 eor tmp0, res0, in0
427 eor tmp1, res1, in1
428 stlxp w4, tmp0, tmp1, [x5]
429 cbnz w4, 2b
430 ret
431 END (fetch_xor_16)
432
433
434 ENTRY_ALIASED (xor_fetch_16)
435 mov x5, x0
436 cbnz w4, 2f
437
438 /* RELAXED. */
439 1: ldxp res0, res1, [x5]
440 eor res0, res0, in0
441 eor res1, res1, in1
442 stxp w4, res0, res1, [x5]
443 cbnz w4, 1b
444 ret
445
446 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
447 2: ldaxp res0, res1, [x5]
448 eor res0, res0, in0
449 eor res1, res1, in1
450 stlxp w4, res0, res1, [x5]
451 cbnz w4, 2b
452 ret
453 END (xor_fetch_16)
454
455
456 ENTRY_ALIASED (fetch_nand_16)
457 mov x5, x0
458 mvn in0, in0
459 mvn in1, in1
460 cbnz w4, 2f
461
462 /* RELAXED. */
463 1: ldxp res0, res1, [x5]
464 orn tmp0, in0, res0
465 orn tmp1, in1, res1
466 stxp w4, tmp0, tmp1, [x5]
467 cbnz w4, 1b
468 ret
469
470 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
471 2: ldaxp res0, res1, [x5]
472 orn tmp0, in0, res0
473 orn tmp1, in1, res1
474 stlxp w4, tmp0, tmp1, [x5]
475 cbnz w4, 2b
476 ret
477 END (fetch_nand_16)
478
479
480 ENTRY_ALIASED (nand_fetch_16)
481 mov x5, x0
482 mvn in0, in0
483 mvn in1, in1
484 cbnz w4, 2f
485
486 /* RELAXED. */
487 1: ldxp res0, res1, [x5]
488 orn res0, in0, res0
489 orn res1, in1, res1
490 stxp w4, res0, res1, [x5]
491 cbnz w4, 1b
492 ret
493
494 /* ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
495 2: ldaxp res0, res1, [x5]
496 orn res0, in0, res0
497 orn res1, in1, res1
498 stlxp w4, res0, res1, [x5]
499 cbnz w4, 2b
500 ret
501 END (nand_fetch_16)
502
503
504 /* __atomic_test_and_set is always inlined, so this entry is unused and
505 only required for completeness. */
506 ENTRY_ALIASED (test_and_set_16)
507
508 /* RELAXED/ACQUIRE/CONSUME/RELEASE/ACQ_REL/SEQ_CST. */
509 mov x5, x0
510 1: ldaxrb w0, [x5]
511 stlxrb w4, w2, [x5]
512 cbnz w4, 1b
513 ret
514 END (test_and_set_16)
515
516
517 #if HAVE_IFUNC
518 /* ifunc implementations: Carries run-time dependence on the presence of further
519 architectural extensions. */
520
521 ENTRY_FEAT (load_16, LRCPC3)
522 cbnz w1, 1f
523
524 /* RELAXED. */
525 ldp res0, res1, [x0]
526 ret
527 1:
528 cmp w1, SEQ_CST
529 b.eq 2f
530
531 /* ACQUIRE/CONSUME (Load-AcquirePC semantics). */
532 /* ldiapp res0, res1, [x0] */
533 .inst 0xd9411800
534 ret
535
536 /* SEQ_CST. */
537 2: ldar tmp0, [x0] /* Block reordering with Store-Release instr. */
538 /* ldiapp res0, res1, [x0] */
539 .inst 0xd9411800
540 ret
541 END_FEAT (load_16, LRCPC3)
542
543
544 ENTRY_FEAT (store_16, LRCPC3)
545 cbnz w4, 1f
546
547 /* RELAXED. */
548 stp in0, in1, [x0]
549 ret
550
551 /* RELEASE/SEQ_CST. */
552 1: /* stilp in0, in1, [x0] */
553 .inst 0xd9031802
554 ret
555 END_FEAT (store_16, LRCPC3)
556
557
558 ENTRY_FEAT (exchange_16, LSE128)
559 mov tmp0, x0
560 mov res0, in0
561 mov res1, in1
562 cbnz w4, 1f
563
564 /* RELAXED. */
565 /* swpp res0, res1, [tmp0] */
566 .inst 0x192180c0
567 ret
568 1:
569 cmp w4, ACQUIRE
570 b.hi 2f
571
572 /* ACQUIRE/CONSUME. */
573 /* swppa res0, res1, [tmp0] */
574 .inst 0x19a180c0
575 ret
576
577 /* RELEASE/ACQ_REL/SEQ_CST. */
578 2: /* swppal res0, res1, [tmp0] */
579 .inst 0x19e180c0
580 ret
581 END_FEAT (exchange_16, LSE128)
582
583
584 ENTRY_FEAT (fetch_or_16, LSE128)
585 mov tmp0, x0
586 mov res0, in0
587 mov res1, in1
588 cbnz w4, 1f
589
590 /* RELAXED. */
591 /* ldsetp res0, res1, [tmp0] */
592 .inst 0x192130c0
593 ret
594 1:
595 cmp w4, ACQUIRE
596 b.hi 2f
597
598 /* ACQUIRE/CONSUME. */
599 /* ldsetpa res0, res1, [tmp0] */
600 .inst 0x19a130c0
601 ret
602
603 /* RELEASE/ACQ_REL/SEQ_CST. */
604 2: /* ldsetpal res0, res1, [tmp0] */
605 .inst 0x19e130c0
606 ret
607 END_FEAT (fetch_or_16, LSE128)
608
609
610 ENTRY_FEAT (or_fetch_16, LSE128)
611 cbnz w4, 1f
612 mov tmp0, in0
613 mov tmp1, in1
614
615 /* RELAXED. */
616 /* ldsetp in0, in1, [x0] */
617 .inst 0x19233002
618 orr res0, in0, tmp0
619 orr res1, in1, tmp1
620 ret
621 1:
622 cmp w4, ACQUIRE
623 b.hi 2f
624
625 /* ACQUIRE/CONSUME. */
626 /* ldsetpa in0, in1, [x0] */
627 .inst 0x19a33002
628 orr res0, in0, tmp0
629 orr res1, in1, tmp1
630 ret
631
632 /* RELEASE/ACQ_REL/SEQ_CST. */
633 2: /* ldsetpal in0, in1, [x0] */
634 .inst 0x19e33002
635 orr res0, in0, tmp0
636 orr res1, in1, tmp1
637 ret
638 END_FEAT (or_fetch_16, LSE128)
639
640
641 ENTRY_FEAT (fetch_and_16, LSE128)
642 mov tmp0, x0
643 mvn res0, in0
644 mvn res1, in1
645 cbnz w4, 1f
646
647 /* RELAXED. */
648 /* ldclrp res0, res1, [tmp0] */
649 .inst 0x192110c0
650 ret
651
652 1:
653 cmp w4, ACQUIRE
654 b.hi 2f
655
656 /* ACQUIRE/CONSUME. */
657 /* ldclrpa res0, res1, [tmp0] */
658 .inst 0x19a110c0
659 ret
660
661 /* RELEASE/ACQ_REL/SEQ_CST. */
662 2: /* ldclrpal res0, res1, [tmp0] */
663 .inst 0x19e110c0
664 ret
665 END_FEAT (fetch_and_16, LSE128)
666
667
668 ENTRY_FEAT (and_fetch_16, LSE128)
669 mvn tmp0, in0
670 mvn tmp0, in1
671 cbnz w4, 1f
672
673 /* RELAXED. */
674 /* ldclrp tmp0, tmp1, [x0] */
675 .inst 0x19271006
676 and res0, tmp0, in0
677 and res1, tmp1, in1
678 ret
679
680 1:
681 cmp w4, ACQUIRE
682 b.hi 2f
683
684 /* ACQUIRE/CONSUME. */
685 /* ldclrpa tmp0, tmp1, [x0] */
686 .inst 0x19a71006
687 and res0, tmp0, in0
688 and res1, tmp1, in1
689 ret
690
691 /* RELEASE/ACQ_REL/SEQ_CST. */
692 2: /* ldclrpal tmp0, tmp1, [x5] */
693 .inst 0x19e710a6
694 and res0, tmp0, in0
695 and res1, tmp1, in1
696 ret
697 END_FEAT (and_fetch_16, LSE128)
698
699
700 ENTRY_FEAT (load_16, LSE2)
701 cbnz w1, 1f
702
703 /* RELAXED. */
704 ldp res0, res1, [x0]
705 ret
706 1:
707 cmp w1, SEQ_CST
708 b.eq 2f
709
710 /* ACQUIRE/CONSUME (Load-AcquirePC semantics). */
711 ldp res0, res1, [x0]
712 dmb ishld
713 ret
714
715 /* SEQ_CST. */
716 2: ldar tmp0, [x0] /* Block reordering with Store-Release instr. */
717 ldp res0, res1, [x0]
718 dmb ishld
719 ret
720 END_FEAT (load_16, LSE2)
721
722
723 ENTRY_FEAT (store_16, LSE2)
724 cbnz w4, 1f
725
726 /* RELAXED. */
727 stp in0, in1, [x0]
728 ret
729
730 /* RELEASE/SEQ_CST. */
731 1: ldxp xzr, tmp0, [x0]
732 stlxp w4, in0, in1, [x0]
733 cbnz w4, 1b
734 ret
735 END_FEAT (store_16, LSE2)
736
737
738 ENTRY_FEAT (compare_exchange_16, LSE)
739 ldp exp0, exp1, [x1]
740 mov tmp0, exp0
741 mov tmp1, exp1
742 cbz w4, 2f
743 cmp w4, RELEASE
744 b.hs 3f
745
746 /* ACQUIRE/CONSUME. */
747 caspa exp0, exp1, in0, in1, [x0]
748 0:
749 cmp exp0, tmp0
750 ccmp exp1, tmp1, 0, eq
751 bne 1f
752 mov x0, 1
753 ret
754 1:
755 stp exp0, exp1, [x1]
756 mov x0, 0
757 ret
758
759 /* RELAXED. */
760 2: casp exp0, exp1, in0, in1, [x0]
761 b 0b
762
763 /* RELEASE. */
764 3: b.hi 4f
765 caspl exp0, exp1, in0, in1, [x0]
766 b 0b
767
768 /* ACQ_REL/SEQ_CST. */
769 4: caspal exp0, exp1, in0, in1, [x0]
770 b 0b
771 END_FEAT (compare_exchange_16, LSE)
772 #endif
773
774 /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
775 #define FEATURE_1_AND 0xc0000000
776 #define FEATURE_1_BTI 1
777 #define FEATURE_1_PAC 2
778 #define FEATURE_1_GCS 4
779
780 /* Supported features based on the code generation options. */
781 #if defined(__ARM_FEATURE_BTI_DEFAULT)
782 # define BTI_FLAG FEATURE_1_BTI
783 #else
784 # define BTI_FLAG 0
785 #endif
786
787 #if __ARM_FEATURE_PAC_DEFAULT & 3
788 # define PAC_FLAG FEATURE_1_PAC
789 #else
790 # define PAC_FLAG 0
791 #endif
792
793 #if __ARM_FEATURE_GCS_DEFAULT
794 # define GCS_FLAG FEATURE_1_GCS
795 #else
796 # define GCS_FLAG 0
797 #endif
798
799 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
800 #define GNU_PROPERTY(type, value) \
801 .section .note.gnu.property, "a"; \
802 .p2align 3; \
803 .word 4; \
804 .word 16; \
805 .word 5; \
806 .asciz "GNU"; \
807 .word type; \
808 .word 4; \
809 .word value; \
810 .word 0;
811
812 #if defined(__linux__) || defined(__FreeBSD__)
813 .section .note.GNU-stack, "", %progbits
814
815 /* Add GNU property note if built with branch protection. */
816 # if (BTI_FLAG|PAC_FLAG|GCS_FLAG) != 0
817 GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG|GCS_FLAG)
818 # endif
819 #endif