From: Marcel Vollweiler <marcel@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [PATCH] gcc/configure.ac: fix register issue for global_load assembler functions
Date: Wed, 9 Jun 2021 16:47:21 +0200 [thread overview]
Message-ID: <284bb460-f192-db1d-8deb-fd9579ebdd9a@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
This patch fixes an issue with global_load assembler functions leading
to a "invalid operand for instruction" error since in different LLVM
versions those functions use either one or two registers.
In this patch a compatibility check is added to the configure.ac.
Marcel
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
[-- Attachment #2: global_load.diff --]
[-- Type: text/plain, Size: 4685 bytes --]
gcc/ChangeLog: adapt configuration according to assembler fix of global_load functions.
* 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..2d27296 100644
--- a/gcc/config/gcn/gcn.c
+++ b/gcc/config/gcn/gcn.c
@@ -5481,13 +5481,24 @@ 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 == 1
+ fprintf (file, "v1");
+#else
+ fprintf (file, "v[1:2]");
+#endif
+ }
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 == 1
+ 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);
+#endif
}
else
output_operand_lossage ("bad ADDR_SPACE_GLOBAL address");
diff --git a/gcc/configure b/gcc/configure
index 4a9e4fa..8e044c3 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -28909,6 +28909,36 @@ 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_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_global_load_fixed=no
+ fi
+ rm -f conftest.s conftest.o conftest
+ fi
+ if test x$gcc_cv_as_global_load_fixed = xyes; then
+
+$as_echo "#define HAVE_GCN_ASM_GLOBAL_LOAD_FIXED 1" >>confdefs.h
+
+ else
+
+$as_echo "#define HAVE_GCN_ASM_GLOBAL_LOAD_FIXED 0" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_global_load_fixed" >&5
+$as_echo "$gcc_cv_as_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..d7ea224 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5357,6 +5357,30 @@ 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_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_global_load_fixed=no
+ fi
+ rm -f conftest.s conftest.o conftest
+ fi
+ if test x$gcc_cv_as_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_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,
next reply other threads:[~2021-06-09 14:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 14:47 Marcel Vollweiler [this message]
2021-06-14 12:36 ` Julian Brown
2021-06-14 13:28 ` Tobias Burnus
2021-06-14 14:26 ` Andrew Stubbs
2021-06-14 15:28 ` Julian Brown
2021-06-16 9:34 ` Marcel Vollweiler
2021-06-16 16:01 ` Julian Brown
2021-06-16 17:19 ` Joseph Myers
2021-06-17 13:50 ` Marcel Vollweiler
2021-06-17 20:31 ` Joseph Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=284bb460-f192-db1d-8deb-fd9579ebdd9a@codesourcery.com \
--to=marcel@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).