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]

PIC cleanup



Per a discussion with Alan Modra and John David Anglin, I'm removing 
support for generating small PIC from the PA port.  Specifying -fpic
will now act just like -fPIC.

This cleans up a few warts in the PA port and will hopefully make it
easier to sort through some of the other PIC issues that have arisen
in the process of getting prepared for GCC 3.0.

This has been bootstrapped in 32bit mode (with and without -fpic).  It's
also been bootstrapped with a few other workarounds for in 64bit mode.

	* pa.c (override_options): Promote -fpic to -fPIC.
	(legitimize_pic_address): Simplify due to removal of
	small PIC as a code generation option.
	(secondary_reload_class): Similarly.
	* pa.h (GO_IF_LEGITIMATE_ADDRESS): Similarly.
	(PRINT_OPERAND_ADDRESS): Similarly.
	* pa.md (various patterns): Similarly.
	(small pic lo_sum pattern): Remove.
	
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/pa/pa.c,v
retrieving revision 1.93.2.4
diff -c -3 -p -r1.93.2.4 pa.c
*** pa.c	2001/02/20 03:23:40	1.93.2.4
--- pa.c	2001/02/27 22:50:42
*************** override_options ()
*** 183,190 ****
        write_symbols = NO_DEBUG;
      }
  
!   /* We always generate PIC code when in 64bit mode.  */
!   if (TARGET_64BIT)
      flag_pic = 2;
  
    /* Register global variables with the garbage collector.  */
--- 183,191 ----
        write_symbols = NO_DEBUG;
      }
  
!   /* We only support the "big PIC" model now.  And we always generate PIC
!      code when in 64bit mode.  */
!   if (flag_pic == 1 || TARGET_64BIT)
      flag_pic = 2;
  
    /* Register global variables with the garbage collector.  */
*************** legitimize_pic_address (orig, mode, reg)
*** 713,734 ****
        if (reg == 0)
  	abort ();
  
!       if (flag_pic == 2)
! 	{
! 	  emit_move_insn (reg,
! 			  gen_rtx_PLUS (word_mode, pic_offset_table_rtx,
! 					gen_rtx_HIGH (word_mode, orig)));
! 	  pic_ref
! 	    = gen_rtx_MEM (Pmode,
! 			   gen_rtx_LO_SUM (Pmode, reg,
! 					   gen_rtx_UNSPEC (Pmode,
! 							   gen_rtvec (1, orig),
! 							   0)));
! 	}
!       else
! 	pic_ref = gen_rtx_MEM (Pmode,
! 			       gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
! 					     orig));
  
        current_function_uses_pic_offset_table = 1;
        RTX_UNCHANGING_P (pic_ref) = 1;
--- 714,728 ----
        if (reg == 0)
  	abort ();
  
!       emit_move_insn (reg,
! 		      gen_rtx_PLUS (word_mode, pic_offset_table_rtx,
! 				    gen_rtx_HIGH (word_mode, orig)));
!       pic_ref
! 	= gen_rtx_MEM (Pmode,
! 		       gen_rtx_LO_SUM (Pmode, reg,
! 				       gen_rtx_UNSPEC (Pmode,
! 						       gen_rtvec (1, orig),
! 						       0)));
  
        current_function_uses_pic_offset_table = 1;
        RTX_UNCHANGING_P (pic_ref) = 1;
*************** secondary_reload_class (class, mode, in)
*** 4564,4570 ****
  
    /* Trying to load a constant into a FP register during PIC code
       generation will require %r1 as a scratch register.  */
!   if (flag_pic == 2
        && GET_MODE_CLASS (mode) == MODE_INT
        && FP_REG_CLASS_P (class)
        && (GET_CODE (in) == CONST_INT || GET_CODE (in) == CONST_DOUBLE))
--- 4558,4564 ----
  
    /* Trying to load a constant into a FP register during PIC code
       generation will require %r1 as a scratch register.  */
!   if (flag_pic
        && GET_MODE_CLASS (mode) == MODE_INT
        && FP_REG_CLASS_P (class)
        && (GET_CODE (in) == CONST_INT || GET_CODE (in) == CONST_DOUBLE))
Index: pa.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/pa/pa.h,v
retrieving revision 1.103.2.1
diff -c -3 -p -r1.103.2.1 pa.h
*** pa.h	2001/02/20 03:23:41	1.103.2.1
--- pa.h	2001/02/27 22:50:48
*************** extern int may_call_alloca;
*** 1269,1284 ****
    else if (GET_CODE (X) == PLUS)			\
      {							\
        rtx base = 0, index = 0;				\
!       if (flag_pic && XEXP (X, 0) == pic_offset_table_rtx)\
! 	{						\
! 	  if (GET_CODE (XEXP (X, 1)) == REG		\
! 	      && REG_OK_FOR_BASE_P (XEXP (X, 1)))	\
! 	    goto ADDR;					\
! 	  else if (flag_pic == 1			\
! 		   && GET_CODE (XEXP (X, 1)) == SYMBOL_REF)\
! 	    goto ADDR;					\
! 	}						\
!       else if (REG_P (XEXP (X, 0))			\
  	  && REG_OK_FOR_BASE_P (XEXP (X, 0)))		\
  	base = XEXP (X, 0), index = XEXP (X, 1);	\
        else if (REG_P (XEXP (X, 1))			\
--- 1269,1275 ----
    else if (GET_CODE (X) == PLUS)			\
      {							\
        rtx base = 0, index = 0;				\
!       if (REG_P (XEXP (X, 0))				\
  	  && REG_OK_FOR_BASE_P (XEXP (X, 0)))		\
  	base = XEXP (X, 0), index = XEXP (X, 1);	\
        else if (REG_P (XEXP (X, 1))			\
*************** while (0)
*** 1970,1978 ****
  	fputs ("R'", FILE);						\
        else if (flag_pic == 0)						\
  	fputs ("RR'", FILE);						\
!       else if (flag_pic == 1)						\
! 	abort ();							\
!       else if (flag_pic == 2)						\
  	fputs ("RT'", FILE);						\
        output_global_address (FILE, XEXP (addr, 1), 0);			\
        fputs ("(", FILE);						\
--- 1961,1967 ----
  	fputs ("R'", FILE);						\
        else if (flag_pic == 0)						\
  	fputs ("RR'", FILE);						\
!       else								\
  	fputs ("RT'", FILE);						\
        output_global_address (FILE, XEXP (addr, 1), 0);			\
        fputs ("(", FILE);						\
Index: pa.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/pa/pa.md,v
retrieving revision 1.81.2.1
diff -c -3 -p -r1.81.2.1 pa.md
*** pa.md	2001/02/20 03:23:41	1.81.2.1
--- pa.md	2001/02/27 22:50:53
***************
*** 2085,2101 ****
    DONE;
  }")
  
- ;;; pic symbol references
- 
- (define_insn ""
-   [(set (match_operand:SI 0 "register_operand" "=r")
- 	(mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
- 			 (match_operand:SI 2 "symbolic_operand" ""))))]
-   "flag_pic && operands[1] == pic_offset_table_rtx"
-   "ldw T'%2(%1),%0"
-   [(set_attr "type" "load")
-    (set_attr "length" "4")])
- 
  (define_insn ""
    [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
  				"=r,r,r,r,r,r,Q,*q,!f,f,*TR")
--- 2085,2090 ----
***************
*** 2331,2337 ****
  		 (high:SI (match_operand 2 "" ""))))]
    "symbolic_operand (operands[2], Pmode)
     && ! function_label_operand (operands[2], Pmode)
!    && flag_pic == 2"
    "addil LT'%G2,%1"
    [(set_attr "type" "binary")
     (set_attr "length" "4")])
--- 2320,2326 ----
  		 (high:SI (match_operand 2 "" ""))))]
    "symbolic_operand (operands[2], Pmode)
     && ! function_label_operand (operands[2], Pmode)
!    && flag_pic"
    "addil LT'%G2,%1"
    [(set_attr "type" "binary")
     (set_attr "length" "4")])
***************
*** 2343,2349 ****
    "symbolic_operand (operands[2], Pmode)
     && ! function_label_operand (operands[2], Pmode)
     && TARGET_64BIT
!    && flag_pic == 2"
    "addil LT'%G2,%1"
    [(set_attr "type" "binary")
     (set_attr "length" "4")])
--- 2332,2338 ----
    "symbolic_operand (operands[2], Pmode)
     && ! function_label_operand (operands[2], Pmode)
     && TARGET_64BIT
!    && flag_pic"
    "addil LT'%G2,%1"
    [(set_attr "type" "binary")
     (set_attr "length" "4")])





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