This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


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

Re: [rfa] Attempt #3: Eliminate HOST_*_FORMAT from arm-*tdep.c


Ping?



> Hello,
> 
> Attatched is another attemt at eliminating the HOST_*_FORMAT references in arm-tdep.c and arm-linux-tdep.c.  I'm definitly getting closer!
> 
> This time, I also ``fixed'' the functions convert_to_extended() and convert_from_extended() to use portable floatformat_*() functions.
> 
> With the patch applied testing on a big-endian host using the arm-sim target suggests things do indeed imrove.  The tests:
> 
> gdb.base/callfuncs.exp: p t_float_values
> gdb.base/callfuncs.exp: p t_float_values2
> gdb.base/callfwmall.exp: p t_float_values
> gdb.base/callfwmall.exp: p t_float_values2
> 
> all started passing.  At the same time I didn't see any regressions.
> Interestingly, testing on a little endian host showed no change in the test results.
> 
> There is one FIXME.  The code always uses floatformat_arm_ext.  I'm windering if there needs to be both floatformat_arm_ext_big and floatformat_arm_ext_little.  Anyone know the exact format used when storing BE/LE extended floats on the arm architecture?
> 
> Anyway, I'm hopeing this is sufficient improvement over the previous mess to go in.
> 
>     Andrew
> 
> 
> 
> 2001-07-24  Andrew Cagney  <ac131313@redhat.com>
> * arm-tdep.c (convert_from_extended, convert_to_extended): Delete
> 	assembler version of function.
> 	(convert_from_extended, convert_to_extended): Rewrite using
> 	floatformat_to_doublest and floatformat_from_doublest.
> 	(arm_push_arguments): Use extract_floating and
> 	store_floating to perform floating point conversions.
> 	(SWAP_TARGET_AND_HOST): Delete macro.
> 	* arm-linux-tdep.c (arm_linux_push_arguments): Use
> 	extract_floating and store_floating to perform floating point
> 	conversions.
> 
> Index: arm-linux-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-linux-tdep.c,v
> retrieving revision 1.9
> diff -p -r1.9 arm-linux-tdep.c
> *** arm-linux-tdep.c	2001/07/15 20:10:02	1.9
> --- arm-linux-tdep.c	2001/07/27 02:44:41
> *************** arm_linux_push_arguments (int nargs, str
> *** 159,165 ****
>       {
>         int len;
>         char *val;
> -       double dbl_arg;
>         CORE_ADDR regval;
>         enum type_code typecode;
>         struct type *arg_type, *target_type;
> --- 159,164 ----
> *************** arm_linux_push_arguments (int nargs, str
> *** 179,192 ****
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
> - 	  /* Float argument in buffer is in host format.  Read it and 
> - 	     convert to DOUBLEST, and store it in target double.  */
>   	  DOUBLEST dblval;
> ! 	  
>   	  len = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> ! 	  floatformat_to_doublest (HOST_FLOAT_FORMAT, val, &dblval);
> ! 	  store_floating (&dbl_arg, len, dblval);
> ! 	  val = (char *) &dbl_arg;
>   	}
>   
>         /* If the argument is a pointer to a function, and it is a Thumb
> --- 178,188 ----
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
>   	  DOUBLEST dblval;
> ! 	  dblval = extract_floating (val, len);
>   	  len = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> ! 	  val = alloca (len);
> ! 	  store_floating (val, len, dblval);
>   	}
>   
>         /* If the argument is a pointer to a function, and it is a Thumb
> Index: arm-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-tdep.c,v
> retrieving revision 1.13
> diff -p -r1.13 arm-tdep.c
> *** arm-tdep.c	2001/07/15 20:10:02	1.13
> --- arm-tdep.c	2001/07/27 02:44:46
> *************** struct frame_extra_info
> *** 117,140 ****
>   #define MAKE_THUMB_ADDR(addr)	((addr) | 1)
>   #define UNMAKE_THUMB_ADDR(addr) ((addr) & ~1)
>   
> - #define SWAP_TARGET_AND_HOST(buffer,len) 				\
> -   do									\
> -     {									\
> -       if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER)				\
> - 	{								\
> - 	  char tmp;							\
> - 	  char *p = (char *)(buffer);					\
> - 	  char *q = ((char *)(buffer)) + len - 1;		   	\
> - 	  for (; p < q; p++, q--)				 	\
> - 	    {								\
> - 	      tmp = *q;							\
> - 	      *q = *p;							\
> - 	      *p = tmp;							\
> - 	    }								\
> - 	}								\
> -     }									\
> -   while (0)
> - 
>   /* Will a function return an aggregate type in memory or in a
>      register?  Return 0 if an aggregate type can be returned in a
>      register, 1 if it must be returned in memory.  */
> --- 117,122 ----
> *************** arm_push_arguments (int nargs, struct va
> *** 1309,1315 ****
>       {
>         int len;
>         char *val;
> -       double dbl_arg;
>         CORE_ADDR regval;
>         enum type_code typecode;
>         struct type *arg_type, *target_type;
> --- 1291,1296 ----
> *************** arm_push_arguments (int nargs, struct va
> *** 1329,1350 ****
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
> ! 	  float f;
> ! 	  double d;
> ! 	  char * bufo = (char *) &d;
> ! 	  char * bufd = (char *) &dbl_arg;
> ! 
> ! 	  len = sizeof (double);
> ! 	  f = *(float *) val;
> ! 	  SWAP_TARGET_AND_HOST (&f, sizeof (float));  /* adjust endianess */
> ! 	  d = f;
> ! 	  /* We must revert the longwords so they get loaded into the
> ! 	     the right registers. */
> ! 	  memcpy (bufd, bufo + len / 2, len / 2);
> ! 	  SWAP_TARGET_AND_HOST (bufd, len / 2);  /* adjust endianess */
> ! 	  memcpy (bufd + len / 2, bufo, len / 2);
> ! 	  SWAP_TARGET_AND_HOST (bufd + len / 2, len / 2); /* adjust endianess */
> ! 	  val = (char *) &dbl_arg;
>   	}
>   #if 1
>         /* I don't know why this code was disable. The only logical use
> --- 1310,1320 ----
>            calling the function.  */
>         if (TYPE_CODE_FLT == typecode && REGISTER_SIZE == len)
>   	{
> ! 	  DOUBLEST dblval;
> ! 	  dblval = extract_floating (val, len);
> ! 	  len = TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
> ! 	  val = alloca (len);
> ! 	  store_floating (val, len, dblval);
>   	}
>   #if 1
>         /* I don't know why this code was disable. The only logical use
> *************** arm_float_info (void)
> *** 1464,1507 ****
>     fputs ("flags: ", stdout);
>     print_fpu_flags (status);
>   }
> - 
> - #if 0
> - /* FIXME:  The generated assembler works but sucks.  Instead of using
> -    r0, r1 it pushes them on the stack, then loads them into r3, r4 and
> -    uses those registers.  I must be missing something.  ScottB  */
>   
> ! void
> ! convert_from_extended (void *ptr, void *dbl)
> ! {
> !   __asm__ ("
> ! 	   ldfe f0,[%0]
> ! 	   stfd f0,[%1] "
> ! :				/* no output */
> ! :	   "r" (ptr), "r" (dbl));
> ! }
>   
> - void
> - convert_to_extended (void *dbl, void *ptr)
> - {
> -   __asm__ ("
> - 	   ldfd f0,[%0]
> - 	   stfe f0,[%1] "
> - :				/* no output */
> - :	   "r" (dbl), "r" (ptr));
> - }
> - #else
>   static void
>   convert_from_extended (void *ptr, void *dbl)
>   {
> !   *(double *) dbl = *(double *) ptr;
>   }
>   
>   void
>   convert_to_extended (void *dbl, void *ptr)
>   {
> !   *(double *) ptr = *(double *) dbl;
>   }
> - #endif
>   
>   /* Nonzero if register N requires conversion from raw format to
>      virtual format.  */
> --- 1434,1458 ----
>     fputs ("flags: ", stdout);
>     print_fpu_flags (status);
>   }
>   
> ! /* FIXME: cagney/2001-07-24: Is floatformat_arm_ext byte order
> !    dependant or independant? */
>   
>   static void
>   convert_from_extended (void *ptr, void *dbl)
>   {
> !   DOUBLEST d;
> !   floatformat_to_doublest (&floatformat_arm_ext, ptr, &d);
> !   floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &d, dbl);
>   }
>   
>   void
>   convert_to_extended (void *dbl, void *ptr)
>   {
> !   DOUBLEST d;
> !   floatformat_to_doublest (TARGET_DOUBLE_FORMAT, ptr, &d);
> !   floatformat_from_doublest (&floatformat_arm_ext, &d, dbl);
>   }
>   
>   /* Nonzero if register N requires conversion from raw format to
>      virtual format.  */
> 



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