From patchwork Sat Apr 8 03:03:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671495 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611676wrt; Fri, 7 Apr 2023 20:05:19 -0700 (PDT) X-Google-Smtp-Source: AKy350bYMnKsqQp48aKuFTWfIZRk8qA//+OuyGpm0jYJGNaXPeAu4Hpeo1KFXM2A/qFs5woiAchm X-Received: by 2002:a05:6214:2506:b0:5e0:e52c:5d87 with SMTP id gf6-20020a056214250600b005e0e52c5d87mr9462647qvb.48.1680923119164; Fri, 07 Apr 2023 20:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923119; cv=none; d=google.com; s=arc-20160816; b=KqLqZ62Zu7uNa6+OALgu4VmKSXupFggkygyrbQ+8lfeqDmjA8qERUXw4QkS9MW30p0 RYj5qXhmhBnTSUiD5WA5qe9XX6OC0drCGJhTYP32FV//vcBgLdULs4zk79W65pnOaiVr Y9UPlFTUV2pgUGRhtOeeP4oPjPVCRSCUAXrhLDoJURTHqUuLKTznmcMDx0o5WMmuKtaf n3mesfXuTSwEMH9ExVXnTFS9KwnZz3gHujRhvJYI0Hgaz9eS69xqzZuP3+/MI6d8gMgN wfXlCwZet9ooIyXJT8CRIYC77li785MIFcIb0+ddBFF6hVUdwbN8AcXWQt0OGv/GBgqu UD+A== 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:cc:to :from:dkim-signature; bh=DIvMa6yODJNeTBsR2OjDHB1GmvQgxFX82aBlXYH2wug=; b=Ix+dZjFHAfp7gODtfaXD28t9T7zbysUxvcqDWYtXWpTC21QuvXvZ7mrcz9SwPcl3Wy /gUMSJnhW1fJN2ohOHLm/VOY4FiLS1BOQiCWfRgUkCd5O3Msp8x4cBR9FshbzcU3ip6o vttuqxYo9m1vhiXlswVkZjJG7DFgoWLSTjwvmMzhiwMrV8V1pt1PySQ+1pmK1NevfpOM ddq5wUz1OHI9TCK5KoLKNfb2KoqQwpTFbuih2Kim9CZGCxQzbjmFniE/N/FZdqxuwCth cqv8jyOuih5ylOQqzjB4s3Zk0cH//vNSCmCfFbA/Rs8vZLsNDTwp+4xa+0kRTw1jukC2 ypBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="VQF/omSn"; 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 j12-20020ac85f8c000000b003d3b9f79b50si3637003qta.467.2023.04.07.20.05.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05: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="VQF/omSn"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkys3-00045h-HH; Fri, 07 Apr 2023 23:04:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys1-00044y-Al for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:05 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkyrz-0004V3-6G for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:04 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-24059dcdd90so186174a91.2 for ; Fri, 07 Apr 2023 20:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DIvMa6yODJNeTBsR2OjDHB1GmvQgxFX82aBlXYH2wug=; b=VQF/omSn3a38pU5ljC0bM2Y438nmFjf/SeLl9tiLfA/wt6kzi+1h9a2Wc6tHgXGO+7 Y0YLRVKW5MBqGN2uSqBRL6fa1FljuIKXtMd+jjzGuoIW70eN9UG47DsQniNX1EUkRk6l Op1T/xlnJ9c2TSUyhQGtUEq9Ex9Xp8SO7srfG9VggsTbWDCT/89hZVK+Jq6QHtQvd22k Sq7QXYXvTLh6Lspa5+HkFt97skV4Wnh54/MftWbCxEpjzA9ncv9jWLYp6SQqeMlgvoWK kSiBXZGv/8wjfOA2Eg6nKnKGgAuN6rXdtlnP42RMqKrFkw/YnFcTC5EYMWIviKjMmEgG jyLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923041; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DIvMa6yODJNeTBsR2OjDHB1GmvQgxFX82aBlXYH2wug=; b=KTnx7DQ7MbMZZCSZaH+Tl+IlrRxAJzBXoRzKBJerCB+LC5T1P3n6YXT6E5OMfuiQLX 5kEn36JCQRtK5GVFmCvAWUyHtQ41MBqu2laySYFCAF6CmsrCh6Pm4FvJ7mwvLyN9F6Ug MhEPPPc728du93IKrUwFjt3uy6qvotrGlbYIh/BzRahsrsbRR9w66lO1dNueNUjkVSxR 3B5NyqGXQ3Cdgc/A5T1kaFnLNrKXOKdA3B5AjBTUNzGFEjKT6eNfF4yDffehDBMOuuaA ZjKFVOd6SsJjzhsv6meyrFYAna3YSsSCG0GWwN+Sn1iehXpfT7uQfhdM1tDGYVquxIkr Yblw== X-Gm-Message-State: AAQBX9fCgsqByFNrgsrO3EImiZjF0OB246gL81nOdK3x6ECJcTneN9O5 Y7NewOdC/g+H8iBaXjy4hFL7XW8EA21ciQmYe9M= X-Received: by 2002:a62:6443:0:b0:625:ce21:3b1b with SMTP id y64-20020a626443000000b00625ce213b1bmr3852802pfb.3.1680923041640; Fri, 07 Apr 2023 20:04:01 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 01/12] tcg/mips: Move TCG_AREG0 to S8 Date: Fri, 7 Apr 2023 20:03:48 -0700 Message-Id: <20230408030359.3368868-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 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-bounces+patch=linaro.org@nongnu.org No functional change; just moving the saved reserved regs to the end. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 +- tcg/mips/tcg-target.c.inc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 68b11e4d48..8cdc803523 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -76,7 +76,7 @@ typedef enum { TCG_REG_RA, TCG_REG_CALL_STACK = TCG_REG_SP, - TCG_AREG0 = TCG_REG_S0, + TCG_AREG0 = TCG_REG_S8, } TCGReg; /* used for function call generation */ diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 34908c799a..c24b780818 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2493,7 +2493,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) } static const int tcg_target_callee_save_regs[] = { - TCG_REG_S0, /* used for the global env (TCG_AREG0) */ + TCG_REG_S0, TCG_REG_S1, TCG_REG_S2, TCG_REG_S3, @@ -2501,7 +2501,7 @@ static const int tcg_target_callee_save_regs[] = { TCG_REG_S5, TCG_REG_S6, TCG_REG_S7, - TCG_REG_S8, + TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ }; From patchwork Sat Apr 8 03:03:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671500 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611829wrt; Fri, 7 Apr 2023 20:05:49 -0700 (PDT) X-Google-Smtp-Source: AKy350b2AMtZwzsMP4du80AtSFplcChaVK3BLYhC2SPdjK6c9Ct+oCQK8sTe2EATo6CRzGdHHZmn X-Received: by 2002:a05:6214:2a8b:b0:5c9:422e:c7b9 with SMTP id jr11-20020a0562142a8b00b005c9422ec7b9mr7408135qvb.19.1680923149727; Fri, 07 Apr 2023 20:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923149; cv=none; d=google.com; s=arc-20160816; b=WMNnuXhRuYBj2/O/3o1I4Ciz+nB1+EKc3cdb0Kh+re1EwZW8eslUR1o8cSJDAwvJBU ja+mh2itjAwSvlUg5/eZFdB13J+adBO6YGQGFBFtFgtvIDhg//VqP9+M7SdimStQaWrW PWdoMRJwUYImiIgRwFGhrj9U6MWBo+2QAsffPvYk6xNRHmM7PMT9YNX++8x8GCafSxc2 0odwAgewRLfrSCOfjLSAwuxVd+G34aL6eBUd1cf72guAabjtElt+bWfzkvbR0VEKaFeD /qYjxc+HQV6PNii2yV7BqAkZtCOkEBzP+iqAMxCpibQEWRt1S521EDNdbhmGqTL7bQFR qavg== 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:cc:to :from:dkim-signature; bh=bW/9qvl2SShSEu4dmNJ/Qic9SYEvM+f5ESU99Mx+Y1A=; b=xI+wF4eIgCaa1uFN4+uRru9AswXviQGbD18Hxag+KQqLujyQXnVWKKXbtz5kAaq9Li SAn0PN6rqveP7UV5buYvWIRZ5oWoA4jCLyLD+0Z+dMiv8+yOhVj2pwoUjNjcG5mJefx/ oTx1MYnvbsMJ1rWZNdChPdotHELhMfLMU2xY+Pm0wfOgmfTiL9C4ZIJ8Q56XCbGyjnTy tDJI+Xs1toZ44J6X/DN8JBWESLCXwJlKVS/K16Q+2IBJrNz2pHMiW9+U3jT1fRoeR5nL G7O5bQw47LWJmVuMdMKNPzn1aaR/10xmoOoSXrq0FYwN6yZx9wb3CWnWohdse/sZFSlu N2UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LWXAT+4r; 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 gs4-20020a056214226400b005ac53071c52si3937797qvb.294.2023.04.07.20.05.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05:49 -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=LWXAT+4r; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkys4-000465-Mj; Fri, 07 Apr 2023 23:04:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys2-00045A-3L for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:06 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys0-0004VC-6r for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:05 -0400 Received: by mail-pl1-x632.google.com with SMTP id ik20so271255plb.3 for ; Fri, 07 Apr 2023 20:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bW/9qvl2SShSEu4dmNJ/Qic9SYEvM+f5ESU99Mx+Y1A=; b=LWXAT+4rPistnTNVuibEQuEPdepdbNeUGwua2dTNuoLLBUVZazqZMhHtqNzHwp8fF1 6G2StfcY2nsmu9X6xtQTS0vPdEk1CKaTo/Qy3+RpsXZ6ZFZt5oZkaGuCIP3npGuhyEo2 AW7OB1yQo445RHA4SVcdhUNQQm2FdCgaO6hj5LSoI2f/RA4i4ktMpOWhOCM334w/hazp nmDshBhJLB5zZ6oSQb2u/XyZ8bCSUepclXQx5cNclgM/GeDOgYfp3vPGTagLzBT8sCdy YYB1xRyGbwL/fLF7rnfgLw74jEIsomCb/sN7JjGqUX5F78p0JEHOeidysYMOVk1NLL9I GnHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bW/9qvl2SShSEu4dmNJ/Qic9SYEvM+f5ESU99Mx+Y1A=; b=x5uk7tkMhymhDud9MT+9gufuTOY3gF+yMv3NcYF1yxu20J2hxVDhsy///mzatH9pub 3dkzzkA1NUFIQGJm6EU/mwwjwkx0S5HNjckwbytlpYggf3GYOea1vlYJRrc9F+1eDbbc th+wbThWjOcC/fZ/+QfCIMc/jnSJcyywDa/UTTZJuLZoli+NJipXe6Xr3rXht90iz3pK N1AC3CWFa2yYX13I6fpYKpzvymYiqU4vBBuV5kVsjweE8E9dOaLW5C37PoapKiTT8l6W QIGSry6GHAnLnyRvSlsnEGLyr5S/X5jl+Cgfy3gKIYqm/xh1LBtySaPJnXeQdl+FLmRM Hg2w== X-Gm-Message-State: AAQBX9dzGMI6gtDjWOBL9aKXHp4Ro17vemjlLhZ7QjYJyt76TURkztyE rh6ev+mpx5LGYiHdlovg+2Ki1VOEpJM/X8vC5ok= X-Received: by 2002:a05:6a20:6504:b0:d9:162d:98e8 with SMTP id n4-20020a056a20650400b000d9162d98e8mr4537341pzg.13.1680923042415; Fri, 07 Apr 2023 20:04:02 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 02/12] tcg/mips: Move TCG_GUEST_BASE_REG to S7 Date: Fri, 7 Apr 2023 20:03:49 -0700 Message-Id: <20230408030359.3368868-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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 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-bounces+patch=linaro.org@nongnu.org No functional change; just moving the saved reserved regs to the end. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index c24b780818..cc4ca2ddbe 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -86,7 +86,7 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { #define TCG_TMP3 TCG_REG_T7 #ifndef CONFIG_SOFTMMU -#define TCG_GUEST_BASE_REG TCG_REG_S1 +#define TCG_GUEST_BASE_REG TCG_REG_S7 #endif /* check if we really need so many registers :P */ @@ -2500,7 +2500,7 @@ static const int tcg_target_callee_save_regs[] = { TCG_REG_S4, TCG_REG_S5, TCG_REG_S6, - TCG_REG_S7, + TCG_REG_S7, /* used for guest_base */ TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ }; From patchwork Sat Apr 8 03:03:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671496 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611729wrt; Fri, 7 Apr 2023 20:05:31 -0700 (PDT) X-Google-Smtp-Source: AKy350buCy4eTUFJs+ciHYCtuefpkgUMVV7GJY7P6eRNZPgPB6mya5I5guo3zff5pvwhJyhvtnup X-Received: by 2002:a05:622a:15d0:b0:3e6:9395:908b with SMTP id d16-20020a05622a15d000b003e69395908bmr4689377qty.27.1680923131349; Fri, 07 Apr 2023 20:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923131; cv=none; d=google.com; s=arc-20160816; b=bdTT+zz/BXTJhWow3+ck53eUPpMwiihYSIjGkL9OSh572XIERcLG8DAcTgln45sAUb Bg5mqCKTthUdLLtZgsUoGeQbi3lRAzm4nVyjZ3okJ2YluBA9mc/RZtfyMRRRfan54JTy i/HLKA9DKsxO0C5Z+NG4ZC5VR5riu+Eh2mOluUei+rjKLHIg/fn4EQQJnD3DTWBWoKew MpDIkDDl1840YXPQrzGyr1Nc/AcEoTtfBkLWCRSE29DFsutEZSe8N3uJpQyAvOCnwjLU irXzCO2+Kh2cFYWz92tL1yTNyBdbP0V98qXLVFjgVaxEnYfX6W1kDf7DkT9p3RLnQiQ4 DqcA== 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:cc:to :from:dkim-signature; bh=paKwch7BjeMSmw6hwR7oUnfRqPHVOt6iFq9garwBFk4=; b=zabkSqAjgFLju3GDXMUliumFHrsnQrGtGz6Wkj3CmqyCw9BwGOHRpuxixAg/7/PFkd UpSi0NkzmCACy37cyXprzW7ogjFR32xJJUGuGWaXbFBu8WRTtZPh8Qf68Av6wCwFCiEq nDYnLaa9DgWQuUVUCLWvfPhFpncUNWSvqTAVGzWOkhXS058ppWF1Qr/mFT8LhLFQOpI6 hiXBxcRcZ/hoIpY9DSullPxJbBAEg37Q0gbCnYPkjv1T6yrzj9bYjX0TafTznSqtb7H/ d4lyJ2H9uinCHQttkb3eaLq00gZlaNAvACWPHtHXxBgeTaRE06HBOBMONWPWr+GhO2Vx FWbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eyhjwGRv; 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 p13-20020a05622a00cd00b003e13a43920esi3676605qtw.143.2023.04.07.20.05.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05:31 -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=eyhjwGRv; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysK-000497-8y; Fri, 07 Apr 2023 23:04:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys2-00045G-B7 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:06 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys0-0004VX-L1 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:06 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2406ba77100so167640a91.3 for ; Fri, 07 Apr 2023 20:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=paKwch7BjeMSmw6hwR7oUnfRqPHVOt6iFq9garwBFk4=; b=eyhjwGRvQyLlXdxCtMgim5Yfn0doYYesVfGVNttLMbtNM/n8/3Mqm5fne8AVFqtxAk D8SWfr6Lo67957ZPVUsBXfQG6YeNY6r4ADydzfaGxlI00rNY3WItQVUh2aibXnSOx/tY vJNi5zOP5YAxBjjqBVO/29NcwdU/4MaDpifzls6q2g9mhTOt/aqDaSjo4B91x+LuzaGy j+EkX5YM2N9nnu9Hvaq8NL3bXwwBNfVTfkXQ4UNQNUmTfide5DqFyZ6ZPJkiHRSvfadO PmczQtpL9lP5LT1+8uPkDVtqaDCa/NDBzawjsXxYeV83mTTiKboKoQ7v9bqu3dzmcctd nk1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923043; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=paKwch7BjeMSmw6hwR7oUnfRqPHVOt6iFq9garwBFk4=; b=tfxEIlnXKGv8gwpxfSEiTXeyKb8kg4F3HlaxtKNIYhsy1sr7I4cLd3ZMv1MuhxzxMp r2T1CjOQ7dZ90rMdZa8YGstTc5ezdzSogUOu7Qvi7Xa3Qqa4hsq3liPWdHYcjT2bng9G 94sKAcXWVg1NtrCZFyTwQGBOFP2H4SsYB2UVF/PnoCSpuNTG4XsJjQSVhRphY33c2mDz bjC/QwTJ6xY6PhCg+4RvK9F0AdThHmN0QIN3bim58BU0Mae4H5rWSaWhsrGBy1WlySr5 5aQSakpKnOMfWWQlw7uhsIYGdP57CDas5Lta/Bm1Lo+LavMKwDZJbEsLIeeEBOvNKZE3 xHqA== X-Gm-Message-State: AAQBX9f7B9aAM5IS6AftxZClObjLt3PozdPzsMtQwxThoU+EIjYd0Fvo glMSEGd4eRF9ZCgzFalSo/wXBAeOoA6vgM+ycGs= X-Received: by 2002:a62:4c1:0:b0:625:e051:e462 with SMTP id 184-20020a6204c1000000b00625e051e462mr4138100pfe.15.1680923043260; Fri, 07 Apr 2023 20:04:03 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 03/12] tcg/mips: Unify TCG_GUEST_BASE_REG tests Date: Fri, 7 Apr 2023 20:03:50 -0700 Message-Id: <20230408030359.3368868-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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 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-bounces+patch=linaro.org@nongnu.org In tcg_out_qemu_ld/st, we already check for guest_base matching int16_t. Mirror that when setting up TCG_GUEST_BASE_REG in the prologue. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index cc4ca2ddbe..0ade890ade 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -2622,7 +2622,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) } #ifndef CONFIG_SOFTMMU - if (guest_base) { + if (guest_base != (int16_t)guest_base) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } From patchwork Sat Apr 8 03:03:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671506 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611998wrt; Fri, 7 Apr 2023 20:06:31 -0700 (PDT) X-Google-Smtp-Source: AKy350aSqA2qWN12eo0u+e7TuYB8pJVh48FBpyAx+kkkW1MMCYDkPN9jK8NRK0Ei9V80EE3g1uK0 X-Received: by 2002:a05:622a:1987:b0:3e4:635b:1644 with SMTP id u7-20020a05622a198700b003e4635b1644mr18111324qtc.18.1680923190915; Fri, 07 Apr 2023 20:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923190; cv=none; d=google.com; s=arc-20160816; b=tIzEVtXDpSwvdhus1BxTdgwx0LpVO0L0Q5uN+aBMfjKBJj0wMoz5qsR2HMryeE2+Gr YYikn4AOQQlh/wezPLBETVYaSoGpy1QA0rJMPjipsQb2Rj+2uBOmiZYUr3NlXHy/Xtaw XNgDFRVVGSJ8oaN4qSSZynFwzS9RAMzy7ENldEZCgXiBvjwej5N5tA1cdOpZ02SK8n4v PTXqYGm+erpuZ9lwhO5SVYDa/cUu368rEZV6y6PReaZViehCe5YjRqNtZYXfi9/vFzUc PHBy2lF2PtrVfaqn0qWjTHlPIHZiBNIeFTnIY47IpqB3qhO1c85VQnD9tm/nbvNuqJpu NGlw== 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:cc:to :from:dkim-signature; bh=c5z2pzBP4n2HbltkzexFBId6I7UVABJ9+twoIc3kNok=; b=pmpEWGyrWDX5yo/Txosp8A/U0V05zuc2WXwMMhM3x3BKDkiQum2xnHuhq2SSZ+0Y99 KiVIl5/JbchY9sybXe2hywUQ5WmGOyamZTnT0H16tHqqGOOj4hKGGg9Ox7mwZN/R0Byh upP4UDaRUR1EOBq/gFqnnvEyDh6iv5aADbHM5/zPu9VXtQ53nYQLvvXEmZMex59x4uts 3pPWQ7fXCGq2tlzrNRsSJQaFkAvNrA0b6011MisxTPgR56zCdFlk6Nn0seBmk3f3YX4L w6DpgChwWkvshahUbhufpq9dcM/OOkC9MRMjd7pZYw8bUiVt5Tp+HpuzzaimDH7Tgp1C jdVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gl7qkuCN; 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 h11-20020a05620a284b00b00746768a200csi3884972qkp.68.2023.04.07.20.06.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:06:30 -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=gl7qkuCN; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysN-0004Bu-VT; Fri, 07 Apr 2023 23:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys3-00045j-Kw for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:07 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys1-0004Vv-R2 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:07 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-62ddb232ddaso1414033b3a.1 for ; Fri, 07 Apr 2023 20:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c5z2pzBP4n2HbltkzexFBId6I7UVABJ9+twoIc3kNok=; b=gl7qkuCNaaivOCQJm03bqTtlswOamaHuBdFG2RitJZZ0C+vQ8aJnezAJrFrwdSG6xm 4ZDFEl0av25cPV4dfSHE0obrV9RVuM4S2iUtCJDCwnRAORbK5znrOs1B6nrGdwP8V6pf uoawKzUZvOG1L0vNRXNTII5E9oSG53eUaZu7ah6igVtSkJwTG1w7sC486MW+mkeh/jpj e6rEmK52+TD2/z/bhD2uR49ytFd+RtKYPWGkE+lW4khdG7LLJK+1mj14MbWWvgeeWbkm QP4Yu5QiiGc0SiNBPYFXdWQNSP1WnFh5taEWawa2jPuTHVoXn9BTl5hR5TPRJvGLt0k7 Rr3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c5z2pzBP4n2HbltkzexFBId6I7UVABJ9+twoIc3kNok=; b=mHqu+moUmNSvEVUXcomuBSaz4KA7KH4n87sYGOBH7pGcI6uovU0gX89fgs4svRoMN7 4hAq9LP8Vqi8f/iVBJ+rkzaifZjW+xU/i0xE424kFxWSUBwqfCsee6prlWX9JpfAXk03 d/dgC7IN7jOMwszHONrleF8BNnqidOjmIrtn4h09a+wWRTJkhj3/JTv+zgwQxtdURX/8 nBCXpUOKa7HJ3NwaNKM/ZO8dQV6fMfO5Q83fZe0iZ8qWaxBda6SgoxXJYQP9rs0kgMoV 0/geT+cSm9AJ2buLTgm7fD4FmAgDE7hsVgW7BIBsR5h4ZCD4ICHMcN50GUxqBC9glWap GTCA== X-Gm-Message-State: AAQBX9f1TyvOq93QuBHToXKNZaFH/PAegB1jueUhyNSLe77YgW7WG9pW pstcIHY8/MVYhSCgWmlEW9U4YukYJjf2QOjvVHA= X-Received: by 2002:a62:5204:0:b0:629:fae0:d96a with SMTP id g4-20020a625204000000b00629fae0d96amr3950131pfb.16.1680923044157; Fri, 07 Apr 2023 20:04:04 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 04/12] tcg/mips: Create and use TCG_REG_TB Date: Fri, 7 Apr 2023 20:03:51 -0700 Message-Id: <20230408030359.3368868-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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 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-bounces+patch=linaro.org@nongnu.org This vastly reduces the size of code generated for 64-bit addresses. The code for exit_tb, for instance, where we load a (tagged) pointer to the current TB, goes from 0x400aa9725c: li v0,64 0x400aa97260: dsll v0,v0,0x10 0x400aa97264: ori v0,v0,0xaa9 0x400aa97268: dsll v0,v0,0x10 0x400aa9726c: j 0x400aa9703c 0x400aa97270: ori v0,v0,0x7083 to 0x400aa97240: j 0x400aa97040 0x400aa97244: daddiu v0,s6,-189 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 69 +++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 10 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 0ade890ade..c2f8d6550b 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -88,6 +88,11 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { #ifndef CONFIG_SOFTMMU #define TCG_GUEST_BASE_REG TCG_REG_S7 #endif +#if TCG_TARGET_REG_BITS == 64 +#define TCG_REG_TB TCG_REG_S6 +#else +#define TCG_REG_TB (qemu_build_not_reached(), TCG_REG_ZERO) +#endif /* check if we really need so many registers :P */ static const int tcg_target_reg_alloc_order[] = { @@ -1895,27 +1900,61 @@ static void tcg_out_clz(TCGContext *s, MIPSInsn opcv2, MIPSInsn opcv6, static void tcg_out_exit_tb(TCGContext *s, uintptr_t a0) { - TCGReg b0 = TCG_REG_ZERO; + TCGReg base = TCG_REG_ZERO; + int16_t lo = 0; - if (a0 & ~0xffff) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_V0, a0 & ~0xffff); - b0 = TCG_REG_V0; + if (a0) { + intptr_t ofs; + if (TCG_TARGET_REG_BITS == 64) { + ofs = tcg_tbrel_diff(s, (void *)a0); + lo = ofs; + if (ofs == lo) { + base = TCG_REG_TB; + } else { + base = TCG_REG_V0; + tcg_out_movi(s, TCG_TYPE_PTR, base, ofs - lo); + tcg_out_opc_reg(s, ALIAS_PADD, base, base, TCG_REG_TB); + } + } else { + ofs = a0; + lo = ofs; + base = TCG_REG_V0; + tcg_out_movi(s, TCG_TYPE_PTR, base, ofs - lo); + } } if (!tcg_out_opc_jmp(s, OPC_J, tb_ret_addr)) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, (uintptr_t)tb_ret_addr); tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); } - tcg_out_opc_imm(s, OPC_ORI, TCG_REG_V0, b0, a0 & 0xffff); + /* delay slot */ + tcg_out_opc_imm(s, ALIAS_PADDI, TCG_REG_V0, base, lo); } static void tcg_out_goto_tb(TCGContext *s, int which) { + intptr_t ofs = get_jmp_target_addr(s, which); + TCGReg base, dest; + /* indirect jump method */ - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_REG_ZERO, - get_jmp_target_addr(s, which)); - tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); + if (TCG_TARGET_REG_BITS == 64) { + dest = TCG_REG_TB; + base = TCG_REG_TB; + ofs = tcg_tbrel_diff(s, (void *)ofs); + } else { + dest = TCG_TMP0; + base = TCG_REG_ZERO; + } + tcg_out_ld(s, TCG_TYPE_PTR, dest, base, ofs); + tcg_out_opc_reg(s, OPC_JR, 0, dest, 0); + /* delay slot */ tcg_out_nop(s); + set_jmp_reset_offset(s, which); + if (TCG_TARGET_REG_BITS == 64) { + /* For the unlinked case, need to reset TCG_REG_TB. */ + tcg_out_ldst(s, ALIAS_PADDI, TCG_REG_TB, TCG_REG_TB, + -tcg_current_code_size(s)); + } } void tb_target_set_jmp_target(const TranslationBlock *tb, int n, @@ -1946,7 +1985,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_goto_ptr: /* jmp to the given host address (could be epilogue) */ tcg_out_opc_reg(s, OPC_JR, 0, a0, 0); - tcg_out_nop(s); + if (TCG_TARGET_REG_BITS == 64) { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, a0); + } else { + tcg_out_nop(s); + } break; case INDEX_op_br: tcg_out_brcond(s, TCG_COND_EQ, TCG_REG_ZERO, TCG_REG_ZERO, @@ -2499,7 +2542,7 @@ static const int tcg_target_callee_save_regs[] = { TCG_REG_S3, TCG_REG_S4, TCG_REG_S5, - TCG_REG_S6, + TCG_REG_S6, /* used for the tb base (TCG_REG_TB) */ TCG_REG_S7, /* used for guest_base */ TCG_REG_S8, /* used for the global env (TCG_AREG0) */ TCG_REG_RA, /* should be last for ABI compliance */ @@ -2627,6 +2670,9 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif + if (TCG_TARGET_REG_BITS == 64) { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, tcg_target_call_iarg_regs[1]); + } /* Call generated code */ tcg_out_opc_reg(s, OPC_JR, 0, tcg_target_call_iarg_regs[1], 0); @@ -2808,6 +2854,9 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_RA); /* return address */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); /* stack pointer */ tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); /* global pointer */ + if (TCG_TARGET_REG_BITS == 64) { + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TB); /* tc->tc_ptr */ + } } typedef struct { From patchwork Sat Apr 8 03:03:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671501 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611842wrt; Fri, 7 Apr 2023 20:05:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YDrNlaoJ8nDKG2IXe/Jd6RvFSMWzOXkD9wtcf/1UxaAYO03yOddq3y+5cKRtiptVYEbSU0 X-Received: by 2002:a05:622a:1102:b0:3e2:3ae2:790e with SMTP id e2-20020a05622a110200b003e23ae2790emr1209231qty.32.1680923153477; Fri, 07 Apr 2023 20:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923153; cv=none; d=google.com; s=arc-20160816; b=p4BhMeyR00SRsJn26vWPwsul030C728Xe/FkRrS9iXoDk+RhXWzb2HRbtAsiicg8bO 8mkkuR4hneehkbDgYg9CnnHSNYEupuBa0b7LEY6M6aPluNfAva/VHuq0jDS9yVKBMOh/ k7FoPBGnVNvK4RPkiDRPzX1L8n2frtDUns885YrNovxfGAlZ5x312d0sbtTYOm1yLUUi e+zozYfMsqbqaXVUE/iXK3sRSoEhVpM6b5w2cAbIWn5CEAZWTot45naQTiHl0/O4y0E9 xvciCSGAPmwLIw8IPfiP1IhQ9B+YHQhm+HsEMyMj3I5uS1XfGjZmtCdQBOK/FOVdxw2U uDjQ== 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:cc:to :from:dkim-signature; bh=W3/mfgEEhut6lCtnwnsC8h9ARH2ugsuuRzfccUIm+yY=; b=Td9rR4ppnFay5P2Hc0xothhCGzFJH5+XwRGmyGo+9zFEE7vcVUeWmiDazaT6jWsaNi 8tgSxLAcm+90dNqcHKJhLx5zF/TES30Dxw6KwQSh/oefZSKwBRd4e1Pqm/MW7wzIyCTH vW67hWR2Wl6YHsOTdTWTPFlvRMqTxieYzeC/qd+Jq9JDLtOmU1bWqJ/y7xZBHbFe++bt g2TE4VGizGEGZDZjHXPHqm9Tlg/9b6ATw8TtNiFd5WYROGWQ6NMIHfeBylF35WQC+JVd dEytjWI+Bp03/nMQlm91vVR1t/37qIGhA8P3yC19sym8m60qMtlyOxSYzvpVv6iwzUoF fswA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="NPU/kOF9"; 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 207-20020a3708d8000000b007436f57d322si3642669qki.278.2023.04.07.20.05.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05:53 -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="NPU/kOF9"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysK-0004A4-V7; Fri, 07 Apr 2023 23:04:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys4-00045q-16 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:08 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys2-0004WC-FJ for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:07 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a51ba7fdfcso2440695ad.3 for ; Fri, 07 Apr 2023 20:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W3/mfgEEhut6lCtnwnsC8h9ARH2ugsuuRzfccUIm+yY=; b=NPU/kOF95RAupGvsmTotsiz3qhWtLOBSASgDXO+AI30lz/6nIFjeeqmBnLPQMegUx6 r99dw5CD931Qkli7uBs8fxMjjpCkCIYMCZt+TWhzbY270Ra6iZy6aqLROygVlyLBzsPS cZ+HN7QV3Fk7xl7It1GQ+OPasvIedjpfOSusghtudtosikMrcWLcIZvQr0qXIOLhcQgc he1xa0MG9XthIyX9zhyQ8ZbLheZzHu/PYeqMOzS0+TLPAyCTQI0RdMlXk0pXgEcq6s8/ tbHFAof6dPT5HhX//8QMn47f/Wj46fW5gV9BaveHNodcHStXGusr7EjUoCrVp1o8Hzv/ dfKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W3/mfgEEhut6lCtnwnsC8h9ARH2ugsuuRzfccUIm+yY=; b=65L25JfcJdM4pMzIV3eN22DL4ergAD9mz/E8tm4hRGqmZ8RBeKK1Ky5D0RJAEOYuQg 9WAko/Yqf+SfnYJF9aVatt3YVv3uMAmy9Pi+KutMflGa2NNOm9gOnMbeFQnvY7VvgCNH uCm1gJ+4i83F3rz6ffl/XoyLrmCCh7bWb0GBTG8GWjGAhEdWl/vrUTODebIKWSSzL0pS pU3kP+RdJr6TNMTGEG1luY3LklMF+PPnHnBQy8eCFVNU3+vKD29ExzufCiPnABODlkCM jssSGIdiNXiYx6AV1bY41yU45ztOwtFOVwXMJO0HgJlQSswLVMuKm6+c/EshZKYbpHTK qbTQ== X-Gm-Message-State: AAQBX9fe54WmiFLw7IRpzNBxu5m/w63c3Fil6m4MM+imJMM9mUlV/Hr8 J5q69681fi+hVU8ABTq+EGTRir8juuTK0kySGm0= X-Received: by 2002:a62:3802:0:b0:633:5c46:5a68 with SMTP id f2-20020a623802000000b006335c465a68mr138760pfa.10.1680923044977; Fri, 07 Apr 2023 20:04:04 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 05/12] tcg/mips: Split out tcg_out_movi_one Date: Fri, 7 Apr 2023 20:03:52 -0700 Message-Id: <20230408030359.3368868-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 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-bounces+patch=linaro.org@nongnu.org Emit all constants that can be loaded in exactly one insn. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/mips/tcg-target.c.inc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index c2f8d6550b..f0ae418ba6 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -514,20 +514,34 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } +static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) +{ + if (arg == (int16_t)arg) { + tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg == (uint16_t)arg) { + tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + return true; + } + if (arg == (int32_t)arg && (arg & 0xffff) == 0) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; } - if (arg == (int16_t)arg) { - tcg_out_opc_imm(s, OPC_ADDIU, ret, TCG_REG_ZERO, arg); - return; - } - if (arg == (uint16_t)arg) { - tcg_out_opc_imm(s, OPC_ORI, ret, TCG_REG_ZERO, arg); + + if (tcg_out_movi_one(s, ret, arg)) { return; } + if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); } else { From patchwork Sat Apr 8 03:03:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671504 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611928wrt; Fri, 7 Apr 2023 20:06:11 -0700 (PDT) X-Google-Smtp-Source: AKy350atNSJzVi0HhX38FhUUTFOepyapIV4I64aU1aN48euuRdD2QeAnR+RvjFSSL5cRdFJ7pfJ2 X-Received: by 2002:ad4:5bac:0:b0:5e8:42d0:d74d with SMTP id 12-20020ad45bac000000b005e842d0d74dmr5839080qvq.29.1680923171495; Fri, 07 Apr 2023 20:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923171; cv=none; d=google.com; s=arc-20160816; b=AyyDeq5oiPV7gb8FvghvM6FBiw/z7bHhPdXDLf0TWpA49Kh86+fc22jBzb3f9RYWGw eKiP2e1Dt9HSRgu3e2NSxUwGO7W+xAAYC2CZ1M2WwxITFpG4XfenZmCMHCLUeTJaLtyf GtfTpSZ4EIgx06SMMp6l6gAasT38jJwOT6yH2OT7T//yCkeht1acepZT2uD79l7gfowg z7hQMmjTQHLun4atQdBqeeJYFNb0iCO+Rh8DO/Fv6VnpIRqOoDBBtFvLnQM4N+Pwd8JB NjGlaXpKG8ZIiWeTb3lmNM+XN4xSaj23DicoNp/uOkkDGFVqBaxrxNhpAEs8ZBegY4te D84A== 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:cc:to :from:dkim-signature; bh=Gzu1AS/Q0oolCiATqMvs9UIOuiHEvGAooRn6q/C3R8E=; b=wnEGhGkQTdQ7XLlnQ19KVy4DWmdNr+Y9E6lJxPC53989Fji+7jdjQVfFeM92y3hnsB ZMFWyel/flYBFVsPaR20KR1zI3sIyUQ0AQGevTf19MrS8PyvenYHuI5xcCvb60KembCK C0AhSDD4iZ407iEV/i4fGAV0QnQIyVptxNR5NaQMrxGPjVMUzNOu3lM21xbP1qiph7MY wwkLfBv5fX94EJUOF0Gf98uO+KFLzFS0nFZh8n+yvDJKJUdZnofia5JY7cBxFB2cDWBC opmL8hW4TBXKb4lyz9QBxuIZtb7izBd3YRVTbdLhzfZSBQWOvfSVZTWTmHKcLUk+6DgD HVsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U7LR/u4j"; 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 v4-20020a05622a188400b003a97c56d020si3729662qtc.364.2023.04.07.20.06.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:06:11 -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="U7LR/u4j"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysN-0004Bt-M3; Fri, 07 Apr 2023 23:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys4-00046A-Nl for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:08 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys3-0004WW-40 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:08 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-62e62c2fbc3so273548b3a.3 for ; Fri, 07 Apr 2023 20:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gzu1AS/Q0oolCiATqMvs9UIOuiHEvGAooRn6q/C3R8E=; b=U7LR/u4jCS4SDehGeBbXPyApjo1EoVdQthKRJSIDi5B4sZsoHnXBn/VmkRxxopSdAs fXNjwqIwKr/bMNsGnmaUlh0h4oadBKiCfdQgJ5ASRWNz9BrQqXwVI629oEZ6n8adNkx+ nSmocfMq72ms79kDi7YxAWwCzB+dYOG468CgaHLbCb0bp8xv23KXayeLsTWZZeKntEFn amlRQUO6RhjxeIiLJYIvJIhH4kAQuN3vJaRQe7vrZ9yKSID+3LKb9Eyjo7KNW96h9xjW FBx+hIBJq3tKYTHNkid87Y0pcUNHEjFq05MKDpn9ta29gAacKAh15IylFJPjNIKFneJM c+Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gzu1AS/Q0oolCiATqMvs9UIOuiHEvGAooRn6q/C3R8E=; b=ZffO+/cNA25M9G1xeW+UXxFq2FBEcHBP7Prp5SH9aj34L0O6+Ia98P23vXmuWw9FUw aiXqaPJvFNMP3Lv1w/uZtmvrSjOXIeHW+8PxjhxGO8dzEkrBDdhnG2xGmyJWXs/nkbMq e/ngrCLBcOhLZSZKi4Z6HbsxKIr6ULwx1BRXq51HkpR0skkwVXiuK7aHei/fc4y9AFiG Zk4hhqdGG1S9Xh9huWVgX2xy670nQplm+YBfdj7lq1zFNo2ooSBtvLwXT3Wdl79vLOys b15lf9SeJqunKN1jm9rHgzDDsCJm5imaGboruFT7fkIUneAZNTKq0Jk5lZ89huEWXTks 0n1w== X-Gm-Message-State: AAQBX9e3piIIrLE0QAt3q/nWgySJWrgB2wxHMEqqwLfVC2TrBKw5UzQs QWswW6nAaz6n0WRKO/JJu+w9fS/cJThj6GZRM9I= X-Received: by 2002:a62:1c8c:0:b0:626:80f:7a0d with SMTP id c134-20020a621c8c000000b00626080f7a0dmr4027913pfc.8.1680923045697; Fri, 07 Apr 2023 20:04:05 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 06/12] tcg/mips: Split out tcg_out_movi_two Date: Fri, 7 Apr 2023 20:03:53 -0700 Message-Id: <20230408030359.3368868-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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 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-bounces+patch=linaro.org@nongnu.org Emit all 32-bit signed constants, which can be loaded in two insns. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index f0ae418ba6..78710a25bf 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -531,6 +531,22 @@ static bool tcg_out_movi_one(TCGContext *s, TCGReg ret, tcg_target_long arg) return false; } +static bool tcg_out_movi_two(TCGContext *s, TCGReg ret, tcg_target_long arg) +{ + /* + * All signed 32-bit constants are loadable with two immediates, + * and everything else requires more work. + */ + if (arg == (int32_t)arg) { + if (!tcg_out_movi_one(s, ret, arg)) { + tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); + } + return true; + } + return false; +} + static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { @@ -538,21 +554,18 @@ static void tcg_out_movi(TCGContext *s, TCGType type, arg = (int32_t)arg; } - if (tcg_out_movi_one(s, ret, arg)) { + /* Load all 32-bit constants. */ + if (tcg_out_movi_two(s, ret, arg)) { return; } - if (TCG_TARGET_REG_BITS == 32 || arg == (int32_t)arg) { - tcg_out_opc_imm(s, OPC_LUI, ret, TCG_REG_ZERO, arg >> 16); + tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); + if (arg & 0xffff0000ull) { + tcg_out_dsll(s, ret, ret, 16); + tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); + tcg_out_dsll(s, ret, ret, 16); } else { - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } + tcg_out_dsll(s, ret, ret, 32); } if (arg & 0xffff) { tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); From patchwork Sat Apr 8 03:03:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671497 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611739wrt; Fri, 7 Apr 2023 20:05:33 -0700 (PDT) X-Google-Smtp-Source: AKy350bXm5wDlF7iYHw8NcRmz0EsviNZMmb175rDxxu+ia8sLlV56GA1LTiTIF5zbIB+cPS4Niid X-Received: by 2002:a05:622a:15c3:b0:3e1:b06d:e9e1 with SMTP id d3-20020a05622a15c300b003e1b06de9e1mr1099050qty.57.1680923133144; Fri, 07 Apr 2023 20:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923133; cv=none; d=google.com; s=arc-20160816; b=t1iLcYbH+GuKp1mJfwNINgs1idlV4epUBsddCYXDKQrv62iIpVEiTKvKVdIhpnaxwC jbaCzU2/S7UVle3IdgL/RL3QIGMeHFb5fEfVQY0W+nMFVAujc4/2OlEYW5HIDb88cHE+ DlFkyWZ4B1OijQdVx8+rzmwhDrxmNqq+AN0lUOW97EVeTRzD0PJpuOXy8CpVCRCqH4IZ 9Hz5cm/99WZSG6b5Y3jg5x4QBEahy7CfZBrB+7mzc1sIPxfpig/Cj0Muh2gjrAZMmKWn 2bqH3R7TDsR+1HaORyXN5FehErKKxpt10NhT+D4lpLQY2g07vMn5+hmT8chiw5y6/M3a MwYw== 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:cc:to :from:dkim-signature; bh=e/k0JGlbcsqGMaHltbL7Xp0AwaOGu40VP+SK9t+4TaA=; b=pFkY6er4VU0gLsxeabUX86k2H17zzxtob6Au6CdSnbYkycxU/8CfpMWMtI3FAovAsj hh9CZxe/4EQkAbby+cNdhjr9guUJiaSAJVyS/GXhWia2Ti+BRBwJsGNd3O6GvsVemnar o2w1f/QWMIy4MD0U/UWLWZSLRU+cqMwXL6A7j95M/fvlFns09ctjX2uMsM39uwGXC2du kyfwZD+JU/3n4oqtU6SspPBXRFrVXtxO5j0UR1eANwhIsgA4s2u6QnLmJ1zVNBFCvFR0 r3CQhws6jOMmHpX9nlTRrdaQlyLgk9CaC0ila1ifRY/Kzs1o2ppAkYeCxh/xF+iHSDx0 Q5hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kzt3BqEe; 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 p11-20020a05622a00cb00b003d8088fc76esi3733111qtw.788.2023.04.07.20.05.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05:33 -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=kzt3BqEe; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysK-0004A0-Ku; Fri, 07 Apr 2023 23:04:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys7-00046c-5b for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:12 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys3-0004Wr-Tw for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:09 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-62e026c026fso273861b3a.0 for ; Fri, 07 Apr 2023 20:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e/k0JGlbcsqGMaHltbL7Xp0AwaOGu40VP+SK9t+4TaA=; b=kzt3BqEeQcEofufPrw3vrT2rNOSw+xy4ch54VhPcozeJoLidfTxyloyPlNGyrge1oY sI81VPPzXbgco8goiZk67CDDJQV+lmBegLd1K1lGZmHpaB9ppVOA+sbxoUTJD+ioAW5/ b4DCfpLfzAQa+Ir6dMFt3OCWAAzwYVGWEErm/T8Atzf5BSzCi34dIqVW94wd82KMP7Pi iMveu793cHi/Jh3+aMclxEvca7K3w8d0yoiT3Cdfk+mb/La/LsNFQYStO4Zzece43jWH bRGwPUeZv1jyqN7VDMVAGEaS+JE18Q7cPdVrrKRrh4+aFDyKjulww1dzYxV48+bXxlbP nmww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e/k0JGlbcsqGMaHltbL7Xp0AwaOGu40VP+SK9t+4TaA=; b=ON8SDfVIhGzBgod/PG8zLHPqjtxLQQ6BAS7LHUbfOMg6TlPkjDeHp2IlgzckyHWGy+ p5vlLnYB7Dvulx7D+6vi8QL0dYWIc+GKtpaX0ByyXl2yQKHi9T8lG4u5+wMVkVGNMlL7 21A4F7LC2VPIxCannXryJjCwQDYL5dOUN9JGnnkrfIHVl+ZqnbYvO3frt4cMX7Hrq6/G GzxLhAcoEn7KDbp4WGB0Fv1SMOiM5l8mRxn/um6rQlE+/ETKVISJ7HFoRA5nKbS3QJwB dnF8i2azcBI+28kPw7WhoEitppndx73t4ZxO16x6tQ624loXedzEi/2sAWj4976kE5hb R/AQ== X-Gm-Message-State: AAQBX9eYhTDcAUN4TIEINLQ2rBKy1edvBXeKoovzbNjvkd7vM6UlL1Dd +6F3AV1he3wZaCI9SFVMR2e83nz9D9uZb/xTicw= X-Received: by 2002:aa7:956b:0:b0:623:5880:98cd with SMTP id x11-20020aa7956b000000b00623588098cdmr940927pfq.5.1680923046508; Fri, 07 Apr 2023 20:04:06 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 07/12] tcg/mips: Use the constant pool for 64-bit constants Date: Fri, 7 Apr 2023 20:03:54 -0700 Message-Id: <20230408030359.3368868-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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 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-bounces+patch=linaro.org@nongnu.org During normal processing, the constant pool is accessible via TCG_REG_TB. During the prologue, it is accessible via TCG_REG_T9. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 1 + tcg/mips/tcg-target.c.inc | 65 +++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index 8cdc803523..88a8137bcc 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -207,5 +207,6 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_MEMORY_BSWAP 1 #define TCG_TARGET_NEED_LDST_LABELS +#define TCG_TARGET_NEED_POOL_LABELS #endif diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 78710a25bf..235295c689 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -25,6 +25,7 @@ */ #include "../tcg-ldst.c.inc" +#include "../tcg-pool.c.inc" #if HOST_BIG_ENDIAN # define MIPS_BE 1 @@ -168,9 +169,18 @@ static bool reloc_pc16(tcg_insn_unit *src_rw, const tcg_insn_unit *target) static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { - tcg_debug_assert(type == R_MIPS_PC16); - tcg_debug_assert(addend == 0); - return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); + value += addend; + switch (type) { + case R_MIPS_PC16: + return reloc_pc16(code_ptr, (const tcg_insn_unit *)value); + case R_MIPS_16: + if (value != (int16_t)value) { + return false; + } + *code_ptr = deposit32(*code_ptr, 0, 16, value); + return true; + } + g_assert_not_reached(); } #define TCG_CT_CONST_ZERO 0x100 @@ -490,6 +500,11 @@ static void tcg_out_nop(TCGContext *s) tcg_out32(s, 0); } +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) +{ + memset(p, 0, count * sizeof(tcg_insn_unit)); +} + static void tcg_out_dsll(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa) { tcg_out_opc_sa64(s, OPC_DSLL, OPC_DSLL32, rd, rt, sa); @@ -547,8 +562,15 @@ static bool tcg_out_movi_two(TCGContext *s, TCGReg ret, tcg_target_long arg) return false; } -static void tcg_out_movi(TCGContext *s, TCGType type, - TCGReg ret, tcg_target_long arg) +static void tcg_out_movi_pool(TCGContext *s, TCGReg ret, + tcg_target_long arg, TCGReg tbreg) +{ + new_pool_label(s, arg, R_MIPS_16, s->code_ptr, tcg_tbrel_diff(s, NULL)); + tcg_out_opc_imm(s, OPC_LD, ret, tbreg, 0); +} + +static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, + tcg_target_long arg, TCGReg tbreg) { if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; @@ -558,18 +580,17 @@ static void tcg_out_movi(TCGContext *s, TCGType type, if (tcg_out_movi_two(s, ret, arg)) { return; } + assert(TCG_TARGET_REG_BITS == 64); - tcg_out_movi(s, TCG_TYPE_I32, ret, arg >> 31 >> 1); - if (arg & 0xffff0000ull) { - tcg_out_dsll(s, ret, ret, 16); - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg >> 16); - tcg_out_dsll(s, ret, ret, 16); - } else { - tcg_out_dsll(s, ret, ret, 32); - } - if (arg & 0xffff) { - tcg_out_opc_imm(s, OPC_ORI, ret, ret, arg & 0xffff); - } + /* Otherwise, put 64-bit constants into the constant pool. */ + tcg_out_movi_pool(s, ret, arg, tbreg); +} + +static void tcg_out_movi(TCGContext *s, TCGType type, + TCGReg ret, tcg_target_long arg) +{ + TCGReg tbreg = TCG_TARGET_REG_BITS == 64 ? TCG_REG_TB : 0; + tcg_out_movi_int(s, type, ret, arg, tbreg); } static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg rd, TCGReg rs) @@ -2693,10 +2714,20 @@ static void tcg_target_qemu_prologue(TCGContext *s) #ifndef CONFIG_SOFTMMU if (guest_base != (int16_t)guest_base) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); + /* + * The function call abi for n32 and n64 will have loaded $25 (t9) + * with the address of the prologue, so we can use that instead + * of TCG_REG_TB. + */ +#if TCG_TARGET_REG_BITS == 64 && !defined(__mips_abicalls) +# error "Unknown mips abi" +#endif + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base, + TCG_TARGET_REG_BITS == 64 ? TCG_REG_T9 : 0); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif + if (TCG_TARGET_REG_BITS == 64) { tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_TB, tcg_target_call_iarg_regs[1]); } From patchwork Sat Apr 8 03:03:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671498 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611746wrt; Fri, 7 Apr 2023 20:05:34 -0700 (PDT) X-Google-Smtp-Source: AKy350YZCv1Rru8eZUG7Fqm3ujYEaM4BOBR8ygwMhhpYre8M5kmr3DqsFesXcxcBpx/EyqB0vLjm X-Received: by 2002:a05:6214:21aa:b0:5a5:9297:21b2 with SMTP id t10-20020a05621421aa00b005a5929721b2mr6790171qvc.21.1680923134412; Fri, 07 Apr 2023 20:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923134; cv=none; d=google.com; s=arc-20160816; b=c4THFEh4EgC9Rns8NQZB7srST7YkcXDo1gOxGfWnTbE7ZzqZU3qgiia3R6j1ulGTBD TiYd8YkZXpmxqTzQxWZVMtgV28Xt0BiwciP3JBd6Io3QCs766cA9bfrMauXP0z9gSKzx IwVtiXxMEOCncwMU1imh2gEX4ZuY0tZMnIBBMhk8Tt/WPPzhsFpdnJ7yuam+/m6wTqIp H8lvaNUnXtj+fUBGlYVA6VkC2or29703goPRFFMa17uFLLOONxB3MjGxxUnYoOtvflJ1 QyjTXQAxeR5eAzJgldo9sypPd6g/yVLViHo5XPvZb9sJkmu3ChbN4SKmOw9y7mKZXF07 TMpg== 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:cc:to :from:dkim-signature; bh=bWlAtcRNymG4w15Enb26bcQblUABjzhSzKBMFvp6WBM=; b=DupDzJ50uQ4laoiuSgGdPOWg+RUMVMn5FvmYUinAwxT7vsVYxNXchhHhfGo4OMM0h+ HY1WjVkEc0RlSkBToRQVap4QHQ6o49rdmSOspWh1BCYe2tgyR/YyyM+TesXboVoHiZcr 0J00SbJtAi7aHlGYodQu4yy1JN2mdc4V5lIqQawlf41xhOCe1lRQD8pIdqP0zA0yiCOU NT4R238bobai6yZ+ziZ9RAvGCPqf/Oa2HIxu9URF8FlDj3IlF2RgdKxeoIN41sh6Y1xB DRMzCxfZUYMRNs9cuYzguqzOZ7yOYFeK2cjonSVW2nALn/t7JJeMkGtCvDAF1H4hhOW6 wVZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u8ZAe8rG; 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 p16-20020a05622a049000b003d5151ca404si3817207qtx.165.2023.04.07.20.05.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05:34 -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=u8ZAe8rG; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysL-0004An-Mo; Fri, 07 Apr 2023 23:04:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys7-00046b-5Q for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:12 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys4-0004Vv-5s for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:09 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-62ddb232ddaso1414066b3a.1 for ; Fri, 07 Apr 2023 20:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bWlAtcRNymG4w15Enb26bcQblUABjzhSzKBMFvp6WBM=; b=u8ZAe8rGeYptpJksNsa8IKzrvjmNwmAzuJUsJT1/o6YBe+7BPVWgiM2z7aouROdi98 o5CLeLe9WfLzfnHPaQstCoyvykU76hxWWNL+I/R+85EXOB7p5g8wkJh9Qq67ytW0pxcY ZWiw77XCL89dPDOvgr6UqXWeVpZ/GMbCNVJksdw0Wqqp7M3MDr6LchiqIy1U0JbIrTFW UY5TrOpBDX6nVjBZuM8UCetEPkpfXCs0MtAPGVbqoDgpElkczaFOH74W8DzN+JsnBmim 5Di1PLq59kON2PERTBs+ap0/h4tBeOdZqzYtBXmB+PAYy9VSEPa4XIJfE4wRHBC4ZVts fCRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923047; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bWlAtcRNymG4w15Enb26bcQblUABjzhSzKBMFvp6WBM=; b=xAvkAzWKRUDJip0VY4vTByu0/Q159PUb+wq/erf+Yyq5i2J42exwpa46pvCI1g34Kz SnrgS3yI4FKhqJVOQHsf/txGLtWUZpF7HpMeL71zx89j3ZEEMxuHe4jLSCXLro2SdSnJ xhy20zCVhciBKYYuxqD9eBfVkMtNHQcY68ceKoz4kwhVLp7DlbKfSOyLgTOp70Apc+W6 gKEu0nsdJKMVEaApobo3tSTPCAxdUB7DjBGTuz7b9CLByCbDu1/fOQ89pdR5tEBRCxFr MKsrFqhULU7tWa3oWlSmwKUPEB9xcuqdEd5VEfs7rjYSwRoQR2gIJCeHuAipA8CianPR K7tQ== X-Gm-Message-State: AAQBX9dRj8TQ0sn78XOywGpJrK+ExpCSYbQRB+4DLQOYKpR86QUdSwqv H3IWR2EoeUZuVfxbiYg7tE/qf6hhT6xsRQZv5uk= X-Received: by 2002:a05:6a00:2ea1:b0:5a8:c913:b108 with SMTP id fd33-20020a056a002ea100b005a8c913b108mr4167085pfb.9.1680923047420; Fri, 07 Apr 2023 20:04:07 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 08/12] tcg/mips: Aggressively use the constant pool for n64 calls Date: Fri, 7 Apr 2023 20:03:55 -0700 Message-Id: <20230408030359.3368868-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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 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-bounces+patch=linaro.org@nongnu.org Repeated calls to a single helper are common -- especially the ones for softmmu memory access. Prefer the constant pool to longer sequences to increase sharing. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 235295c689..e37aca5986 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1105,9 +1105,19 @@ static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) { - /* Note that the ABI requires the called function's address to be - loaded into T9, even if a direct branch is in range. */ - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T9, (uintptr_t)arg); + /* + * Note that __mips_abicalls requires the called function's address + * to be loaded into $25 (t9), even if a direct branch is in range. + * + * For n64, always drop the pointer into the constant pool. + * We can re-use helper addresses often and do not want any + * of the longer sequences tcg_out_movi may try. + */ + if (sizeof(uintptr_t) == 8) { + tcg_out_movi_pool(s, TCG_REG_T9, (uintptr_t)arg, TCG_REG_TB); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_T9, (uintptr_t)arg); + } /* But do try a direct branch, allowing the cpu better insn prefetch. */ if (tail) { From patchwork Sat Apr 8 03:03:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671502 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611887wrt; Fri, 7 Apr 2023 20:06:01 -0700 (PDT) X-Google-Smtp-Source: AKy350Y66An0vAxfQDCz2CvszwjdZbMJcFLdWe2wUM1XpNZgatEye6/boa5/dvyhdhJw8R3eNf2s X-Received: by 2002:ad4:5b87:0:b0:5e9:a248:877b with SMTP id 7-20020ad45b87000000b005e9a248877bmr455487qvp.5.1680923161059; Fri, 07 Apr 2023 20:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923161; cv=none; d=google.com; s=arc-20160816; b=YdB8uzD6P7G+ib6DLBt/irAmbkMIhLR13JXOUUDkv1FDAw5ZW39B+WOPM0HZNIyXiu L/Jv1j+26H4RLdmASyyp6NB2/ZktcsdnB946JjjgQN0bJ0LKBCHywSGjj2KzIPXYIu3l 6Al5T9oIRLMF0mI4IK5jDHEv2lw82M2IKBpzRravm57MFqrTFQEcvMAXtkdnslJo4QpZ KYmd8Aj9oeIyijISoGLprrg+OqRsx6ewHvzv/vcNHizfQP/K0TCzNuZmDSHLEZiS0F3h QcEWMWKx7zj04hDxUQ6LcpEsp789hm62I2H060bDYW/Qh8EPVWkS4Yg3Hwkqm10cb2ki 2DJA== 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:cc:to :from:dkim-signature; bh=FzyqRtK+sy/Z6TtVMGGAfWbqpPjrDQw0gAte8M7H4fw=; b=JAgaIcWXbKvkqySGDCMHSv5qm+S9k/XNwgrs/ImT9ZP7J14rmw8EtWFb5EcCUPDRyo qkqKCHGZOxLCEI0h1jkMyx0e+Sr+7ljoXwR7ljDc9qNE9zt/LytVNKTeZ0HWZJM7T35/ Yx5RA7Vsgnbw+dRaf+2qBMkTAE96ESf5t1RfYIzOa1YU7/+DDg4w+exkpA8dux+D3A2U +Gpzq1hWA1o3U0sVgF6MTn5PXOj6rj/NHktZOpBSdaYMQ7vGJJJxspJovdDdIDMi3aqZ L2f9TnYwkk8uv1HNyYErHDvtzpxguPMDPx2z0a/XvyAqApUbP2za1FKK+25Td6PZWjuC U8Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBbmcMBk; 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 kd25-20020a056214401900b005ad4f60da65si3767835qvb.432.2023.04.07.20.06.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:06:01 -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=WBbmcMBk; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysM-0004B5-C9; Fri, 07 Apr 2023 23:04:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys8-00046i-Jo for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:12 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys6-0004XJ-U8 for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:12 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1a2b01f5ac0so2480265ad.3 for ; Fri, 07 Apr 2023 20:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FzyqRtK+sy/Z6TtVMGGAfWbqpPjrDQw0gAte8M7H4fw=; b=WBbmcMBkf84HRImxrgiMlGphpcTxjmM0y94roAkxI+Nns7qfCz4Bi9a8aFw6mN4SRQ 4LsDC92CFQgKGtcu3bguK2sXIADMyrSSbcDVhL8wl0VBNhxDghn+3KgpRzR4yakg7zIl 6BlE8mbh/jvUU6uBi6sjFHR7ciYveEMAUENMsOCayAPZQj1btQIkMCNus1mRzR08zT8w 6j4U5LoYjl+87E+GU07SnEHZJqep5tIF4tJY0Gs0FBcQ4tQIhv/DtaWFg3cr1aNGo28I WEFYth84zFpYI+NSSay0SVihFFa2dM+IdqcSepft93ach8dxbg96G9Box7MsHpk2eI4+ B/vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923048; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FzyqRtK+sy/Z6TtVMGGAfWbqpPjrDQw0gAte8M7H4fw=; b=f90RZ+MtFx7i/4e3WMWhY0lmhAb7cnsDo+B7QWxp1lufmw3sySihFl77h9Ve/rjL12 /GTaf5fDb53oqvoagRnJBjGfc1YjT0jcKcYy6xtor1empip7Un37BG2Dtk5ZVdHILhHO A4p6D/vwbXPW+IYef7UneGYwzIZV/MS/b6/CgMuOqckwPJwhSx64eQWUBa30CjCWCbKO yd3gV3CODCscXd4YDz3ie1MjQ+8RE83Q2zyqHmFCXu5vSL877KCd32bYhlVUuz333SWR Us/3XYzrZe+D6YDaZchgEO4d97/cdtJF7hZBUjvcVL+O03ny7zrMeOD46HBRwZHsrUnj TG0A== X-Gm-Message-State: AAQBX9efMQe+I0QTIoXIkB7OrOcUGZLB7sNDvABJOs7TBQ2exhoLj51H o8Xv729A8KEQ2v0L2aKTUCcXqcZKntfOGYV+duQ= X-Received: by 2002:a62:1c8f:0:b0:628:1852:8431 with SMTP id c137-20020a621c8f000000b0062818528431mr3516875pfc.30.1680923048271; Fri, 07 Apr 2023 20:04:08 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 09/12] tcg/mips: Try tb-relative addresses in tcg_out_movi Date: Fri, 7 Apr 2023 20:03:56 -0700 Message-Id: <20230408030359.3368868-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 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-bounces+patch=linaro.org@nongnu.org These addresses are often loaded by the qemu_ld/st slow path, for loading the retaddr value. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index e37aca5986..8c9a4cba9b 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -572,6 +572,8 @@ static void tcg_out_movi_pool(TCGContext *s, TCGReg ret, static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, TCGReg tbreg) { + tcg_target_long tmp; + if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; } @@ -582,6 +584,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, } assert(TCG_TARGET_REG_BITS == 64); + /* Load addresses within 2GB of TB with 1 or 3 insns. */ + tmp = tcg_tbrel_diff(s, (void *)arg); + if (tmp == (int16_t)tmp) { + tcg_out_opc_imm(s, OPC_DADDIU, ret, tbreg, tmp); + return; + } + if (tcg_out_movi_two(s, ret, tmp)) { + tcg_out_opc_reg(s, OPC_DADDU, ret, ret, tbreg); + return; + } + /* Otherwise, put 64-bit constants into the constant pool. */ tcg_out_movi_pool(s, ret, arg, tbreg); } From patchwork Sat Apr 8 03:03:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671499 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611784wrt; Fri, 7 Apr 2023 20:05:39 -0700 (PDT) X-Google-Smtp-Source: AKy350YH+zlX1VcQZzyo/bybB9n/za7Ta4Hn8fajPZMz89PxT1ied4cvkeoJZ8jnErnjjdhJJ4Dz X-Received: by 2002:a05:6214:250d:b0:5d2:4e83:d699 with SMTP id gf13-20020a056214250d00b005d24e83d699mr8838882qvb.32.1680923139438; Fri, 07 Apr 2023 20:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923139; cv=none; d=google.com; s=arc-20160816; b=Jeb62Jc6xWZAoqosl6u4kplUSj1qKtTlG+Zl6PhI2AKeqwNmjVt2ncgUrmJx1ymC95 i/phWqiGlRl+sYarVXX525CPCSMUyE5ExHL3pxhp337Dg4na/daU2KH7mCSW9bxoVdcV 1Qq8i048hTx3eae1JIL1a4cNUGoEyqjsQA5ov/XEga/gZiVLfcjaFwXfTiciCuzQKnlH o0mfdagXBYJoBXLjbVo4uZ8zsygx7xCcyeSpD0GmvSYStTT4tWVy0aJ7vugvo6ulWrL7 RknwW+r+TT+Osf+apJNt3UfRMKpuYFpDEvn4C35IW6t/ogBizLi7eXvN9Z3u+aSuRM// 80ww== 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:cc:to :from:dkim-signature; bh=qXbf2aRMCTtBppHDpY9IM0kHjyXVcQd7tAf8ZqkWMDo=; b=DR0zmBIu0AjEC0mj3rYSZCylobIZqeI/RJ5rfEShQGcCBtDag9C+qYgSU80HRB/rDF 6V7X9stjfAsfmWZ92eESViNMBDriRhPWKlmDeGcLAc0PvVvbWmRvmoA/LQ4v67au4xkW ItzPyYRMAfhvtE2n2RwNSke9yPtB66OpcpYgdC7VR7Fdd4DzmuVdhm83XwiZRfH6PhFj r4CJcWYNEg7enoRgc4fgCgxV60QjltYfzbpeMvD9WJAvU1tXCJveKp6itVAEYh4Vpy4I tjxp7YEPIwxJ7+EptIfJ+yZA2uFBlwXp0+oqoyaum1yjK14Cgc5QMgO/qXAfSyUIzIcE yPIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FTXCgVP/"; 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 m15-20020ad45dcf000000b005dd2a3971d8si3723073qvh.425.2023.04.07.20.05.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:05: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="FTXCgVP/"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysL-0004Aq-Mh; Fri, 07 Apr 2023 23:04:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys8-00046w-OZ for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:16 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys6-0004XV-UQ for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:12 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a52667955dso568995ad.1 for ; Fri, 07 Apr 2023 20:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qXbf2aRMCTtBppHDpY9IM0kHjyXVcQd7tAf8ZqkWMDo=; b=FTXCgVP/95HEFIspOLfZ136qECwjSGJQUvczi/SbQeHnx+gOnaVOXZveNJxqncUL4U Jk9MrOR86i36mPOQsvyXh63NrUCXoWzJ+dBKcS5DnfhQ8+Ngqfi2ID7q5QjiJyaKqMtF pU02bOELa6OmdJgBa0zfLvlgN6f67kaZ4WXbW2Fm8b/FXgBO1Suc4HjoX8jGGEshsZXH Zz6T60PwEfq3tW5+lcHnLquv9K7VCHLwfpT/VGRkxh2Z2kMpK4tuwukfdeTcRUigQAd3 xKlN6U/EJ+Iv2il2tyArOHbAqec+CsJ0ZbEVlcKeswGv+eSdhvAyoi/K5+Vx3dqHMHco 3yvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qXbf2aRMCTtBppHDpY9IM0kHjyXVcQd7tAf8ZqkWMDo=; b=LL8lRelLXS6mRD07e4TjsdLlb6nUwvQHYfQ0e5HsDcq+3czESCNCqdbp1FN/NIls6V xngYsxaI5dxOzaIXAwUkFuDBWXZKj2c3+leT9hFNFTIhBjIBBcOTvz4BkP99zt3oi2y2 C1Ku8CYX24OGUtH9T2eR0Um35nqgRUqYg7lAvbn6JleyuP/DWFWyngQmDwh5Z/HSei9N xpXII56DxO0FMXk2YplvBvB8DfTOtDNBIk132MGXcwhP/0VwWwl5MYJwL05YkRKHZJsn 1321njZQZdqnIYLQL5Na/etN1Xf7q1zMsc9XLSi2k/oN8xWk29Y/mkFMyuUsSKVjLU32 Pg+g== X-Gm-Message-State: AAQBX9doE68hm7aCyJ+AvmkRO/dD0JNI0gT3I+aWoCGNtum+YO7+nloj WEPkpkYtbfZi4Gr3qn7PcNSF16FIMHT7yXaOqsI= X-Received: by 2002:aa7:94b8:0:b0:62d:b7ad:8071 with SMTP id a24-20020aa794b8000000b0062db7ad8071mr4589155pfl.15.1680923049084; Fri, 07 Apr 2023 20:04:09 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 10/12] tcg/mips: Try three insns with shift and add in tcg_out_movi Date: Fri, 7 Apr 2023 20:03:57 -0700 Message-Id: <20230408030359.3368868-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 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-bounces+patch=linaro.org@nongnu.org These sequences are inexpensive to test. Maxing out at three insns results in the same space as a load plus the constant pool entry. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 8c9a4cba9b..e7930963fc 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -573,6 +573,7 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, TCGReg tbreg) { tcg_target_long tmp; + int sh, lo; if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { arg = (int32_t)arg; @@ -595,6 +596,49 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, return; } + /* + * Load bitmasks with a right-shift. This is good for things + * like 0x0fff_ffff_ffff_fff0: ADDUI r,0,0xff00 + DSRL r,r,4. + * or similarly using LUI. For this to work, bit 31 must be set. + */ + if (arg > 0 && (int32_t)arg < 0) { + sh = clz64(arg); + if (tcg_out_movi_one(s, ret, arg << sh)) { + tcg_out_dsrl(s, ret, ret, sh); + return; + } + } + + /* + * Load slightly larger constants using left-shift. + * Limit this sequence to 3 insns to avoid too much expansion. + */ + sh = ctz64(arg); + if (sh && tcg_out_movi_two(s, ret, arg >> sh)) { + tcg_out_dsll(s, ret, ret, sh); + return; + } + + /* + * Load slightly larger constants using left-shift and add/or. + * Prefer addi with a negative immediate when that would produce + * a larger shift. For this to work, bits 15 and 16 must be set. + */ + lo = arg & 0xffff; + if (lo) { + if ((arg & 0x18000) == 0x18000) { + lo = (int16_t)arg; + } + tmp = arg - lo; + sh = ctz64(tmp); + tmp >>= sh; + if (tcg_out_movi_one(s, ret, tmp)) { + tcg_out_dsll(s, ret, ret, sh); + tcg_out_opc_imm(s, lo < 0 ? OPC_DADDIU : OPC_ORI, ret, ret, lo); + return; + } + } + /* Otherwise, put 64-bit constants into the constant pool. */ tcg_out_movi_pool(s, ret, arg, tbreg); } From patchwork Sat Apr 8 03:03:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671503 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611924wrt; Fri, 7 Apr 2023 20:06:10 -0700 (PDT) X-Google-Smtp-Source: AKy350Yj+QM2hbGeNZi8MRi2yw/TT3kiv7fNrwk0nrqoIaGt/n/W2KukqLwOCejNbYt7MPY//b13 X-Received: by 2002:ac8:5b0e:0:b0:3e6:71d6:5d5d with SMTP id m14-20020ac85b0e000000b003e671d65d5dmr6270935qtw.1.1680923170148; Fri, 07 Apr 2023 20:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923170; cv=none; d=google.com; s=arc-20160816; b=TFIXZTrGeWQrZhTf6CB6nvc5UF2U49RpVWiqL2JClRJ5OcTfLwvu/VwKx9Qn0L1H6r ZbRrWl6AqFctbaHdciOucA67APUos+rGIU6tAlOEM1oV/iOYFJ7vEByAowG6ZVXkGhJD pOwVashHkrfmzFDWG4LTRK61WPl72KNufx0U0U8ijnqhuzOyf1GjpHHDJLt0Hgbx8Zml 46a/luBjBsm+NoRtqbrw8QH3iIWgLuqVArKllfRfaEOeOGTzL3w0rvNC5gl2uxHaVRma gPC0bsp0YYl1PvzpnL3DBqpOILAaHdf27nTe3CTP+wd4qV3PFVGhtwQ5g/5Yin7UQ8YR zrJQ== 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:cc:to :from:dkim-signature; bh=mTrnnmRF46TF0Utts5Gj6LSoaUp0gjklQtGKntHQY08=; b=v4XQFk8umh5bsnAUQAqZcONSlsgG2iuZqZpVlyJrkttZlvv2TFIt1RgNvmeEk2QfoI QxriyV8pS5DpjiocsE0kL4xGKqQamP9Kt19ozgU80hsm/wATlzvzin8wNMr2XP3+aeCO DeDVsw8KgnRpMalIb7domgqnKb2iBegsuQGYHQgSagXHBY8FogwmrKjZQOAxww9/O6pQ QAZd+Qrhj39ez6gzpnFTcgSYf1Lmbmnv1YGviOmKsTzUD/Y/9HY7ewe3BgyjfrB44IDd 2EpxJCarVKiz162H3UXSh3EaBYPfrM4VPdIX5RA0GJmPh3IkbxYEqWtMUFn178tn0d8K XzdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iV/uqwPy"; 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 t7-20020ae9df07000000b007467bbb1e49si3588584qkf.123.2023.04.07.20.06.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:06:10 -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="iV/uqwPy"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysN-0004BR-0v; Fri, 07 Apr 2023 23:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkys9-000477-KO for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:16 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys7-0004Xc-CU for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:13 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1a2b01f5ac0so2480275ad.3 for ; Fri, 07 Apr 2023 20:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mTrnnmRF46TF0Utts5Gj6LSoaUp0gjklQtGKntHQY08=; b=iV/uqwPyAjg8i0zJ0P5MOgM4SVHbmtSLK62/+5jCD60Y8BDj6xDc+Ub4r8R5zDsfg0 oD+lqIxzO5JVOlGCq63a9atk/Sl0zNzHuyazeTanT+92g9f9NmBOek+KRfVViaWfGUwZ U9JThhc/JpZKb7hJ+oXZmwncapf66Ik5koPIsnzmbkWeKlvORgoW5TMHHlNik90yOaSG bwlgqUiWXYAI8QhMl8tk08cgZVpHv2WaFqx1miyCkzUvJmdx03ccbfO/yPIgDTy8op/f HTg6Oed68t/4qWMtIGmIAGnomR1lWF1yAq6pEP3q7bfAjqZAnkZ3xs9510+iFy8WLN7r VOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mTrnnmRF46TF0Utts5Gj6LSoaUp0gjklQtGKntHQY08=; b=GGWKfTE6r4XhtwKj4MzlQ3ayLj63ZJbXfp/QGPdf1GKIXGuscHeFR1z/ka5+anQtDo +MlHQQCLoaNRcsJN5GVJX64jVbe2WqDbE7gIjXj2iODDKvWrusXFDIvoreFk4tc1a+ja kvecOLidhe+1m/tqc8QzC/P54OOxBBx0EPKAl5vJrbAdqadbrx8FoUJCLoxpCkS6+2I8 LEWXEtawLmgEjzixVeLZ9ZkBOhDvdU/zf+IITc0NJuCYcJq1/NOZ7hfRshiTPRzP5uQq y3dY84MAaxiM9Ka4RI5XK3J8PVFh9JfbOSFCYjDNye8S3oJ+amhY1t7c9bdO84ODxr67 ipFQ== X-Gm-Message-State: AAQBX9cTrgtzTFoZfMttxn5wYr1QLciyPCoFWr6PCQUaPKqzSaZ4mLgc 4LcqWQ2OZVWSki+ws1Us2M94WLksd1CgX0JKXEk= X-Received: by 2002:a62:194b:0:b0:622:bbad:a2f3 with SMTP id 72-20020a62194b000000b00622bbada2f3mr4169171pfz.9.1680923049906; Fri, 07 Apr 2023 20:04:09 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 11/12] tcg/mips: Use qemu_build_not_reached for LO/HI_OFF Date: Fri, 7 Apr 2023 20:03:58 -0700 Message-Id: <20230408030359.3368868-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 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-bounces+patch=linaro.org@nongnu.org The new(ish) macro produces a compile-time error instead of a link-time error. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index e7930963fc..1df00bf027 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -37,11 +37,9 @@ # define LO_OFF (MIPS_BE * 4) # define HI_OFF (4 - LO_OFF) #else -/* To assert at compile-time that these values are never used - for TCG_TARGET_REG_BITS == 64. */ -int link_error(void); -# define LO_OFF link_error() -# define HI_OFF link_error() +/* Assert at compile-time that these values are never used for 64-bit. */ +# define LO_OFF ({ qemu_build_not_reached(); 0; }) +# define HI_OFF ({ qemu_build_not_reached(); 0; }) #endif #ifdef CONFIG_DEBUG_TCG From patchwork Sat Apr 8 03:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 671505 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp611957wrt; Fri, 7 Apr 2023 20:06:20 -0700 (PDT) X-Google-Smtp-Source: AKy350a+EhePn4c1gRpBebPVUz1gelGVPualWvhJNzGA7zhcyYxwsPMBrSEKgQjkegeWGXTsj+Ss X-Received: by 2002:a05:622a:1a26:b0:3e4:e278:a6a0 with SMTP id f38-20020a05622a1a2600b003e4e278a6a0mr19645477qtb.16.1680923180594; Fri, 07 Apr 2023 20:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680923180; cv=none; d=google.com; s=arc-20160816; b=NrO1XCGew6JYbVPKkAKYJyVOjm0XqOv41IWruoaVvIP3NXLoP+qp6nT0wKzLstecOa FOe/D6azqEH1/YCdG/zgYQelG7+YKSnxuK4SbP4gJ6WPEe8UZ0xujvxU3Nw4jaXaQYMB V761dtSrVIPzQ7vsl/H/0tPc+SpfeHhQxoZuZEfjpK9Okl+/ukhGBMJWrtaSqgpVff3A JvMUc6NYuOy6Yq3IdzZGilUiUX797v0xG11q1KP8Ui67aQc+eIFo0jW9pDK6SunXuxip hFkNfFMGrXPW0hkmbYTnZ6pOTHYoC4EeprEqKQONESyn7iSPRfCL8dYwlVSWkAh/iA4r bLJg== 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:cc:to :from:dkim-signature; bh=SMU8At/4U7O1Bf4F5hIg0nT65apfwtt8AlnB6b9nPKA=; b=Bye2aZBwPM7arFnBZuUj33SXAORT0s5lUuRxU71EmxqUf3jvQqdFHOHkk2gA2dYqc4 yIG4n6F75QsMb9zGMKzmEol2BWsgd0RcLmNrde2m6BD3h9xLO+pnkmFlJnhkTp4apgno gwilHq6PgOt8x6+z5syWSIQseT+98Uy6Fp8a3pTteywYqsQ435E9kvOlkwUmo03dOcjD fTqZSz9HSLzlW1YDmQ0Smziyg1m2EeJd8PzBBJjQ9EpoK3dAHWye3fxwvvm90+poEn7+ j2IXBmWO3E7h0DmQsFNoCMQaL2ZE2eWIoJsEwl0WF0owVoA7ZzYL5zRD68Du93e529vo vvBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ou7uAIW3; 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 n190-20020a37bdc7000000b00730749b412fsi3700627qkf.612.2023.04.07.20.06.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Apr 2023 20:06:20 -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=ou7uAIW3; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkysN-0004Bh-87; Fri, 07 Apr 2023 23:04:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkysB-00047D-0j for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:16 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkys8-0004Xx-HR for qemu-devel@nongnu.org; Fri, 07 Apr 2023 23:04:14 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-632384298b3so271007b3a.0 for ; Fri, 07 Apr 2023 20:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680923051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SMU8At/4U7O1Bf4F5hIg0nT65apfwtt8AlnB6b9nPKA=; b=ou7uAIW3MZl13Z7eKTD+wPz+TNlGe3gYZGCDPxSNJIZ9rJYDDI9kPuBtHGPa6Ju4ZK 39ZmJiMaHlLKco733GwV0epXcoWso6pHXF3hPHfztxqwci9Og++Oz+1ReMzw5JbatEu4 MwEtO5q3ZORV0zAWpC9lcgTPlCHz7KGU6zIfPQcdYR1LaKIFJvP/cHiUB4F6RwJPNwuJ xNvMGjw3nNLFhrjaKhgGraVJbHKpLUx2aS4eOgVHplID2WbkvnYVAxGyZtuzVCR91Wuw /hP3sMRRVYDKTCa9/o0i+woKs0GeczfdZHEY/ZjB+a1ARrNvv2A6yZ8e7M0CbRdEfY1a ozSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680923051; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SMU8At/4U7O1Bf4F5hIg0nT65apfwtt8AlnB6b9nPKA=; b=1oMLYj+egl7GbxTxX7Ns8msDFWsv4b7PA+EXQ6kIi15SXy7Hqt84+D2tQzdk8hMh1D PYP+e+mw12QHNcGTsWOGEXli093RcBowufvTZL5ZQXb55wK1ru6g/hluEoZTVvIRp9r9 wq8B9xU4YoY40jbNY4sv7/CoXiIUrFY5a7OPuLa3ARybxaTUKNIAet1r3Yw2bKir1YOs YM1nkLeLzU/LiyH1SuNbGUJANjNiGy96Z4xawTuD5dwxZnd/9X5CplbyBM3Img1x8nsO 5DJtzk3AUTFDntGJvIJJaMwsXaFEUzygjIHipo0DtCrkMENGMtHgblrPelAV/Y7qgqSO A+ig== X-Gm-Message-State: AAQBX9ewa1UUaGn9jBO3yQYMoM0fyzQdGraqoBg1cpTtX91GbwbUXbeA 4/G3fjG/y8zyLXmGSYN6+2U0QRTbM2D3JHrWHrc= X-Received: by 2002:a05:6a00:2d95:b0:62d:d85b:fcfc with SMTP id fb21-20020a056a002d9500b0062dd85bfcfcmr4388409pfb.8.1680923050955; Fri, 07 Apr 2023 20:04:10 -0700 (PDT) Received: from stoup.. ([2602:ae:1541:f901:8bb4:5a9d:7ab7:b4b8]) by smtp.gmail.com with ESMTPSA id c12-20020aa78e0c000000b0062b5a55835dsm3687025pfr.213.2023.04.07.20.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 20:04:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 12/12] tcg/mips: Replace MIPS_BE with HOST_BIG_ENDIAN Date: Fri, 7 Apr 2023 20:03:59 -0700 Message-Id: <20230408030359.3368868-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230408030359.3368868-1-richard.henderson@linaro.org> References: <20230408030359.3368868-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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 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-bounces+patch=linaro.org@nongnu.org Since e03b56863d2b, which replaced HOST_WORDS_BIGENDIAN with HOST_BIG_ENDIAN, there is no need to define a second symbol which is [0,1]. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/mips/tcg-target.c.inc | 88 ++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 1df00bf027..9767065af0 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -27,14 +27,8 @@ #include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" -#if HOST_BIG_ENDIAN -# define MIPS_BE 1 -#else -# define MIPS_BE 0 -#endif - #if TCG_TARGET_REG_BITS == 32 -# define LO_OFF (MIPS_BE * 4) +# define LO_OFF (HOST_BIG_ENDIAN * 4) # define HI_OFF (4 - LO_OFF) #else /* Assert at compile-time that these values are never used for 64-bit. */ @@ -1354,7 +1348,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) if (TCG_TARGET_REG_BITS == 32 && (opc & MO_SIZE) == MO_64) { /* We eliminated V0 from the possible output registers, so it cannot be clobbered here. So we must move V1 first. */ - if (MIPS_BE) { + if (HOST_BIG_ENDIAN) { tcg_out_mov(s, TCG_TYPE_I32, v0, TCG_REG_V1); v0 = l->datahi_reg; } else { @@ -1438,8 +1432,8 @@ static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { /* A0 is env, A1 is skipped, A2:A3 is the uint64_t address. */ - TCGReg a2 = MIPS_BE ? l->addrhi_reg : l->addrlo_reg; - TCGReg a3 = MIPS_BE ? l->addrlo_reg : l->addrhi_reg; + TCGReg a2 = HOST_BIG_ENDIAN ? l->addrhi_reg : l->addrlo_reg; + TCGReg a3 = HOST_BIG_ENDIAN ? l->addrlo_reg : l->addrhi_reg; if (a3 != TCG_REG_A2) { tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); @@ -1551,8 +1545,8 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, OPC_LW, TCG_TMP1, base, 4); tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, TCG_TMP0); tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, TCG_TMP1); - tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? lo : hi, TCG_TMP0, 16); - tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? hi : lo, TCG_TMP1, 16); + tcg_out_opc_sa(s, OPC_ROTR, HOST_BIG_ENDIAN ? lo : hi, TCG_TMP0, 16); + tcg_out_opc_sa(s, OPC_ROTR, HOST_BIG_ENDIAN ? hi : lo, TCG_TMP1, 16); } else { tcg_out_bswap_subr(s, bswap32_addr); /* delay slot */ @@ -1560,15 +1554,15 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, OPC_LW, TCG_TMP0, base, 4); tcg_out_bswap_subr(s, bswap32_addr); /* delay slot */ - tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? lo : hi, TCG_TMP3); - tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? hi : lo, TCG_TMP3); + tcg_out_mov(s, TCG_TYPE_I32, HOST_BIG_ENDIAN ? lo : hi, TCG_TMP3); + tcg_out_mov(s, TCG_TYPE_I32, HOST_BIG_ENDIAN ? hi : lo, TCG_TMP3); } break; case MO_UQ: /* Prefer to load from offset 0 first, but allow for overlap. */ if (TCG_TARGET_REG_BITS == 64) { tcg_out_opc_imm(s, OPC_LD, lo, base, 0); - } else if (MIPS_BE ? hi != base : lo == base) { + } else if (HOST_BIG_ENDIAN ? hi != base : lo == base) { tcg_out_opc_imm(s, OPC_LW, hi, base, HI_OFF); tcg_out_opc_imm(s, OPC_LW, lo, base, LO_OFF); } else { @@ -1584,10 +1578,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, TCGType type) { - const MIPSInsn lw1 = MIPS_BE ? OPC_LWL : OPC_LWR; - const MIPSInsn lw2 = MIPS_BE ? OPC_LWR : OPC_LWL; - const MIPSInsn ld1 = MIPS_BE ? OPC_LDL : OPC_LDR; - const MIPSInsn ld2 = MIPS_BE ? OPC_LDR : OPC_LDL; + const MIPSInsn lw1 = HOST_BIG_ENDIAN ? OPC_LWL : OPC_LWR; + const MIPSInsn lw2 = HOST_BIG_ENDIAN ? OPC_LWR : OPC_LWL; + const MIPSInsn ld1 = HOST_BIG_ENDIAN ? OPC_LDL : OPC_LDR; + const MIPSInsn ld2 = HOST_BIG_ENDIAN ? OPC_LDR : OPC_LDL; bool sgn = (opc & MO_SIGN); @@ -1653,10 +1647,10 @@ static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, ld1, lo, base, 0); tcg_out_opc_imm(s, ld2, lo, base, 7); } else { - tcg_out_opc_imm(s, lw1, MIPS_BE ? hi : lo, base, 0 + 0); - tcg_out_opc_imm(s, lw2, MIPS_BE ? hi : lo, base, 0 + 3); - tcg_out_opc_imm(s, lw1, MIPS_BE ? lo : hi, base, 4 + 0); - tcg_out_opc_imm(s, lw2, MIPS_BE ? lo : hi, base, 4 + 3); + tcg_out_opc_imm(s, lw1, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 0); + tcg_out_opc_imm(s, lw2, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 3); + tcg_out_opc_imm(s, lw1, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 0); + tcg_out_opc_imm(s, lw2, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 3); } break; @@ -1680,19 +1674,19 @@ static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, lw2, TCG_TMP1, base, 4 + 3); tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, TCG_TMP0); tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, TCG_TMP1); - tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? lo : hi, TCG_TMP0, 16); - tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? hi : lo, TCG_TMP1, 16); + tcg_out_opc_sa(s, OPC_ROTR, HOST_BIG_ENDIAN ? lo : hi, TCG_TMP0, 16); + tcg_out_opc_sa(s, OPC_ROTR, HOST_BIG_ENDIAN ? hi : lo, TCG_TMP1, 16); } else { tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); tcg_out_bswap_subr(s, bswap32_addr); /* delay slot */ tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 4 + 0); - tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? lo : hi, TCG_TMP3); + tcg_out_mov(s, TCG_TYPE_I32, HOST_BIG_ENDIAN ? lo : hi, TCG_TMP3); tcg_out_bswap_subr(s, bswap32_addr); /* delay slot */ tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 4 + 3); - tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? hi : lo, TCG_TMP3); + tcg_out_mov(s, TCG_TYPE_I32, HOST_BIG_ENDIAN ? hi : lo, TCG_TMP3); } break; @@ -1802,16 +1796,16 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_bswap64(s, TCG_TMP3, lo); tcg_out_opc_imm(s, OPC_SD, TCG_TMP3, base, 0); } else if (use_mips32r2_instructions) { - tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, MIPS_BE ? lo : hi); - tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, MIPS_BE ? hi : lo); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, HOST_BIG_ENDIAN ? lo : hi); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, HOST_BIG_ENDIAN ? hi : lo); tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP0, TCG_TMP0, 16); tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP1, TCG_TMP1, 16); tcg_out_opc_imm(s, OPC_SW, TCG_TMP0, base, 0); tcg_out_opc_imm(s, OPC_SW, TCG_TMP1, base, 4); } else { - tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi, 0); + tcg_out_bswap32(s, TCG_TMP3, HOST_BIG_ENDIAN ? lo : hi, 0); tcg_out_opc_imm(s, OPC_SW, TCG_TMP3, base, 0); - tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo, 0); + tcg_out_bswap32(s, TCG_TMP3, HOST_BIG_ENDIAN ? hi : lo, 0); tcg_out_opc_imm(s, OPC_SW, TCG_TMP3, base, 4); } break; @@ -1819,8 +1813,8 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, if (TCG_TARGET_REG_BITS == 64) { tcg_out_opc_imm(s, OPC_SD, lo, base, 0); } else { - tcg_out_opc_imm(s, OPC_SW, MIPS_BE ? hi : lo, base, 0); - tcg_out_opc_imm(s, OPC_SW, MIPS_BE ? lo : hi, base, 4); + tcg_out_opc_imm(s, OPC_SW, HOST_BIG_ENDIAN ? hi : lo, base, 0); + tcg_out_opc_imm(s, OPC_SW, HOST_BIG_ENDIAN ? lo : hi, base, 4); } break; @@ -1832,10 +1826,10 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc) { - const MIPSInsn sw1 = MIPS_BE ? OPC_SWL : OPC_SWR; - const MIPSInsn sw2 = MIPS_BE ? OPC_SWR : OPC_SWL; - const MIPSInsn sd1 = MIPS_BE ? OPC_SDL : OPC_SDR; - const MIPSInsn sd2 = MIPS_BE ? OPC_SDR : OPC_SDL; + const MIPSInsn sw1 = HOST_BIG_ENDIAN ? OPC_SWL : OPC_SWR; + const MIPSInsn sw2 = HOST_BIG_ENDIAN ? OPC_SWR : OPC_SWL; + const MIPSInsn sd1 = HOST_BIG_ENDIAN ? OPC_SDL : OPC_SDR; + const MIPSInsn sd2 = HOST_BIG_ENDIAN ? OPC_SDR : OPC_SDL; /* Don't clutter the code below with checks to avoid bswapping ZERO. */ if ((lo | hi) == 0) { @@ -1869,17 +1863,17 @@ static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_bswap64(s, TCG_TMP3, lo); lo = TCG_TMP3; } else if (use_mips32r2_instructions) { - tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, MIPS_BE ? hi : lo); - tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, MIPS_BE ? lo : hi); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, HOST_BIG_ENDIAN ? hi : lo); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, HOST_BIG_ENDIAN ? lo : hi); tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP0, TCG_TMP0, 16); tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP1, TCG_TMP1, 16); - hi = MIPS_BE ? TCG_TMP0 : TCG_TMP1; - lo = MIPS_BE ? TCG_TMP1 : TCG_TMP0; + hi = HOST_BIG_ENDIAN ? TCG_TMP0 : TCG_TMP1; + lo = HOST_BIG_ENDIAN ? TCG_TMP1 : TCG_TMP0; } else { - tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi, 0); + tcg_out_bswap32(s, TCG_TMP3, HOST_BIG_ENDIAN ? lo : hi, 0); tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 0 + 0); tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 0 + 3); - tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo, 0); + tcg_out_bswap32(s, TCG_TMP3, HOST_BIG_ENDIAN ? hi : lo, 0); tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 4 + 0); tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 4 + 3); break; @@ -1890,10 +1884,10 @@ static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, tcg_out_opc_imm(s, sd1, lo, base, 0); tcg_out_opc_imm(s, sd2, lo, base, 7); } else { - tcg_out_opc_imm(s, sw1, MIPS_BE ? hi : lo, base, 0 + 0); - tcg_out_opc_imm(s, sw2, MIPS_BE ? hi : lo, base, 0 + 3); - tcg_out_opc_imm(s, sw1, MIPS_BE ? lo : hi, base, 4 + 0); - tcg_out_opc_imm(s, sw2, MIPS_BE ? lo : hi, base, 4 + 3); + tcg_out_opc_imm(s, sw1, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 0); + tcg_out_opc_imm(s, sw2, HOST_BIG_ENDIAN ? hi : lo, base, 0 + 3); + tcg_out_opc_imm(s, sw1, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 0); + tcg_out_opc_imm(s, sw2, HOST_BIG_ENDIAN ? lo : hi, base, 4 + 3); } break;