This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Blackfin patch: additional flat shared library options


This implements a few improvements to the shared flat library support.

We can generate better code if we are able to make certain assumptions.
 If we assume that any given flat library is a leaf, i.e. it does not
link against any other shared libraries, then we can generate normal
call and jump insns without having to go through the GOT, since we know
that all such symbols are local.  This is now implemented with the
switch -mleaf-id-shared-library.

If we additionally assume that we're compiling an entire binary with the
ID shared library framework (i.e. producing a GOT and referencing data
through it), but not actually using any shared libraries, then we can
also omit reloading the GOT pointer at every function entry point.  This
is now implemented with the switch -msep-data, which also exists on m68k
and (I believe) does exactly the same thing there.  This is useful for
XIP binaries.

Committed as 119012.


Bernd
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 119011)
+++ ChangeLog	(working copy)
@@ -12,6 +12,19 @@
 	functions.
 	(TARGET_CANNOT_FORCE_CONST_MEM): New macro.
 
+	* config/bfin/bfin.md (call_symbol, call_value_symbol, sibcall_symbol,
+	sibcall_value_symbol): Allow these patterns if
+	TARGET_LEAF_ID_SHARED_LIBRARY.
+	* config/bfin/bfin.c (bfin_expand_call): Allow them here as well.
+	(override_options): Turn on id shared library flags if -msep-data,
+	but disallow the combination of these options on the command line.
+	* config/bfin/bfin.h (TARGET_LEAF_ID_SHARED_LIBRARY, MASK_SEP_DATA
+	MASK_LEAF_ID_SHARED_LIBRARY, TARGET_SEP_DATA): New macros.
+	(DRIVER_SELF_SPECS): -mleaf-id-shared-library implies
+	-mid-shared-library.
+	(TARGET_SWITCHES): Add -mleaf-id-shared-library and -msep-data.
+	* doc/invoke.texi (Blackfin Options): Document new switches.
+
 2006-11-19  Andrew Pinski  <pinskia@gmail.com>
 
 	PR rtl-opt/29879
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 119010)
+++ doc/invoke.texi	(working copy)
@@ -431,7 +431,8 @@ Objective-C and Objective-C++ Dialects}.
 -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
 -mlow-64k -mno-low64k -mid-shared-library @gol
 -mno-id-shared-library -mshared-library-id=@var{n} @gol
--mlong-calls  -mno-long-calls}
+-mleaf-id-shared-library  -mno-leaf-id-shared-library @gol
+-msep-data  -mno-sep-data  -mlong-calls  -mno-long-calls}
 
 @emph{CRIS Options}
 @gccoptlist{-mcpu=@var{cpu}  -march=@var{cpu}  -mtune=@var{cpu} @gol
@@ -7849,6 +7850,18 @@ without virtual memory management.  This
 Generate code that doesn't assume ID based shared libraries are being used.
 This is the default.
 
+@item -mleaf-id-shared-library
+@opindex mleaf-id-shared-library
+Generate code that supports shared libraries via the library ID method,
+but assumes that this library or executable won't link against any other
+ID shared libraries.  That allows the compiler to use faster code for jumps
+and calls.
+
+@item -mno-leaf-id-shared-library
+@opindex mno-leaf-id-shared-library
+Do not assume that the code being compiled won't link against any ID shared
+libraries.  Slower code will be generated for jump and call insns.
+
 @item -mshared-library-id=n
 @opindex mshared-library-id
 Specified the identification number of the ID based shared library being
@@ -7856,6 +7869,18 @@ compiled.  Specifying a value of 0 will 
 other values will force the allocation of that number to the current
 library but is no more space or time efficient than omitting this option.
 
+@item -msep-data
+@opindex msep-data
+Generate code that allows the data segment to be located in a different
+area of memory from the text segment.  This allows for execute in place in
+an environment without virtual memory management by eliminating relocations
+against the text section.
+
+@item -mno-sep-data
+@opindex mno-sep-data
+Generate code that assumes that the data segment follows the text segment.
+This is the default.
+
 @item -mlong-calls
 @itemx -mno-long-calls
 @opindex mlong-calls
Index: config/bfin/bfin.opt
===================================================================
--- config/bfin/bfin.opt	(revision 119010)
+++ config/bfin/bfin.opt	(working copy)
@@ -40,10 +40,19 @@ mid-shared-library
 Target Report Mask(ID_SHARED_LIBRARY)
 Enabled ID based shared library
 
+mleaf-id-shared-library
+Target Report Mask(LEAF_ID_SHARED_LIBRARY)
+Generate code that won't be linked against any other ID shared libraries,
+but may be used as a shared library.
+
 mshared-library-id=
 Target RejectNegative Joined UInteger Var(bfin_library_id)
 ID of shared library to build
 
+msep-data
+Target Report Mask(SEP_DATA)
+Enable separate data segment
+
 mlong-calls
 Target Report Mask(LONG_CALLS)
 Avoid generating pc-relative calls; use indirection
Index: config/bfin/t-bfin-elf
===================================================================
--- config/bfin/t-bfin-elf	(revision 119010)
+++ config/bfin/t-bfin-elf	(working copy)
@@ -22,10 +22,12 @@ GCC_CFLAGS += -N
 CRTSTUFF_T_CFLAGS = -fpic
 TARGET_LIBGCC2_CFLAGS = -fpic
 
-MULTILIB_OPTIONS=mid-shared-library mfdpic
+MULTILIB_OPTIONS=mid-shared-library mleaf-id-shared-library
+MULTILIB_OPTIONS+=msep-data mfdpic
 MULTILIB_DEFAULTS=
 MULTILIB_DIRNAMES=
-MULTILIB_EXCEPTIONS=mid-shared-library/mfdpic
+MULTILIB_EXCEPTIONS=mid-shared-library*/mfdpic mleaf-id-shared-library*
+MULTILIB_EXCEPTIONS+=*msep-data*
 
 # Assemble startup files.
 $(T)crti.o: $(srcdir)/config/bfin/crti.s $(GCC_PASSES)
Index: config/bfin/bfin.c
===================================================================
--- config/bfin/bfin.c	(revision 119011)
+++ config/bfin/bfin.c	(working copy)
@@ -948,6 +948,7 @@ bfin_expand_prologue (void)
   do_link (spreg, frame_size, false);
 
   if (TARGET_ID_SHARED_LIBRARY
+      && !TARGET_SEP_DATA
       && (current_function_uses_pic_offset_table
 	  || !current_function_is_leaf))
     bfin_load_pic_reg (pic_offset_table_rtx);
@@ -1780,7 +1781,7 @@ bfin_expand_call (rtx retval, rtx fnaddr
   else if ((!register_no_elim_operand (callee, Pmode)
 	    && GET_CODE (callee) != SYMBOL_REF)
 	   || (GET_CODE (callee) == SYMBOL_REF
-	       && (flag_pic
+	       && ((TARGET_ID_SHARED_LIBRARY && !TARGET_LEAF_ID_SHARED_LIBRARY)
 		   || bfin_longcall_p (callee, INTVAL (cookie)))))
     {
       callee = copy_to_mode_reg (Pmode, callee);
@@ -2007,6 +2008,14 @@ override_options (void)
   if (TARGET_ID_SHARED_LIBRARY && TARGET_FDPIC)
       error ("ID shared libraries and FD-PIC mode can't be used together.");
 
+  /* Don't allow the user to specify -mid-shared-library and -msep-data
+     together, as it makes little sense from a user's point of view...  */
+  if (TARGET_SEP_DATA && TARGET_ID_SHARED_LIBRARY)
+    error ("cannot specify both -msep-data and -mid-shared-library");
+  /* ... internally, however, it's nearly the same.  */
+  if (TARGET_SEP_DATA)
+    target_flags |= MASK_ID_SHARED_LIBRARY | MASK_LEAF_ID_SHARED_LIBRARY;
+
   /* There is no single unaligned SI op for PIC code.  Sometimes we
      need to use ".4byte" and sometimes we need to use ".picptr".
      See bfin_assemble_integer for details.  */
Index: config/bfin/bfin.h
===================================================================
--- config/bfin/bfin.h	(revision 119011)
+++ config/bfin/bfin.h	(working copy)
@@ -51,6 +51,7 @@ extern int target_flags;
 #endif
 
 #define DRIVER_SELF_SPECS SUBTARGET_DRIVER_SELF_SPECS	"\
+ %{mleaf-id-shared-library:%{!mid-shared-library:-mid-shared-library}} \
  %{mfdpic:%{!fpic:%{!fpie:%{!fPIC:%{!fPIE:\
    	    %{!fno-pic:%{!fno-pie:%{!fno-PIC:%{!fno-PIE:-fpie}}}}}}}}} \
 "
Index: config/bfin/bfin.md
===================================================================
--- config/bfin/bfin.md	(revision 119011)
+++ config/bfin/bfin.md	(working copy)
@@ -1771,7 +1771,7 @@ (define_insn "*call_symbol"
 	 (match_operand 1 "general_operand" "g"))
    (use (match_operand 2 "" ""))]
   "! SIBLING_CALL_P (insn)
-   && !TARGET_ID_SHARED_LIBRARY
+   && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
    && GET_CODE (operands[0]) == SYMBOL_REF
    && !bfin_longcall_p (operands[0], INTVAL (operands[2]))"
   "call %0;"
@@ -1784,7 +1784,7 @@ (define_insn "*sibcall_symbol"
    (use (match_operand 2 "" ""))
    (return)]
   "SIBLING_CALL_P (insn)
-   && !TARGET_ID_SHARED_LIBRARY
+   && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
    && GET_CODE (operands[0]) == SYMBOL_REF
    && !bfin_longcall_p (operands[0], INTVAL (operands[2]))"
   "jump.l %0;"
@@ -1797,7 +1797,7 @@ (define_insn "*call_value_symbol"
 	      (match_operand 2 "general_operand" "g")))
    (use (match_operand 3 "" ""))]
   "! SIBLING_CALL_P (insn)
-   && !TARGET_ID_SHARED_LIBRARY
+   && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
    && GET_CODE (operands[1]) == SYMBOL_REF
    && !bfin_longcall_p (operands[1], INTVAL (operands[3]))"
   "call %1;"
@@ -1811,7 +1811,7 @@ (define_insn "*sibcall_value_symbol"
    (use (match_operand 3 "" ""))
    (return)]
   "SIBLING_CALL_P (insn)
-   && !TARGET_ID_SHARED_LIBRARY
+   && (!TARGET_ID_SHARED_LIBRARY || TARGET_LEAF_ID_SHARED_LIBRARY)
    && GET_CODE (operands[1]) == SYMBOL_REF
    && !bfin_longcall_p (operands[1], INTVAL (operands[3]))"
   "jump.l %1;"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]