This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

support for -mtaso patch


I've put together the following patch to add an -mtaso switch to the Alpha
target that will allow loader conversions of pointers to 32-bit ints and
will not warn on conversions between 64-bit pointers and 32-bit ints.
Gnu as and ld (with the -taso switch; I don't know how to get gcc to add
-taso to the ld switches automatically if -mtaso is used, so right now,
to link you need gcc -Wl,-taso) already do the right things to handle the
generated code in versions of binutils >= 2.9.5.0.24.  The CVS versions
of glibc 2.1.3 and 2.2 do the right thing; if you want to use this with
earlier versions of glibc, you need to add the line

  personality(0x0800000);

to your code before the first call to malloc.

ld.so does not, yet, do the right thing.

These changes have bootstrapped successfully with the mainline source of
gcc version 2.96 20000320 for LANGUAGES='c c++' (I have been unable to
get f77 to bootstrap for a while) on alphaev6-unknown-linux-gnu, and the
Scheme system I use (several hundred thousand lines of C code) passed all
its tests successfully (except for the ones involving dynamic linking).

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.

===================================================================
RCS file: RCS/alpha.h,v
retrieving revision 1.1
diff -c -r1.1 alpha.h
*** alpha.h	2000/03/21 16:14:21	1.1
--- alpha.h	2000/03/21 19:16:25
***************
*** 156,161 ****
--- 156,165 ----
  #define MASK_CIX	(1 << 11)
  #define TARGET_CIX	(target_flags & MASK_CIX)
  
+ /* This means to allow conversions between pointers and ints. */
+ #define MASK_TASO       (1 << 12)
+ #define TARGET_TASO     (target_flags & MASK_TASO)
+ 
  /* This means that the processor is an EV5, EV56, or PCA56.  This is defined
     only in TARGET_CPU_DEFAULT.  */
  #define MASK_CPU_EV5	(1 << 28)
***************
*** 217,222 ****
--- 221,227 ----
      {"no-fix", -MASK_FIX, ""},						\
      {"cix", MASK_CIX, "Emit code for the counting ISA extension"},	\
      {"no-cix", -MASK_CIX, ""},						\
+     {"taso", MASK_TASO, "Allow conversions between pointers and ints"}, \
      {"", TARGET_DEFAULT | TARGET_CPU_DEFAULT, ""} }
  
  #define TARGET_DEFAULT MASK_FP|MASK_FPREGS
===================================================================
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/22 17:15:03
***************
*** 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,3719 ----
        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 64->32 bit conversions 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;
--- 3730,3743 ----
  	  && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value))
  #endif
  	  /* Don't warn about converting any constant.  */
! 	  && !TREE_CONSTANT (value)
! #ifdef TARGET_TASO
! 	  /* don't warn about 32->64 bit conversions 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/22 04:07:11
***************
*** 4088,4093 ****
--- 4088,4107 ----
  	      == 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)) == NOP_EXPR
+ 	      || 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))

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