OSDN Git Service

* configure.in: Check whether gas supports -relax.
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Jun 2000 14:31:54 +0000 (14:31 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Jun 2000 14:31:54 +0000 (14:31 +0000)
* configure, config.in: Rebuilt.
* config/sparc/sparc.h (ASM_RELAX_SPEC): Define.
(EXTRA_SPECS): Add asm_relax.
(ASM_SPEC): Add %(asm_relax).
(TARGET_SWITCHES): Add -mrelax and -mno-relax.
* config/sparc/linux64.h (LINK_ARCH_SPEC): Rename to LINK_SPEC.
(LINK_SPEC): Pass -relax to linker unless -mno-relax or -r.
(ASM_SPEC): Add %(asm_relax).
* config/sparc/linux.h (LINK_SPEC, ASM_SPEC): Likewise.
* config/sparc/sparc.c (output_sibcall): If HAVE_AS_RELAX_OPTION,
never use sethi/jmpl for leaf tail calls.  Use or with rs2 %g0
instead of mov, so that gas can further optimize it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34466 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config.in
gcc/config/sparc/linux.h
gcc/config/sparc/linux64.h
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.h
gcc/configure
gcc/configure.in

index 1971ecb..f09a3bb 100644 (file)
@@ -1,3 +1,19 @@
+2000-06-09  Jakub Jelinek  <jakub@redhat.com>
+
+       * configure.in: Check whether gas supports -relax.
+       * configure, config.in: Rebuilt.
+       * config/sparc/sparc.h (ASM_RELAX_SPEC): Define.
+       (EXTRA_SPECS): Add asm_relax.
+       (ASM_SPEC): Add %(asm_relax).
+       (TARGET_SWITCHES): Add -mrelax and -mno-relax.
+       * config/sparc/linux64.h (LINK_ARCH_SPEC): Rename to LINK_SPEC.
+       (LINK_SPEC): Pass -relax to linker unless -mno-relax or -r.
+       (ASM_SPEC): Add %(asm_relax).
+       * config/sparc/linux.h (LINK_SPEC, ASM_SPEC): Likewise.
+       * config/sparc/sparc.c (output_sibcall): If HAVE_AS_RELAX_OPTION,
+       never use sethi/jmpl for leaf tail calls.  Use or with rs2 %g0
+       instead of mov, so that gas can further optimize it.
+
 2000-06-08  James E. Wilson  <wilson@bletchleypark.cygnus.com>
 
        * dwarf2out.c (size_of_die, case dw_val_class_const): Use
index 1ed9c20..6521a6e 100644 (file)
 /* Define if your assembler supports .register. */
 #undef HAVE_AS_REGISTER_PSEUDO_OP
 
+/* Define if your assembler supports -relax option. */
+#undef HAVE_AS_RELAX_OPTION
+
 /* Define if the assembler supports 64bit sparc. */
 #undef AS_SPARC64_FLAG
 
index 75d0927..b92ecd5 100644 (file)
@@ -179,6 +179,7 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #else
 #define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
+  %{!mno-relax:%{!r:-relax}} \
   %{!shared: \
     %{!ibcs: \
       %{!static: \
@@ -191,7 +192,8 @@ Boston, MA 02111-1307, USA.  */
    It's safe to pass -s always, even if -g is not used. */
 #undef ASM_SPEC
 #define ASM_SPEC \
-  "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} %{fPIC:-K PIC}"
+  "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} \
+   %{fPIC:-K PIC} %(asm_relax)"
 
 /* Same as sparc.h */
 #undef DBX_REGISTER_NUMBER
index 18a7f8b..0f87b2c 100644 (file)
@@ -246,6 +246,7 @@ Boston, MA 02111-1307, USA.  */
 #define LINK_SPEC "\
 %(link_arch) \
 %{mlittle-endian:-EL} \
+%{!mno-relax:%{!r:-relax}} \
 "
 
 #undef CC1_SPEC
@@ -283,7 +284,7 @@ Boston, MA 02111-1307, USA.  */
 #else /* !SPARC_BI_ARCH */
 
 #undef LINK_SPEC
-#define LINK_ARCH_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
+#define LINK_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
   %{!shared: \
     %{!ibcs: \
       %{!static: \
@@ -291,6 +292,7 @@ Boston, MA 02111-1307, USA.  */
         %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
         %{static:-static}}} \
 %{mlittle-endian:-EL} \
+%{!mno-relax:%{!r:-relax}} \
 "
 
 #endif /* !SPARC_BI_ARCH */
@@ -308,8 +310,7 @@ Boston, MA 02111-1307, USA.  */
 %{Wa,*:%*} \
 -s %{fpic:-K PIC} %{fPIC:-K PIC} \
 %{mlittle-endian:-EL} \
-%(asm_cpu) %(asm_arch) \
-"
+%(asm_cpu) %(asm_arch) %(asm_relax)"
 
 /* Same as sparc.h */
 #undef DBX_REGISTER_NUMBER
index 1887396..2b44d2f 100644 (file)
@@ -3737,7 +3737,15 @@ output_sibcall (insn, call_operand)
 
   if (leaf_regs)
     {
+#ifdef HAVE_AS_RELAX_OPTION
+      /* If as and ld are relaxing tail call insns into branch always,
+        use or %o7,%g0,X; call Y; or X,%g0,%o7 always, so that it can
+        be optimized.  With sethi/jmpl as nor ld has no easy way how to
+        find out if somebody does not branch between the sethi and jmpl.  */
+      int spare_slot = 0;
+#else
       int spare_slot = ((TARGET_ARCH32 || TARGET_CM_MEDLOW) && ! flag_pic);
+#endif
       int size = 0;
 
       if ((actual_fsize || ! spare_slot) && delay_slot)
@@ -3786,9 +3794,11 @@ output_sibcall (insn, call_operand)
        {
          if (size)
            fprintf (asm_out_file, "\tsub\t%%sp, -%d, %%sp\n", size);
-         output_asm_insn ("mov\t%%o7, %%g1", operands);
+         /* Use or with rs2 %%g0 instead of mov, so that as/ld can optimize
+            it into branch if possible.  */
+         output_asm_insn ("or\t%%o7, %%g0, %%g1", operands);
          output_asm_insn ("call\t%a0, 0", operands);
-         output_asm_insn (" mov\t%%g1, %%o7", operands);
+         output_asm_insn (" or\t%%g1, %%g0, %%o7", operands);
        }
       return "";
     }
index 5b22657..1a584cd 100644 (file)
@@ -324,12 +324,17 @@ Unrecognized value in TARGET_CPU_DEFAULT.
 %{!m32:%{!m64:%(asm_arch_default)}} \
 "
 
+#ifdef HAVE_AS_RELAX_OPTION
+#define ASM_RELAX_SPEC "%{!mno-relax:-relax}"
+#else
+#define ASM_RELAX_SPEC ""
+#endif
+
 /* Special flags to the Sun-4 assembler when using pipe for input.  */
 
 #define ASM_SPEC "\
 %| %{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \
-%(asm_cpu) \
-"
+%(asm_cpu) %(asm_relax)"
 
 #define LIB_SPEC "%{!shared:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} %{g:-lg}}"
 
@@ -362,6 +367,7 @@ Unrecognized value in TARGET_CPU_DEFAULT.
   { "asm_cpu_default", ASM_CPU_DEFAULT_SPEC }, \
   { "asm_arch32",      ASM_ARCH32_SPEC },      \
   { "asm_arch64",      ASM_ARCH64_SPEC },      \
+  { "asm_relax",       ASM_RELAX_SPEC },       \
   { "asm_arch_default",        ASM_ARCH_DEFAULT_SPEC },\
   { "asm_arch",                ASM_ARCH_SPEC },        \
   SUBTARGET_EXTRA_SPECS
@@ -606,6 +612,8 @@ extern int target_flags;
     {"no-stack-bias", -MASK_STACK_BIAS,                        "Do not use stack bias" }, \
     {"faster-structs", MASK_FASTER_STRUCTS,                    "Use structs on stronger alignment for double-word copies" }, \
     {"no-faster-structs", -MASK_FASTER_STRUCTS,                "Do not use structs on stronger alignment for double-word copies" }, \
+    {"relax", 0,                                       "Optimize tail call instructions in assembler and linker" }, \
+    {"no-relax", 0,                                    "Do not optimize tail call instructions in assembler or linker" }, \
     SUBTARGET_SWITCHES                 \
     { "", TARGET_DEFAULT, ""}}
 
index 1cbe6cb..5dda2db 100755 (executable)
@@ -8916,10 +8916,38 @@ EOF
 
     fi
 
+    echo $ac_n "checking assembler supports -relax""... $ac_c" 1>&6
+echo "configure:8921: checking assembler supports -relax" >&5
+if eval "test \"`echo '$''{'gcc_cv_as_relax_opt'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+       gcc_cv_as_relax_opt=unknown
+       if test x$gcc_cv_as != x; then
+           # Check if gas supports -relax
+           echo ".text" > conftest.s
+           if $gcc_cv_as -relax -o conftest.o conftest.s > /dev/null 2>&1; then
+               gcc_cv_as_relax_opt=yes
+           else
+               gcc_cv_as_relax_opt=no
+           fi
+           rm -f conftest.s conftest.o
+       fi
+    
+fi
+
+echo "$ac_t""$gcc_cv_as_relax_opt" 1>&6
+    if test "x$gcc_cv_as_relax_opt" = xyes; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_AS_RELAX_OPTION 1
+EOF
+
+    fi
+
     case "$tm_file" in
     *64*)
        echo $ac_n "checking for 64 bit support in assembler ($gcc_cv_as)""... $ac_c" 1>&6
-echo "configure:8923: checking for 64 bit support in assembler ($gcc_cv_as)" >&5
+echo "configure:8951: checking for 64 bit support in assembler ($gcc_cv_as)" >&5
 if eval "test \"`echo '$''{'gcc_cv_as_flags64'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8964,7 +8992,7 @@ EOF
 
     if test "x$gcc_cv_as_flags64" != xno; then
        echo $ac_n "checking for assembler offsetable %lo() support""... $ac_c" 1>&6
-echo "configure:8968: checking for assembler offsetable %lo() support" >&5
+echo "configure:8996: checking for assembler offsetable %lo() support" >&5
 if eval "test \"`echo '$''{'gcc_cv_as_offsetable_lo10'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -9003,7 +9031,7 @@ EOF
 
   i[34567]86-*-*)
     echo $ac_n "checking assembler instructions""... $ac_c" 1>&6
-echo "configure:9007: checking assembler instructions" >&5
+echo "configure:9035: checking assembler instructions" >&5
     gcc_cv_as_instructions=
     if test x$gcc_cv_as != x; then
        set "filds fists" "filds mem; fists mem"
@@ -9133,7 +9161,7 @@ fi
 
 # Build a new-libstdc++ system (ie libstdc++-v3)
 echo $ac_n "checking for libstdc++ to install""... $ac_c" 1>&6
-echo "configure:9137: checking for libstdc++ to install" >&5
+echo "configure:9165: checking for libstdc++ to install" >&5
 # Check whether --enable-libstdcxx-v3 or --disable-libstdcxx-v3 was given.
 if test "${enable_libstdcxx_v3+set}" = set; then
   enableval="$enable_libstdcxx_v3"
@@ -9157,7 +9185,7 @@ EOF
 
 
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:9161: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:9189: checking whether to enable maintainer-specific portions of Makefiles" >&5
     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
index bc4cf07..9054054 100644 (file)
@@ -4550,6 +4550,25 @@ case "$target" in
                [Define if your assembler supports .register.])
     fi
 
+    AC_CACHE_CHECK([assembler supports -relax],
+       gcc_cv_as_relax_opt, [
+       gcc_cv_as_relax_opt=unknown
+       if test x$gcc_cv_as != x; then
+           # Check if gas supports -relax
+           echo ".text" > conftest.s
+           if $gcc_cv_as -relax -o conftest.o conftest.s > /dev/null 2>&1; then
+               gcc_cv_as_relax_opt=yes
+           else
+               gcc_cv_as_relax_opt=no
+           fi
+           rm -f conftest.s conftest.o
+       fi
+    ])
+    if test "x$gcc_cv_as_relax_opt" = xyes; then
+       AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
+               [Define if your assembler supports -relax option.])
+    fi
+
     case "$tm_file" in
     *64*)
        AC_CACHE_CHECK([for 64 bit support in assembler ($gcc_cv_as)],