From patchwork Tue Apr 26 18:18:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 566115 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3872730map; Tue, 26 Apr 2022 12:17:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTPgZeJW8nfvaDLiVDa6NqQZizjSF68+WJRFvYNu7Yp4v4GJgwo0SLaidPJqotU6Vo14/V X-Received: by 2002:a0d:e8d6:0:b0:2f4:df67:6dc3 with SMTP id r205-20020a0de8d6000000b002f4df676dc3mr24425076ywe.57.1651000659142; Tue, 26 Apr 2022 12:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651000659; cv=none; d=google.com; s=arc-20160816; b=P3QAskAOlJEjS6AUQMP3PFlIDDDXtl+AUc1WTWoXEPYvt66xko8Hgce9Eoam+zYeV5 0qa3Z9EF2lOFv8nFAp6l465Zr7t9lLxvwMVvedSeAzPpt2FdMEaTnHAsZsnvwFlEnW+S /IPQAlXMb3TGEAViDkiewmmoNIHIZjXzHcmWN2fglHzEx8HKZOfoE/zHzxeyOdJgVFET mQGHnjeodIYV1qZ+KQjv1kJae8Hu/ZezS6l5Y4/Q5qoeVTrbqfkK2JKfx9Ii7u5n56mj 1qudtK0I7AB886yWMJMEYDkfpzQxrNMeexW4AY94VK2686dRFjyX5roFpWz2eYwRV+0Z NurA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=mYrrK9wMFTiFo0vQpejbJip6v2871lt8Lm0SZNjZ9fM=; b=bMRy4/evDWiMsGLXNupBoi1wpiBV/EKRVdJ1ZasX0gMX3pm5vJIqeVtxnlSvB52dSF vkTyPDiutAAclCat1NxlMymJlizi/x5GHaoPJ8xz5b0fIBogpaSVzQ1quw0WlAAelaDg FzuAsCG1KbILRWKauIaCpo+xRGdpthfmCpPXx3bVypQ4pRxXOsBjgsAEXR+W/EfzVmW4 jvWTGQyA8gNgB6YNL12jJPXXzKfJvsG83W3hiH9bNVgJ7uxs6GR+LwVaD8w0Gi9vpkOf Xz2rNeti7RXbCbrVyoj+UiVxbo9dHaC0qFEeqHVHGhZYi+MpyuCpJicAkK5YG+WdLcSU Lktw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/P+yKyg"; 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 l128-20020a815786000000b002e5bb9dcadesi13581176ywb.359.2022.04.26.12.17.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Apr 2022 12:17:39 -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="V/P+yKyg"; 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]:38890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njQgs-0004vv-LW for patch@linaro.org; Tue, 26 Apr 2022 15:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njPps-0001nx-M7 for qemu-devel@nongnu.org; Tue, 26 Apr 2022 14:22:54 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:39860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njPpr-0005Mw-1N for qemu-devel@nongnu.org; Tue, 26 Apr 2022 14:22:52 -0400 Received: by mail-pj1-x1029.google.com with SMTP id bd19-20020a17090b0b9300b001d98af6dcd1so2848601pjb.4 for ; Tue, 26 Apr 2022 11:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mYrrK9wMFTiFo0vQpejbJip6v2871lt8Lm0SZNjZ9fM=; b=V/P+yKyg/Kh6Ls2rYjzegeFFl1sgVIm6BrmqqWtghCGfyKxlzjU1QwJQYZdQ+XYwei A59rWEEzypFjWfMjD51y2BKfnakPLgd3pGOE6o5IZQJTvc5DsDyZ+WpIpQ35op6Oh8xH /vECJBCDZSNaCOOmQaGa0u1jfR1kKxB9bGyigk05K3K0aTVr/gVyOY8AmTN1fWSwHNtS L6j9gfNrfRLlhk2oHJX/tQWg4EAmr4grbJGrGSaCTBhQYHA0wJS09W2GJg+Z9nl81CA/ ikPiGcCvNRLSu+qAtQ5djfEaaN1udGlhurDmc9oXhljyxjN9zflge2PjNZwrSJjTxHb7 0YFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mYrrK9wMFTiFo0vQpejbJip6v2871lt8Lm0SZNjZ9fM=; b=OYqHLcKHb8VBDOhOhMRWqWXdZv+Y9NxlSdwh6lMNxTnqLsL7wifQ33L+hfAYIjy6nY V6uY50b5iuBjckqlaiBqHJ/TD5u1BNDnYmkO1o7noQ+0r7rnJJJbK2y87UahVIIZgjly nBC94hkd/zhM5CyXr31qqW7e/xiG8V9gfjhIAWdv8JDDzE5uDl44mesH6CMPsJBonoYA 40ydZjQeG41gKTLlaE14skG+gTysTGEq5DrMYv/YeKxy/sV8JapoZFYtAqmlovBwF4GD +l7kLdoTYs1zEcHAlqloB4WxbhB69WFT+zYlKBadYIPQOJ9aUkUYX6YYtuGhPal0EAZt tnXA== X-Gm-Message-State: AOAM533ke8zfAZzooJHcmTzSVIs/AHO7XFjYQG4Q7dvohpxAX9f4wxk3 KKb+ylkuDVFCNDJSdL8pRQ7bfBVJrJs1dQ== X-Received: by 2002:a17:902:9887:b0:151:6e1c:7082 with SMTP id s7-20020a170902988700b001516e1c7082mr24091460plp.162.1650997369487; Tue, 26 Apr 2022 11:22:49 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id k187-20020a636fc4000000b003983a01b896sm13585053pgc.90.2022.04.26.11.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 11:22:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 44/68] target/nios2: Split out helpers for gen_i_cmpxx Date: Tue, 26 Apr 2022 11:18:43 -0700 Message-Id: <20220426181907.103691-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220426181907.103691-1-richard.henderson@linaro.org> References: <20220426181907.103691-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: , Cc: Peter Maydell 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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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) \