public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: James Clarke <jrtc27@jrtc27.com>
To: gcc-patches@gcc.gnu.org
Cc: James Clarke <jrtc27@jrtc27.com>
Subject: [PATCH] RISC-V: Pass -mno-relax through to assembler if supported
Date: Sun, 18 Nov 2018 15:28:00 -0000	[thread overview]
Message-ID: <20181118152807.2967-1-jrtc27@jrtc27.com> (raw)

GCC will emit ".option (no)relax" in its outputted assembly, but when
using it as an assembler driver, such as for preprocessed assembly, it's
merely preprocessing and therefore will not generate this directive.
Therefore we should pass -mno-relax on to the assembler if specified
(and supported) as we do for other flags.

gcc/
	* configure.ac: (gcc_cv_as_riscv_mno_relax): Check if the
	assembler supports -mno-relax.
	* configure: Regenerate
	* config.in: Regenerate
	* config/riscv/riscv.h (ASM_MNO_RELAX_SPEC): Define based on
	HAVE_AS_MNO_RELAX_OPTION.
	(ASM_SPEC): Add %(asm_mno_relax_spec).
	(EXTRA_SPECS): Define to include $(asm_mno_relax_spec) and
	SUBTARGET_EXTRA_SPECS.
	(SUBTARGET_EXTRA_SPECS): Provide empty default value.
---
 gcc/config/riscv/riscv.h | 25 +++++++++++++++++++++++++
 gcc/configure.ac         |  8 ++++++++
 2 files changed, 33 insertions(+)

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 13e15cc85..77d92acb2 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -55,14 +55,39 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_64BIT           (__riscv_xlen == 64)
 #endif /* IN_LIBGCC2 */
 
+#ifdef HAVE_AS_MNO_RELAX_OPTION
+#define ASM_MNO_RELAX_SPEC "%{mno-relax}"
+#else
+#define ASM_MNO_RELAX_SPEC ""
+#endif
+
 #undef ASM_SPEC
 #define ASM_SPEC "\
 %(subtarget_asm_debugging_spec) \
 %{" FPIE_OR_FPIC_SPEC ":-fpic} \
 %{march=*} \
 %{mabi=*} \
+%(asm_mno_relax_spec) \
 %(subtarget_asm_spec)"
 
+/* This macro defines names of additional specifications to put in the specs
+   that can be used in various specifications like CC1_SPEC.  Its definition
+   is an initializer with a subgrouping for each command option.
+
+   Each subgrouping contains a string constant, that defines the
+   specification name, and a string constant that used by the GCC driver
+   program.
+
+   Do not define this macro if it does not need to do anything.  */
+
+#define EXTRA_SPECS							\
+  { "asm_mno_relax_spec", ASM_MNO_RELAX_SPEC },				\
+  SUBTARGET_EXTRA_SPECS
+
+#ifndef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS
+#endif
+
 #define TARGET_DEFAULT_CMODEL CM_MEDLOW
 
 #define LOCAL_LABEL_PREFIX	"."
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 260d987da..4b7c0c79f 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4827,6 +4827,14 @@ pointers into PC-relative form.])
 	[Requesting --with-nan= requires assembler support for -mnan=])
     fi
     ;;
+
+  riscv*-*-*)
+    gcc_GAS_CHECK_FEATURE([-mno-relax option], gcc_cv_as_riscv_mno_relax,,
+      [-mno-relax], [.text],,
+      [AC_DEFINE(HAVE_AS_MNO_RELAX_OPTION, 1,
+		[Define if your assembler supports -mno-relax option.])])
+    ;;
+
     s390*-*-*)
     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
       gcc_cv_as_s390_gnu_attribute, [2,18,0],,
-- 
2.14.1

             reply	other threads:[~2018-11-18 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-18 15:28 James Clarke [this message]
2018-11-20 19:24 ` Jim Wilson

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=20181118152807.2967-1-jrtc27@jrtc27.com \
    --to=jrtc27@jrtc27.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).