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]

Alpha -mtaso support, revised patch


I've cleaned up my patch to support taso in gcc on the alpha.
These diffs were made against the 20000320 mainline source.
I've bootstraped with 'LANGUAGES=c BOOT_CFLAGS="-g -O2 -mtaso" on
alphaev6-unknown-linux-gnu and alphaev56-dec-osf5.0; I've run the gcc
testsuite on alphaev6-unknown-linux-gnu without regressions.
I don't have dejagnu set up on the osf box.

Let me say why I didn't make what might seem to be the obvious changes
to initializer_constant_valid_p in varasm.c, which has the following lines:

      /* Allow (int) &foo provided int is as wide as a pointer.  */
      if (INTEGRAL_TYPE_P (TREE_TYPE (value))
	  && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
	  && (TYPE_PRECISION (TREE_TYPE (value))
	      >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
					     endtype);

In fact, in my tests, this code was not the code that excluded (int) &foo
on the alpha, where int is 32 bits and &foo is 64 bits.  The tree that is
generated for this construct actually has a NOP_EXPR or a CONVERT_EXPR
(sorry, I don't know which, I didn't note it) to convert to a 32 bit
int from a 64 bit int, whose operand is a CONVERT_EXPR to a 64 bit int
from a 64 bit pointer.  So the following code is executed for the outer
conversion:

      /* Allow conversions between other integer types only if
	 explicit value.  */
      if (INTEGRAL_TYPE_P (TREE_TYPE (value))
	  && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0))))
	{
	  tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
						     endtype);
	  if (inner == null_pointer_node)
	    return null_pointer_node;
	  break;
	}

and the first code is executed for the inner conversion; the inner conversion
doesn't return null_pointer_node (it eventually returns foo), so the second
code breaks (and eventually returns 0, which doesn't allow the conversion).

So, to deal with the trees that were actually passed to
initializer_constant_valid_p by digest-init in c-typeck.c,  I added the
extra check to initializer_constant_valid_p.

Also unfortunately, I didn't save the original files before modifying elf.h
and osf.h, but here is what I ended up with:

elf.h-#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax}            \
elf.h-  %{O*:-O3} %{!O*:-O1}                                            \
elf.h:  %{mtaso:-taso}                                            \
elf.h-  %{shared:-shared}                                               \
elf.h-  %{!shared:                                                      \
--
osf.h-#define LINK_SPEC  \
osf.h-  "-G 8 %{O*:-O3} %{!O*:-O1} %{static:-non_shared}               \
osf.h:   %{mtaso:-taso}                                            \
osf.h-   %{!static:%{shared:-shared} %{!shared:-call_shared}} %{pg}    \
osf.h-   %{rpath*}"

I also cleaned up the documentation and changelog entries.

Brad Lucier

	* config/alpha/alpha.h (MASK_TASO, TARGET_TASO): Define
	macros.  Add -mtaso switch to set TARGET_TASO.
	* varasm.c (initializer_constant_valid_p): Add code to
	handle load-time initialization of (int) &f when TARGET_TASO
	is true.
	* c-typeck.c: Disable warnings about conversions between
	64-bit pointers and 32-bit ints when TARGET_TASO is true.
	* invoke.texi: Document -mtaso for alpha.
	* config/alpha/elf.h: Have -mtaso pass -taso to the linker.
	* config/alpha/osf.h: Have -mtaso pass -taso to the linker.

===================================================================
RCS file: RCS/c-typeck.c,v
retrieving revision 1.1
diff -c -r1.1 c-typeck.c
*** c-typeck.c	2000/03/22 17:01:19	1.1
--- c-typeck.c	2000/03/29 18:05:25
***************
*** 3706,3712 ****
        if (TREE_CODE (type) == INTEGER_TYPE
  	  && TREE_CODE (otype) == POINTER_TYPE
  	  && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
! 	  && !TREE_CONSTANT (value))
  	warning ("cast from pointer to integer of different size");
  
        if (warn_bad_function_cast
--- 3706,3720 ----
        if (TREE_CODE (type) == INTEGER_TYPE
  	  && TREE_CODE (otype) == POINTER_TYPE
  	  && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
! 	  && !TREE_CONSTANT (value)
! #ifdef TARGET_TASO
! 	  /* Do not warn about conversions from 64-bit pointer to
! 	     32-bit int if TARGET_TASO.  */
! 	  && !(TARGET_TASO
! 	       && TYPE_PRECISION (type) == 32
! 	       && TYPE_PRECISION (otype) == 64)
! #endif
! 	  )
  	warning ("cast from pointer to integer of different size");
  
        if (warn_bad_function_cast
***************
*** 3723,3729 ****
  	  && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value))
  #endif
  	  /* Don't warn about converting any constant.  */
! 	  && !TREE_CONSTANT (value))
  	warning ("cast to pointer from integer of different size");
  
        ovalue = value;
--- 3731,3745 ----
  	  && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value))
  #endif
  	  /* Don't warn about converting any constant.  */
! 	  && !TREE_CONSTANT (value)
! #ifdef TARGET_TASO
! 	  /* Do not warn about conversions from 64-bit pointer to
! 	     32-bit int if TARGET_TASO.  */
! 	  && !(TARGET_TASO
! 	       && TYPE_PRECISION (type) == 64
! 	       && TYPE_PRECISION (otype) == 32)
! #endif
! 	  )
  	warning ("cast to pointer from integer of different size");
  
        ovalue = value;
===================================================================
RCS file: RCS/varasm.c,v
retrieving revision 1.1
diff -c -r1.1 varasm.c
*** varasm.c	2000/03/21 15:56:27	1.1
--- varasm.c	2000/03/29 18:03:41
***************
*** 4088,4093 ****
--- 4088,4106 ----
  	      == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
  	return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
  
+ #ifdef TARGET_TASO
+       /* Allow conversions to 32 bit ints from 64 bit ints that come from
+ 	 &foo.  */
+       if (TARGET_TASO
+ 	  && INTEGRAL_TYPE_P (TREE_TYPE (value))
+ 	  && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (value, 0)))
+ 	  && TYPE_PRECISION (TREE_TYPE (value)) == 32
+ 	  && TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))) == 64
+ 	  && TREE_CODE (TREE_OPERAND (value, 0)) == CONVERT_EXPR
+ 	  && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (value, 0), 0))))
+ 	return initializer_constant_valid_p (TREE_OPERAND (TREE_OPERAND (value, 0), 0), endtype);
+ #endif
+ 
        /* Allow conversions between other integer types only if
  	 explicit value.  */
        if (INTEGRAL_TYPE_P (TREE_TYPE (value))
===================================================================
RCS file: RCS/invoke.texi,v
retrieving revision 1.1
diff -c -r1.1 invoke.texi
*** invoke.texi	2000/03/29 17:40:27	1.1
--- invoke.texi	2000/03/29 17:47:47
***************
*** 6443,6448 ****
--- 6443,6457 ----
  for the EV6) and supports the BWX, CIX, and MAX extensions.
  @end table
  
+ @item -mtaso
+ Allows load-time calculation of @code{(int) &f} where @code{f} is
+ a load-time constant.  Passes the @samp{-taso} flag to the loader.
+ Does not warn on conversions between 32-bit ints and 64-bit pointers.
+ Note that to use this option your loader will need to support @samp{-taso},
+ and you will have to ensure that @code{malloc} in your run-time library
+ returns objects whose addresses are in the lower 32 bits of the
+ address space.
+ 
  @item -mmemory-latency=@var{time}
  Sets the latency the scheduler should assume for typical memory
  references as seen by the application.  This number is highly
===================================================================
RCS file: RCS/alpha.h,v
retrieving revision 1.1
diff -r1.1 alpha.h
158a159,162
> /* This means to allow conversions between pointers and ints. */
> #define MASK_TASO       (1 << 12)
> #define TARGET_TASO     (target_flags & MASK_TASO)
> 
219a224
>     {"taso", MASK_TASO, "Allow conversions between pointers and ints"}, \

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