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]

mips16 sdata fixes


My earlier sdata changes were failing on mips16 due to the lack of
(set ... (lo_sum ...)) patterns.  Tsk.

This patch adds the missing patterns and cleans up some other aspects of
the unspec -> lo_sum transition.  Tested on mips64vrel-elf & the same
targets as the last message.  OK to install?

BRichard


	* config/mips/mips.md (*lowsi): Renamed from lowsi.
	(*lowdi): Likewise lowdi.
	(*lowsi_mips16, *lowdi_mips16): New patterns.
	* config/mips/mips.c (mips_const_insns, mips_output_move): Remove
	mips16 CONSTANT_RELOC handling.
	(mips_delegitimize_address): Adjust for new sdata representation.

Index: config/mips/mips.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.md,v
retrieving revision 1.198
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.198 mips.md
*** config/mips/mips.md	3 Oct 2003 21:13:13 -0000	1.198
--- config/mips/mips.md	5 Oct 2003 08:18:38 -0000
*************** (define_insn "luidi"
*** 4180,4186 ****
  ;; Operand 2 is the address: print_operand works out which relocation
  ;; should be applied.
  
! (define_insn "lowsi"
    [(set (match_operand:SI 0 "register_operand" "=r")
  	(lo_sum:SI (match_operand:SI 1 "register_operand" "r")
  		   (match_operand:SI 2 "immediate_operand" "")))]
--- 4180,4186 ----
  ;; Operand 2 is the address: print_operand works out which relocation
  ;; should be applied.
  
! (define_insn "*lowsi"
    [(set (match_operand:SI 0 "register_operand" "=r")
  	(lo_sum:SI (match_operand:SI 1 "register_operand" "r")
  		   (match_operand:SI 2 "immediate_operand" "")))]
*************** (define_insn "lowsi"
*** 4189,4195 ****
    [(set_attr "type"	"arith")
     (set_attr "mode"	"SI")])
  
! (define_insn "lowdi"
    [(set (match_operand:DI 0 "register_operand" "=r")
  	(lo_sum:DI (match_operand:DI 1 "register_operand" "r")
  		   (match_operand:DI 2 "immediate_operand" "")))]
--- 4189,4195 ----
    [(set_attr "type"	"arith")
     (set_attr "mode"	"SI")])
  
! (define_insn "*lowdi"
    [(set (match_operand:DI 0 "register_operand" "=r")
  	(lo_sum:DI (match_operand:DI 1 "register_operand" "r")
  		   (match_operand:DI 2 "immediate_operand" "")))]
*************** (define_insn "lowdi"
*** 4197,4202 ****
--- 4197,4222 ----
    "daddiu\t%0,%1,%R2"
    [(set_attr "type"	"arith")
     (set_attr "mode"	"DI")])
+ 
+ (define_insn "*lowsi_mips16"
+   [(set (match_operand:SI 0 "register_operand" "=d")
+ 	(lo_sum:SI (match_operand:SI 1 "register_operand" "0")
+ 		   (match_operand:SI 2 "immediate_operand" "")))]
+   "TARGET_MIPS16"
+   "addiu\t%0,%R2"
+   [(set_attr "type"	"arith")
+    (set_attr "mode"	"SI")
+    (set_attr "length"	"8")])
+ 
+ (define_insn "*lowdi_mips16"
+   [(set (match_operand:DI 0 "register_operand" "=d")
+ 	(lo_sum:DI (match_operand:DI 1 "register_operand" "0")
+ 		   (match_operand:DI 2 "immediate_operand" "")))]
+   "TARGET_MIPS16 && TARGET_64BIT"
+   "daddiu\t%0,%R2"
+   [(set_attr "type"	"arith")
+    (set_attr "mode"	"DI")
+    (set_attr "length"	"8")])
  
  ;; 64-bit integer moves
  
Index: config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.322
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.322 mips.c
*** config/mips/mips.c	4 Oct 2003 08:11:06 -0000	1.322
--- config/mips/mips.c	5 Oct 2003 08:18:40 -0000
*************** mips_address_insns (rtx x, enum machine_
*** 1201,1206 ****
--- 1202,1209 ----
        return factor;
  
      case ADDRESS_LO_SUM:
+       return (TARGET_MIPS16 ? factor * 2 : factor);
+ 
      case ADDRESS_CONST_INT:
        return factor;
  
*************** mips_const_insns (rtx x)
*** 1249,1260 ****
  	  return 0;
  
  	case CONSTANT_GP:
- 	  return 1;
- 
  	case CONSTANT_RELOC:
! 	  /* When generating mips16 code, we need to set the destination to
! 	     $0 and then add in the signed offset.  See mips_output_move.  */
! 	  return (TARGET_MIPS16 ? 3 : 1);
  
  	case CONSTANT_SYMBOLIC:
  	  return mips_symbol_insns (mips_classify_symbol (c.symbol));
--- 1252,1259 ----
  	  return 0;
  
  	case CONSTANT_GP:
  	case CONSTANT_RELOC:
! 	  return 1;
  
  	case CONSTANT_SYMBOLIC:
  	  return mips_symbol_insns (mips_classify_symbol (c.symbol));
*************** mips_delegitimize_address (rtx x)
*** 2012,2023 ****
        && mips_classify_symbol (c.symbol) == SYMBOL_GOT_GLOBAL)
      return c.symbol;
  
!   if (GET_CODE (x) == PLUS
!       && (XEXP (x, 0) == pic_offset_table_rtx
! 	  || XEXP (x, 0) == cfun->machine->mips16_gp_pseudo_rtx)
!       && mips_classify_constant (&c, XEXP (x, 1)) == CONSTANT_RELOC
!       && mips_classify_symbol (c.symbol) == SYMBOL_SMALL_DATA)
!     return plus_constant (c.symbol, c.offset);
  
    return x;
  }
--- 2011,2021 ----
        && mips_classify_symbol (c.symbol) == SYMBOL_GOT_GLOBAL)
      return c.symbol;
  
!   if (GET_CODE (x) == LO_SUM
!       && XEXP (x, 0) == (TARGET_MIPS16
! 			 ? cfun->machine->mips16_gp_pseudo_rtx
! 			 : pic_offset_table_rtx))
!     return XEXP (x, 1);
  
    return x;
  }
*************** mips_output_move (rtx dest, rtx src)
*** 2720,2726 ****
  	  return "move\t%0,%1";
  
  	case CONSTANT_RELOC:
! 	  return (TARGET_MIPS16 ? "li\t%0,0\n\taddiu\t%0,%1" : "li\t%0,%1");
  
  	case CONSTANT_SYMBOLIC:
  	  return (dbl_p ? "dla\t%0,%a1" : "la\t%0,%a1");
--- 2718,2724 ----
  	  return "move\t%0,%1";
  
  	case CONSTANT_RELOC:
! 	  return "li\t%0,%1";
  
  	case CONSTANT_SYMBOLIC:
  	  return (dbl_p ? "dla\t%0,%a1" : "la\t%0,%a1");


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