diff options
author | Andrew Stubbs <ams@codesourcery.com> | 2021-09-24 11:37:37 +0100 |
---|---|---|
committer | Andrew Stubbs <ams@codesourcery.com> | 2021-10-07 11:26:44 +0100 |
commit | 6ca03ca35a58ebf9792aa8a08adf00b6fd3e0015 (patch) | |
tree | b22b3e23c2343a1b3e165b4faee5b38d9c3f5a0b /gcc/config | |
parent | 6496ae5c9651206c9de43f63018a549a2ef2244e (diff) | |
download | gcc-6ca03ca35a58ebf9792aa8a08adf00b6fd3e0015.zip gcc-6ca03ca35a58ebf9792aa8a08adf00b6fd3e0015.tar.gz gcc-6ca03ca35a58ebf9792aa8a08adf00b6fd3e0015.tar.bz2 |
amdgcn: Support LLVM 13 assembler syntax
The LLVM devs have changed the assembler architecture attribute names on both
CLI and in the ".amdgcn_target" directive, and changed the attribute syntax
inside the directive, without keeping any backwards compatibility. :-(
This patch improves our configure tests to detect what dialect to use, what
attributes are valid, and adjusts the specs to match.
gcc/ChangeLog:
* config.in: Regenerate.
* config/gcn/gcn-hsa.h (X_FIJI): New macro.
(X_900): New macro.
(X_906): New macro.
(X_908): New macro.
(A_FIJI): Rename to ...
(S_FIJI): ... this.
(A_900): Rename to ...
(S_900): ... this.
(A_906): Rename to ...
(S_906): ... this.
(A_908): Rename to ...
(S_908): ... this.
(SRAMOPT): New macro.
(ASM_SPEC): Adjust xnack option usage.
* config/gcn/gcn.c (output_file_start): Adjust amdgcn_target usage.
* configure: Regenerate.
* configure.ac: Detect LLVM assembler dialect.
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/gcn/gcn-hsa.h | 63 | ||||
-rw-r--r-- | gcc/config/gcn/gcn.c | 44 |
2 files changed, 89 insertions, 18 deletions
diff --git a/gcc/config/gcn/gcn-hsa.h b/gcc/config/gcn/gcn-hsa.h index fc99c8d..60fd40a 100644 --- a/gcc/config/gcn/gcn-hsa.h +++ b/gcc/config/gcn/gcn-hsa.h @@ -75,25 +75,64 @@ extern unsigned int gcn_local_sym_hash (const char *name); supported for gcn. */ #define GOMP_SELF_SPECS "" +#ifdef HAVE_GCN_XNACK_FIJI +#define X_FIJI +#else +#define X_FIJI "!march=*:;march=fiji:;" +#endif +#ifdef HAVE_GCN_XNACK_GFX900 +#define X_900 +#else +#define X_900 "march=gfx900:;" +#endif +#ifdef HAVE_GCN_XNACK_GFX906 +#define X_906 +#else +#define X_906 "march=gfx906:;" +#endif +#ifdef HAVE_GCN_XNACK_GFX908 +#define X_908 +#else +#define X_908 "march=gfx908:;" +#endif + #ifdef HAVE_GCN_SRAM_ECC_FIJI -#define A_FIJI +#define S_FIJI #else -#define A_FIJI "!march=*:;march=fiji:;" +#define S_FIJI "!march=*:;march=fiji:;" #endif #ifdef HAVE_GCN_SRAM_ECC_GFX900 -#define A_900 +#define S_900 #else -#define A_900 "march=gfx900:;" +#define S_900 "march=gfx900:;" #endif #ifdef HAVE_GCN_SRAM_ECC_GFX906 -#define A_906 +#define S_906 #else -#define A_906 "march=gfx906:;" +#define S_906 "march=gfx906:;" #endif #ifdef HAVE_GCN_SRAM_ECC_GFX908 -#define A_908 +#define S_908 +#else +#define S_908 "march=gfx908:;" +#endif + +#ifdef HAVE_GCN_ASM_V3_SYNTAX +#define SRAMOPT "sram-ecc" +#endif +#ifdef HAVE_GCN_ASM_V4_SYNTAX +#define SRAMOPT "sramecc" +#endif +#if !defined(SRAMOPT) && !defined(IN_LIBGCC2) +#error "No assembler syntax configured" +#endif + +#ifdef HAVE_GCN_ASM_V4_SYNTAX +/* FIJI cards don't seem to support drivers new enough to allow HSACOv4. */ +#define HSACO3_SELECT_OPT \ + "%{!march=*|march=fiji:--amdhsa-code-object-version=3} " #else -#define A_908 "march=gfx908:;" +#define HSACO3_SELECT_OPT #endif /* These targets can't have SRAM-ECC, even if a broken assembler allows it. */ @@ -103,10 +142,12 @@ extern unsigned int gcn_local_sym_hash (const char *name); /* Use LLVM assembler and linker options. */ #define ASM_SPEC "-triple=amdgcn--amdhsa " \ "%:last_arg(%{march=*:-mcpu=%*}) " \ - "-mattr=%{mxnack:+xnack;:-xnack} " \ + HSACO3_SELECT_OPT \ + "-mattr=%{" X_FIJI X_900 X_906 X_908 \ + "mxnack:+xnack;:-xnack} " \ /* FIXME: support "any" when we move to HSACOv4. */ \ - "-mattr=%{" A_FIJI A_900 A_906 A_908 \ - "!msram-ecc=off:+sram-ecc;:-sram-ecc} " \ + "-mattr=%{" S_FIJI S_900 S_906 S_908 \ + "!msram-ecc=off:+" SRAMOPT ";:-" SRAMOPT "} " \ "-filetype=obj" #define LINK_SPEC "--pie --export-dynamic" #define LIB_SPEC "-lc" diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 2a3fc96..8517168 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -5217,42 +5217,72 @@ static void output_file_start (void) { const char *cpu; - bool use_sram = flag_sram_ecc; + bool use_xnack_attr = true; + bool use_sram_attr = true; switch (gcn_arch) { case PROCESSOR_FIJI: cpu = "gfx803"; +#ifndef HAVE_GCN_XNACK_FIJI + use_xnack_attr = false; +#endif #ifndef HAVE_GCN_SRAM_ECC_FIJI - use_sram = false; + use_sram_attr = false; #endif break; case PROCESSOR_VEGA10: cpu = "gfx900"; +#ifndef HAVE_GCN_XNACK_GFX900 + use_xnack_attr = false; +#endif #ifndef HAVE_GCN_SRAM_ECC_GFX900 - use_sram = false; + use_sram_attr = false; #endif break; case PROCESSOR_VEGA20: cpu = "gfx906"; +#ifndef HAVE_GCN_XNACK_GFX906 + use_xnack_attr = false; +#endif #ifndef HAVE_GCN_SRAM_ECC_GFX906 - use_sram = false; + use_sram_attr = false; #endif break; case PROCESSOR_GFX908: cpu = "gfx908"; +#ifndef HAVE_GCN_XNACK_GFX908 + use_xnack_attr = false; +#endif #ifndef HAVE_GCN_SRAM_ECC_GFX908 - use_sram = false; + use_sram_attr = false; #endif break; default: gcc_unreachable (); } +#if HAVE_GCN_ASM_V3_SYNTAX const char *xnack = (flag_xnack ? "+xnack" : ""); + const char *sram_ecc = (flag_sram_ecc ? "+sram-ecc" : ""); +#endif +#if HAVE_GCN_ASM_V4_SYNTAX + const char *xnack = (flag_xnack ? ":xnack+" : ":xnack-"); /* FIXME: support "any" when we move to HSACOv4. */ - const char *sram_ecc = (use_sram ? "+sram-ecc" : ""); + const char *sram_ecc = (flag_sram_ecc ? ":sramecc+" : ":sramecc-"); +#endif + if (!use_xnack_attr) + xnack = ""; + if (!use_sram_attr) + sram_ecc = ""; fprintf(asm_out_file, "\t.amdgcn_target \"amdgcn-unknown-amdhsa--%s%s%s\"\n", - cpu, xnack, sram_ecc); + cpu, +#if HAVE_GCN_ASM_V3_SYNTAX + xnack, sram_ecc +#endif +#ifdef HAVE_GCN_ASM_V4_SYNTAX + sram_ecc, xnack +#endif + ); } /* Implement ASM_DECLARE_FUNCTION_NAME via gcn-hsa.h. |