2019-09-19 16:36:38 +02:00
|
|
|
/* Out-of-line LSE atomics for AArch64 architecture.
|
2022-01-03 10:42:10 +01:00
|
|
|
Copyright (C) 2019-2022 Free Software Foundation, Inc.
|
2019-09-19 16:36:38 +02:00
|
|
|
Contributed by Linaro Ltd.
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The problem that we are trying to solve is operating system deployment
|
|
|
|
* of ARMv8.1-Atomics, also known as Large System Exensions (LSE).
|
|
|
|
*
|
|
|
|
* There are a number of potential solutions for this problem which have
|
|
|
|
* been proposed and rejected for various reasons. To recap:
|
|
|
|
*
|
|
|
|
* (1) Multiple builds. The dynamic linker will examine /lib64/atomics/
|
|
|
|
* if HWCAP_ATOMICS is set, allowing entire libraries to be overwritten.
|
|
|
|
* However, not all Linux distributions are happy with multiple builds,
|
|
|
|
* and anyway it has no effect on main applications.
|
|
|
|
*
|
|
|
|
* (2) IFUNC. We could put these functions into libgcc_s.so, and have
|
|
|
|
* a single copy of each function for all DSOs. However, ARM is concerned
|
|
|
|
* that the branch-to-indirect-branch that is implied by using a PLT,
|
|
|
|
* as required by IFUNC, is too much overhead for smaller cpus.
|
|
|
|
*
|
|
|
|
* (3) Statically predicted direct branches. This is the approach that
|
|
|
|
* is taken here. These functions are linked into every DSO that uses them.
|
|
|
|
* All of the symbols are hidden, so that the functions are called via a
|
|
|
|
* direct branch. The choice of LSE vs non-LSE is done via one byte load
|
|
|
|
* followed by a well-predicted direct branch. The functions are compiled
|
|
|
|
* separately to minimize code size.
|
|
|
|
*/
|
|
|
|
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#include "auto-target.h"
|
|
|
|
|
2019-09-19 16:36:38 +02:00
|
|
|
/* Tell the assembler to accept LSE instructions. */
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#ifdef HAVE_AS_LSE
|
2019-09-19 16:36:38 +02:00
|
|
|
.arch armv8-a+lse
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#else
|
|
|
|
.arch armv8-a
|
|
|
|
#endif
|
2019-09-19 16:36:38 +02:00
|
|
|
|
|
|
|
/* Declare the symbol gating the LSE implementations. */
|
|
|
|
.hidden __aarch64_have_lse_atomics
|
|
|
|
|
|
|
|
/* Turn size and memory model defines into mnemonic fragments. */
|
|
|
|
#if SIZE == 1
|
|
|
|
# define S b
|
|
|
|
# define UXT uxtb
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# define B 0x00000000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif SIZE == 2
|
|
|
|
# define S h
|
|
|
|
# define UXT uxth
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# define B 0x40000000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif SIZE == 4 || SIZE == 8 || SIZE == 16
|
|
|
|
# define S
|
|
|
|
# define UXT mov
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# if SIZE == 4
|
|
|
|
# define B 0x80000000
|
|
|
|
# elif SIZE == 8
|
|
|
|
# define B 0xc0000000
|
|
|
|
# endif
|
2019-09-19 16:36:38 +02:00
|
|
|
#else
|
|
|
|
# error
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if MODEL == 1
|
|
|
|
# define SUFF _relax
|
|
|
|
# define A
|
|
|
|
# define L
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# define M 0x000000
|
|
|
|
# define N 0x000000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif MODEL == 2
|
|
|
|
# define SUFF _acq
|
|
|
|
# define A a
|
|
|
|
# define L
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# define M 0x400000
|
|
|
|
# define N 0x800000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif MODEL == 3
|
|
|
|
# define SUFF _rel
|
|
|
|
# define A
|
|
|
|
# define L l
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# define M 0x008000
|
|
|
|
# define N 0x400000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif MODEL == 4
|
|
|
|
# define SUFF _acq_rel
|
|
|
|
# define A a
|
|
|
|
# define L l
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
# define M 0x408000
|
|
|
|
# define N 0xc00000
|
2019-09-19 16:36:38 +02:00
|
|
|
#else
|
|
|
|
# error
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Concatenate symbols. */
|
|
|
|
#define glue2_(A, B) A ## B
|
|
|
|
#define glue2(A, B) glue2_(A, B)
|
|
|
|
#define glue3_(A, B, C) A ## B ## C
|
|
|
|
#define glue3(A, B, C) glue3_(A, B, C)
|
|
|
|
#define glue4_(A, B, C, D) A ## B ## C ## D
|
|
|
|
#define glue4(A, B, C, D) glue4_(A, B, C, D)
|
|
|
|
|
|
|
|
/* Select the size of a register, given a regno. */
|
|
|
|
#define x(N) glue2(x, N)
|
|
|
|
#define w(N) glue2(w, N)
|
|
|
|
#if SIZE < 8
|
|
|
|
# define s(N) w(N)
|
|
|
|
#else
|
|
|
|
# define s(N) x(N)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define NAME(BASE) glue4(__aarch64_, BASE, SIZE, SUFF)
|
|
|
|
#define LDXR glue4(ld, A, xr, S)
|
|
|
|
#define STXR glue4(st, L, xr, S)
|
|
|
|
|
|
|
|
/* Temporary registers used. Other than these, only the return value
|
|
|
|
register (x0) and the flags are modified. */
|
|
|
|
#define tmp0 16
|
|
|
|
#define tmp1 17
|
|
|
|
#define tmp2 15
|
|
|
|
|
2020-07-02 18:11:56 +02:00
|
|
|
#define BTI_C hint 34
|
|
|
|
|
2019-09-19 16:36:38 +02:00
|
|
|
/* Start and end a function. */
|
|
|
|
.macro STARTFN name
|
|
|
|
.text
|
|
|
|
.balign 16
|
|
|
|
.globl \name
|
|
|
|
.hidden \name
|
|
|
|
.type \name, %function
|
|
|
|
.cfi_startproc
|
|
|
|
\name:
|
2020-07-02 18:11:56 +02:00
|
|
|
BTI_C
|
2019-09-19 16:36:38 +02:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro ENDFN name
|
|
|
|
.cfi_endproc
|
|
|
|
.size \name, . - \name
|
|
|
|
.endm
|
|
|
|
|
|
|
|
/* Branch to LABEL if LSE is disabled. */
|
|
|
|
.macro JUMP_IF_NOT_LSE label
|
|
|
|
adrp x(tmp0), __aarch64_have_lse_atomics
|
|
|
|
ldrb w(tmp0), [x(tmp0), :lo12:__aarch64_have_lse_atomics]
|
|
|
|
cbz w(tmp0), \label
|
|
|
|
.endm
|
|
|
|
|
|
|
|
#ifdef L_cas
|
|
|
|
|
|
|
|
STARTFN NAME(cas)
|
|
|
|
JUMP_IF_NOT_LSE 8f
|
|
|
|
|
|
|
|
#if SIZE < 16
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#ifdef HAVE_AS_LSE
|
|
|
|
# define CAS glue4(cas, A, L, S) s(0), s(1), [x2]
|
|
|
|
#else
|
|
|
|
# define CAS .inst 0x08a07c41 + B + M
|
|
|
|
#endif
|
2019-09-19 16:36:38 +02:00
|
|
|
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
CAS /* s(0), s(1), [x2] */
|
2019-09-19 16:36:38 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
8: UXT s(tmp0), s(0)
|
|
|
|
0: LDXR s(0), [x2]
|
|
|
|
cmp s(0), s(tmp0)
|
|
|
|
bne 1f
|
|
|
|
STXR w(tmp1), s(1), [x2]
|
|
|
|
cbnz w(tmp1), 0b
|
|
|
|
1: ret
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define LDXP glue3(ld, A, xp)
|
|
|
|
#define STXP glue3(st, L, xp)
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#ifdef HAVE_AS_LSE
|
|
|
|
# define CASP glue3(casp, A, L) x0, x1, x2, x3, [x4]
|
|
|
|
#else
|
|
|
|
# define CASP .inst 0x48207c82 + M
|
|
|
|
#endif
|
2019-09-19 16:36:38 +02:00
|
|
|
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
CASP /* x0, x1, x2, x3, [x4] */
|
2019-09-19 16:36:38 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
8: mov x(tmp0), x0
|
|
|
|
mov x(tmp1), x1
|
|
|
|
0: LDXP x0, x1, [x4]
|
|
|
|
cmp x0, x(tmp0)
|
|
|
|
ccmp x1, x(tmp1), #0, eq
|
|
|
|
bne 1f
|
2020-08-03 22:55:28 +02:00
|
|
|
STXP w(tmp2), x2, x3, [x4]
|
2019-09-19 16:36:38 +02:00
|
|
|
cbnz w(tmp2), 0b
|
|
|
|
1: ret
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ENDFN NAME(cas)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef L_swp
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#ifdef HAVE_AS_LSE
|
|
|
|
# define SWP glue4(swp, A, L, S) s(0), s(0), [x1]
|
|
|
|
#else
|
|
|
|
# define SWP .inst 0x38208020 + B + N
|
|
|
|
#endif
|
2019-09-19 16:36:38 +02:00
|
|
|
|
|
|
|
STARTFN NAME(swp)
|
|
|
|
JUMP_IF_NOT_LSE 8f
|
|
|
|
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
SWP /* s(0), s(0), [x1] */
|
2019-09-19 16:36:38 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
8: mov s(tmp0), s(0)
|
|
|
|
0: LDXR s(0), [x1]
|
|
|
|
STXR w(tmp1), s(tmp0), [x1]
|
|
|
|
cbnz w(tmp1), 0b
|
|
|
|
ret
|
|
|
|
|
|
|
|
ENDFN NAME(swp)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(L_ldadd) || defined(L_ldclr) \
|
|
|
|
|| defined(L_ldeor) || defined(L_ldset)
|
|
|
|
|
|
|
|
#ifdef L_ldadd
|
|
|
|
#define LDNM ldadd
|
|
|
|
#define OP add
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#define OPN 0x0000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif defined(L_ldclr)
|
|
|
|
#define LDNM ldclr
|
|
|
|
#define OP bic
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#define OPN 0x1000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif defined(L_ldeor)
|
|
|
|
#define LDNM ldeor
|
|
|
|
#define OP eor
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#define OPN 0x2000
|
2019-09-19 16:36:38 +02:00
|
|
|
#elif defined(L_ldset)
|
|
|
|
#define LDNM ldset
|
|
|
|
#define OP orr
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#define OPN 0x3000
|
2019-09-19 16:36:38 +02:00
|
|
|
#else
|
|
|
|
#error
|
|
|
|
#endif
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
#ifdef HAVE_AS_LSE
|
|
|
|
# define LDOP glue4(LDNM, A, L, S) s(0), s(0), [x1]
|
|
|
|
#else
|
|
|
|
# define LDOP .inst 0x38200020 + OPN + B + N
|
|
|
|
#endif
|
2019-09-19 16:36:38 +02:00
|
|
|
|
|
|
|
STARTFN NAME(LDNM)
|
|
|
|
JUMP_IF_NOT_LSE 8f
|
|
|
|
|
aarch64: Fix bootstrap with old binutils [PR93053]
As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build
when using older binutils which lack LSE support, because those instructions
are used in libgcc.
Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build
even with older binutils by using .inst directive if LSE support isn't
available in the assembler.
2020-04-15 Jakub Jelinek <jakub@redhat.com>
PR target/93053
* configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking.
* config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE
is not defined, use just .arch armv8-a.
(B, M, N, OPN): Define.
(COMMENT): New .macro.
(CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not
defined. Otherwise, move the operands right after the glue? and
comment out operands where the macros are used.
* configure: Regenerated.
* config.in: Regenerated.
2020-04-15 11:01:19 +02:00
|
|
|
LDOP /* s(0), s(0), [x1] */
|
2019-09-19 16:36:38 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
8: mov s(tmp0), s(0)
|
|
|
|
0: LDXR s(0), [x1]
|
|
|
|
OP s(tmp1), s(0), s(tmp0)
|
2019-09-25 23:48:41 +02:00
|
|
|
STXR w(tmp2), s(tmp1), [x1]
|
|
|
|
cbnz w(tmp2), 0b
|
2019-09-19 16:36:38 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
ENDFN NAME(LDNM)
|
|
|
|
#endif
|
2020-07-03 15:11:49 +02:00
|
|
|
|
2020-07-02 18:11:56 +02:00
|
|
|
/* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
|
|
|
|
#define FEATURE_1_AND 0xc0000000
|
|
|
|
#define FEATURE_1_BTI 1
|
|
|
|
#define FEATURE_1_PAC 2
|
|
|
|
|
2020-07-16 17:26:10 +02:00
|
|
|
/* Supported features based on the code generation options. */
|
|
|
|
#if defined(__ARM_FEATURE_BTI_DEFAULT)
|
|
|
|
# define BTI_FLAG FEATURE_1_BTI
|
|
|
|
#else
|
|
|
|
# define BTI_FLAG 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if __ARM_FEATURE_PAC_DEFAULT & 3
|
|
|
|
# define PAC_FLAG FEATURE_1_PAC
|
|
|
|
#else
|
|
|
|
# define PAC_FLAG 0
|
|
|
|
#endif
|
|
|
|
|
2020-07-02 18:11:56 +02:00
|
|
|
/* Add a NT_GNU_PROPERTY_TYPE_0 note. */
|
|
|
|
#define GNU_PROPERTY(type, value) \
|
|
|
|
.section .note.gnu.property, "a"; \
|
|
|
|
.p2align 3; \
|
|
|
|
.word 4; \
|
|
|
|
.word 16; \
|
|
|
|
.word 5; \
|
|
|
|
.asciz "GNU"; \
|
|
|
|
.word type; \
|
|
|
|
.word 4; \
|
|
|
|
.word value; \
|
|
|
|
.word 0;
|
|
|
|
|
2020-07-03 15:11:49 +02:00
|
|
|
#if defined(__linux__) || defined(__FreeBSD__)
|
|
|
|
.section .note.GNU-stack, "", %progbits
|
2020-07-02 18:11:56 +02:00
|
|
|
|
|
|
|
/* Add GNU property note if built with branch protection. */
|
2020-07-16 17:26:10 +02:00
|
|
|
# if (BTI_FLAG|PAC_FLAG) != 0
|
|
|
|
GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
|
2020-07-02 18:11:56 +02:00
|
|
|
# endif
|
2020-07-03 15:11:49 +02:00
|
|
|
#endif
|