From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36298 invoked by alias); 20 Nov 2015 16:12:07 -0000 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 Received: (qmail 35957 invoked by uid 89); 20 Nov 2015 16:12:06 -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-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 Nov 2015 16:12:05 +0000 Received: by pacej9 with SMTP id ej9so120395581pac.2 for ; Fri, 20 Nov 2015 08:12:03 -0800 (PST) X-Received: by 10.68.165.131 with SMTP id yy3mr20501849pbb.163.1448035923672; Fri, 20 Nov 2015 08:12:03 -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.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Nov 2015 08:12:03 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [AArch64] Support gnu vector in inferior call Date: Fri, 20 Nov 2015 16:12:00 -0000 Message-Id: <1448035917-3049-2-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 X-SW-Source: 2015-11/txt/msg00431.txt.bz2 As defined in AArch64 AAPCS, short vectors are passed through V registers, and its maximum alignment is 16-byte. This patch is to reflect these rules in GDB. This patch fixes some fails in gdb.base/gnu_vector.exp. gdb: 2015-11-20 Yao Qi * aarch64-tdep.c (aarch64_type_align): For vector type, return its length, but with the maximum of 16 bytes. (is_hfa): Return zero for vector type. (aarch64_push_dummy_call): Handle short vectors. (aarch64_extract_return_value): Likewise. (aarch64_store_return_value): Likewise. --- gdb/aarch64-tdep.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index de85cb0..175ed08 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -894,6 +894,17 @@ aarch64_type_align (struct type *t) return TYPE_LENGTH (t); case TYPE_CODE_ARRAY: + if (TYPE_VECTOR (t)) + { + /* Use the natural alignment for vector types (the same for + scalar type), but the maximum alignment is 128-bit. */ + if (TYPE_LENGTH (t) > 16) + return 16; + else + return TYPE_LENGTH (t); + } + else + return aarch64_type_align (TYPE_TARGET_TYPE (t)); case TYPE_CODE_COMPLEX: return aarch64_type_align (TYPE_TARGET_TYPE (t)); @@ -921,6 +932,10 @@ is_hfa (struct type *ty) case TYPE_CODE_ARRAY: { struct type *target_ty = TYPE_TARGET_TYPE (ty); + + if (TYPE_VECTOR (ty)) + return 0; + if (TYPE_CODE (target_ty) == TYPE_CODE_FLT && TYPE_LENGTH (ty) <= 4) return 1; break; @@ -1318,6 +1333,12 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, pass_on_stack (&info, arg_type, arg); } } + else if (TYPE_CODE (arg_type) == TYPE_CODE_ARRAY + && TYPE_VECTOR (arg_type) && (len == 16 || len == 8)) + { + /* Short vector types are passed in V registers. */ + pass_in_v_or_stack (gdbarch, regcache, &info, arg_type, arg); + } else if (len > 16) { /* PCS B.7 Aggregates larger than 16 bytes are passed by @@ -1643,6 +1664,15 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs, valbuf += len; } } + else if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type) + && (TYPE_LENGTH (type) == 16 || TYPE_LENGTH (type) == 8)) + { + /* Short vector is returned in V register. */ + gdb_byte buf[V_REGISTER_SIZE]; + + regcache_cooked_read (regs, AARCH64_V0_REGNUM, buf); + memcpy (valbuf, buf, TYPE_LENGTH (type)); + } else { /* For a structure or union the behaviour is as if the value had @@ -1772,6 +1802,15 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, valbuf += len; } } + else if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_VECTOR (type) + && (TYPE_LENGTH (type) == 8 || TYPE_LENGTH (type) == 16)) + { + /* Short vector. */ + gdb_byte buf[V_REGISTER_SIZE]; + + memcpy (buf, valbuf, TYPE_LENGTH (type)); + regcache_cooked_write (regs, AARCH64_V0_REGNUM, buf); + } else { /* For a structure or union the behaviour is as if the value had -- 1.9.1