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]

Re: [PATCH PING 2/5] Named address spaces: support multiple pointer modes


Richard Henderson wrote:
> On 09/24/2009 09:06 AM, Ulrich Weigand wrote:
> > Putting the macro into targhooks.h actually looks quite straightforward.
> 
> No.  targhooks.h is (again) used only by files that need to implement
> the target structure.  It should not be pulled in to other files.

OK, I see.  I guess this means going back to your suggestion to use
a helper function instead of a macro.  The patch below implements this
(function in targhooks.c, prototype in target.h).

Does this look better?

Thanks,
Ulrich


ChangeLog:

	* target-def.h (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P): Remove.
	* targhooks.c (target_default_address_pointer_modes_p): New function.
	* target.h (target_default_address_pointer_modes_p): Add prototype.

	* alias.c (find_base_value): Use target_default_address_pointer_modes_p
	instead of TARGET_DEFAULT_ADDRESS_POINTER_MODES_P.
	(find_base_term): Likewise.
	* rtlanal.c (nonzero_bits1): Likewise.
	(num_sign_bit_copies1): Likewise.
	* simplify-rtx.c (simplify_unary_operation_1): Likewise.

	* alias.c: Do not include "targhooks.h".
	* rtlanal.c: Likewise.
	* simplify-rtx.c: Likewise.
	* Makefile.in (alias.o): Update dependencies.
	(rtlanal.o): Likewise.
	(simplify-rtx.o): Likewise.


Index: gcc/targhooks.c
===================================================================
*** gcc/targhooks.c	(revision 152125)
--- gcc/targhooks.c	(working copy)
*************** default_addr_space_valid_pointer_mode (e
*** 811,816 ****
--- 811,832 ----
    return targetm.valid_pointer_mode (mode);
  }
  
+ /* Some places still assume that all pointer or address modes are the
+    standard Pmode and ptr_mode.  These optimizations become invalid if
+    the target actually supports multiple different modes.  For now,
+    we disable such optimizations on such targets, using this function.  */
+ 
+ bool
+ target_default_pointer_address_modes_p (void)
+ {
+   if (targetm.addr_space.address_mode != default_addr_space_address_mode)
+     return false;
+   if (targetm.addr_space.pointer_mode != default_addr_space_pointer_mode)
+     return false;
+ 
+   return true;
+ }
+ 
  /* Named address space version of legitimate_address_p.  */
  
  bool
Index: gcc/target.h
===================================================================
*** gcc/target.h	(revision 151838)
--- gcc/target.h	(working copy)
*************** typedef int (* print_switch_fn_type) (pr
*** 68,73 ****
--- 68,79 ----
  /* An example implementation for ELF targets.  Defined in varasm.c  */
  extern int elf_record_gcc_switches (print_switch_type type, const char *);
  
+ /* Some places still assume that all pointer or address modes are the
+    standard Pmode and ptr_mode.  These optimizations become invalid if
+    the target actually supports multiple different modes.  For now,
+    we disable such optimizations on such targets, using this function.  */
+ extern bool target_default_pointer_address_modes_p (void);
+ 
  struct stdarg_info;
  struct spec_info_def;
  
Index: gcc/rtlanal.c
===================================================================
*** gcc/rtlanal.c	(revision 151919)
--- gcc/rtlanal.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 38,44 ****
  #include "function.h"
  #include "df.h"
  #include "tree.h"
- #include "target-def.h"
  
  /* Forward declarations */
  static void set_of_1 (rtx, const_rtx, void *);
--- 38,43 ----
*************** nonzero_bits1 (const_rtx x, enum machine
*** 3752,3758 ****
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P
  	  && POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
  	  && REG_POINTER (x))
  	nonzero &= GET_MODE_MASK (ptr_mode);
--- 3751,3757 ----
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (target_default_address_pointer_modes_p ()
  	  && POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
  	  && REG_POINTER (x))
  	nonzero &= GET_MODE_MASK (ptr_mode);
*************** nonzero_bits1 (const_rtx x, enum machine
*** 3993,3999 ****
  	/* As we do not know which address space the pointer is refering to,
  	   we can do this only if the target does not support different pointer
  	   or address modes depending on the address space.  */
! 	if (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P
  	    && POINTERS_EXTEND_UNSIGNED > 0 && GET_MODE (x) == Pmode
  	    && (code == PLUS || code == MINUS)
  	    && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
--- 3992,3998 ----
  	/* As we do not know which address space the pointer is refering to,
  	   we can do this only if the target does not support different pointer
  	   or address modes depending on the address space.  */
! 	if (target_default_address_pointer_modes_p ()
  	    && POINTERS_EXTEND_UNSIGNED > 0 && GET_MODE (x) == Pmode
  	    && (code == PLUS || code == MINUS)
  	    && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
*************** num_sign_bit_copies1 (const_rtx x, enum 
*** 4271,4277 ****
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P
  	  && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
  	  && mode == Pmode && REG_POINTER (x))
  	return GET_MODE_BITSIZE (Pmode) - GET_MODE_BITSIZE (ptr_mode) + 1;
--- 4270,4276 ----
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (target_default_address_pointer_modes_p ()
  	  && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
  	  && mode == Pmode && REG_POINTER (x))
  	return GET_MODE_BITSIZE (Pmode) - GET_MODE_BITSIZE (ptr_mode) + 1;
*************** num_sign_bit_copies1 (const_rtx x, enum 
*** 4472,4478 ****
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P
  	  && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
  	  && (code == PLUS || code == MINUS)
  	  && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
--- 4471,4477 ----
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (target_default_address_pointer_modes_p ()
  	  && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
  	  && (code == PLUS || code == MINUS)
  	  && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
Index: gcc/alias.c
===================================================================
*** gcc/alias.c	(revision 151919)
--- gcc/alias.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 49,55 ****
  #include "tree-ssa-alias.h"
  #include "pointer-set.h"
  #include "tree-flow.h"
- #include "target-def.h"
  
  /* The aliasing API provided here solves related but different problems:
  
--- 49,54 ----
*************** find_base_value (rtx src)
*** 1053,1059 ****
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!TARGET_DEFAULT_POINTER_ADDRESS_MODES_P)
  	break;
        if (GET_MODE_SIZE (GET_MODE (src)) < GET_MODE_SIZE (Pmode))
  	break;
--- 1052,1058 ----
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!target_default_pointer_address_modes_p ())
  	break;
        if (GET_MODE_SIZE (GET_MODE (src)) < GET_MODE_SIZE (Pmode))
  	break;
*************** find_base_value (rtx src)
*** 1072,1078 ****
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!TARGET_DEFAULT_POINTER_ADDRESS_MODES_P)
  	break;
  
        {
--- 1071,1077 ----
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!target_default_pointer_address_modes_p ())
  	break;
  
        {
*************** find_base_term (rtx x)
*** 1470,1476 ****
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!TARGET_DEFAULT_POINTER_ADDRESS_MODES_P)
  	return 0;
        if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (Pmode))
  	return 0;
--- 1469,1475 ----
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!target_default_pointer_address_modes_p ())
  	return 0;
        if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (Pmode))
  	return 0;
*************** find_base_term (rtx x)
*** 1489,1495 ****
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!TARGET_DEFAULT_POINTER_ADDRESS_MODES_P)
  	return 0;
  
        {
--- 1488,1494 ----
        /* As we do not know which address space the pointer is refering to, we can
  	 handle this only if the target does not support different pointer or
  	 address modes depending on the address space.  */
!       if (!target_default_pointer_address_modes_p ())
  	return 0;
  
        {
Index: gcc/simplify-rtx.c
===================================================================
*** gcc/simplify-rtx.c	(revision 151919)
--- gcc/simplify-rtx.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 39,45 ****
  #include "output.h"
  #include "ggc.h"
  #include "target.h"
- #include "target-def.h"
  
  /* Simplification and canonicalization of RTL.  */
  
--- 39,44 ----
*************** simplify_unary_operation_1 (enum rtx_cod
*** 967,973 ****
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P
  	  && ! POINTERS_EXTEND_UNSIGNED
  	  && mode == Pmode && GET_MODE (op) == ptr_mode
  	  && (CONSTANT_P (op)
--- 966,972 ----
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (target_default_address_pointer_modes_p ()
  	  && ! POINTERS_EXTEND_UNSIGNED
  	  && mode == Pmode && GET_MODE (op) == ptr_mode
  	  && (CONSTANT_P (op)
*************** simplify_unary_operation_1 (enum rtx_cod
*** 993,999 ****
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (TARGET_DEFAULT_ADDRESS_POINTER_MODES_P
  	  && POINTERS_EXTEND_UNSIGNED > 0
  	  && mode == Pmode && GET_MODE (op) == ptr_mode
  	  && (CONSTANT_P (op)
--- 992,998 ----
        /* As we do not know which address space the pointer is refering to,
  	 we can do this only if the target does not support different pointer
  	 or address modes depending on the address space.  */
!       if (target_default_address_pointer_modes_p ()
  	  && POINTERS_EXTEND_UNSIGNED > 0
  	  && mode == Pmode && GET_MODE (op) == ptr_mode
  	  && (CONSTANT_P (op)
Index: gcc/target-def.h
===================================================================
*** gcc/target-def.h	(revision 151919)
--- gcc/target-def.h	(working copy)
***************
*** 505,518 ****
      TARGET_ADDR_SPACE_CONVERT,			\
    }
  
- /* Some places still assume that all pointer or address modes are the
-    standard Pmode and ptr_mode.  These optimizations become invalid if
-    the target actually supports multiple different modes.  For now,
-    we disable such optimizations on such targets, using this macro.  */
- #define TARGET_DEFAULT_POINTER_ADDRESS_MODES_P \
-   (targetm.addr_space.address_mode == default_addr_space_address_mode \
-    && targetm.addr_space.pointer_mode == default_addr_space_pointer_mode)
- 
  #ifndef TARGET_SCALAR_MODE_SUPPORTED_P
  #define TARGET_SCALAR_MODE_SUPPORTED_P default_scalar_mode_supported_p
  #endif
--- 505,510 ----
Index: gcc/Makefile.in
===================================================================
*** gcc/Makefile.in	(revision 151919)
--- gcc/Makefile.in	(working copy)
*************** print-rtl.o : print-rtl.c $(CONFIG_H) $(
*** 2659,2665 ****
  rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H) \
     $(RTL_H) hard-reg-set.h $(TM_P_H) insn-config.h $(RECOG_H) $(REAL_H) \
     $(FLAGS_H) $(REGS_H) output.h $(TARGET_H) $(FUNCTION_H) $(TREE_H) \
!    $(DF_H) $(TARGET_DEF_H)
  
  varasm.o : varasm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(RTL_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) hard-reg-set.h $(REGS_H) \
--- 2659,2665 ----
  rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TOPLEV_H) \
     $(RTL_H) hard-reg-set.h $(TM_P_H) insn-config.h $(RECOG_H) $(REAL_H) \
     $(FLAGS_H) $(REGS_H) output.h $(TARGET_H) $(FUNCTION_H) $(TREE_H) \
!    $(DF_H)
  
  varasm.o : varasm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(RTL_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) hard-reg-set.h $(REGS_H) \
*************** jump.o : jump.c $(CONFIG_H) $(SYSTEM_H) 
*** 2763,2769 ****
  simplify-rtx.o : simplify-rtx.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(RTL_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) $(REAL_H) insn-config.h \
     $(RECOG_H) $(EXPR_H) $(TOPLEV_H) output.h $(FUNCTION_H) $(GGC_H) $(TM_P_H) \
!    $(TREE_H) $(TARGET_H) $(TARGET_DEF_H)
  cgraph.o : cgraph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     langhooks.h $(TOPLEV_H) $(FLAGS_H) $(GGC_H) $(TARGET_H) $(CGRAPH_H) \
     gt-cgraph.h output.h intl.h $(BASIC_BLOCK_H) debug.h $(HASHTAB_H) \
--- 2763,2769 ----
  simplify-rtx.o : simplify-rtx.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(RTL_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) $(REAL_H) insn-config.h \
     $(RECOG_H) $(EXPR_H) $(TOPLEV_H) output.h $(FUNCTION_H) $(GGC_H) $(TM_P_H) \
!    $(TREE_H) $(TARGET_H)
  cgraph.o : cgraph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     langhooks.h $(TOPLEV_H) $(FLAGS_H) $(GGC_H) $(TARGET_H) $(CGRAPH_H) \
     gt-cgraph.h output.h intl.h $(BASIC_BLOCK_H) debug.h $(HASHTAB_H) \
*************** alias.o : alias.c $(CONFIG_H) $(SYSTEM_H
*** 3068,3074 ****
     $(ALIAS_H) $(EMIT_RTL_H) $(GGC_H) $(FUNCTION_H) cselib.h $(TREE_H) $(TM_P_H) \
     langhooks.h $(TARGET_H) gt-alias.h $(TIMEVAR_H) $(CGRAPH_H) \
     $(SPLAY_TREE_H) $(VARRAY_H) $(IPA_TYPE_ESCAPE_H) $(DF_H) $(TREE_PASS_H) \
!    tree-ssa-alias.h pointer-set.h $(TREE_FLOW_H) $(TARGET_DEF_H)
  stack-ptr-mod.o : stack-ptr-mod.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     $(TM_H) $(TREE_H) $(RTL_H) $(REGS_H) $(EXPR_H) $(TREE_PASS_H) \
     $(BASIC_BLOCK_H) $(FLAGS_H) output.h $(DF_H)
--- 3068,3074 ----
     $(ALIAS_H) $(EMIT_RTL_H) $(GGC_H) $(FUNCTION_H) cselib.h $(TREE_H) $(TM_P_H) \
     langhooks.h $(TARGET_H) gt-alias.h $(TIMEVAR_H) $(CGRAPH_H) \
     $(SPLAY_TREE_H) $(VARRAY_H) $(IPA_TYPE_ESCAPE_H) $(DF_H) $(TREE_PASS_H) \
!    tree-ssa-alias.h pointer-set.h $(TREE_FLOW_H)
  stack-ptr-mod.o : stack-ptr-mod.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
     $(TM_H) $(TREE_H) $(RTL_H) $(REGS_H) $(EXPR_H) $(TREE_PASS_H) \
     $(BASIC_BLOCK_H) $(FLAGS_H) output.h $(DF_H)


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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