From patchwork Thu Nov 29 16:48:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 30394 Received: (qmail 34146 invoked by alias); 29 Nov 2018 16:50:07 -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 27900 invoked by uid 89); 29 Nov 2018 16:48:30 -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= X-HELO: mail-wr1-f66.google.com Received: from mail-wr1-f66.google.com (HELO mail-wr1-f66.google.com) (209.85.221.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Nov 2018 16:48:25 +0000 Received: by mail-wr1-f66.google.com with SMTP id p4so2592547wrt.7 for ; Thu, 29 Nov 2018 08:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=e29QgqF5c5YT6e/jPU5QiOJKHASXTwRYjWtdpiYl7Mk=; b=atueAQwuG6QbfDTG1oOAS5c9MneAElDyocn876R59Rf3GJ5J+cYf/6tNPfqWnmEx5N VZ6eqAz0xS+KdogpG8SToV9Fg2+p8jOmj1GkkwCkXPDC11xYoF7o3HnlbaxbR1K5OIMc dH3qI5oO9QWSdnWtUpX5fnGAuWByEDiKZsN6miMrUy10XhZtw6Y79m2WrA7BNjn+D2XQ JoPNxzy41wIeqaNcfHlWOxMA0TD0Rp5rbSga1aggGMoYT8MO1yqzxpcHgaKeQbnG+Kw8 0NjYy2imX36UaGRGYGEJyguojTe4BT8OxqRhx9bkC7bqXhdddPyUhha/jwvtow+A5uaT qTEA== Return-Path: Received: from localhost (host86-156-236-171.range86-156.btcentralplus.com. [86.156.236.171]) by smtp.gmail.com with ESMTPSA id f15sm1770160wrt.10.2018.11.29.08.48.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Nov 2018 08:48:20 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: jimw@sifive.com, palmer@sifive.com, jhb@FreeBSD.org, Andrew Burgess Subject: [PATCH 2/4] gdb/riscv: Add equality operators to riscv_gdb_features Date: Thu, 29 Nov 2018 16:48:11 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Add '==' and '!=' operators for the struct riscv_gdb_features, allowing a small simplification. gdb/ChangeLog: * arch/riscv.h (riscv_gdb_features::operator==): New. (riscv_gdb_features::operator!=): New. * riscv-tdep.c (riscv_gdbarch_init): Make use of the inequality operator. --- gdb/ChangeLog | 7 +++++++ gdb/arch/riscv.h | 13 +++++++++++++ gdb/riscv-tdep.c | 4 +--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h index ec4d5f39525..be41828eff6 100644 --- a/gdb/arch/riscv.h +++ b/gdb/arch/riscv.h @@ -53,6 +53,19 @@ struct riscv_gdbarch_features this field is true then the hardware floating point abi is in use, and values are passed in f-registers matching the size of FLEN. */ bool hw_float_abi = false; + + /* Equality operator. */ + bool operator== (const struct riscv_gdbarch_features &rhs) const + { + return (xlen == rhs.xlen && flen == rhs.flen + && hw_float_abi == rhs.hw_float_abi); + } + + /* Inequality operator. */ + bool operator!= (const struct riscv_gdbarch_features &rhs) const + { + return !((*this) == rhs); + } }; /* Create and return a target description that is compatible with diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index d66fe5c8793..30c777db6f2 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -3025,9 +3025,7 @@ riscv_gdbarch_init (struct gdbarch_info info, gdbarch. */ struct gdbarch_tdep *other_tdep = gdbarch_tdep (arches->gdbarch); - if (other_tdep->features.hw_float_abi != features.hw_float_abi - || other_tdep->features.xlen != features.xlen - || other_tdep->features.flen != features.flen) + if (other_tdep->features != features) continue; break;