public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Chen Gang <xili_gchen_5257@hotmail.com>
To: Jeff Law <law@redhat.com>, Richard Henderson <rth@redhat.com>,
	"Joseph S. Myers" <joseph@codesourcery.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: [PATCH] gcc/ira.c: Check !HAVE_FP_INSTEAD_INSNS when frame pointer is needed and as global register
Date: Sun, 11 Oct 2015 15:16:00 -0000	[thread overview]
Message-ID: <COL130-W507E81834CE1C264271E3BB9320@phx.gbl> (raw)
In-Reply-To: <561A7D5C.40409@hotmail.com>

From fadd991f87dbd5752e9b6a2cce300dfe7cc8af25 Mon Sep 17 00:00:00 2001
From: Chen Gang <gang.chen.5i5j@gmail.com>
Date: Sun, 11 Oct 2015 22:59:35 +0800
Subject: [PATCH] gcc/ira.c: Check !HAVE_FP_INSTEAD_INSNS when frame pointer is needed and as global register

For some architectures (e.g. bfin), when this case occurs, they will use
another instructions instead of frame pointer (e.g. LINK for bfin), so
they can still generate correct output assembly code.

2015-10-11  Chen Gang  <gang.chen.5i5j@gmail.com>

	gcc/
	* config.in: Add HAVE_FP_INSTEAD_INSNS.
	* configure: Check HAVE_FP_INSTEAD_INSNS to set 0 or 1.
	* ira.c: Check !HAVE_FP_INSTEAD_INSNS when frame pointer is
	needed and as global register.
---
 gcc/config.in |  5 +++++
 gcc/configure | 18 ++++++++++++++++++
 gcc/ira.c     |  3 ++-
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/gcc/config.in b/gcc/config.in
index 093478c..97f5957 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1154,6 +1154,11 @@
 #undef HAVE_FWRITE_UNLOCKED
 #endif
 
+/* Define 0/1 if your machine supports frame pointer instead instructions. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_FP_INSTEAD_INSNS
+#endif
+
 
 /* Define if your assembler supports specifying the alignment of objects
    allocated using the GAS .comm command. */
diff --git a/gcc/configure b/gcc/configure
index f6ae9906..a1aa430 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -22356,6 +22356,24 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_flags">&5
 $as_echo "$gcc_cv_as_flags">&6; }
 
+# Check if the target have frame pointer instead instructions
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target frame pointer instead instructions">&5
+$as_echo_n "checking target frame pointer instead instructions...">&6; }
+case "$cpu_type" in
+  bfin)
+    gcc_cv_fp_instead="yes"
+    ;;
+  *)
+    gcc_cv_fp_instead="no"
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_fp_instead">&5
+$as_echo "$gcc_cv_fp_instead">&6; }
+
+cat>>confdefs.h <<_ACEOF
+#define HAVE_FP_INSTEAD_INSNS `if test $gcc_cv_fp_instead = yes; then echo 1; else echo 0; fi`
+_ACEOF
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .balign and .p2align">&5
 $as_echo_n "checking assembler for .balign and .p2align... ">&6; }
 if test "${gcc_cv_as_balign_and_p2align+set}" = set; then :
diff --git a/gcc/ira.c b/gcc/ira.c
index 28517c1..998d11b 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -5471,7 +5471,8 @@ do_reload (void)
      register.  Often we can get away with letting the user appropriate
      the frame pointer, but we should let them know when code generation
      makes that impossible.  */
-  if (global_regs[HARD_FRAME_POINTER_REGNUM] && frame_pointer_needed)
+  if (global_regs[HARD_FRAME_POINTER_REGNUM] && frame_pointer_needed
+      && !HAVE_FP_INSTEAD_INSNS)
     {
       tree decl = global_regs_decl[HARD_FRAME_POINTER_REGNUM];
       error_at (DECL_SOURCE_LOCATION (current_function_decl),
-- 
1.9.3

 		 	   		  

       reply	other threads:[~2015-10-11 15:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <561A7D5C.40409@hotmail.com>
2015-10-11 15:16 ` Chen Gang [this message]
2015-10-12 10:49   ` Bernd Schmidt
2015-10-12 22:30     ` Chen Gang
2015-10-12 23:03       ` Mike Stump
2015-10-13 14:48         ` Chen Gang
2015-10-13 14:56           ` Bernd Schmidt
2015-10-13 15:10             ` Chen Gang

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=COL130-W507E81834CE1C264271E3BB9320@phx.gbl \
    --to=xili_gchen_5257@hotmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=law@redhat.com \
    --cc=rth@redhat.com \
    /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).