From patchwork Tue Nov 13 05:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 30129 Received: (qmail 61002 invoked by alias); 13 Nov 2018 05:38:39 -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 60991 invoked by uid 89); 13 Nov 2018 05:38:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:209.85.210.196, H*RU:209.85.210.196, H*r:sk:y18-v6s, HX-HELO:sk:mail-pf X-HELO: mail-pf1-f196.google.com Received: from mail-pf1-f196.google.com (HELO mail-pf1-f196.google.com) (209.85.210.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Nov 2018 05:38:37 +0000 Received: by mail-pf1-f196.google.com with SMTP id y18-v6so5471330pfn.1 for ; Mon, 12 Nov 2018 21:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YM10RWhjatAvqNiOhV1utiQG6z3rZs8BtAoiGfu6o34=; b=g7zl3sjMAAprsf7ACPLeo8oh18mD1hIRjuCjyx4LWucxcFBag6FYjq6XnozacmpK0C 3vGISnYv4Wu/zuyctACG1PrUkF2tT5GKNxMS3BgMHp+ugNMKu4gQElLJ8mhnJqG5qDPK S1jyF+08GXZ9bJCybcVpnxmRj+WLi6um+fl4CN70Iv6AXGIqRqSQOYSU5ERmOp8Z4wYr /u4tJRiOHSg/3zFTEG076FE5wz5kmHW+W1/+4IvPWWqdX05+1PdG+GzcD0bfGGbjpCRd HJCNLmywWynHrbXOgQLCh2vwCLml5xRxcMZy/eP5ZPzWEghRlvx1EfTc0zO+tDa2+5AL W2dA== Return-Path: Received: from rohan.hsd1.ca.comcast.net ([2601:646:c100:8240:b06e:359d:dfe4:197]) by smtp.gmail.com with ESMTPSA id p62-v6sm19789169pfp.111.2018.11.12.21.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 21:38:35 -0800 (PST) From: Jim Wilson To: gdb-patches@sourceware.org Cc: andrew.burgess@embecosm.com, Jim Wilson Subject: [PATCH 2/3 v2] RISC-V: Handle vector type alignment. Date: Mon, 12 Nov 2018 21:38:32 -0800 Message-Id: <20181113053832.5042-1-jimw@sifive.com> In-Reply-To: References: For riscv64-linxu target, first half of fix for FAIL: gdb.base/gnu_vector.exp: call add_various_floatvecs GCC gives vectors natural aligment based on total size, not element size, bounded by the maximum supported type alignment. gdb/ * riscv-tdep.c (BIGGEST_ALIGNMENT): New. (riscv_type_alignment) : If TYPE_VECTOR, return min of TYPE_LENGTH and BIGGEST_ALIGNMENT. --- gdb/riscv-tdep.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index f4650dfbf3..58dca3b86e 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -59,6 +59,9 @@ /* The stack must be 16-byte aligned. */ #define SP_ALIGNMENT 16 +/* The biggest alignment that the target supports. */ +#define BIGGEST_ALIGNMENT 16 + /* Forward declarations. */ static bool riscv_has_feature (struct gdbarch *gdbarch, char feature); @@ -1640,6 +1643,10 @@ riscv_type_alignment (struct type *t) return TYPE_LENGTH (t); case TYPE_CODE_ARRAY: + if (TYPE_VECTOR (t)) + return std::min (TYPE_LENGTH (t), (unsigned) BIGGEST_ALIGNMENT); + /* FALLTHROUGH */ + case TYPE_CODE_COMPLEX: return riscv_type_alignment (TYPE_TARGET_TYPE (t));