From patchwork Fri Nov 20 16:11:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 9758 Received: (qmail 39007 invoked by alias); 20 Nov 2015 16:12:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 38002 invoked by uid 89); 20 Nov 2015 16:12:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 Nov 2015 16:12:07 +0000 Received: by pacdm15 with SMTP id dm15so120470201pac.3 for ; Fri, 20 Nov 2015 08:12:05 -0800 (PST) X-Received: by 10.68.192.133 with SMTP id hg5mr20190616pbc.63.1448035925285; Fri, 20 Nov 2015 08:12:05 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id ws6sm230974pbc.33.2015.11.20.08.12.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Nov 2015 08:12:04 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 2/3] [AArch64] Handle HFA and HVA together Date: Fri, 20 Nov 2015 16:11:56 +0000 Message-Id: <1448035917-3049-3-git-send-email-yao.qi@linaro.org> In-Reply-To: <1448035917-3049-1-git-send-email-yao.qi@linaro.org> References: <1448035917-3049-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes AArch64 AAPCS defined HFA (homogeneous floating-point aggregate) and HVF (homogeneous short vector aggregate), bug GDB only handles the former. In the AAPCS doc, both types are treated exactly the same in terms of alignment and passing locations (on registers or stack). This patch is to extend is_hfa to handle both HFA and HVA. gdb: 2015-11-20 Yao Qi * aarch64-tdep.c (is_hfa): Rename to ... (is_hfa_or_hva): ... this. Handle vector type. All callers updated. (aarch64_extract_return_value): Update debugging message. (aarch64_store_return_value): Likewise. (aarch64_return_in_memory): Update comments. --- gdb/aarch64-tdep.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 175ed08..cdc1b93 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -921,11 +921,12 @@ aarch64_type_align (struct type *t) } } -/* Return 1 if *TY is a homogeneous floating-point aggregate as - defined in the AAPCS64 ABI document; otherwise return 0. */ +/* Return 1 if *TY is a homogeneous floating-point aggregate or + homogeneous short-vector aggregate as defined in the AAPCS64 ABI + document; otherwise return 0. */ static int -is_hfa (struct type *ty) +is_hfa_or_hva (struct type *ty) { switch (TYPE_CODE (ty)) { @@ -936,7 +937,10 @@ is_hfa (struct type *ty) if (TYPE_VECTOR (ty)) return 0; - if (TYPE_CODE (target_ty) == TYPE_CODE_FLT && TYPE_LENGTH (ty) <= 4) + if (TYPE_LENGTH (ty) <= 4 /* HFA or HVA has at most 4 members. */ + && (TYPE_CODE (target_ty) == TYPE_CODE_FLT /* HFA */ + || (TYPE_CODE (target_ty) == TYPE_CODE_ARRAY /* HVA */ + && TYPE_VECTOR (target_ty)))) return 1; break; } @@ -944,12 +948,15 @@ is_hfa (struct type *ty) case TYPE_CODE_UNION: case TYPE_CODE_STRUCT: { + /* HFA or HVA has at most four members. */ if (TYPE_NFIELDS (ty) > 0 && TYPE_NFIELDS (ty) <= 4) { struct type *member0_type; member0_type = check_typedef (TYPE_FIELD_TYPE (ty, 0)); - if (TYPE_CODE (member0_type) == TYPE_CODE_FLT) + if (TYPE_CODE (member0_type) == TYPE_CODE_FLT + || (TYPE_CODE (member0_type) == TYPE_CODE_ARRAY + && TYPE_VECTOR (member0_type))) { int i; @@ -1304,7 +1311,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, case TYPE_CODE_STRUCT: case TYPE_CODE_ARRAY: case TYPE_CODE_UNION: - if (is_hfa (arg_type)) + if (is_hfa_or_hva (arg_type)) { int elements = TYPE_NFIELDS (arg_type); @@ -1640,7 +1647,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, memcpy (valbuf, buf, len); valbuf += len; } - else if (is_hfa (type)) + else if (is_hfa_or_hva (type)) { int elements = TYPE_NFIELDS (type); struct type *member_type = check_typedef (TYPE_FIELD_TYPE (type, 0)); @@ -1654,7 +1661,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, if (aarch64_debug) { - debug_printf ("read HFA return value element %d from %s\n", + debug_printf ("read HFA or HVA return value element %d from %s\n", i + 1, gdbarch_register_name (gdbarch, regno)); } @@ -1705,14 +1712,10 @@ aarch64_return_in_memory (struct gdbarch *gdbarch, struct type *type) type = check_typedef (type); - /* In the AArch64 ABI, "integer" like aggregate types are returned - in registers. For an aggregate type to be integer like, its size - must be less than or equal to 4 * X_REGISTER_SIZE. */ - - if (is_hfa (type)) + if (is_hfa_or_hva (type)) { - /* PCS B.5 If the argument is a Named HFA, then the argument is - used unmodified. */ + /* v0-v7 are used to return values and one register is allocated + for one member. However, HFA or HVA has at most four members. */ return 0; } @@ -1778,7 +1781,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, } } } - else if (is_hfa (type)) + else if (is_hfa_or_hva (type)) { int elements = TYPE_NFIELDS (type); struct type *member_type = check_typedef (TYPE_FIELD_TYPE (type, 0)); @@ -1792,7 +1795,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, if (aarch64_debug) { - debug_printf ("write HFA return value element %d to %s\n", + debug_printf ("write HFA or HVA return value element %d to %s\n", i + 1, gdbarch_register_name (gdbarch, regno)); }