From patchwork Tue Nov 6 21:44:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 30049 Received: (qmail 49365 invoked by alias); 6 Nov 2018 21:44:37 -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 49033 invoked by uid 89); 6 Nov 2018 21:44:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, 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=H*RU:209.85.210.193, Hx-spam-relays-external:209.85.210.193, HX-HELO:sk:mail-pf, H*r:sk:mail-pf X-HELO: mail-pf1-f193.google.com Received: from mail-pf1-f193.google.com (HELO mail-pf1-f193.google.com) (209.85.210.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Nov 2018 21:44:33 +0000 Received: by mail-pf1-f193.google.com with SMTP id u13-v6so6725178pfm.4 for ; Tue, 06 Nov 2018 13:44:33 -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=i33MHTe/lpxR8f3s5rXQ0MAPv8w6ncA+03W7mVviuEA=; b=b3nA2oIpTEukMCUZi5vBeBs/Ypw1cWUprEt+6pMRdozZGHn/OpO452DZrCjjW5Utik ys6WdeB4rstFaT7NgUblo8whAGS+y91qqell15++PL+8Xl0Xf4Sbpo/Lt1bjha9Wy0X6 /JrlBtNbcf4mjnMFW/EEhS9Ti4SZ5eeGRzWddmnyxj764qs4uATSvuX7b8WdEmlaPmAN maNi/2Hx6zYMG7W1Ju6o0qf5Lti1JEz9Lzo1923ZWOucJlF5oO7XqBzz9NZcHkdxl9/b lqJ5eI1vkkIIaHvg/snVzSpjLuIy/kgIrLuxB7OvU1vfXNLjz1SIZtLNQr+UmSWuRMqp WEmQ== Return-Path: Received: from rohan.guest.sifive.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id d5-v6sm33549089pfo.131.2018.11.06.13.44.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:44:30 -0800 (PST) From: Jim Wilson To: gdb-patches@sourceware.org Cc: Jim Wilson Subject: [PATCH 2/3] RISC-V: gdb.base/gnu_vector fixes. Date: Tue, 6 Nov 2018 13:44:28 -0800 Message-Id: <20181106214428.22262-1-jimw@sifive.com> In-Reply-To: References: 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 ac4f2533f4..3d4f7e3dcc 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));