public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed, 3/7] MIPS -mcode-readable support
@ 2007-08-08 15:26 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2007-08-08 15:26 UTC (permalink / raw)
  To: gcc-patches

This is the third patch in the -mcode-readable series.  It adds a new
symbol type, SYMBOL_FORCE_TO_MEM, for symbols that must be forced into
the constant pool and loaded from there.

Tested in the same way as the first patch and applied.

Richard


gcc/
	* config/mips/mips-protos.h (SYMBOL_FORCE_TO_MEM): New symbol type.
	* config/mips/mips.c (mips_classify_symbol): Skip TARGET_ABICALLS
	block for locally-binding symbols if TARGET_ABSOLUTE_ABICALLS.
	Return SYMBOL_FORCE_TO_MEM instead of SYMBOL_ABSOLUTE for
	non-call contexts if TARGET_MIPS16.
	(mips_symbolic_constant_p): Handle SYMBOL_FORCE_TO_MEM.
	(mips_symbolic_address_p): Likewise.  Remove special TARGET_MIPS16
	code for SYMBOL_ABSOLUTE.
	(mips_symbol_insns): Likewise.

Index: gcc/config/mips/mips-protos.h
===================================================================
--- gcc/config/mips/mips-protos.h	2007-08-03 17:05:26.000000000 +0100
+++ gcc/config/mips/mips-protos.h	2007-08-03 17:12:23.000000000 +0100
@@ -55,6 +55,9 @@ enum mips_symbol_context {
        The symbol's value will be calculated using a MIPS16 PC-relative
        calculation.
 
+   SYMBOL_FORCE_TO_MEM
+       The symbol's value must be forced to memory and loaded from there.
+
    SYMBOL_GOT_PAGE_OFST
        The symbol's value will be calculated by loading an address
        from the GOT and then applying a 16-bit offset.
@@ -109,6 +112,7 @@ enum mips_symbol_type {
   SYMBOL_ABSOLUTE,
   SYMBOL_GP_RELATIVE,
   SYMBOL_PC_RELATIVE,
+  SYMBOL_FORCE_TO_MEM,
   SYMBOL_GOT_PAGE_OFST,
   SYMBOL_GOT_DISP,
   SYMBOL_GOTOFF_PAGE,
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2007-08-03 17:05:42.000000000 +0100
+++ gcc/config/mips/mips.c	2007-08-03 17:12:23.000000000 +0100
@@ -1438,7 +1438,7 @@ mips_symbol_binds_local_p (rtx x)
    LABEL_REF X in context CONTEXT.  */
 
 static enum mips_symbol_type
-mips_classify_symbol (rtx x, enum mips_symbol_context context ATTRIBUTE_UNUSED)
+mips_classify_symbol (rtx x, enum mips_symbol_context context)
 {
   if (TARGET_RTP_PIC)
     return SYMBOL_GOT_DISP;
@@ -1473,13 +1473,11 @@ mips_classify_symbol (rtx x, enum mips_s
       && !SYMBOL_REF_WEAK (x))
     return SYMBOL_GP_RELATIVE;
 
-  if (TARGET_ABICALLS)
+  /* Don't use GOT accesses for locally-binding symbols when -mno-shared
+     is in effect.  */
+  if (TARGET_ABICALLS
+      && !(TARGET_ABSOLUTE_ABICALLS && mips_symbol_binds_local_p (x)))
     {
-      /* Don't use GOT accesses for locally-binding symbols; we can use
-	 %hi and %lo instead.  */
-      if (TARGET_ABSOLUTE_ABICALLS && mips_symbol_binds_local_p (x))
-	return SYMBOL_ABSOLUTE;
-
       /* There are three cases to consider:
 
 	    - o32 PIC (either with or without explicit relocs)
@@ -1505,6 +1503,8 @@ mips_classify_symbol (rtx x, enum mips_s
       return SYMBOL_GOT_PAGE_OFST;
     }
 
+  if (TARGET_MIPS16 && context != SYMBOL_CONTEXT_CALL)
+    return SYMBOL_FORCE_TO_MEM;
   return SYMBOL_ABSOLUTE;
 }
 
@@ -1560,6 +1560,7 @@ mips_symbolic_constant_p (rtx x, enum mi
   switch (*symbol_type)
     {
     case SYMBOL_ABSOLUTE:
+    case SYMBOL_FORCE_TO_MEM:
     case SYMBOL_64_HIGH:
     case SYMBOL_64_MID:
     case SYMBOL_64_LOW:
@@ -1682,8 +1683,6 @@ mips_symbolic_address_p (enum mips_symbo
   switch (symbol_type)
     {
     case SYMBOL_ABSOLUTE:
-      return !TARGET_MIPS16;
-
     case SYMBOL_GP_RELATIVE:
       return true;
 
@@ -1694,8 +1693,10 @@ mips_symbolic_address_p (enum mips_symbo
     case SYMBOL_GOT_PAGE_OFST:
       return true;
 
+    case SYMBOL_FORCE_TO_MEM:
     case SYMBOL_GOT_DISP:
-      /* The address will have to be loaded from the GOT first.  */
+      /* The address will have to be loaded from the constant pool
+	 or GOT before it is used in an address.  */
       return false;
 
     case SYMBOL_GOTOFF_PAGE:
@@ -1841,11 +1842,6 @@ mips_symbol_insns (enum mips_symbol_type
   switch (type)
     {
     case SYMBOL_ABSOLUTE:
-      /* In mips16 code, general symbols must be fetched from the
-	 constant pool.  */
-      if (TARGET_MIPS16)
-	return 0;
-
       /* When using 64-bit symbols, we need 5 preparatory instructions,
 	 such as:
 
@@ -1868,6 +1864,10 @@ mips_symbol_insns (enum mips_symbol_type
 	 extended instruction.  */
       return 2;
 
+    case SYMBOL_FORCE_TO_MEM:
+      /* The constant must be loaded from the constant pool.  */
+      return 0;
+
     case SYMBOL_GOT_PAGE_OFST:
     case SYMBOL_GOT_DISP:
       /* Unless -funit-at-a-time is in effect, we can't be sure whether

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-08-08 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-08 15:26 [committed, 3/7] MIPS -mcode-readable support Richard Sandiford

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