From patchwork Fri Apr 22 16:52:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564873 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp683538map; Fri, 22 Apr 2022 10:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT3igkthWS+Z9LQhPmZ0eQ83TAH2Qu9+FyyIP96C+xl5tSM1YJqDXDX/EWHyCadWFuUz2r X-Received: by 2002:a0d:eb4e:0:b0:2f4:dbd9:6e64 with SMTP id u75-20020a0deb4e000000b002f4dbd96e64mr5911161ywe.486.1650648499748; Fri, 22 Apr 2022 10:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650648499; cv=none; d=google.com; s=arc-20160816; b=bO+0tlAZuKKKxhNiMZC/fUAnuXpfuI/lj0JOOg74mXrNt8ZDaTdq4s8/pCqiyyA/IS yu538pGA9teqbWbklsoIVZE0jA0rylkbscx83IsSNAVaUhrBklI9NUe4/R89If6GX1/n BSD773rCzSj6zsdA4wH4GzFgU6z1tO060UZrN2c7Jea3KGCMKhSoYnBDKJOFRF5gBPQo xsEWFSPRpbH1BuLoSVFOwcbMmDPJ8vWGdZMXRvCJi3YSz+c86PJQLLN6kY2eQMGn1JhA AaTZklPQvatu/a0LKR10IeJ52/o0pT5LHZbL7wBcn4mg3cJ/QyvIjhqJ37fzoJtZK/as OCHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zCoM+nxCW+KhPaK3jdR/NXDiI5y1zUCOgbetADXQNIY=; b=Z5cSdn1lPNOE+FAb10AkiLvCWGweSp/Ckss/Q7ba0bNfeK3wNHYALc7gRaBC/z7Lji DyA/gSP2uPyMufcCRDghK1k7W5xkGvCv/8AEZs+U9CgtWnpdY05lAdRFJihzWPi6ufRL /qGem+OsjAnk1AC+cnFfN+Njlb0Cz84SkUXzubfQI3OFBIU6eU43py7DF8E+6YMO1AFC 7ZeF3q7FQsMfxAWnVadafnNLnnwFR2a9A+bTMs/QAlkyyZDbkhjOGucFtHiqZFfIAt42 RHEFzuSfZAiOmz6Pm/U1I93pIA3PnpfrTmHCjcd94ph0cSPN/DaQM0dQ3Bpc2m2PdNKy p7hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uS1aPitE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n200-20020a2540d1000000b00645d7004610si1582142yba.615.2022.04.22.10.28.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Apr 2022 10:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uS1aPitE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhx4s-0003Lv-V2 for patch@linaro.org; Fri, 22 Apr 2022 13:28:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhwad-0008HV-Tx for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:57:03 -0400 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]:41510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhwab-0007yY-R0 for qemu-devel@nongnu.org; Fri, 22 Apr 2022 12:57:03 -0400 Received: by mail-il1-x131.google.com with SMTP id h4so5417914ilq.8 for ; Fri, 22 Apr 2022 09:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zCoM+nxCW+KhPaK3jdR/NXDiI5y1zUCOgbetADXQNIY=; b=uS1aPitEgiCNiYI8ZMc40KsbtT16ogFkT5/u41LVGeI7s8LsPHmrU12kDvKuhMr3pg aR+XYa9jtYkuxhe9RU32t/yilViTkoS5vtxBtzmeB/otr+QztyNCfCfql5LOEj2pLMMi 72JiSpyfMPJDbDVTOStMa1W88WAXRxJtNdAiRIWX+8wAjH7NiH0wVkSHkOqSDv4/sEjf 0fpRdBNyYy0baPKITvMSytqTHjfn4OZn4y9ta0SlWtDsghx4kNGLgumNTLvqqsWZToi4 GIQFu+kczuyH5yMDdWv+UCAmTkmYJFNdiU7lp3AqzRTRnW7sv5oBsNOYqX9QUIJqJBRb wWNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zCoM+nxCW+KhPaK3jdR/NXDiI5y1zUCOgbetADXQNIY=; b=s3huyu3EQ3/RkxufUcx9OY7K8DZ9gLv/C8ra4R7X1TcaqrsRhEQxpPizA+QIc2HSjs Bs2rbw1Ao1dhV8l5527r/eTNG54JoFhxbLWAeubkXe2lxb2Ic2KGTBU5w5ZcvOykfCJT Lappoej/n+noyxX8VEK+JUKLHgE9yPmW1ZUHYZ1EjbMTxOQIARZ9msb0/y4rTeN3Ro8p H20IY3C9Ol1hkX5zLy8kY0FSBKHGQyaUdV4dibipyvu9ifw0SJUCHom6Ey8vK2aDqx/X 3rSy/GRQf/Urn3H96f3PLi0kr6Q2QhJEwppeLPeevZaAgv6JhRQgt3bCx3y5yPR38x1N qoWw== X-Gm-Message-State: AOAM533kUuqG1fg5s+2p0JG3KN+v3wz6JZN7P4Ena4mhpOykszxO01AR ap3cgWZkyDb7idhzHBb6wFWZdtOoQYJfrc0h X-Received: by 2002:a05:6e02:1be1:b0:2cd:5e70:a2ea with SMTP id y1-20020a056e021be100b002cd5e70a2eamr2487891ilv.204.1650646620733; Fri, 22 Apr 2022 09:57:00 -0700 (PDT) Received: from stoup.. ([2607:fb90:27d0:b0f2:934d:3e2:9f8c:dd1]) by smtp.gmail.com with ESMTPSA id n23-20020a6b8b17000000b00649a2634725sm816380iod.17.2022.04.22.09.56.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:57:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v8 44/68] target/nios2: Split out helpers for gen_i_cmpxx Date: Fri, 22 Apr 2022 09:52:14 -0700 Message-Id: <20220422165238.1971496-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220422165238.1971496-1-richard.henderson@linaro.org> References: <20220422165238.1971496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::131; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do as little work as possible within the macro. Split out helper functions and pass in arguments instead. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/nios2/translate.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/target/nios2/translate.c b/target/nios2/translate.c index a3c63dbbbd..86978ba47a 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -71,6 +71,18 @@ typedef struct { .a = extract32((code), 27, 5), \ } +typedef target_ulong ImmFromIType(const InstrIType *); + +static target_ulong imm_unsigned(const InstrIType *i) +{ + return i->imm16.u; +} + +static target_ulong imm_signed(const InstrIType *i) +{ + return i->imm16.s; +} + /* R-Type instruction parsing */ typedef struct { uint8_t op; @@ -268,15 +280,23 @@ static void gen_bxx(DisasContext *dc, uint32_t code, uint32_t flags) } /* Comparison instructions */ -#define gen_i_cmpxx(fname, op3) \ -static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ -{ \ - I_TYPE(instr, (code)); \ - tcg_gen_setcondi_tl(flags, cpu_R[instr.b], cpu_R[instr.a], (op3)); \ +static void do_i_cmpxx(DisasContext *dc, uint32_t insn, + TCGCond cond, ImmFromIType *imm) +{ + I_TYPE(instr, insn); + + if (likely(instr.b != R_ZERO)) { + tcg_gen_setcondi_tl(cond, cpu_R[instr.b], + load_gpr(dc, instr.a), imm(&instr)); + } } -gen_i_cmpxx(gen_cmpxxsi, instr.imm16.s) -gen_i_cmpxx(gen_cmpxxui, instr.imm16.u) +#define gen_i_cmpxx(fname, imm) \ + static void (fname)(DisasContext *dc, uint32_t code, uint32_t flags) \ + { do_i_cmpxx(dc, code, flags, imm); } + +gen_i_cmpxx(gen_cmpxxsi, imm_signed) +gen_i_cmpxx(gen_cmpxxui, imm_unsigned) /* Math/logic instructions */ #define gen_i_math_logic(fname, insn, resimm, op3) \