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: [named-addr-spaces-branch][Patch,committed] Fix C++ bug; Add common pointer target hook


On Sun, Nov 30, 2008 at 10:55 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> This patch fixes a bug in running the C++ test suite on hosted compilers that I
> introduced with the named address support.
>
> I also added a hook for common_pointer_type to pick an appropriate named
> address space when dealing with pointers to two different named address
> spaces.
>
> I did some cleanup as well.
>
> 2008-11-30  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>        * targhook.c (default_addr_space_common_pointer): New default hook
>        for determining whether there is a common pointer format to use
>        between two pointers.
>
>        * targhook.h (default_addr_space_common_pointer): Add
>        declaration.
>
>        * tree.c (integer_pow2p): Rewrite to eliminate the macro
>        OTHER_ADDR_SPACE_POINTER_TYPE_P.
>        (tree_log2): Ditto.
>        (tree_floor_log2): Ditto.
>        (build_pointer_type_for_mode): Add support for being passed
>        error_mark_node.
>        (build_reference_type_for_mode): Add named address space support.
>
>        * tree.h (OTHER_ADDR_SPACE_POINTER_TYPE_P): Delete.
>        (GENERIC_ADDR_SPACE_POINTER_TYPE_P): Ditto.
>
>        * target.h (struct addr_space): Add new hook to determine whether
>        there is a common pointer pointer to use between two pointers.
>        Change pointer_mode argument to addr_space_t from int.
>
>        * fold-const.c (fit_double_type): Rewrite to eliminate the macro
>        OTHER_ADDR_SPACE_POINTER_TYPE_P.  Get the named address space from
>        the type the pointer points to instead of the pointer itself.
>        (fold_convert_const): Ditto.
>
>        * tree-ssa-loop-ivopts.c (strip_offset): Rewrite to eliminate the
>        macros OTHER_ADDR_SPACE_POINTER_TYPE_P and
>        GENERIC_ADDR_SPACE_POINTER_TYPE_P.
>
>        * expr.c (expand_expr_addr_expr): Rewrite to eliminate the macro
>        OTHER_ADDR_SPACE_POINTER_TYPE_P.
>
>        * c-typechk.c (common_pointer_type): Determine what named address
>        space should be used if pointers to two different named address spaces.
>        (build_binary_op): Rewrite to eliminate the macro
>        OTHER_ADDR_SPACE_POINTER_TYPE_P.
>
>        * varasm.c (default_addr_space_pointer_mode): Change argument type.
>
>        * tree-ssa.c (useless_type_conversion_p_1): Rewrite to eliminate
>        the macro GENERIC_ADDR_SPACE_POINTER_TYPE_P.
>
>        * target-def.h (TARGET_ADDR_SPACE_COMMON_POINTER): New target hook
>        for determining what named address space should be used when two
>        pointers are combined.
>        (TARGET_ADDR_SPACE_HOOKS): Add TARGET_ADDR_SPACE_COMMON_POINTER.
>
>        * output.h (default_addr_space_pointer_mode): Change argument
>        type.
>
>        * config/spu/spu.c (spu_addr_space_common_pointer): New target
>        hook to return what address space to use between two pointers.
>        (TARGET_ADDR_SPACE_COMMON_POINTER): Define target hook.
>        (spu_ea_pointer_mode): Change argument from int to addr_space_t.
>        (spu_addr_space_can_convert_p): Use TARGET_NO_LOCAL_EA_CONVERSION
>        instead of TARGET_NO_EA_LOCAL_CONVERSION.
>
>        * config/spu/spu.opt (-mno-local-ea-conversion): Make mask
>        correspond with switch.
>        (-mlocal-ea-conversion): Ditto.
>
> Index: gcc/targhooks.c
> ===================================================================
> --- gcc/targhooks.c     (revision 142261)
> +++ gcc/targhooks.c     (working copy)
> @@ -739,6 +739,18 @@ default_addr_space_nop_convert_p (addr_s
>   return to_addr == from_addr;
>  }
>
> +/* The default hook for determining whether there is a common pointer format to
> +   use when two pointers are used together.  */
> +
> +addr_space_t
> +default_addr_space_common_pointer (addr_space_t addr1, addr_space_t addr2)
> +{
> +  if (addr1 == addr2)
> +    return addr1;
> +
> +  gcc_unreachable ();
> +}
> +
>  /* The default hook for TARGET_ADDR_SPACE_CONVERT. This hook should never be
>    called for targets with only a generic address space.  */
>
> Index: gcc/targhooks.h
> ===================================================================
> --- gcc/targhooks.h     (revision 142261)
> +++ gcc/targhooks.h     (working copy)
> @@ -110,4 +110,6 @@ extern rtx default_addr_space_convert (r
>                                       addr_space_t);
>  extern bool default_addr_space_can_convert_p (addr_space_t, addr_space_t);
>  extern bool default_addr_space_nop_convert_p (addr_space_t, addr_space_t);
> +extern addr_space_t default_addr_space_common_pointer (addr_space_t,
> +                                                      addr_space_t);
>  extern tree default_addr_space_section_name (addr_space_t);
> Index: gcc/tree.c
> ===================================================================
> --- gcc/tree.c  (revision 142261)
> +++ gcc/tree.c  (working copy)
> @@ -1478,14 +1478,14 @@ integer_pow2p (const_tree expr)
>   if (TREE_CODE (expr) != INTEGER_CST)
>     return 0;
>
> -  if (OTHER_ADDR_SPACE_POINTER_TYPE_P (TREE_TYPE (expr)))
> +  if (POINTER_TYPE_P (TREE_TYPE (expr)))
>     {
> -      addr_space_t addr_space = TYPE_ADDR_SPACE (TREE_TYPE (expr));
> -      enum machine_mode mode = targetm.addr_space.pointer_mode (addr_space);
> -      prec = GET_MODE_BITSIZE (mode);
> +      addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (expr));
> +      if (as)
> +       prec = GET_MODE_BITSIZE (targetm.addr_space.pointer_mode (as));
> +      else
> +       prec = POINTER_SIZE;
>     }

I can see a pattern here.  Either this needs a function or, more likely, this
is broken - why does TYPE_PRECISION not work here?

Richard.


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