This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: IA64 Patch for pointer extension
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 2 May 2005 14:11:07 -0700 (PDT)
- Subject: Re: IA64 Patch for pointer extension
> On Wed, Apr 27, 2005 at 02:12:42PM -0700, Steve Ellcey wrote:
> > I don't really understand what you are suggesting here. I enter
> > output_constant with a tree, not rtl.
>
> But the expansion of the inner expression produces rtl.
>
> > Here is a patch I came up with, it includes the earlier change and a
> > second test case. All I did was stop output_constant from setting
> > thissize to a smaller size when I have a pointer. It works on the
> > second test case but I haven't done a full regression test yet.
>
> I can only imagine that this has exactly the opposite problem
> as currently exists.
It seemed to work OK for me, here is another patch that I came up with,
it has been tested on IA64 HP-UX with no regressions. I don't know if
it addresses the rtl issue in the way you were thinking of or not.
Steve Ellcey
sje@cup.hp.com
ChangeLog:
2005-05-02 Steve Ellcey <sje@cup.hp.com>
* expr.c (expand_expr_real_1): Handle expansion of pointers.
* varasm.c (output_constant): Put out pointers in Pmode size.
testsuite/ChangeLog:
2005-05-02 Steve Ellcey <sje@cup.hp.com>
* gcc.dg/ia64-ptr-1.c: New.
* gcc.dg/ia64-ptr-2.c: New.
*** gcc.orig/gcc/expr.c Wed Apr 27 13:41:01 2005
--- gcc/gcc/expr.c Wed Apr 27 13:40:52 2005
*************** expand_expr_real_1 (tree exp, rtx target
*** 7409,7414 ****
--- 7409,7417 ----
if (GET_MODE (op0) == mode)
;
+ else if (POINTER_TYPE_P (TREE_TYPE (exp)))
+ op0 = convert_memory_address (mode, op0);
+
/* If OP0 is a constant, just convert it into the proper mode. */
else if (CONSTANT_P (op0))
{
*** gcc.orig/gcc/varasm.c Wed Apr 27 13:43:39 2005
--- gcc/gcc/varasm.c Mon May 2 13:57:49 2005
*************** output_constant (tree exp, unsigned HOST
*** 3793,3798 ****
--- 3793,3799 ----
{
enum tree_code code;
unsigned HOST_WIDE_INT thissize;
+ rtx x;
/* Some front-ends use constants other than the standard language-independent
varieties, but which may still be output directly. Give the front-end a
*************** output_constant (tree exp, unsigned HOST
*** 3840,3851 ****
case BOOLEAN_TYPE:
case INTEGER_TYPE:
case ENUMERAL_TYPE:
- case POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
EXPAND_INITIALIZER),
MIN (size, thissize), align, 0))
error ("initializer for integer value is too complicated");
break;
--- 3841,3864 ----
case BOOLEAN_TYPE:
case INTEGER_TYPE:
case ENUMERAL_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
EXPAND_INITIALIZER),
MIN (size, thissize), align, 0))
+ error ("initializer for integer value is too complicated");
+ break;
+
+ case POINTER_TYPE:
+ x = expand_expr (exp, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
+ #ifdef POINTERS_EXTEND_UNSIGNED
+ if (size == GET_MODE_SIZE (Pmode) && GET_MODE (x) != Pmode)
+ {
+ thissize = size;
+ convert_memory_address(Pmode, x);
+ }
+ #endif
+ if (! assemble_integer (x, MIN (size, thissize), align, 0))
error ("initializer for integer value is too complicated");
break;
*** gcc.orig/gcc/testsuite/gcc.dg/ia64-ptr-1.c Wed Apr 27 13:58:45 2005
--- gcc/gcc/testsuite/gcc.dg/ia64-ptr-1.c Wed Apr 27 13:40:18 2005
***************
*** 0 ****
--- 1,24 ----
+ /* { dg-do run { target ia64-*-hpux* } } */
+ /* { dg-options "-O0" } */
+
+ extern void abort (void);
+
+ typedef int *PTR64 __attribute__((mode(DI)));
+
+ void bar(PTR64 x)
+ {
+ *x = 13;
+ }
+
+ void foo(int * x)
+ {
+ bar(x);
+ }
+
+ main()
+ {
+ int i;
+ foo(&i);
+ if (i != 13) abort();
+ return 0;
+ }
*** gcc.orig/gcc/testsuite/gcc.dg/ia64-ptr-2.c Wed Apr 27 13:58:41 2005
--- gcc/gcc/testsuite/gcc.dg/ia64-ptr-2.c Wed Apr 27 13:58:19 2005
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do run { target ia64-*-hpux* } } */
+ /* { dg-options "-O0" } */
+
+ extern void abort (void);
+
+ typedef void * ptr64 __attribute__((mode(DI)));
+ int x;
+ void *y = &x;
+ ptr64 z = &x;
+
+ main()
+ {
+ x = 9;
+ * (int *) y = 11;
+ * (int *) z = 13;
+ if (x != 13) abort ();
+ return 0;
+ }