Am 16.06.2021 um 19:19 schrieb Joseph Myers:
On Wed, 16 Jun 2021, Julian Brown wrote:
+ if test x$gcc_cv_as_gcn_global_load_fixed = xyes; then
+ AC_DEFINE(HAVE_GCN_ASM_GLOBAL_LOAD_FIXED, 1, [Define if your
assembler has fixed global_load functions.])
+ else
+ AC_DEFINE(HAVE_GCN_ASM_GLOBAL_LOAD_FIXED, 0, [Define if your
assembler has fixed global_load functions.])
+ fi
+ AC_MSG_RESULT($gcc_cv_as_gcn_global_load_fixed)
+ ;;
+esac
I think the more-common idiom seems to be just having a single
AC_DEFINE if the feature is present -- like (as a random example)
HAVE_AS_IX86_REP_LOCK_PREFIX, which omits the "define ... 0" case you
have here. (You'd use "#ifdef ..." instead of "#if ... == 1" to check
the feature then, of course).
Actually I think what's preferable is the approach used with e.g.
GATHER_STATISTICS - define to 0 or 1 using a single AC_DEFINE_UNQUOTED
call (via a shell variable that's set to 0 or 1 as appropriate), then test
in "if" conditions, not #if, as far as possible, so that both alternatives
in the conditional code always get syntax-checked when compiling GCC (for
this target).
Thank you for your proposals. I adapted configure.ac and gcn.c
accordingly (similar to the GATHER_STATISTICS example).
Marcel
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank
Thürauf
gcc/configure.ac: Adapt configuration according to assembler fix of global_load
functions.
gcc/ChangeLog:
* config.in: Regenerate.
* config/gcn/gcn.c (print_operand_address): Fix for global_load
assembler
functions.
* configure: Regenerate.
* configure.ac: Fix for global_load assembler functions.
diff --git a/gcc/config.in b/gcc/config.in
index e54f59c..18e6271 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1431,6 +1431,12 @@
#endif
+/* Define if your assembler has fixed global_load functions. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_GCN_ASM_GLOBAL_LOAD_FIXED
+#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.c b/gcc/config/gcn/gcn.c
index 283a91f..54a1c0b 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -5481,13 +5481,22 @@ print_operand_address (FILE *file, rtx mem)
if (vgpr_offset == NULL_RTX)
/* In this case, the vector offset is zero, so we use the first
lane of v1, which is initialized to zero. */
- fprintf (file, "v[1:2]");
+ {
+ if (HAVE_GCN_ASM_GLOBAL_LOAD_FIXED)
+ fprintf (file, "v1");
+ else
+ fprintf (file, "v[1:2]");
+ }
else if (REG_P (vgpr_offset)
&& VGPR_REGNO_P (REGNO (vgpr_offset)))
{
- fprintf (file, "v[%d:%d]",
- REGNO (vgpr_offset) - FIRST_VGPR_REG,
- REGNO (vgpr_offset) - FIRST_VGPR_REG + 1);
+ if (HAVE_GCN_ASM_GLOBAL_LOAD_FIXED)
+ fprintf (file, "v%d",
+ REGNO (vgpr_offset) - FIRST_VGPR_REG);
+ else
+ fprintf (file, "v[%d:%d]",
+ REGNO (vgpr_offset) - FIRST_VGPR_REG,
+ REGNO (vgpr_offset) - FIRST_VGPR_REG + 1);
}
else
output_operand_lossage ("bad ADDR_SPACE_GLOBAL address");
diff --git a/gcc/configure b/gcc/configure
index 4a9e4fa..dd0194a 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -28909,6 +28909,33 @@ case "$target" in
;;
esac
+# This tests if the assembler supports two registers for global_load functions
+# (like in LLVM versions <12) or one register (like in LLVM 12).
+case "$target" in
+ amdgcn-* | gcn-*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler fix for
global_load functions" >&5
+$as_echo_n "checking assembler fix for global_load functions... " >&6; }
+ gcc_cv_as_gcn_global_load_fixed=yes
+ if test x$gcc_cv_as != x; then
+ cat > conftest.s <<EOF
+ global_store_dwordx2 v[1:2], v[4:5], s[14:15]
+EOF
+ if $gcc_cv_as -triple=amdgcn--amdhsa -filetype=obj -mcpu=gfx900 -o
conftest.o conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_gcn_global_load_fixed=no
+ fi
+ rm -f conftest.s conftest.o conftest
+ fi
+ global_load_fixed=`if test x$gcc_cv_as_gcn_global_load_fixed = xyes; then
echo 1; else echo 0; fi`
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GCN_ASM_GLOBAL_LOAD_FIXED $global_load_fixed
+_ACEOF
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result:
$gcc_cv_as_gcn_global_load_fixed" >&5
+$as_echo "$gcc_cv_as_gcn_global_load_fixed" >&6; }
+ ;;
+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 d9fc3c2..5f30f80 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5357,6 +5357,28 @@ case "$target" in
;;
esac
+# This tests if the assembler supports two registers for global_load functions
+# (like in LLVM versions <12) or one register (like in LLVM 12).
+case "$target" in
+ amdgcn-* | gcn-*)
+ AC_MSG_CHECKING(assembler fix for global_load functions)
+ gcc_cv_as_gcn_global_load_fixed=yes
+ if test x$gcc_cv_as != x; then
+ cat > conftest.s <<EOF
+ global_store_dwordx2 v[[1:2]], v[[4:5]], s[[14:15]]
+EOF
+ if $gcc_cv_as -triple=amdgcn--amdhsa -filetype=obj -mcpu=gfx900 -o
conftest.o conftest.s > /dev/null 2>&1; then
+ gcc_cv_as_gcn_global_load_fixed=no
+ fi
+ rm -f conftest.s conftest.o conftest
+ fi
+ global_load_fixed=`if test x$gcc_cv_as_gcn_global_load_fixed = xyes; then
echo 1; else echo 0; fi`
+ AC_DEFINE_UNQUOTED(HAVE_GCN_ASM_GLOBAL_LOAD_FIXED, $global_load_fixed,
+ [Define if your assembler has fixed global_load functions.])
+ AC_MSG_RESULT($gcc_cv_as_gcn_global_load_fixed)
+ ;;
+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,