From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12087 invoked by alias); 28 Sep 2011 05:20:47 -0000 Received: (qmail 12074 invoked by uid 22791); 28 Sep 2011 05:20:43 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,TW_CP,TW_EG X-Spam-Check-By: sourceware.org Received: from shards.monkeyblade.net (HELO shards.monkeyblade.net) (198.137.202.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Sep 2011 05:20:29 +0000 Received: from localhost (cpe-66-65-62-183.nyc.res.rr.com [66.65.62.183]) (authenticated bits=0) by shards.monkeyblade.net (8.14.4/8.14.4) with ESMTP id p8S5KSJ5022604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 27 Sep 2011 22:20:28 -0700 Date: Wed, 28 Sep 2011 06:32:00 -0000 Message-Id: <20110928.012027.2236138577869370946.davem@davemloft.net> To: gdb-patches@sourceware.org Subject: [PATCH] Fix complex float on sparc From: David Miller Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00463.txt.bz2 Lots of testcase failures have crept into the sparc targets, I'll try to fix as many as I can. This gets the complex float cases of callfuncs.exp passing again for both 32-bit and 64-bit. For sparc32 it's pass in memory, return in float regs. For sparc64 it's pass in float regs (<= 16 bytes) or memory (> 16 bytes), always return in float regs. Ok to commit? gdb/ 2011-09-27 David S. Miller * sparc-tdep.h (SPARC_F2_REGNUM, SPARC_F3_REGNUM, SPARC_F4_REGNUM, SPARC_F5_REGNUM, SPARC_F6_REGNUM, SPARC_F7_REGNUM): New enums. * sparc-tdep.c (sparc_complex_floating_p): New function. (sparc32_store_arguments): Handle complex floats. (sparc32_extract_return_value): Likewise. (sparc32_store_return_value): Likewise. (sparc32_stabs_argument_has_addr): Likewise. * sparc64-tdep.c (sparc64_complex_floating_p): New function. (sparc64_store_floating_fields): Handle complex floats. (sparc64_store_arguments): Likewise. (sparc64_store_return_value): Likewise. diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index faa7b3a..8541a31 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -221,6 +221,25 @@ sparc_floating_p (const struct type *type) return 0; } +/* Check whether TYPE is "Complex Floating". */ + +static int +sparc_complex_floating_p (const struct type *type) +{ + switch (TYPE_CODE (type)) + { + case TYPE_CODE_COMPLEX: + { + int len = TYPE_LENGTH (type); + return (len == 8 || len == 16 || len == 32); + } + default: + break; + } + + return 0; +} + /* Check whether TYPE is "Structure or Union". In terms of Ada subprogram calls, arrays are treated the same as @@ -454,7 +473,8 @@ sparc32_store_arguments (struct regcache *regcache, int nargs, int len = TYPE_LENGTH (type); if (sparc_structure_or_union_p (type) - || (sparc_floating_p (type) && len == 16)) + || (sparc_floating_p (type) && len == 16) + || sparc_complex_floating_p (type)) { /* Structure, Union and Quad-Precision Arguments. */ sp -= len; @@ -1238,12 +1258,25 @@ sparc32_extract_return_value (struct type *type, struct regcache *regcache, gdb_assert (!sparc_structure_or_union_p (type)); gdb_assert (!(sparc_floating_p (type) && len == 16)); - if (sparc_floating_p (type)) + if (sparc_floating_p (type) + || sparc_complex_floating_p (type)) { /* Floating return values. */ regcache_cooked_read (regcache, SPARC_F0_REGNUM, buf); if (len > 4) regcache_cooked_read (regcache, SPARC_F1_REGNUM, buf + 4); + if (len > 8) + { + regcache_cooked_read (regcache, SPARC_F2_REGNUM, buf + 8); + regcache_cooked_read (regcache, SPARC_F3_REGNUM, buf + 12); + } + if (len > 16) + { + regcache_cooked_read (regcache, SPARC_F4_REGNUM, buf + 16); + regcache_cooked_read (regcache, SPARC_F5_REGNUM, buf + 20); + regcache_cooked_read (regcache, SPARC_F6_REGNUM, buf + 24); + regcache_cooked_read (regcache, SPARC_F7_REGNUM, buf + 28); + } memcpy (valbuf, buf, len); } else @@ -1281,13 +1314,26 @@ sparc32_store_return_value (struct type *type, struct regcache *regcache, gdb_assert (!(sparc_floating_p (type) && len == 16)); gdb_assert (len <= 8); - if (sparc_floating_p (type)) + if (sparc_floating_p (type) + || sparc_complex_floating_p (type)) { /* Floating return values. */ memcpy (buf, valbuf, len); regcache_cooked_write (regcache, SPARC_F0_REGNUM, buf); if (len > 4) regcache_cooked_write (regcache, SPARC_F1_REGNUM, buf + 4); + if (len > 8) + { + regcache_cooked_write (regcache, SPARC_F2_REGNUM, buf + 8); + regcache_cooked_write (regcache, SPARC_F3_REGNUM, buf + 12); + } + if (len > 16) + { + regcache_cooked_write (regcache, SPARC_F4_REGNUM, buf + 16); + regcache_cooked_write (regcache, SPARC_F5_REGNUM, buf + 20); + regcache_cooked_write (regcache, SPARC_F6_REGNUM, buf + 24); + regcache_cooked_write (regcache, SPARC_F7_REGNUM, buf + 28); + } } else { @@ -1351,7 +1397,8 @@ static int sparc32_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) { return (sparc_structure_or_union_p (type) - || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16)); + || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16) + || sparc_complex_floating_p (type)); } static int diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h index d4e8b06..92b4705 100644 --- a/gdb/sparc-tdep.h +++ b/gdb/sparc-tdep.h @@ -114,6 +114,12 @@ enum sparc_regnum SPARC_I7_REGNUM, /* %i7 */ SPARC_F0_REGNUM, /* %f0 */ SPARC_F1_REGNUM, + SPARC_F2_REGNUM, + SPARC_F3_REGNUM, + SPARC_F4_REGNUM, + SPARC_F5_REGNUM, + SPARC_F6_REGNUM, + SPARC_F7_REGNUM, SPARC_F31_REGNUM /* %f31 */ = SPARC_F0_REGNUM + 31 }; diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 0430ecf..097f658 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -103,6 +103,26 @@ sparc64_floating_p (const struct type *type) return 0; } +/* Check whether TYPE is "Complex Floating". */ + +static int +sparc64_complex_floating_p (const struct type *type) +{ + switch (TYPE_CODE (type)) + { + case TYPE_CODE_COMPLEX: + { + int len = TYPE_LENGTH (type); + gdb_assert (len == 8 || len == 16 || len == 32); + } + return 1; + default: + break; + } + + return 0; +} + /* Check whether TYPE is "Structure or Union". In terms of Ada subprogram calls, arrays are treated the same as @@ -622,11 +642,13 @@ static void sparc64_store_floating_fields (struct regcache *regcache, struct type *type, const gdb_byte *valbuf, int element, int bitpos) { + int len = TYPE_LENGTH (type); + gdb_assert (element < 16); - if (sparc64_floating_p (type)) + if (sparc64_floating_p (type) + || (sparc64_complex_floating_p (type) && len <= 16)) { - int len = TYPE_LENGTH (type); int regnum; if (len == 16) @@ -886,7 +908,8 @@ sparc64_store_arguments (struct regcache *regcache, int nargs, if (element < 16) sparc64_store_floating_fields (regcache, type, valbuf, element, 0); } - else if (sparc64_floating_p (type)) + else if (sparc64_floating_p (type) + || sparc64_complex_floating_p (type)) { /* Floating arguments. */ if (len == 16) @@ -1067,7 +1090,8 @@ sparc64_store_return_value (struct type *type, struct regcache *regcache, if (TYPE_CODE (type) != TYPE_CODE_UNION) sparc64_store_floating_fields (regcache, type, buf, 0, 0); } - else if (sparc64_floating_p (type)) + else if (sparc64_floating_p (type) + || sparc64_complex_floating_p (type)) { /* Floating return values. */ memcpy (buf, valbuf, len);