From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47187 invoked by alias); 20 Nov 2015 16:35:31 -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 46038 invoked by uid 89); 20 Nov 2015 16:35:30 -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:35:29 +0000 Received: by pacej9 with SMTP id ej9so120939987pac.2 for ; Fri, 20 Nov 2015 08:35:28 -0800 (PST) X-Received: by 10.68.125.197 with SMTP id ms5mr20710158pbb.161.1448037327944; Fri, 20 Nov 2015 08:35:27 -0800 (PST) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id oi3sm306725pbb.53.2015.11.20.08.35.24 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 20 Nov 2015 08:35:27 -0800 (PST) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 1/3] [AArch64] Support gnu vector in inferior call References: <1448035917-3049-1-git-send-email-yao.qi@linaro.org> <1448035917-3049-2-git-send-email-yao.qi@linaro.org> <564F48C5.5090801@redhat.com> Date: Fri, 20 Nov 2015 16:35:00 -0000 In-Reply-To: <564F48C5.5090801@redhat.com> (Pedro Alves's message of "Fri, 20 Nov 2015 16:22:29 +0000") Message-ID: <86h9kgzl13.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg00437.txt.bz2 Pedro Alves writes: >> + else if (TYPE_CODE (arg_type) =3D=3D TYPE_CODE_ARRAY >> + && TYPE_VECTOR (arg_type) && (len =3D=3D 16 || len =3D=3D 8)) >> + { >> + /* Short vector types are passed in V registers. */ >> + pass_in_v_or_stack (gdbarch, regcache, &info, arg_type, arg); > > Indentation looks odd here. Ur, sorry. Patch is updated. --=20 Yao (=E9=BD=90=E5=B0=A7) From: Yao Qi Subject: [PATCH] [AArch64] Support gnu vector in inferior call 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. diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index de85cb0..8ce0eaa 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); =20 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)); =20 @@ -921,6 +932,10 @@ is_hfa (struct type *ty) case TYPE_CODE_ARRAY: { struct type *target_ty =3D TYPE_TARGET_TYPE (ty); + + if (TYPE_VECTOR (ty)) + return 0; + if (TYPE_CODE (target_ty) =3D=3D TYPE_CODE_FLT && TYPE_LENGTH (ty) <=3D 4) return 1; break; @@ -1318,6 +1333,12 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, st= ruct value *function, pass_on_stack (&info, arg_type, arg); } } + else if (TYPE_CODE (arg_type) =3D=3D TYPE_CODE_ARRAY + && TYPE_VECTOR (arg_type) && (len =3D=3D 16 || len =3D=3D 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, str= uct regcache *regs, valbuf +=3D len; } } + else if (TYPE_CODE (type) =3D=3D TYPE_CODE_ARRAY && TYPE_VECTOR (type) + && (TYPE_LENGTH (type) =3D=3D 16 || TYPE_LENGTH (type) =3D=3D 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, struc= t regcache *regs, valbuf +=3D len; } } + else if (TYPE_CODE (type) =3D=3D TYPE_CODE_ARRAY && TYPE_VECTOR (type) + && (TYPE_LENGTH (type) =3D=3D 8 || TYPE_LENGTH (type) =3D=3D 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