aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Stubbs <ams@codesourcery.com>2021-07-27 15:40:21 +0100
committerAndrew Stubbs <ams@codesourcery.com>2021-07-28 13:53:05 +0100
commit1af16666943ef075673501765a13e425e47015cd (patch)
tree125841bf2e8d59d6fa25396abc5e6d9a274c9116 /gcc
parent04600a47224b1ff85c6fb870218b51969cceff21 (diff)
downloadgcc-1af16666943ef075673501765a13e425e47015cd.zip
gcc-1af16666943ef075673501765a13e425e47015cd.tar.gz
gcc-1af16666943ef075673501765a13e425e47015cd.tar.bz2
amdgcn: Fix attributes for LLVM-12 [PR 100208]
This should work for a wider range of LLVM 12 variants now. More work required for LLVM 13 though. gcc/ChangeLog: PR target/100208 * config.in: Regenerate. * config/gcn/gcn-hsa.h (A_FIJI): New define. (A_900): New define. (A_906): New define. (A_908): New define. (ASM_SPEC): Use A_FIJI, A_900, A_906 and A_908. * config/gcn/gcn.c (output_file_start): Adjust attributes according to the assembler capabilities. * config/gcn/mkoffload.c (main): Likewise. * configure: Regenerate. * configure.ac: Add tests for LLVM assembler attribute features.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config.in24
-rw-r--r--gcc/config/gcn/gcn-hsa.h25
-rw-r--r--gcc/config/gcn/gcn.c31
-rw-r--r--gcc/config/gcn/mkoffload.c3
-rwxr-xr-xgcc/configure129
-rw-r--r--gcc/configure.ac29
6 files changed, 235 insertions, 6 deletions
diff --git a/gcc/config.in b/gcc/config.in
index 2abac53..affaff2 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1449,6 +1449,30 @@
#endif
+/* Define if your assembler allows -mattr=+sram-ecc for fiji. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GCN_SRAM_ECC_FIJI
+#endif
+
+
+/* Define if your assembler allows -mattr=+sram-ecc for gfx900. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GCN_SRAM_ECC_GFX900
+#endif
+
+
+/* Define if your assembler allows -mattr=+sram-ecc for gfx906. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GCN_SRAM_ECC_GFX906
+#endif
+
+
+/* Define if your assembler allows -mattr=+sram-ecc for gfx908. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GCN_SRAM_ECC_GFX908
+#endif
+
+
/* Define to 1 if you have the `getchar_unlocked' function. */
#ifndef USED_FOR_TARGET
#undef HAVE_GETCHAR_UNLOCKED
diff --git a/gcc/config/gcn/gcn-hsa.h b/gcc/config/gcn/gcn-hsa.h
index 724e9a3..fc99c8d 100644
--- a/gcc/config/gcn/gcn-hsa.h
+++ b/gcc/config/gcn/gcn-hsa.h
@@ -75,6 +75,28 @@ extern unsigned int gcn_local_sym_hash (const char *name);
supported for gcn. */
#define GOMP_SELF_SPECS ""
+#ifdef HAVE_GCN_SRAM_ECC_FIJI
+#define A_FIJI
+#else
+#define A_FIJI "!march=*:;march=fiji:;"
+#endif
+#ifdef HAVE_GCN_SRAM_ECC_GFX900
+#define A_900
+#else
+#define A_900 "march=gfx900:;"
+#endif
+#ifdef HAVE_GCN_SRAM_ECC_GFX906
+#define A_906
+#else
+#define A_906 "march=gfx906:;"
+#endif
+#ifdef HAVE_GCN_SRAM_ECC_GFX908
+#define A_908
+#else
+#define A_908 "march=gfx908:;"
+#endif
+
+/* These targets can't have SRAM-ECC, even if a broken assembler allows it. */
#define DRIVER_SELF_SPECS \
"%{march=fiji|march=gfx900|march=gfx906:%{!msram-ecc=*:-msram-ecc=off}}"
@@ -83,7 +105,8 @@ extern unsigned int gcn_local_sym_hash (const char *name);
"%:last_arg(%{march=*:-mcpu=%*}) " \
"-mattr=%{mxnack:+xnack;:-xnack} " \
/* FIXME: support "any" when we move to HSACOv4. */ \
- "-mattr=%{!msram-ecc=off:+sram-ecc;:-sram-ecc} " \
+ "-mattr=%{" A_FIJI A_900 A_906 A_908 \
+ "!msram-ecc=off:+sram-ecc;:-sram-ecc} " \
"-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 385b90c..d25c4e5 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -5181,18 +5181,39 @@ static void
output_file_start (void)
{
const char *cpu;
+ bool use_sram = flag_sram_ecc;
switch (gcn_arch)
{
- case PROCESSOR_FIJI: cpu = "gfx803"; break;
- case PROCESSOR_VEGA10: cpu = "gfx900"; break;
- case PROCESSOR_VEGA20: cpu = "gfx906"; break;
- case PROCESSOR_GFX908: cpu = "gfx908"; break;
+ case PROCESSOR_FIJI:
+ cpu = "gfx803";
+#ifndef HAVE_GCN_SRAM_ECC_FIJI
+ use_sram = false;
+#endif
+ break;
+ case PROCESSOR_VEGA10:
+ cpu = "gfx900";
+#ifndef HAVE_GCN_SRAM_ECC_GFX900
+ use_sram = false;
+#endif
+ break;
+ case PROCESSOR_VEGA20:
+ cpu = "gfx906";
+#ifndef HAVE_GCN_SRAM_ECC_GFX906
+ use_sram = false;
+#endif
+ break;
+ case PROCESSOR_GFX908:
+ cpu = "gfx908";
+#ifndef HAVE_GCN_SRAM_ECC_GFX908
+ use_sram = false;
+#endif
+ break;
default: gcc_unreachable ();
}
const char *xnack = (flag_xnack ? "+xnack" : "");
/* FIXME: support "any" when we move to HSACOv4. */
- const char *sram_ecc = (flag_sram_ecc ? "+sram-ecc" : "");
+ const char *sram_ecc = (use_sram ? "+sram-ecc" : "");
fprintf(asm_out_file, "\t.amdgcn_target \"amdgcn-unknown-amdhsa--%s%s%s\"\n",
cpu, xnack, sram_ecc);
diff --git a/gcc/config/gcn/mkoffload.c b/gcc/config/gcn/mkoffload.c
index 804cc26..732bdfd 100644
--- a/gcc/config/gcn/mkoffload.c
+++ b/gcc/config/gcn/mkoffload.c
@@ -898,6 +898,9 @@ main (int argc, char **argv)
case EF_AMDGPU_MACH_AMDGCN_GFX803:
case EF_AMDGPU_MACH_AMDGCN_GFX900:
case EF_AMDGPU_MACH_AMDGCN_GFX906:
+#ifndef HAVE_GCN_SRAM_ECC_GFX908
+ case EF_AMDGPU_MACH_AMDGCN_GFX908:
+#endif
break;
default:
/* FIXME: change this when we move to HSACOv4. */
diff --git a/gcc/configure b/gcc/configure
index a15f8b4..8b5acd7 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -29046,6 +29046,135 @@ $as_echo "$gcc_cv_as_gcn_global_load_fixed" >&6; }
;;
esac
+case "$target" in
+ amdgcn-* | gcn-*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembler accepts -mattr=+sram-ecc for fiji" >&5
+$as_echo_n "checking assembler for assembler accepts -mattr=+sram-ecc for fiji... " >&6; }
+if ${gcc_cv_as_gcn_sram_ecc_fiji+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_gcn_sram_ecc_fiji=no
+ if test x$gcc_cv_as != x; then
+ $as_echo '.amdgcn_target "amdgcn-unknown-amdhsa--gfx803+sram-ecc"' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -triple=amdgcn--amdhsa -mcpu=fiji -mattr=-xnack -mattr=+sram-ecc -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_gcn_sram_ecc_fiji=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_gcn_sram_ecc_fiji" >&5
+$as_echo "$gcc_cv_as_gcn_sram_ecc_fiji" >&6; }
+if test $gcc_cv_as_gcn_sram_ecc_fiji = yes; then
+
+$as_echo "#define HAVE_GCN_SRAM_ECC_FIJI 1" >>confdefs.h
+
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembler accepts -mattr=+sram-ecc for gfx900" >&5
+$as_echo_n "checking assembler for assembler accepts -mattr=+sram-ecc for gfx900... " >&6; }
+if ${gcc_cv_as_gcn_sram_ecc_gfx900+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_gcn_sram_ecc_gfx900=no
+ if test x$gcc_cv_as != x; then
+ $as_echo '.amdgcn_target "amdgcn-unknown-amdhsa--gfx900+sram-ecc"' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -triple=amdgcn--amdhsa -mcpu=gfx900 -mattr=-xnack -mattr=+sram-ecc -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_gcn_sram_ecc_gfx900=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_gcn_sram_ecc_gfx900" >&5
+$as_echo "$gcc_cv_as_gcn_sram_ecc_gfx900" >&6; }
+if test $gcc_cv_as_gcn_sram_ecc_gfx900 = yes; then
+
+$as_echo "#define HAVE_GCN_SRAM_ECC_GFX900 1" >>confdefs.h
+
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembler accepts -mattr=+sram-ecc for gfx906" >&5
+$as_echo_n "checking assembler for assembler accepts -mattr=+sram-ecc for gfx906... " >&6; }
+if ${gcc_cv_as_gcn_sram_ecc_gfx906+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_gcn_sram_ecc_gfx906=no
+ if test x$gcc_cv_as != x; then
+ $as_echo '.amdgcn_target "amdgcn-unknown-amdhsa--gfx906+sram-ecc"' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -triple=amdgcn--amdhsa -mcpu=gfx906 -mattr=-xnack -mattr=+sram-ecc -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_gcn_sram_ecc_gfx906=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_gcn_sram_ecc_gfx906" >&5
+$as_echo "$gcc_cv_as_gcn_sram_ecc_gfx906" >&6; }
+if test $gcc_cv_as_gcn_sram_ecc_gfx906 = yes; then
+
+$as_echo "#define HAVE_GCN_SRAM_ECC_GFX906 1" >>confdefs.h
+
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for assembler accepts -mattr=+sram-ecc for gfx908" >&5
+$as_echo_n "checking assembler for assembler accepts -mattr=+sram-ecc for gfx908... " >&6; }
+if ${gcc_cv_as_gcn_sram_ecc_gfx908+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ gcc_cv_as_gcn_sram_ecc_gfx908=no
+ if test x$gcc_cv_as != x; then
+ $as_echo '.amdgcn_target "amdgcn-unknown-amdhsa--gfx908+sram-ecc"' > conftest.s
+ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -triple=amdgcn--amdhsa -mcpu=gfx908 -mattr=-xnack -mattr=+sram-ecc -o conftest.o conftest.s >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }
+ then
+ gcc_cv_as_gcn_sram_ecc_gfx908=yes
+ else
+ echo "configure: failed program was" >&5
+ cat conftest.s >&5
+ fi
+ rm -f conftest.o conftest.s
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_gcn_sram_ecc_gfx908" >&5
+$as_echo "$gcc_cv_as_gcn_sram_ecc_gfx908" >&6; }
+if test $gcc_cv_as_gcn_sram_ecc_gfx908 = yes; then
+
+$as_echo "#define HAVE_GCN_SRAM_ECC_GFX908 1" >>confdefs.h
+
+fi
+
+ ;;
+esac
+
# ??? Not all targets support dwarf2 debug_line, even within a version
# of gas. Moreover, we need to emit a valid instruction to trigger any
# info to the output file. So, as supported targets are added to gas 2.11,
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 26da073..c8e0d63 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5431,6 +5431,35 @@ EOF
;;
esac
+case "$target" in
+ amdgcn-* | gcn-*)
+ gcc_GAS_CHECK_FEATURE([assembler accepts -mattr=+sram-ecc for fiji],
+ gcc_cv_as_gcn_sram_ecc_fiji,,
+ [-triple=amdgcn--amdhsa -mcpu=fiji -mattr=-xnack -mattr=+sram-ecc],
+ [.amdgcn_target "amdgcn-unknown-amdhsa--gfx803+sram-ecc"],,
+ [AC_DEFINE(HAVE_GCN_SRAM_ECC_FIJI, 1,
+ [Define if your assembler allows -mattr=+sram-ecc for fiji.])])
+ gcc_GAS_CHECK_FEATURE([assembler accepts -mattr=+sram-ecc for gfx900],
+ gcc_cv_as_gcn_sram_ecc_gfx900,,
+ [-triple=amdgcn--amdhsa -mcpu=gfx900 -mattr=-xnack -mattr=+sram-ecc],
+ [.amdgcn_target "amdgcn-unknown-amdhsa--gfx900+sram-ecc"],,
+ [AC_DEFINE(HAVE_GCN_SRAM_ECC_GFX900, 1,
+ [Define if your assembler allows -mattr=+sram-ecc for gfx900.])])
+ gcc_GAS_CHECK_FEATURE([assembler accepts -mattr=+sram-ecc for gfx906],
+ gcc_cv_as_gcn_sram_ecc_gfx906,,
+ [-triple=amdgcn--amdhsa -mcpu=gfx906 -mattr=-xnack -mattr=+sram-ecc],
+ [.amdgcn_target "amdgcn-unknown-amdhsa--gfx906+sram-ecc"],,
+ [AC_DEFINE(HAVE_GCN_SRAM_ECC_GFX906, 1,
+ [Define if your assembler allows -mattr=+sram-ecc for gfx906.])])
+ gcc_GAS_CHECK_FEATURE([assembler accepts -mattr=+sram-ecc for gfx908],
+ gcc_cv_as_gcn_sram_ecc_gfx908,,
+ [-triple=amdgcn--amdhsa -mcpu=gfx908 -mattr=-xnack -mattr=+sram-ecc],
+ [.amdgcn_target "amdgcn-unknown-amdhsa--gfx908+sram-ecc"],,
+ [AC_DEFINE(HAVE_GCN_SRAM_ECC_GFX908, 1,
+ [Define if your assembler allows -mattr=+sram-ecc for gfx908.])])
+ ;;
+esac
+
# ??? Not all targets support dwarf2 debug_line, even within a version
# of gas. Moreover, we need to emit a valid instruction to trigger any
# info to the output file. So, as supported targets are added to gas 2.11,