This is the mail archive of the gcc@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]

problems modifying varasm.c


I'm trying to add -mtaso support for alpha so that

typedef struct { int a; int b; } foo;

extern foo f;

static int tbl1[] =
{
  (int) &f
};

will compile correctly. (I believe the ld can handle it using REFLONG
relocations.)

First I defined the following macros in alpha.h:

===================================================================
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

Then I used TARGET_TASO in varasm.c


===================================================================
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/21 18:50:05
***************
*** 4103,4110 ****
        /* 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);
  
--- 4103,4118 ----
        /* 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))))
! #ifdef TARGET_TASO
! 	      || (TARGET_TASO
! 		  && (TYPE_PRECISION (TREE_TYPE (value)) == 32)
! 		  && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))
! 		      == 64))
! #endif
! 	   ))
! 	  
  	return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  					     endtype);
  
***************
*** 4115,4122 ****
  	{
  	  if (integer_zerop (TREE_OPERAND (value, 0)))
  	    return null_pointer_node;
! 	  else if (TYPE_PRECISION (TREE_TYPE (value))
! 		   <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))
  	    return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  						 endtype);
  	}
--- 4123,4137 ----
  	{
  	  if (integer_zerop (TREE_OPERAND (value, 0)))
  	    return null_pointer_node;
! 	  else if ((TYPE_PRECISION (TREE_TYPE (value))
! 		    <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0))))
! #ifdef TARGET_TASO
! 		   || (TARGET_TASO
! 		       && (TYPE_PRECISION (TREE_TYPE (value)) == 64)
! 		       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))
! 			   == 32))
! #endif
! 		   )
  	    return initializer_constant_valid_p (TREE_OPERAND (value, 0),
  						 endtype);
  	}

I've stepped through this code about 5 times, but I cannot see why
I still get the error message:

popov-167% ./cc1 -mtaso crap.c
crap.c:8: initializer element is not computable at load time
crap.c:8: (near initialization for `tbl1[0]')

Does anyone have any suggestions?

Brad

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