public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Pass -mno-relax through to assembler if supported
@ 2018-11-18 15:28 James Clarke
  2018-11-20 19:24 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: James Clarke @ 2018-11-18 15:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: James Clarke

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] RISC-V: Pass -mno-relax through to assembler if supported
  2018-11-18 15:28 [PATCH] RISC-V: Pass -mno-relax through to assembler if supported James Clarke
@ 2018-11-20 19:24 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2018-11-20 19:24 UTC (permalink / raw)
  To: James Clarke, gcc-patches

On 11/18/18 7:28 AM, James Clarke wrote:
> 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.

This looks good.  I will commit when your assignment comes through.

Jim

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-20 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-18 15:28 [PATCH] RISC-V: Pass -mno-relax through to assembler if supported James Clarke
2018-11-20 19:24 ` Jim Wilson

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).