From: Andrew Cagney Date: Tue, 21 Aug 2001 04:31:32 +0000 (+0000) Subject: * arm-tdep.c (convert_from_extended, convert_to_extended): Delete X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a37b3cc06e2418058e6f3a5dee58957649938d0f;p=binutils-gdb.git * arm-tdep.c (convert_from_extended, convert_to_extended): Delete assembler version of function. (convert_from_extended, convert_to_extended): Rewrite. Use floatformat_to_doublest, floatformat_from_doublest, floatformat_arm_ext_big, floatformat_arm_ext_littlebyte_bigword. (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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 62381a863eb..a192c74a11a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2001-07-24 Andrew Cagney + + * arm-tdep.c (convert_from_extended, convert_to_extended): Delete + assembler version of function. + (convert_from_extended, convert_to_extended): Rewrite. Use + floatformat_to_doublest, floatformat_from_doublest, + floatformat_arm_ext_big, floatformat_arm_ext_littlebyte_bigword. + (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. + 2001-08-20 Andrew Cagney * gdbtypes.h (struct type): Clarify meaning of field ``length''. diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 6faf85be9ba..ae06160ca5b 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -160,7 +160,6 @@ arm_linux_push_arguments (int nargs, struct value **args, CORE_ADDR sp, { int len; char *val; - double dbl_arg; CORE_ADDR regval; enum type_code typecode; struct type *arg_type, *target_type; @@ -180,14 +179,11 @@ arm_linux_push_arguments (int nargs, struct value **args, CORE_ADDR sp, 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; - + dblval = extract_floating (val, len); 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; + val = alloca (len); + store_floating (val, len, dblval); } /* If the argument is a pointer to a function, and it is a Thumb diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index e9fe7c7622c..1cb42a3702b 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -118,24 +118,6 @@ struct frame_extra_info #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. */ @@ -1310,7 +1292,6 @@ arm_push_arguments (int nargs, struct value **args, CORE_ADDR sp, { int len; char *val; - double dbl_arg; CORE_ADDR regval; enum type_code typecode; struct type *arg_type, *target_type; @@ -1330,22 +1311,11 @@ arm_push_arguments (int nargs, struct value **args, CORE_ADDR sp, 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; + 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 @@ -1466,43 +1436,34 @@ arm_float_info (void) 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)); -} +/* NOTE: cagney/2001-08-20: Both convert_from_extended() and + convert_to_extended() use floatformat_arm_ext_littlebyte_bigword. + It is thought that this is is the floating-point register format on + little-endian systems. */ -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; + DOUBLEST d; + if (TARGET_BYTE_ORDER == BIG_ENDIAN) + floatformat_to_doublest (&floatformat_arm_ext_big, ptr, &d); + else + floatformat_to_doublest (&floatformat_arm_ext_littlebyte_bigword, + ptr, &d); + floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &d, dbl); } void convert_to_extended (void *dbl, void *ptr) { - *(double *) ptr = *(double *) dbl; + DOUBLEST d; + floatformat_to_doublest (TARGET_DOUBLE_FORMAT, ptr, &d); + if (TARGET_BYTE_ORDER == BIG_ENDIAN) + floatformat_from_doublest (&floatformat_arm_ext_big, &d, dbl); + else + floatformat_from_doublest (&floatformat_arm_ext_littlebyte_bigword, + &d, dbl); } -#endif /* Nonzero if register N requires conversion from raw format to virtual format. */