From patchwork Tue Dec 21 16:47:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526595 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5222658imb; Tue, 21 Dec 2021 08:48:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo3MmhOFrjEnO1qlQM/bqyTKosWMAOXOGMgJ20vyYejApmL9tzybsJk5aDFuR5qntq3sQu X-Received: by 2002:a05:622a:164e:: with SMTP id y14mr2947826qtj.651.1640105337673; Tue, 21 Dec 2021 08:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105337; cv=none; d=google.com; s=arc-20160816; b=svL1Cthk+HnbnJQ3tr26HxEfIfi202OtdtlqDpxnwTFFlFR/qwhcXWibg6z9HYnZjT FPwCdzR35qGTuLCg02+gIezqBgKiyXEvxOYDrsvtm1izn2QWDNZVn2yToRGWDrCPCPRg v4Tvm2l0l5uyVvjCxb/5aP0PWcpbaKcyvJbu9pZIHdBkwGPh8LC+WYsx/5+PDRPjB0B8 fjJZju4K6O/+giR+AEY8wzw0I0tKjS2Zn1d+sUH9LwZIf/5DVlZ0Mk5xZf7XH4sfDKJs EspOZUfnGN5sPXXMkVMDDHu8T5jmTwPcMtvynhAMHW5i3mwrs26HzzSg3zrLyeGF6cUU o4Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+Py+EjlgiNuKFcv4guGE3lJAZOnNjGvtb46J0VGe4hU=; b=nYnRIvSY0NDTq45BfsIzQnexttKrqd6PwQJDwblSyA884BPNIyPCQrbQeikVTHHoZe dY5LixKie2l1pLJLXXgbcdYcDt26pMuwcRf1bcshU6K7FrH04LBnSUk6G4+H8tGTMKgG aaEQ4WP5FHyd78FknA7x26Qbm9gxXYEhIl8rTfFRxLFUyWT7XIbfusBMeGgkJ9Ll+8Qb oNVfsWhEx/3K52VegG3bK4VXftVGj3Xuw8x4MTdMRHCOycDkMRJArWTgz7Q9ESjN71gZ 0wMONZXCz2LtzbV8AD6ldMP3yUFMycbcQZlRStFR0R5iAvhlYAry+mcmYxAzVaBYAEje kHwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TkBcyIEx; 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 l200si584466qke.660.2021.12.21.08.48.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:48:57 -0800 (PST) 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=TkBcyIEx; 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]:37296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziJs-0008Hf-Ao for patch@linaro.org; Tue, 21 Dec 2021 11:48:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIh-0008FU-VT for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:43 -0500 Received: from [2607:f8b0:4864:20::102d] (port=45741 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIf-0007aD-IA for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:43 -0500 Received: by mail-pj1-x102d.google.com with SMTP id f18-20020a17090aa79200b001ad9cb23022so3725100pjq.4 for ; Tue, 21 Dec 2021 08:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Py+EjlgiNuKFcv4guGE3lJAZOnNjGvtb46J0VGe4hU=; b=TkBcyIExVGJMc+rwT31njotMvU6wmfPztJcf0g7M+iubcIrR4F9JGTsqvc5ofzamt8 EJOM7xz0wl9zLNGjicUHTwO9KbtbNSXdHbjqtPl7XI2iDlXpFt9HTGUwa8GAPbaJcRo9 DTxBdmCIm6KUIqUH2/7y53qQbrHImNICpPjVmbdxoAqEH44iGI4suN5ufY429z225vZz 1V9LzOh9Rr/IaPUCz5Q/YFxFALtijUZEJTWY0/46yPEgXEDujhQVhrNvFYMgfjy5hpVt MvP3QqqxOwPdzlZxe0egc2AgH/Yw28mJA6ZOi2q95Ab+0VeI+dRkHnOSgljNP3pKQ1k8 kqbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Py+EjlgiNuKFcv4guGE3lJAZOnNjGvtb46J0VGe4hU=; b=voJAfR1mPMR60hfb6E8VW7/rQZv8XysTyq+qHPoUSb6sKbmOYKICikf86TzXbodlUc jRTEWx/rgySjTxqsNwp0vivo3XGOgKupmMiJ41dcsAE/AgBe+5uaCIiD9h74MwnLRmLE LUaXkXYSwHdnxLQX8Vb85KlfT4jjPsSgPEps7DT5ROhX4wmXEdVjTRaI/LjaUn4AmJ7t Ni9P1oH7vJCt+YeA8Fjb/c7IwbQo2JuqX+6hBmmepaUaHnUxomoHcgDAQZQNaafQ4Ujq JnwqFJeYtsnGX/qNLE6yBs7h1KMGfAvdUgf8ZuCT/OZgUJpoQ3Gat4pMxfaXQhcCSN7D T2jQ== X-Gm-Message-State: AOAM531BTWOAt+33r3A4H4lq9KiUH5jLqeeN1fe1Y0G86wsQyDmPUGvw C7/WEQ4pYQdpT4ha6OdM0G62mC1gMxnmdQ== X-Received: by 2002:a17:90a:d792:: with SMTP id z18mr4961289pju.182.1640105260154; Tue, 21 Dec 2021 08:47:40 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/31] elf: Add machine type value for LoongArch Date: Tue, 21 Dec 2021 08:47:07 -0800 Message-Id: <20211221164737.1076007-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui This is already officially allocated as recorded in GNU binutils repo [1], and the description is updated in [2]. Add to enable further work. [1]: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4cf2ad720078a9f490dd5b5bc8893a926479196e [2]: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=01a8c731aacbdbed0eb5682d13cc074dc7e25fb3 Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-2-git@xen0n.name> Signed-off-by: Richard Henderson --- include/elf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/elf.h b/include/elf.h index 811bf4a1cb..3a4bcb646a 100644 --- a/include/elf.h +++ b/include/elf.h @@ -182,6 +182,8 @@ typedef struct mips_elf_abiflags_v0 { #define EM_NANOMIPS 249 /* Wave Computing nanoMIPS */ +#define EM_LOONGARCH 258 /* LoongArch */ + /* * This is an interim value that we will use until the committee comes * up with a final number. From patchwork Tue Dec 21 16:47:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526597 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5222770imb; Tue, 21 Dec 2021 08:49:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJygeZ4Bflrg2hn7o7NIyIGFa1tSkzaoMvBJNyVsCT5nxJN3e/rW0AHlKeGlwfaaaYUtweXO X-Received: by 2002:a25:ae12:: with SMTP id a18mr5568821ybj.412.1640105344347; Tue, 21 Dec 2021 08:49:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105344; cv=none; d=google.com; s=arc-20160816; b=fTSFQqBZlXA6gZ1MK/ZsvHUUc9t/Gra4FZsAV3+mKUp3j7eoShYcR6aNR3T3VVmXg4 iurWhClw5mAP4faxkQ+YYLiEr+nth4hVyukAN5Qqax0P4KFXubtKikICtZwjjt/XHSL2 /Owbnx+Xgk2KekJQI7U8TXC0N2iPB1NBtADhjyTdeIKMqs/hJeeOfk3Xti1Ogfo7YjgH IBtXtYAhDevqf67U8tPFQ+yAkSZAXkapX32sVQeo9bY5YlFf1m3XdPlOXJn9s6RANv3R vHi4M8xDpiNeJhGromwrg5mM2j6/4uBk9iYgTJfnRjTnwDdCu5LRYxFiZ5uH5UvB1AKY Elhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gw1Elmr7+CuPQ1NTU/QmJ2gSIrEw0R9sp9nE9zFCam0=; b=ogPsVwpdxesjPAtnyHwL0XHt7yVOkMjAZYag4JB605VVuFM4bilVHDzxySCnMru0uD nMXxVMOIh/6odrzvpAFHgJu9XHt6Es1+/3JXQ7bFmUS4czpFx/daTZI0YsgAXTfLqz9X p3zrs1Jf0QDwnzOCQBdKplVQ4KIojR74FO8y3kgLBGqwyzGpQtbPVUZTnjvuPKwGG6pq vH57aIbj/DxvM1jTpjh7SVop64lNlDkgQxPjbsJ0jA7nWpXlDp7669ZePpWeDi11Xz0S skhhLACIcAXVTR/nQpob2shdmUzpfMm6hsPm2zO9TQJiD3l3OhtYwZgUHdl8D4ArpayL rrIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gaDZlvC4; 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 62si18548055ybm.609.2021.12.21.08.49.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:49:04 -0800 (PST) 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=gaDZlvC4; 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]:37292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziJz-0008Ha-Pj for patch@linaro.org; Tue, 21 Dec 2021 11:49:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIh-0008FT-VL for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:43 -0500 Received: from [2607:f8b0:4864:20::632] (port=35720 helo=mail-pl1-x632.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIg-0007aJ-9v for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:43 -0500 Received: by mail-pl1-x632.google.com with SMTP id n16so10441749plc.2 for ; Tue, 21 Dec 2021 08:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gw1Elmr7+CuPQ1NTU/QmJ2gSIrEw0R9sp9nE9zFCam0=; b=gaDZlvC4vO2HyN3FbQ6EnHt7o+YbPtuI8Kbg9RnMMdLovsjCjRx35JaRGB8E4w/Npk QQJYaxbwyuwJJvfm/4w+TuB41Xd5Nu8t3TWE93H6fiXP1pIknZXkRwVRiP9Tv0OLWqHy w0WZJBq7pVJW0rvJwwSI1UZyqJ0pwuIWhhExhgSK7UE5u9qBJruxOVXdnGPxWEcXq+CX iNuITYNNnSPGgYEEwlgyApd/VY3qJVibBaZk6LOkof4JGxIffKIlDL3DDzBiw0akbY6Z cM/OwMkWMZIoJ48IiLlKlYkTbxqKCKlTqJ3V9yfPBixb7CgLgFnwfIrO8s9NqpB2D97z FGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gw1Elmr7+CuPQ1NTU/QmJ2gSIrEw0R9sp9nE9zFCam0=; b=Gmlql+5QJ1ppATsO7PtciGHEQFLBsam29+v2eNLH+Ma3f5z+8onllMhOLyRRxW24Tc crPlsQ/IPVeIdC2bkvp6KLK8IFMMjyD+fLyaktRet93D/xjAm/UGPiJsIFbpXTLohZry neYR0wcBg0M7egj2/eJNNajPAPk8Pn9x6qvbaPgldxizGhUFYTKuXSXm3W9mpuJHsVKx 8USlBB7C5qWws9NdZRfCruvgNXDkWNqiOHv6e5Jn6G976gbh8dufdvyWkkq2J4yXlO85 D5/0NfRF/zSoEy1hyG8ql1YQ4QNTeBoEG8iJzyEYw4Zy37IxbcFXUgqzWX2iEjLNO6r4 bpLg== X-Gm-Message-State: AOAM5339OI6BuZDSxAQ9PLS84Am1jJfwAk5TJrTBRqXvmG65+Lf5SfOd W7tKR+hRjFnZS354pPckxJKn+Yx0H0/JbA== X-Received: by 2002:a17:902:8347:b0:148:ac82:998e with SMTP id z7-20020a170902834700b00148ac82998emr3828465pln.92.1640105261021; Tue, 21 Dec 2021 08:47:41 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/31] MAINTAINERS: Add tcg/loongarch64 entry with myself as maintainer Date: Tue, 21 Dec 2021 08:47:08 -0800 Message-Id: <20211221164737.1076007-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::632 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui I ported the initial code, so I should maintain it of course. Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-3-git@xen0n.name> Signed-off-by: Richard Henderson --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1de6ce6e44..4f6e0de3fb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3139,6 +3139,11 @@ S: Maintained F: tcg/i386/ F: disas/i386.c +LoongArch64 TCG target +M: WANG Xuerui +S: Maintained +F: tcg/loongarch64/ + MIPS TCG target M: Philippe Mathieu-Daudé R: Aurelien Jarno From patchwork Tue Dec 21 16:47:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526600 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5225689imb; Tue, 21 Dec 2021 08:52:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJynUwq0ebq3Tp/1/8+3f5AzAoHuITSBxGLilNVwDl3eCsXx1opjefQKOOrFGTqelzD7ZHo7 X-Received: by 2002:a25:ec07:: with SMTP id j7mr5593272ybh.313.1640105578482; Tue, 21 Dec 2021 08:52:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105578; cv=none; d=google.com; s=arc-20160816; b=hDiSyqOhtadhospErA7iZfLT95FJM0hi82iDxOHYblwBs1PcENpI/o7YlIprhzPhbe iVOhEvu1RgsKXZpDab2A3ppRz42E3qaAlOgzQHkB7AHsDEzzh26//5BEK7nSqJvXDYUc k4U4iqNxm2ynXO92PJKNYuEpVIwkRZug3Mh8d0JwhDpukb6iv8LeB6JJ4ZGOiAOXn0mp sCDDltzfspH0cR5XxBOgA1p2eGY83+YRajrO6kB5WNjEYZ2aCiWC+K9dunvy5E8aFvlw OD71SL/rTKV+om/xUKYUcVb4KWJh1iaPZiMVjsr6f/eddHlPAYtgFoJKAA5K+Q0LBL8i zZ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Kxu2jc1N0XAW22KzYj/CQSmUBlnyGwSKAlOvz/imWBo=; b=hLeXDfn3G8oWcMzAY0W+guk4pNXYyMM1dXplUWqTiAvq+UBEmkm0tbAsPD9WdGHac1 LLt87uDy6CeOmMZ2AOzei4f/LvBtsTkmlmyoJXcUrCrzkkGe5taML4lX9m5xwdg74v4s q1Ovms4b/0w/W8MVtWCh4muItnrSwi75uqFxx6LsgfX5Kr/0vfSiEiU+KXojeR+rKQkT cDYrKDZVKjvozZnnRaJYICkLah4ZIAfIOgZIWPrHkpAxfMAzzl7t8rByG4tl/ef+qEZC QLqC9fpzd2AOxc6hjOBY5gGrIhjE5Vg85ZRW1yn9fMNuoSRiwV9w3lVFZDT8IOsKAnTr mvpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y0nHkSbi; 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 v45si5709700ybi.811.2021.12.21.08.52.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:52:58 -0800 (PST) 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=y0nHkSbi; 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]:45908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziNl-0005mm-SO for patch@linaro.org; Tue, 21 Dec 2021 11:52:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIj-0008Gk-0Q for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:45 -0500 Received: from [2607:f8b0:4864:20::42a] (port=39527 helo=mail-pf1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIh-0007aQ-8D for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:44 -0500 Received: by mail-pf1-x42a.google.com with SMTP id s15so1736663pfk.6 for ; Tue, 21 Dec 2021 08:47:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kxu2jc1N0XAW22KzYj/CQSmUBlnyGwSKAlOvz/imWBo=; b=y0nHkSbil/DVwbssdDx6ugkFBI4T04HpsQQUDS6qOUVeZptIbWAzdmEp7YR2rvqsg2 h8h8fXlK9xgZVTvXTpJonuL8Wtw3hvyIIVqGiwsNyuB8UlaoLcglk1FaIjVtkFlNSp43 vDxxpa07Dl40gQIp2AtpCxaUFgy2L3xZQBmKr55/e/9fMW/1mAm+fjbPi5gGH6xsvvtF 3hGf6LLlyEVu4wqZ7RNNKQgRSG4chB0YLcrIAUbo3Z7g9YvB2sJUi4smnTfwG0BmNdaW 4ExHOchPIoA+4rkbybn7+8A2TvgBMMjhAOXYK3Tp0h+96IAmK4C9jhDGq9qJHgSTCyHx XVAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kxu2jc1N0XAW22KzYj/CQSmUBlnyGwSKAlOvz/imWBo=; b=lsn429HdxUPs/I/qg+9PHtvbDrHKTPd8NxNywW3eBdvzJ9wj18mqoulKHHCD6G/sqb LQ27UpXncDOT9JOZc8YUASSTADa80gOnjGKRr5rQvVnc/Upc7dLyoCTrtEHMeN9yTvXJ ZnxYrGit3ln1QSIBhaU2jzgP3haea0Uk1THzr+JtGxuPqSYhEPVqFccZM6xuEu2boj70 dWFjC1YN9iRXRT+pX/tGB2Cehjm+tYSsSr3eDqoxX8P55jFpwHFLVzr/U/eJR0S8FAEw t/5XvuTBGGy4xH+3z+rQIjAOKra7jS0R6bGRR/nwK0mrGcDr2myiaBM1XdsAZFyMzvsk RAgg== X-Gm-Message-State: AOAM533dI+bqX+L6Y4YkQW+jv2s5zQmdIrs77D3eF5qPoah8tE9UXXpq dTApuhu+6pGlEeWQa1hExpcwzPzsbpVz3w== X-Received: by 2002:a63:4a5f:: with SMTP id j31mr3681554pgl.222.1640105261919; Tue, 21 Dec 2021 08:47:41 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/31] tcg/loongarch64: Add the tcg-target.h file Date: Tue, 21 Dec 2021 08:47:09 -0800 Message-Id: <20211221164737.1076007-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42a (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Support for all optional TCG ops are initially marked disabled; the bits are to be set in individual commits later. Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-4-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.h | 180 +++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 tcg/loongarch64/tcg-target.h diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h new file mode 100644 index 0000000000..25328646f0 --- /dev/null +++ b/tcg/loongarch64/tcg-target.h @@ -0,0 +1,180 @@ +/* + * Tiny Code Generator for QEMU + * + * Copyright (c) 2021 WANG Xuerui + * + * Based on tcg/riscv/tcg-target.h + * + * Copyright (c) 2018 SiFive, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef LOONGARCH_TCG_TARGET_H +#define LOONGARCH_TCG_TARGET_H + +/* + * Loongson removed the (incomplete) 32-bit support from kernel and toolchain + * for the initial upstreaming of this architecture, so don't bother and just + * support the LP64* ABI for now. + */ +#if defined(__loongarch64) +# define TCG_TARGET_REG_BITS 64 +#else +# error unsupported LoongArch register size +#endif + +#define TCG_TARGET_INSN_UNIT_SIZE 4 +#define TCG_TARGET_NB_REGS 32 +#define MAX_CODE_GEN_BUFFER_SIZE SIZE_MAX + +typedef enum { + TCG_REG_ZERO, + TCG_REG_RA, + TCG_REG_TP, + TCG_REG_SP, + TCG_REG_A0, + TCG_REG_A1, + TCG_REG_A2, + TCG_REG_A3, + TCG_REG_A4, + TCG_REG_A5, + TCG_REG_A6, + TCG_REG_A7, + TCG_REG_T0, + TCG_REG_T1, + TCG_REG_T2, + TCG_REG_T3, + TCG_REG_T4, + TCG_REG_T5, + TCG_REG_T6, + TCG_REG_T7, + TCG_REG_T8, + TCG_REG_RESERVED, + TCG_REG_S9, + TCG_REG_S0, + TCG_REG_S1, + TCG_REG_S2, + TCG_REG_S3, + TCG_REG_S4, + TCG_REG_S5, + TCG_REG_S6, + TCG_REG_S7, + TCG_REG_S8, + + /* aliases */ + TCG_AREG0 = TCG_REG_S0, + TCG_REG_TMP0 = TCG_REG_T8, + TCG_REG_TMP1 = TCG_REG_T7, + TCG_REG_TMP2 = TCG_REG_T6, +} TCGReg; + +/* used for function call generation */ +#define TCG_REG_CALL_STACK TCG_REG_SP +#define TCG_TARGET_STACK_ALIGN 16 +#define TCG_TARGET_CALL_ALIGN_ARGS 1 +#define TCG_TARGET_CALL_STACK_OFFSET 0 + +/* optional instructions */ +#define TCG_TARGET_HAS_movcond_i32 0 +#define TCG_TARGET_HAS_div_i32 0 +#define TCG_TARGET_HAS_rem_i32 0 +#define TCG_TARGET_HAS_div2_i32 0 +#define TCG_TARGET_HAS_rot_i32 0 +#define TCG_TARGET_HAS_deposit_i32 0 +#define TCG_TARGET_HAS_extract_i32 0 +#define TCG_TARGET_HAS_sextract_i32 0 +#define TCG_TARGET_HAS_extract2_i32 0 +#define TCG_TARGET_HAS_add2_i32 0 +#define TCG_TARGET_HAS_sub2_i32 0 +#define TCG_TARGET_HAS_mulu2_i32 0 +#define TCG_TARGET_HAS_muls2_i32 0 +#define TCG_TARGET_HAS_muluh_i32 0 +#define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_ext8s_i32 0 +#define TCG_TARGET_HAS_ext16s_i32 0 +#define TCG_TARGET_HAS_ext8u_i32 0 +#define TCG_TARGET_HAS_ext16u_i32 0 +#define TCG_TARGET_HAS_bswap16_i32 0 +#define TCG_TARGET_HAS_bswap32_i32 0 +#define TCG_TARGET_HAS_not_i32 0 +#define TCG_TARGET_HAS_neg_i32 0 +#define TCG_TARGET_HAS_andc_i32 0 +#define TCG_TARGET_HAS_orc_i32 0 +#define TCG_TARGET_HAS_eqv_i32 0 +#define TCG_TARGET_HAS_nand_i32 0 +#define TCG_TARGET_HAS_nor_i32 0 +#define TCG_TARGET_HAS_clz_i32 0 +#define TCG_TARGET_HAS_ctz_i32 0 +#define TCG_TARGET_HAS_ctpop_i32 0 +#define TCG_TARGET_HAS_direct_jump 0 +#define TCG_TARGET_HAS_brcond2 0 +#define TCG_TARGET_HAS_setcond2 0 +#define TCG_TARGET_HAS_qemu_st8_i32 0 + +/* 64-bit operations */ +#define TCG_TARGET_HAS_movcond_i64 0 +#define TCG_TARGET_HAS_div_i64 0 +#define TCG_TARGET_HAS_rem_i64 0 +#define TCG_TARGET_HAS_div2_i64 0 +#define TCG_TARGET_HAS_rot_i64 0 +#define TCG_TARGET_HAS_deposit_i64 0 +#define TCG_TARGET_HAS_extract_i64 0 +#define TCG_TARGET_HAS_sextract_i64 0 +#define TCG_TARGET_HAS_extract2_i64 0 +#define TCG_TARGET_HAS_extrl_i64_i32 0 +#define TCG_TARGET_HAS_extrh_i64_i32 0 +#define TCG_TARGET_HAS_ext8s_i64 0 +#define TCG_TARGET_HAS_ext16s_i64 0 +#define TCG_TARGET_HAS_ext32s_i64 0 +#define TCG_TARGET_HAS_ext8u_i64 0 +#define TCG_TARGET_HAS_ext16u_i64 0 +#define TCG_TARGET_HAS_ext32u_i64 0 +#define TCG_TARGET_HAS_bswap16_i64 0 +#define TCG_TARGET_HAS_bswap32_i64 0 +#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_not_i64 0 +#define TCG_TARGET_HAS_neg_i64 0 +#define TCG_TARGET_HAS_andc_i64 0 +#define TCG_TARGET_HAS_orc_i64 0 +#define TCG_TARGET_HAS_eqv_i64 0 +#define TCG_TARGET_HAS_nand_i64 0 +#define TCG_TARGET_HAS_nor_i64 0 +#define TCG_TARGET_HAS_clz_i64 0 +#define TCG_TARGET_HAS_ctz_i64 0 +#define TCG_TARGET_HAS_ctpop_i64 0 +#define TCG_TARGET_HAS_add2_i64 0 +#define TCG_TARGET_HAS_sub2_i64 0 +#define TCG_TARGET_HAS_mulu2_i64 0 +#define TCG_TARGET_HAS_muls2_i64 0 +#define TCG_TARGET_HAS_muluh_i64 0 +#define TCG_TARGET_HAS_mulsh_i64 0 + +/* not defined -- call should be eliminated at compile time */ +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); + +#define TCG_TARGET_DEFAULT_MO (0) + +#ifdef CONFIG_SOFTMMU +#define TCG_TARGET_NEED_LDST_LABELS +#endif + +#define TCG_TARGET_HAS_MEMORY_BSWAP 0 + +#endif /* LOONGARCH_TCG_TARGET_H */ From patchwork Tue Dec 21 16:47:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526601 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5225760imb; Tue, 21 Dec 2021 08:53:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzt93JemE8ndLsXrTNuSMalwEcroTdrV++ITewP6BczxRuWsxUPK1bzYwQDOx3Ubvz0sizM X-Received: by 2002:a25:b13:: with SMTP id 19mr5970949ybl.71.1640105583828; Tue, 21 Dec 2021 08:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105583; cv=none; d=google.com; s=arc-20160816; b=FksNXxMvRVPHfXk9p/keK0yi2dI1oezA8lM+/zemI+7ZARsIfuBhLk2NMWq6EU5fSV xsgqmVEbxWMssCmG7fMA3qwdzs8sAoCNtGsesjZoIoBJDPvRUKTJ/lgyjYCClZL+KyAV HUJnDsEVLRJQd0EMswSh+eN7uDm6neiMnY/+v1FlILyBo24+yImnUkwMU4CPGEYPbZ35 1D3AOn/HUswEkj54xQlrZBzMDJ/L2lGIiNqJNNYaQfMgUR/gMOP8bcUimTMvU1hXjeSH TFrOxMu4133DYTzhYOskBlhKudirQXhO2UPzLesJshDGufkW/qyCzJ/Ee6lUZzU2NLqA Fw+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9cEJSIOjFY5S3or8G90ik7DoOHrbwbltaeLuXbnK/r4=; b=xuo0J7qTEoSd4w8mTW0cWwxS7a8yK5sfTMkipAU6ozgwKoy6xojQ8OHkkIZ8CNwfbN I10V8COjZxm12Z47HazvVp+Je0t3aII9kCHv4vFGXz59FhD36TkXhH/FM44+R3yeMDm1 rajwWCKQG9ZDixy1M67GKDtD+Itge+Dlqt4/4q3UevihU6YyJoCJexfPORbKEtT7brze Mb6kgh/tQUxaoHu3SlxYQDPoJ/BtCwiVqTvmCHrB1BnyT+VmsKZpaVqAq2nSOtCqKusr uU6HqHyg1dqQw7VwQZJugjbUf0dzi+MaPWu6EzcSr1tfl7Dc1hAiCHCjXmeKuueDpu0r i+Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A8WN5xTS; 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 69si20214771ybc.398.2021.12.21.08.53.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:53:03 -0800 (PST) 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=A8WN5xTS; 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]:45986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziNr-0005pq-64 for patch@linaro.org; Tue, 21 Dec 2021 11:53:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIq-0008MP-2N for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:52 -0500 Received: from [2607:f8b0:4864:20::1032] (port=43954 helo=mail-pj1-x1032.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIi-0007an-MF for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:49 -0500 Received: by mail-pj1-x1032.google.com with SMTP id a11-20020a17090a854b00b001b11aae38d6so3737976pjw.2 for ; Tue, 21 Dec 2021 08:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9cEJSIOjFY5S3or8G90ik7DoOHrbwbltaeLuXbnK/r4=; b=A8WN5xTSqsFNG0rMNiS9lZUfObeWJgojcj6v9h0XEuoMl56D9I2nUbrLJbAskkIp1G XG3mEuoz/8ayImDO2bD4mYH1Tgftt8/lQwlGyWY0R8zI+tNK9jMCyGjjoLcurpWvAxNs xKkgaJVWugcvIiCXWsT79LzCA1mK5qXHQIsMzbbwRghOtufs20yLVZ+pRar70V8xXWkh VV886fYYa4HDCkQ7PegkvpB0Vp5W9HHDfmkImK8QigC7xfqeuFLljhqhcOPMz3taI8WY I/dmxID0yZ/Y3Su9iQNNRQ88is4hFRjC1b1SpQtiVg6RUGt9YI2rTZdD4aIJEsnUBVcE mEqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9cEJSIOjFY5S3or8G90ik7DoOHrbwbltaeLuXbnK/r4=; b=XZ3G0nG4+OFqnw7gpEJuXowqzTAcEvqhFmsfeSLinP08Si927y6Np5KzPXF+MU0iPv MkzxJEoQ9N7/Dywnz6fmMUtt6mHpiADC/UkkMnhiom3MBXwFVw5GBOhNVTSs89aYtzIu aUvwItp4WvKQxCQdXL/KAX66KxmaRGzZBoRuCDc7Ktnw6bV/ohMh5ZHKjMDoWqzHxE+3 pP4kQxZGlBJ2pQqXITxnIwMKcbTvyvwODHgD5HP1KGaAqaAbx4JPj7f/sRfijhvju45R 9IfgrqkVac83oPqbSGgT8mpLe41nHzXF/UeX385fkeYgMGn0q3hD/OSojTP2s8qW70c/ P8mA== X-Gm-Message-State: AOAM5307JxUg3HAPudG9cGvemPTxpzOktCvgm5yDJSEjfEa0xd5oz8Nh PEHUC+sfjP4KB3ZHgUeAuIEFmTRTTvXWrA== X-Received: by 2002:a17:90a:4894:: with SMTP id b20mr5001948pjh.207.1640105262844; Tue, 21 Dec 2021 08:47:42 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/31] tcg/loongarch64: Add generated instruction opcodes and encoding helpers Date: Tue, 21 Dec 2021 08:47:10 -0800 Message-Id: <20211221164737.1076007-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1032 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Philippe Mathieu-Daudé Acked-by: Richard Henderson Message-Id: <20211221054105.178795-5-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-insn-defs.c.inc | 979 ++++++++++++++++++++++++++++ 1 file changed, 979 insertions(+) create mode 100644 tcg/loongarch64/tcg-insn-defs.c.inc diff --git a/tcg/loongarch64/tcg-insn-defs.c.inc b/tcg/loongarch64/tcg-insn-defs.c.inc new file mode 100644 index 0000000000..d162571856 --- /dev/null +++ b/tcg/loongarch64/tcg-insn-defs.c.inc @@ -0,0 +1,979 @@ +/* SPDX-License-Identifier: MIT */ +/* + * LoongArch instruction formats, opcodes, and encoders for TCG use. + * + * This file is auto-generated by genqemutcgdefs from + * https://github.com/loongson-community/loongarch-opcodes, + * from commit 961f0c60f5b63e574d785995600c71ad5413fdc4. + * DO NOT EDIT. + */ + +typedef enum { + OPC_CLZ_W = 0x00001400, + OPC_CTZ_W = 0x00001c00, + OPC_CLZ_D = 0x00002400, + OPC_CTZ_D = 0x00002c00, + OPC_REVB_2H = 0x00003000, + OPC_REVB_2W = 0x00003800, + OPC_REVB_D = 0x00003c00, + OPC_SEXT_H = 0x00005800, + OPC_SEXT_B = 0x00005c00, + OPC_ADD_W = 0x00100000, + OPC_ADD_D = 0x00108000, + OPC_SUB_W = 0x00110000, + OPC_SUB_D = 0x00118000, + OPC_SLT = 0x00120000, + OPC_SLTU = 0x00128000, + OPC_MASKEQZ = 0x00130000, + OPC_MASKNEZ = 0x00138000, + OPC_NOR = 0x00140000, + OPC_AND = 0x00148000, + OPC_OR = 0x00150000, + OPC_XOR = 0x00158000, + OPC_ORN = 0x00160000, + OPC_ANDN = 0x00168000, + OPC_SLL_W = 0x00170000, + OPC_SRL_W = 0x00178000, + OPC_SRA_W = 0x00180000, + OPC_SLL_D = 0x00188000, + OPC_SRL_D = 0x00190000, + OPC_SRA_D = 0x00198000, + OPC_ROTR_W = 0x001b0000, + OPC_ROTR_D = 0x001b8000, + OPC_MUL_W = 0x001c0000, + OPC_MULH_W = 0x001c8000, + OPC_MULH_WU = 0x001d0000, + OPC_MUL_D = 0x001d8000, + OPC_MULH_D = 0x001e0000, + OPC_MULH_DU = 0x001e8000, + OPC_DIV_W = 0x00200000, + OPC_MOD_W = 0x00208000, + OPC_DIV_WU = 0x00210000, + OPC_MOD_WU = 0x00218000, + OPC_DIV_D = 0x00220000, + OPC_MOD_D = 0x00228000, + OPC_DIV_DU = 0x00230000, + OPC_MOD_DU = 0x00238000, + OPC_SLLI_W = 0x00408000, + OPC_SLLI_D = 0x00410000, + OPC_SRLI_W = 0x00448000, + OPC_SRLI_D = 0x00450000, + OPC_SRAI_W = 0x00488000, + OPC_SRAI_D = 0x00490000, + OPC_ROTRI_W = 0x004c8000, + OPC_ROTRI_D = 0x004d0000, + OPC_BSTRINS_W = 0x00600000, + OPC_BSTRPICK_W = 0x00608000, + OPC_BSTRINS_D = 0x00800000, + OPC_BSTRPICK_D = 0x00c00000, + OPC_SLTI = 0x02000000, + OPC_SLTUI = 0x02400000, + OPC_ADDI_W = 0x02800000, + OPC_ADDI_D = 0x02c00000, + OPC_CU52I_D = 0x03000000, + OPC_ANDI = 0x03400000, + OPC_ORI = 0x03800000, + OPC_XORI = 0x03c00000, + OPC_LU12I_W = 0x14000000, + OPC_CU32I_D = 0x16000000, + OPC_PCADDU2I = 0x18000000, + OPC_PCALAU12I = 0x1a000000, + OPC_PCADDU12I = 0x1c000000, + OPC_PCADDU18I = 0x1e000000, + OPC_LD_B = 0x28000000, + OPC_LD_H = 0x28400000, + OPC_LD_W = 0x28800000, + OPC_LD_D = 0x28c00000, + OPC_ST_B = 0x29000000, + OPC_ST_H = 0x29400000, + OPC_ST_W = 0x29800000, + OPC_ST_D = 0x29c00000, + OPC_LD_BU = 0x2a000000, + OPC_LD_HU = 0x2a400000, + OPC_LD_WU = 0x2a800000, + OPC_LDX_B = 0x38000000, + OPC_LDX_H = 0x38040000, + OPC_LDX_W = 0x38080000, + OPC_LDX_D = 0x380c0000, + OPC_STX_B = 0x38100000, + OPC_STX_H = 0x38140000, + OPC_STX_W = 0x38180000, + OPC_STX_D = 0x381c0000, + OPC_LDX_BU = 0x38200000, + OPC_LDX_HU = 0x38240000, + OPC_LDX_WU = 0x38280000, + OPC_DBAR = 0x38720000, + OPC_JIRL = 0x4c000000, + OPC_B = 0x50000000, + OPC_BL = 0x54000000, + OPC_BEQ = 0x58000000, + OPC_BNE = 0x5c000000, + OPC_BGT = 0x60000000, + OPC_BLE = 0x64000000, + OPC_BGTU = 0x68000000, + OPC_BLEU = 0x6c000000, +} LoongArchInsn; + +static int32_t __attribute__((unused)) +encode_d_slot(LoongArchInsn opc, uint32_t d) +{ + return opc | d; +} + +static int32_t __attribute__((unused)) +encode_dj_slots(LoongArchInsn opc, uint32_t d, uint32_t j) +{ + return opc | d | j << 5; +} + +static int32_t __attribute__((unused)) +encode_djk_slots(LoongArchInsn opc, uint32_t d, uint32_t j, uint32_t k) +{ + return opc | d | j << 5 | k << 10; +} + +static int32_t __attribute__((unused)) +encode_djkm_slots(LoongArchInsn opc, uint32_t d, uint32_t j, uint32_t k, + uint32_t m) +{ + return opc | d | j << 5 | k << 10 | m << 16; +} + +static int32_t __attribute__((unused)) +encode_dk_slots(LoongArchInsn opc, uint32_t d, uint32_t k) +{ + return opc | d | k << 10; +} + +static int32_t __attribute__((unused)) +encode_dj_insn(LoongArchInsn opc, TCGReg d, TCGReg j) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + return encode_dj_slots(opc, d, j); +} + +static int32_t __attribute__((unused)) +encode_djk_insn(LoongArchInsn opc, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(k >= 0 && k <= 0x1f); + return encode_djk_slots(opc, d, j, k); +} + +static int32_t __attribute__((unused)) +encode_djsk12_insn(LoongArchInsn opc, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(sk12 >= -0x800 && sk12 <= 0x7ff); + return encode_djk_slots(opc, d, j, sk12 & 0xfff); +} + +static int32_t __attribute__((unused)) +encode_djsk16_insn(LoongArchInsn opc, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(sk16 >= -0x8000 && sk16 <= 0x7fff); + return encode_djk_slots(opc, d, j, sk16 & 0xffff); +} + +static int32_t __attribute__((unused)) +encode_djuk12_insn(LoongArchInsn opc, TCGReg d, TCGReg j, uint32_t uk12) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(uk12 <= 0xfff); + return encode_djk_slots(opc, d, j, uk12); +} + +static int32_t __attribute__((unused)) +encode_djuk5_insn(LoongArchInsn opc, TCGReg d, TCGReg j, uint32_t uk5) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(uk5 <= 0x1f); + return encode_djk_slots(opc, d, j, uk5); +} + +static int32_t __attribute__((unused)) +encode_djuk5um5_insn(LoongArchInsn opc, TCGReg d, TCGReg j, uint32_t uk5, + uint32_t um5) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(uk5 <= 0x1f); + tcg_debug_assert(um5 <= 0x1f); + return encode_djkm_slots(opc, d, j, uk5, um5); +} + +static int32_t __attribute__((unused)) +encode_djuk6_insn(LoongArchInsn opc, TCGReg d, TCGReg j, uint32_t uk6) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(uk6 <= 0x3f); + return encode_djk_slots(opc, d, j, uk6); +} + +static int32_t __attribute__((unused)) +encode_djuk6um6_insn(LoongArchInsn opc, TCGReg d, TCGReg j, uint32_t uk6, + uint32_t um6) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(j >= 0 && j <= 0x1f); + tcg_debug_assert(uk6 <= 0x3f); + tcg_debug_assert(um6 <= 0x3f); + return encode_djkm_slots(opc, d, j, uk6, um6); +} + +static int32_t __attribute__((unused)) +encode_dsj20_insn(LoongArchInsn opc, TCGReg d, int32_t sj20) +{ + tcg_debug_assert(d >= 0 && d <= 0x1f); + tcg_debug_assert(sj20 >= -0x80000 && sj20 <= 0x7ffff); + return encode_dj_slots(opc, d, sj20 & 0xfffff); +} + +static int32_t __attribute__((unused)) +encode_sd10k16_insn(LoongArchInsn opc, int32_t sd10k16) +{ + tcg_debug_assert(sd10k16 >= -0x2000000 && sd10k16 <= 0x1ffffff); + return encode_dk_slots(opc, (sd10k16 >> 16) & 0x3ff, sd10k16 & 0xffff); +} + +static int32_t __attribute__((unused)) +encode_ud15_insn(LoongArchInsn opc, uint32_t ud15) +{ + tcg_debug_assert(ud15 <= 0x7fff); + return encode_d_slot(opc, ud15); +} + +/* Emits the `clz.w d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_clz_w(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_CLZ_W, d, j)); +} + +/* Emits the `ctz.w d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ctz_w(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_CTZ_W, d, j)); +} + +/* Emits the `clz.d d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_clz_d(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_CLZ_D, d, j)); +} + +/* Emits the `ctz.d d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ctz_d(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_CTZ_D, d, j)); +} + +/* Emits the `revb.2h d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_revb_2h(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_REVB_2H, d, j)); +} + +/* Emits the `revb.2w d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_revb_2w(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_REVB_2W, d, j)); +} + +/* Emits the `revb.d d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_revb_d(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_REVB_D, d, j)); +} + +/* Emits the `sext.h d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sext_h(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_SEXT_H, d, j)); +} + +/* Emits the `sext.b d, j` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sext_b(TCGContext *s, TCGReg d, TCGReg j) +{ + tcg_out32(s, encode_dj_insn(OPC_SEXT_B, d, j)); +} + +/* Emits the `add.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_add_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_ADD_W, d, j, k)); +} + +/* Emits the `add.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_add_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_ADD_D, d, j, k)); +} + +/* Emits the `sub.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sub_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SUB_W, d, j, k)); +} + +/* Emits the `sub.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sub_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SUB_D, d, j, k)); +} + +/* Emits the `slt d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_slt(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SLT, d, j, k)); +} + +/* Emits the `sltu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sltu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SLTU, d, j, k)); +} + +/* Emits the `maskeqz d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_maskeqz(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MASKEQZ, d, j, k)); +} + +/* Emits the `masknez d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_masknez(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MASKNEZ, d, j, k)); +} + +/* Emits the `nor d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_nor(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_NOR, d, j, k)); +} + +/* Emits the `and d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_and(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_AND, d, j, k)); +} + +/* Emits the `or d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_or(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_OR, d, j, k)); +} + +/* Emits the `xor d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_xor(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_XOR, d, j, k)); +} + +/* Emits the `orn d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_orn(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_ORN, d, j, k)); +} + +/* Emits the `andn d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_andn(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_ANDN, d, j, k)); +} + +/* Emits the `sll.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sll_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SLL_W, d, j, k)); +} + +/* Emits the `srl.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_srl_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SRL_W, d, j, k)); +} + +/* Emits the `sra.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sra_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SRA_W, d, j, k)); +} + +/* Emits the `sll.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sll_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SLL_D, d, j, k)); +} + +/* Emits the `srl.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_srl_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SRL_D, d, j, k)); +} + +/* Emits the `sra.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sra_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_SRA_D, d, j, k)); +} + +/* Emits the `rotr.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_rotr_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_ROTR_W, d, j, k)); +} + +/* Emits the `rotr.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_rotr_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_ROTR_D, d, j, k)); +} + +/* Emits the `mul.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mul_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MUL_W, d, j, k)); +} + +/* Emits the `mulh.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mulh_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MULH_W, d, j, k)); +} + +/* Emits the `mulh.wu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mulh_wu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MULH_WU, d, j, k)); +} + +/* Emits the `mul.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mul_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MUL_D, d, j, k)); +} + +/* Emits the `mulh.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mulh_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MULH_D, d, j, k)); +} + +/* Emits the `mulh.du d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mulh_du(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MULH_DU, d, j, k)); +} + +/* Emits the `div.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_div_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_DIV_W, d, j, k)); +} + +/* Emits the `mod.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mod_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MOD_W, d, j, k)); +} + +/* Emits the `div.wu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_div_wu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_DIV_WU, d, j, k)); +} + +/* Emits the `mod.wu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mod_wu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MOD_WU, d, j, k)); +} + +/* Emits the `div.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_div_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_DIV_D, d, j, k)); +} + +/* Emits the `mod.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mod_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MOD_D, d, j, k)); +} + +/* Emits the `div.du d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_div_du(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_DIV_DU, d, j, k)); +} + +/* Emits the `mod.du d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_mod_du(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_MOD_DU, d, j, k)); +} + +/* Emits the `slli.w d, j, uk5` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_slli_w(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk5) +{ + tcg_out32(s, encode_djuk5_insn(OPC_SLLI_W, d, j, uk5)); +} + +/* Emits the `slli.d d, j, uk6` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_slli_d(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk6) +{ + tcg_out32(s, encode_djuk6_insn(OPC_SLLI_D, d, j, uk6)); +} + +/* Emits the `srli.w d, j, uk5` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_srli_w(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk5) +{ + tcg_out32(s, encode_djuk5_insn(OPC_SRLI_W, d, j, uk5)); +} + +/* Emits the `srli.d d, j, uk6` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_srli_d(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk6) +{ + tcg_out32(s, encode_djuk6_insn(OPC_SRLI_D, d, j, uk6)); +} + +/* Emits the `srai.w d, j, uk5` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_srai_w(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk5) +{ + tcg_out32(s, encode_djuk5_insn(OPC_SRAI_W, d, j, uk5)); +} + +/* Emits the `srai.d d, j, uk6` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_srai_d(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk6) +{ + tcg_out32(s, encode_djuk6_insn(OPC_SRAI_D, d, j, uk6)); +} + +/* Emits the `rotri.w d, j, uk5` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_rotri_w(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk5) +{ + tcg_out32(s, encode_djuk5_insn(OPC_ROTRI_W, d, j, uk5)); +} + +/* Emits the `rotri.d d, j, uk6` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_rotri_d(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk6) +{ + tcg_out32(s, encode_djuk6_insn(OPC_ROTRI_D, d, j, uk6)); +} + +/* Emits the `bstrins.w d, j, uk5, um5` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bstrins_w(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk5, + uint32_t um5) +{ + tcg_out32(s, encode_djuk5um5_insn(OPC_BSTRINS_W, d, j, uk5, um5)); +} + +/* Emits the `bstrpick.w d, j, uk5, um5` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bstrpick_w(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk5, + uint32_t um5) +{ + tcg_out32(s, encode_djuk5um5_insn(OPC_BSTRPICK_W, d, j, uk5, um5)); +} + +/* Emits the `bstrins.d d, j, uk6, um6` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bstrins_d(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk6, + uint32_t um6) +{ + tcg_out32(s, encode_djuk6um6_insn(OPC_BSTRINS_D, d, j, uk6, um6)); +} + +/* Emits the `bstrpick.d d, j, uk6, um6` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bstrpick_d(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk6, + uint32_t um6) +{ + tcg_out32(s, encode_djuk6um6_insn(OPC_BSTRPICK_D, d, j, uk6, um6)); +} + +/* Emits the `slti d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_slti(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_SLTI, d, j, sk12)); +} + +/* Emits the `sltui d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_sltui(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_SLTUI, d, j, sk12)); +} + +/* Emits the `addi.w d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_addi_w(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_ADDI_W, d, j, sk12)); +} + +/* Emits the `addi.d d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_addi_d(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_ADDI_D, d, j, sk12)); +} + +/* Emits the `cu52i.d d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_cu52i_d(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_CU52I_D, d, j, sk12)); +} + +/* Emits the `andi d, j, uk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_andi(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk12) +{ + tcg_out32(s, encode_djuk12_insn(OPC_ANDI, d, j, uk12)); +} + +/* Emits the `ori d, j, uk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ori(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk12) +{ + tcg_out32(s, encode_djuk12_insn(OPC_ORI, d, j, uk12)); +} + +/* Emits the `xori d, j, uk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_xori(TCGContext *s, TCGReg d, TCGReg j, uint32_t uk12) +{ + tcg_out32(s, encode_djuk12_insn(OPC_XORI, d, j, uk12)); +} + +/* Emits the `lu12i.w d, sj20` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_lu12i_w(TCGContext *s, TCGReg d, int32_t sj20) +{ + tcg_out32(s, encode_dsj20_insn(OPC_LU12I_W, d, sj20)); +} + +/* Emits the `cu32i.d d, sj20` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_cu32i_d(TCGContext *s, TCGReg d, int32_t sj20) +{ + tcg_out32(s, encode_dsj20_insn(OPC_CU32I_D, d, sj20)); +} + +/* Emits the `pcaddu2i d, sj20` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_pcaddu2i(TCGContext *s, TCGReg d, int32_t sj20) +{ + tcg_out32(s, encode_dsj20_insn(OPC_PCADDU2I, d, sj20)); +} + +/* Emits the `pcalau12i d, sj20` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_pcalau12i(TCGContext *s, TCGReg d, int32_t sj20) +{ + tcg_out32(s, encode_dsj20_insn(OPC_PCALAU12I, d, sj20)); +} + +/* Emits the `pcaddu12i d, sj20` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_pcaddu12i(TCGContext *s, TCGReg d, int32_t sj20) +{ + tcg_out32(s, encode_dsj20_insn(OPC_PCADDU12I, d, sj20)); +} + +/* Emits the `pcaddu18i d, sj20` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_pcaddu18i(TCGContext *s, TCGReg d, int32_t sj20) +{ + tcg_out32(s, encode_dsj20_insn(OPC_PCADDU18I, d, sj20)); +} + +/* Emits the `ld.b d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_b(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_B, d, j, sk12)); +} + +/* Emits the `ld.h d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_h(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_H, d, j, sk12)); +} + +/* Emits the `ld.w d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_w(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_W, d, j, sk12)); +} + +/* Emits the `ld.d d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_d(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_D, d, j, sk12)); +} + +/* Emits the `st.b d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_st_b(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_ST_B, d, j, sk12)); +} + +/* Emits the `st.h d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_st_h(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_ST_H, d, j, sk12)); +} + +/* Emits the `st.w d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_st_w(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_ST_W, d, j, sk12)); +} + +/* Emits the `st.d d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_st_d(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_ST_D, d, j, sk12)); +} + +/* Emits the `ld.bu d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_bu(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_BU, d, j, sk12)); +} + +/* Emits the `ld.hu d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_hu(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_HU, d, j, sk12)); +} + +/* Emits the `ld.wu d, j, sk12` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ld_wu(TCGContext *s, TCGReg d, TCGReg j, int32_t sk12) +{ + tcg_out32(s, encode_djsk12_insn(OPC_LD_WU, d, j, sk12)); +} + +/* Emits the `ldx.b d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_b(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_B, d, j, k)); +} + +/* Emits the `ldx.h d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_h(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_H, d, j, k)); +} + +/* Emits the `ldx.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_W, d, j, k)); +} + +/* Emits the `ldx.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_D, d, j, k)); +} + +/* Emits the `stx.b d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_stx_b(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_STX_B, d, j, k)); +} + +/* Emits the `stx.h d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_stx_h(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_STX_H, d, j, k)); +} + +/* Emits the `stx.w d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_stx_w(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_STX_W, d, j, k)); +} + +/* Emits the `stx.d d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_stx_d(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_STX_D, d, j, k)); +} + +/* Emits the `ldx.bu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_bu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_BU, d, j, k)); +} + +/* Emits the `ldx.hu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_hu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_HU, d, j, k)); +} + +/* Emits the `ldx.wu d, j, k` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ldx_wu(TCGContext *s, TCGReg d, TCGReg j, TCGReg k) +{ + tcg_out32(s, encode_djk_insn(OPC_LDX_WU, d, j, k)); +} + +/* Emits the `dbar ud15` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_dbar(TCGContext *s, uint32_t ud15) +{ + tcg_out32(s, encode_ud15_insn(OPC_DBAR, ud15)); +} + +/* Emits the `jirl d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_jirl(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_JIRL, d, j, sk16)); +} + +/* Emits the `b sd10k16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_b(TCGContext *s, int32_t sd10k16) +{ + tcg_out32(s, encode_sd10k16_insn(OPC_B, sd10k16)); +} + +/* Emits the `bl sd10k16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bl(TCGContext *s, int32_t sd10k16) +{ + tcg_out32(s, encode_sd10k16_insn(OPC_BL, sd10k16)); +} + +/* Emits the `beq d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_beq(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_BEQ, d, j, sk16)); +} + +/* Emits the `bne d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bne(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_BNE, d, j, sk16)); +} + +/* Emits the `bgt d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bgt(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_BGT, d, j, sk16)); +} + +/* Emits the `ble d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_ble(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_BLE, d, j, sk16)); +} + +/* Emits the `bgtu d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bgtu(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_BGTU, d, j, sk16)); +} + +/* Emits the `bleu d, j, sk16` instruction. */ +static void __attribute__((unused)) +tcg_out_opc_bleu(TCGContext *s, TCGReg d, TCGReg j, int32_t sk16) +{ + tcg_out32(s, encode_djsk16_insn(OPC_BLEU, d, j, sk16)); +} + +/* End of generated code. */ From patchwork Tue Dec 21 16:47:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526599 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5225682imb; Tue, 21 Dec 2021 08:52:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJy55boEmeUwAvb53VS5mxo8ISGtjRIQh9eiWyGP2JXdc547jk6hFJlNZBkXJXW5BBZGzyWO X-Received: by 2002:a02:878b:: with SMTP id t11mr2499519jai.226.1640105577722; Tue, 21 Dec 2021 08:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105577; cv=none; d=google.com; s=arc-20160816; b=b4RZGieDqIR0/mP/6Cz/IuAKN6fThU/XOJBZ4/nSTRQP7nwXlO0JKI4AMaFyfeDjtg 2e3DR0ubj0cGDrgqUagl811Aoy1lgzxzfQ/RYPtR1FZaTJipD2C2pWmRRJ12MmiWnR/s BZel0m8MmVkikTVHtddLBpYWcsSAO7EKVPeizCDRnoVLKJ1/8HpWlUYOMNaLKCHpJfS+ c2SHxxjn8YvtunmFv1xqX1bKJ92IZ9LIPTN2IzPNxaWil/uZFWNSCRsW6kQgqBmw+GKG 543J1dNOgHrVUpDISkv+8rEq8FZlOGCCehddzNGJL22QjmP8KfxC3yV7SC3ZenRVMbt8 QJ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=oZMFGlzlAMRYV/UR7JxBV1nelVYIW0dbJHkficncfnY=; b=ar87EjsmQDl8buW7b7VSlOLeKS85AW3CZBZgwzyPnC9Q0kDWyRIZxkZKIkEPh49aGP CdEeTUXwTxRCCC+FqRsLpDpLF7d6a7O1Hzj/fKdi70lmc6d2ko0LfB+yi+ApQoCEHmQX YH5M43h1qeUrxQp7YY+XK9r4dx2CkuMjhlIYrqNxcne42deaYIHBcJMi6NQEFZl8fczw AJIedAr0NrhlPxZQDSZhNbDfX6whwruRbgEpA5f6um3GjuOKhXHeQXpkBWsmjFTcR/Kp Mow1FeEo5He/M+r6mo0+XrIQ2DXHp8NfjM6g1k7Y98npoiTYZSBxbNWzklff5vLbNy4P KX1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jHvsVAXW; 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 m12si16793973jav.92.2021.12.21.08.52.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:52:57 -0800 (PST) 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=jHvsVAXW; 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]:45958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziNl-0005oc-7F for patch@linaro.org; Tue, 21 Dec 2021 11:52:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIp-0008MI-1I for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:51 -0500 Received: from [2607:f8b0:4864:20::102c] (port=35839 helo=mail-pj1-x102c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIj-0007as-3U for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:46 -0500 Received: by mail-pj1-x102c.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso3156404pji.0 for ; Tue, 21 Dec 2021 08:47:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oZMFGlzlAMRYV/UR7JxBV1nelVYIW0dbJHkficncfnY=; b=jHvsVAXWGx/YvGZuCWnetVMcnm8llRohA+bupLNZM95+QQqxJiU1etpDLyihAma45u TZAvUjJw/FgdlKs4kJOtmb+Za9s75EPj3+U645lp8KvVwelfOCZIJTpDLvmL98S9BfDQ 8KNv4UQ+di0r/H3MN62nMgAb7lAJI6WUz0B3Rx2hkt0tF94vkYEc1cCUbW/n2mY+evPo oXF0FJ3iHZpp+37O+IYX0G95O69WgAyYR9c+3cDi+0hJcTV/yQFxK8NS5NMG8h4yYV+q +J4N2KxO0pkBzmvu5bwIDgqDsCUvHCjQ+ZOVWjCMHSJebC9+oZPpS/X6QBJP2Z0dvlT8 Zi+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oZMFGlzlAMRYV/UR7JxBV1nelVYIW0dbJHkficncfnY=; b=ZhNve1vzC83TVCG32Hxu54t+rdqnD9mm8mHt84l6hYy6EmXyOvroncacFzjXWBPoL5 0TWKFgRsQjalxZkQI3HaAOBTLrVJrlWB77VOC0Q4yU+NGACz5e/hIVKWFw8SYtNiq+wJ 8bg8AWbicgLVYlt89/zSdIaLOh2vdU2Esmbg3yGvVzACMYxlJ47wK/d+pluZfuQXPd83 JhwG6pghUKds1S1BwabGlWND78lBqfUu4/W3fWZspowTbldsfqH+pYk4xrYaybBV9SdZ sf4x+qkGz2MbgvnKJ48ybXgkMdNVVvOo0aYoJ1hAnOA8QfjzyWxFYfgZSx+4Q9vLDVL0 /HFA== X-Gm-Message-State: AOAM530FHrab4U1hGA2sEa8GjJkhA7EiqjEZT36XiT7YUPWoFhJbJmPz uoJ+g8eoX1TyFQk1MGz1uc4aYVsPIxNpdg== X-Received: by 2002:a17:902:6b46:b0:142:8470:862e with SMTP id g6-20020a1709026b4600b001428470862emr3704981plt.49.1640105263781; Tue, 21 Dec 2021 08:47:43 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/31] tcg/loongarch64: Add register names, allocation order and input/output sets Date: Tue, 21 Dec 2021 08:47:11 -0800 Message-Id: <20211221164737.1076007-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-6-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 118 +++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tcg/loongarch64/tcg-target.c.inc diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc new file mode 100644 index 0000000000..653ef0a4bb --- /dev/null +++ b/tcg/loongarch64/tcg-target.c.inc @@ -0,0 +1,118 @@ +/* + * Tiny Code Generator for QEMU + * + * Copyright (c) 2021 WANG Xuerui + * + * Based on tcg/riscv/tcg-target.c.inc + * + * Copyright (c) 2018 SiFive, Inc + * Copyright (c) 2008-2009 Arnaud Patard + * Copyright (c) 2009 Aurelien Jarno + * Copyright (c) 2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifdef CONFIG_DEBUG_TCG +static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { + "zero", + "ra", + "tp", + "sp", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "t0", + "t1", + "t2", + "t3", + "t4", + "t5", + "t6", + "t7", + "t8", + "r21", /* reserved in the LP64* ABI, hence no ABI name */ + "s9", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8" +}; +#endif + +static const int tcg_target_reg_alloc_order[] = { + /* Registers preserved across calls */ + /* TCG_REG_S0 reserved for TCG_AREG0 */ + TCG_REG_S1, + TCG_REG_S2, + TCG_REG_S3, + TCG_REG_S4, + TCG_REG_S5, + TCG_REG_S6, + TCG_REG_S7, + TCG_REG_S8, + TCG_REG_S9, + + /* Registers (potentially) clobbered across calls */ + TCG_REG_T0, + TCG_REG_T1, + TCG_REG_T2, + TCG_REG_T3, + TCG_REG_T4, + TCG_REG_T5, + TCG_REG_T6, + TCG_REG_T7, + TCG_REG_T8, + + /* Argument registers, opposite order of allocation. */ + TCG_REG_A7, + TCG_REG_A6, + TCG_REG_A5, + TCG_REG_A4, + TCG_REG_A3, + TCG_REG_A2, + TCG_REG_A1, + TCG_REG_A0, +}; + +static const int tcg_target_call_iarg_regs[] = { + TCG_REG_A0, + TCG_REG_A1, + TCG_REG_A2, + TCG_REG_A3, + TCG_REG_A4, + TCG_REG_A5, + TCG_REG_A6, + TCG_REG_A7, +}; + +static const int tcg_target_call_oarg_regs[] = { + TCG_REG_A0, + TCG_REG_A1, +}; From patchwork Tue Dec 21 16:47:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526602 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5225819imb; Tue, 21 Dec 2021 08:53:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIcYn3djVDI4GtrCvFBLKBUxUUO2MDTD9JXWRJN8+VAdRVXLnKixMU4gkYVaTiZ9LLuXbl X-Received: by 2002:a05:6638:d02:: with SMTP id q2mr2582108jaj.225.1640105588160; Tue, 21 Dec 2021 08:53:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105588; cv=none; d=google.com; s=arc-20160816; b=IQx1DtyAnzNOM7nV7aNxLlFlKB++WmzvV4fhb2WQOUGGix2Kn0+dNlMRnWmrZ0Bsb8 BH4faXAcrfzmNV8/TG9wMGKkC1sKD96rMXVzQOIyyR9Qy4ZOAegZbzMZEbeqzotyLqiz 0usgSo0XEvET2LgtkE3I04h5LIy+xlNUyQNyefpIsNVgm5i6yUJk+GxJwlvxi57TaHKD iiwG1NFGVeBuoQWyLormZaUCMarmYmcDy4Cpz/nfyeCO6YK1bUzrhpXb+Ghz5TBK9Bcu 175K6HbykFnvXjb6k0iornlebIyT5q4eR+sw1Rtw3kwOfhH8j1Hy0I3nzwOTnBjjPDlw Xu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GUca+63qIJTLMQAWr92ep0gyUQJuyE3JsMVKseasO3I=; b=cYiVOF1SLYAYkRQaC3tabWLUW3ksh+rjk5JgeEW+c17bD1TTAQCGFfyXx4WLrrWos4 D9TPXhxc7YKE6bjd6w5uMp1wboM9Zywa3Rvb7aQMVnfAoJSCKE2YZRRygTDxd9qmBymv Ts8q53J20zDhuKgkryzrAgQ5hTBBuTwpLbUSdworqc0rZFUDK3KCXa5cYCsJ90lE5rOW 6pMCzPLEV5VaMP9jgmhQ5lWA5xnEx/v7L8qVs9IiYiaeJURNrmuDDKRnmuxNCTP0z8dW rZ8iibx1vJzxyP/vQlFn4EO2f8blbN15B8ctU+NnCOzWcF69kN+mkECu9WR6V6m5Nv2s rj0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MV4jMt/5"; 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 m16si18171899jav.137.2021.12.21.08.53.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:53:08 -0800 (PST) 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="MV4jMt/5"; 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]:46502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziNv-0006BF-MN for patch@linaro.org; Tue, 21 Dec 2021 11:53:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIt-00008X-IA for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:55 -0500 Received: from [2607:f8b0:4864:20::630] (port=45051 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIo-0007b5-OY for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:55 -0500 Received: by mail-pl1-x630.google.com with SMTP id q17so11185497plr.11 for ; Tue, 21 Dec 2021 08:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GUca+63qIJTLMQAWr92ep0gyUQJuyE3JsMVKseasO3I=; b=MV4jMt/5mCVxV8uMwlSmj1AqEwDNc1F0n9t7xFGN5+OpkK62liAyIN7d4vX/VsFTWW 2wq5kMgaom/MjnEaJ+qS5umGpZ18m5N+TdqHe/sD0+Rm1CdJxXu8kcm/kq+zMBilfT3c u/sqlc0Cuf3CqPI1ugTzuQ8XAQGKIngvI54hK8V6YzZ0XyGK4UA16fbV3KIamAu9p0V1 kakoEJGtriC+WAxxIYdOP24HInZgvUSWExuGFyJhcSWxYO8RBl3ZBDvnjx5Rn1CZOj2m IxSvqUE+6mGXX8UHyf4yGIp0Ebnx0/GWRS+ErcW7gjVURmhN6UwHhYDU8Ebtcq2aq0Wa EbiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GUca+63qIJTLMQAWr92ep0gyUQJuyE3JsMVKseasO3I=; b=xAJlyAq3qjcvqAxdOkHHVF6HhsA9V+bDJZ+YeCTEjsRkog5J22B9tjbw5Ref/zd/br UHG5aKoDJKmBUCepaclG2hsDzsUW+aelITPPuThg/keWTfAfRVuG/CSkIqho5TveTE1G wCLuCbcVQBIrAA4mCYo88H3WmyIH48S4AUOiPu1y8MsEJXcf0ZCrUVnumS8oka/klxi8 c23S2uEFHsdAWLwW/AmIB+x6ExsYLvX2wXGoKyC7w3pTM0T4/wEafEcnPOXaVsH/N9Hm aA7gg8OjPSw/TGkPuQvpd+TASYcE7S10n0sf9AqXQJ5muYvBIofx+rWX6TpcU6au0Irp rgSQ== X-Gm-Message-State: AOAM533DTkMtfnWqPYYP7YPOEm/IBB7Wc1ISxY1qZUFq8hGPSAcBbfN+ jm7mAH7cJyNxoNjBTy6kQ+69P3I6Rs2aTQ== X-Received: by 2002:a17:90b:380d:: with SMTP id mq13mr4938491pjb.110.1640105264759; Tue, 21 Dec 2021 08:47:44 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/31] tcg/loongarch64: Define the operand constraints Date: Tue, 21 Dec 2021 08:47:12 -0800 Message-Id: <20211221164737.1076007-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::630 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-7-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-str.h | 28 +++++++++++++++ tcg/loongarch64/tcg-target.c.inc | 52 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tcg/loongarch64/tcg-target-con-str.h diff --git a/tcg/loongarch64/tcg-target-con-str.h b/tcg/loongarch64/tcg-target-con-str.h new file mode 100644 index 0000000000..c3986a4fd4 --- /dev/null +++ b/tcg/loongarch64/tcg-target-con-str.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Define LoongArch target-specific operand constraints. + * + * Copyright (c) 2021 WANG Xuerui + * + * Based on tcg/riscv/tcg-target-con-str.h + * + * Copyright (c) 2021 Linaro + */ + +/* + * Define constraint letters for register sets: + * REGS(letter, register_mask) + */ +REGS('r', ALL_GENERAL_REGS) +REGS('L', ALL_GENERAL_REGS & ~SOFTMMU_RESERVE_REGS) + +/* + * Define constraint letters for constants: + * CONST(letter, TCG_CT_CONST_* bit set) + */ +CONST('I', TCG_CT_CONST_S12) +CONST('N', TCG_CT_CONST_N12) +CONST('U', TCG_CT_CONST_U12) +CONST('Z', TCG_CT_CONST_ZERO) +CONST('C', TCG_CT_CONST_C12) +CONST('W', TCG_CT_CONST_WSZ) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 653ef0a4bb..1c1b798c06 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -116,3 +116,55 @@ static const int tcg_target_call_oarg_regs[] = { TCG_REG_A0, TCG_REG_A1, }; + +#define TCG_CT_CONST_ZERO 0x100 +#define TCG_CT_CONST_S12 0x200 +#define TCG_CT_CONST_N12 0x400 +#define TCG_CT_CONST_U12 0x800 +#define TCG_CT_CONST_C12 0x1000 +#define TCG_CT_CONST_WSZ 0x2000 + +#define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 32) +/* + * For softmmu, we need to avoid conflicts with the first 5 + * argument registers to call the helper. Some of these are + * also used for the tlb lookup. + */ +#ifdef CONFIG_SOFTMMU +#define SOFTMMU_RESERVE_REGS MAKE_64BIT_MASK(TCG_REG_A0, 5) +#else +#define SOFTMMU_RESERVE_REGS 0 +#endif + + +static inline tcg_target_long sextreg(tcg_target_long val, int pos, int len) +{ + return sextract64(val, pos, len); +} + +/* test if a constant matches the constraint */ +static bool tcg_target_const_match(int64_t val, TCGType type, int ct) +{ + if (ct & TCG_CT_CONST) { + return true; + } + if ((ct & TCG_CT_CONST_ZERO) && val == 0) { + return true; + } + if ((ct & TCG_CT_CONST_S12) && val == sextreg(val, 0, 12)) { + return true; + } + if ((ct & TCG_CT_CONST_N12) && -val == sextreg(-val, 0, 12)) { + return true; + } + if ((ct & TCG_CT_CONST_U12) && val >= 0 && val <= 0xfff) { + return true; + } + if ((ct & TCG_CT_CONST_C12) && ~val >= 0 && ~val <= 0xfff) { + return true; + } + if ((ct & TCG_CT_CONST_WSZ) && val == (type == TCG_TYPE_I32 ? 32 : 64)) { + return true; + } + return false; +} From patchwork Tue Dec 21 16:47:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526598 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5222882imb; Tue, 21 Dec 2021 08:49:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI1mhqngsK0l+K9HM4FtFtYMdZ7J3VLAh1No590lF4Fl/S8LEnQcdrVRnIPrcsygdwXwnI X-Received: by 2002:a25:d98d:: with SMTP id q135mr5214598ybg.731.1640105352344; Tue, 21 Dec 2021 08:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105352; cv=none; d=google.com; s=arc-20160816; b=zfCsQTyULhCNixfcWvPDbezVc8KJ0sLWpP6BwUgl8ye0ZySzHdvqtU8/fn7v/bGTnA ifVbpsMJwv0stJcgiefa+6mq2OP81D0FsP0qeZE+MWeFv1P+Yqa1yYlt3mMG9Z1xzIYA HHZ6s/SUWSr9BaHBrPXmwu341DBSLN99iZgZHy6PcIkerzFpOPmadUe8oCyB6uhD5bXS X8xHU6AFRG9psnYpBWq79RO/Ch6iG/dwZD6ESnvRwa+fsxmsKzD7Q3vk7OCTElD5AE9t 02yNsIFh1s6JKO/3jz8RwOIvMyYTQifedhfsgewgYilf3A+lZb/WwfGJWAm2gjxxiaT1 K5RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zUDP7FmcR1rHD0pS6HJ64HKaD5yQmCsg2nMq4yKO5cY=; b=K+lOO7X2JUxoz9IXEUMlw7idTZKpERjb/6pEUXrS+NyrUdusajk9/nsXOYTI2/8PYh O3aHtlQvELG7lYLX1YjM8acRqd5MLNBbCr/c9SYz1AYOPDgrfpueWqwSgFOUG+keylxd xMXRkRFQbLWpK9t+INXic+yzbcMekyI4vT2PwZIUic540/VGdL1hzxFvHY18KP227zpB nDprYlI6FqfiAb03pa38WXn8Sb6s5fDwTb3z3PbIZLzlCgv/hDTLDALWWyJTyHGXxCVH e3dmkJFEmB3OxRlPgso7mam3iJLW9ZDsIpKWyTRa3ykP26k4/owDw3kpD+BaUFipKo0q Ey8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvxR0yI7; 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 n136si20592506yba.80.2021.12.21.08.49.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:49:12 -0800 (PST) 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=VvxR0yI7; 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]:37772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziK7-0000Ah-JU for patch@linaro.org; Tue, 21 Dec 2021 11:49:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIs-00005Y-Pt for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:54 -0500 Received: from [2607:f8b0:4864:20::102d] (port=52974 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIo-0007bA-Oa for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:54 -0500 Received: by mail-pj1-x102d.google.com with SMTP id co15so13019696pjb.2 for ; Tue, 21 Dec 2021 08:47:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zUDP7FmcR1rHD0pS6HJ64HKaD5yQmCsg2nMq4yKO5cY=; b=VvxR0yI78aINeYBYI8Fwm3IgvypmRxbbe4JcW/IuYtTKRQvmJTxCYoE4vKePPcmBJS hZ3/feiJWiWg+MRjhRE18tF8sId+dJIamtL4Vb+n9tQDbjj4JVT3eySfb4eBwMlWmny+ 6JgzFAADuEGVtpkF94ztTTXtF6qIMJyGQoWz98w2iHXdmmhhhMEXBqBzV8rPwx/GmxSe 5+I8iVcRHIt7bwWUPWBIx5BGMoZ1NkhTvyvVoUr1XB1rbZwaO8DUB6VPfL4Q7QNBWJ9b iF45sm/qvn7C2zdkvj6olL6eiyJZBwHEvdMMhj8kkhTSnt9tikOQTgvWWp7xfLPi86Mb t2BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zUDP7FmcR1rHD0pS6HJ64HKaD5yQmCsg2nMq4yKO5cY=; b=aVNfh+TzLwf5oqWKnvR1Z4K+N/ViSBBsdVEjZeXjh1GZk6nBDjxe1GhLsjVy6p3+mP dyeHDNwp0InvkGjIa39VHy5I/CxKwHPCTiMxRaGszEp6CK88ymIBU/Pk8Fi7eRt8sktj 8SBhvnmP9LiswZ2iyhabgz/s/sL7vgnyTzKCJg6Ce39qlgBhuAmuoNbiAJM5zB8UFrTQ si5IHozMT7Wzq9BpeSWAEb4pMU+XuHUJSd8fOZdH4U3K4ask6v76oWC0mUZuS3ZaAhya rU+dQjzMYRtQX4UCNfVm4pb5SeOQK9UNdMP1dgjiNeY8G6ArgiVVimwaqlqkCK0Crvfm UI8w== X-Gm-Message-State: AOAM532iucpHOFX8Ubui66xL3AwBeaDPbrzPTPDcd8KDSWnn6CXNLJjW r0/HHHJHVqLM80BtlZYwM4NW6bAuv9D2uA== X-Received: by 2002:a17:902:c193:b0:149:b6f:4e65 with SMTP id d19-20020a170902c19300b001490b6f4e65mr3871039pld.81.1640105265693; Tue, 21 Dec 2021 08:47:45 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/31] tcg/loongarch64: Implement necessary relocation operations Date: Tue, 21 Dec 2021 08:47:13 -0800 Message-Id: <20211221164737.1076007-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-8-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 1c1b798c06..a88ba9a253 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -168,3 +168,69 @@ static bool tcg_target_const_match(int64_t val, TCGType type, int ct) } return false; } + +/* + * Relocations + */ + +/* + * Relocation records defined in LoongArch ELF psABI v1.00 is way too + * complicated; a whopping stack machine is needed to stuff the fields, at + * the very least one SOP_PUSH and one SOP_POP (of the correct format) are + * needed. + * + * Hence, define our own simpler relocation types. Numbers are chosen as to + * not collide with potential future additions to the true ELF relocation + * type enum. + */ + +/* Field Sk16, shifted right by 2; suitable for conditional jumps */ +#define R_LOONGARCH_BR_SK16 256 +/* Field Sd10k16, shifted right by 2; suitable for B and BL */ +#define R_LOONGARCH_BR_SD10K16 257 + +static bool reloc_br_sk16(tcg_insn_unit *src_rw, const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; + + tcg_debug_assert((offset & 3) == 0); + offset >>= 2; + if (offset == sextreg(offset, 0, 16)) { + *src_rw = deposit64(*src_rw, 10, 16, offset); + return true; + } + + return false; +} + +static bool reloc_br_sd10k16(tcg_insn_unit *src_rw, + const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + intptr_t offset = (intptr_t)target - (intptr_t)src_rx; + + tcg_debug_assert((offset & 3) == 0); + offset >>= 2; + if (offset == sextreg(offset, 0, 26)) { + *src_rw = deposit64(*src_rw, 0, 10, offset >> 16); /* slot d10 */ + *src_rw = deposit64(*src_rw, 10, 16, offset); /* slot k16 */ + return true; + } + + return false; +} + +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, + intptr_t value, intptr_t addend) +{ + tcg_debug_assert(addend == 0); + switch (type) { + case R_LOONGARCH_BR_SK16: + return reloc_br_sk16(code_ptr, (tcg_insn_unit *)value); + case R_LOONGARCH_BR_SD10K16: + return reloc_br_sd10k16(code_ptr, (tcg_insn_unit *)value); + default: + g_assert_not_reached(); + } +} From patchwork Tue Dec 21 16:47:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526619 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5240419imb; Tue, 21 Dec 2021 09:09:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmtad0fHrDV8Zu5nxu52l82AWo84MjB10GpwCM0izxcofNCjOqyoYHCQ8Nnbn92Y8X3GI9 X-Received: by 2002:ab0:7694:: with SMTP id v20mr1739105uaq.70.1640106562719; Tue, 21 Dec 2021 09:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106562; cv=none; d=google.com; s=arc-20160816; b=KY23l6+gIZzmwn+ea+RchKHTKGqRD1KXKcNDfGatHWs+EkhaITjFbH0/2nZbBlBEMD gfTU/newrV89fv9Rr9uLpRLjUtBzri2vp5AFPYaByydSXKgqk+SoVZQ4fDjrVUQgCavp gt5Z8oYvHudL0i+SyGu3ZstT8d4h/QtpA1vKZ1gLYN2JVCp08l+RaNNXVR8uf4LejOAu bW0HCPriUPNVOvoaFFEKm1xJIUuFzV0BptPLA+rGvAVilpg12qwcawXPU8YsETc9iFMz 5FPUsGo4PE0HV0T+Zwh9uC29fajmB21MbRNIRz70KlaHGsLf4yK8lsY0M7fo5po4MfW6 TWfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=An2Fj85dq9l2EupXbwm7D8t73GeHD7BVJ48kGEVh0Z4=; b=WuiAJbFcsdrh63ew+PEW3m98OeLtt4N0AjId5OUhfamUZAr/6syFTglKCWgxhq4bO0 v5VlQgnOecnq4wCsPZx4XLqdbsk3RW1vFTyXe8SIrOynn1FStUkrT2gFYhO3Xd63GUSz nx7soACRmfjlnvLU3fOcsvrTASwCkHpx9+VNO+cdcCMhLJSzqZHVuPF0MwmVzpVx+HEs CK5G8U8I6yFx9zmqO6wEiKyHbtnTCZyQgcNoB4M3+NFXgaTFhP/BDzjgAvrc4sr+wc0i LDzZmLtEVBpaTrFIflyZmZ3tE+b1og3GgDR01AaZzlLT5EIWv82esFAdUfkyvsZV6ebB Ysmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C5J67Kv8; 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 d2si2704873uap.63.2021.12.21.09.09.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:09:22 -0800 (PST) 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=C5J67Kv8; 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]:32918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzidd-0001nL-6A for patch@linaro.org; Tue, 21 Dec 2021 12:09:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ5-0000gO-Ja for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:07 -0500 Received: from [2607:f8b0:4864:20::1035] (port=38875 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIo-0007bE-Ob for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:06 -0500 Received: by mail-pj1-x1035.google.com with SMTP id n15-20020a17090a394f00b001b0f6d6468eso3113900pjf.3 for ; Tue, 21 Dec 2021 08:47:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=An2Fj85dq9l2EupXbwm7D8t73GeHD7BVJ48kGEVh0Z4=; b=C5J67Kv83CFhlGbbr8r5T0CqFIkvwAvFJ9FQ1Pb2vL2homGOHnlccVltMf8w9givBa IEb1mDTNADgl9zDngXUDDhBTdzdGF2OYmUChytE9LuBlQTN5QrHMOYNHQ8duNhE2OyH/ 8WmvvgZfBGGJeiJL4iGq8BAGKqZJa59E2lZVAJNsJwrvJp8d0NtQv6dZgjfe3nVkIoxl RWTR34aOutGTTdxUQKp2hrGtav7J+MdGSbJhAXCEoGpxGC7gzGN6joFHOiEw5xpP4rpZ 1LoroZU2xguZjKabAxTyLPI7fr+IVtKghhY19CF4eW/eVuD8WTJs5SLGKjeLZVKzFf1L xVgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=An2Fj85dq9l2EupXbwm7D8t73GeHD7BVJ48kGEVh0Z4=; b=QXBv/Je7xcHORnVRzI8+etQfejCVop6YovNQEI3olHSCCwAyJ0PmOOmBEhxmP6671f 0oCvjGUZEYhKp/znhw61VLZUB2tpkjCdpOIK1fGiUEhS5sANmunoatCSEVp1lG6MY+tY gShwp8vEpbfrvTEeMjV0pIFM0OJsc1H8b1Em0xEhsjrl8tsK5ei8PfbxT6QWu49qEW+x 1NZX7PBPYvd76UT5I9NGnOatHcMDLRngYmfRgyrGW1niJwEcMNIudGqzwaMoiNwHPkI6 wUJLBVHpBNxIaNI94DAYwQOnfQ3L2H9QBoKyLme5bQHmS4InsOCRjyCX7+7vKEAyf4m6 zqbw== X-Gm-Message-State: AOAM532Kpu1ZzE2oy3iiM6Dnn06dgCDeFGcjx8xt4rOHgXUQNUZUXO4h keu7EvXKJQWXOMX69o9HOE1S3c1TCs4HeQ== X-Received: by 2002:a17:902:8505:b0:142:892d:918 with SMTP id bj5-20020a170902850500b00142892d0918mr4024049plb.39.1640105266608; Tue, 21 Dec 2021 08:47:46 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/31] tcg/loongarch64: Implement the memory barrier op Date: Tue, 21 Dec 2021 08:47:14 -0800 Message-Id: <20211221164737.1076007-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-9-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index a88ba9a253..615bed9096 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -234,3 +234,35 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, g_assert_not_reached(); } } + +#include "tcg-insn-defs.c.inc" + +/* + * TCG intrinsics + */ + +static void tcg_out_mb(TCGContext *s, TCGArg a0) +{ + /* Baseline LoongArch only has the full barrier, unfortunately. */ + tcg_out_opc_dbar(s, 0); +} + +/* + * Entry-points + */ + +static void tcg_out_op(TCGContext *s, TCGOpcode opc, + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]) +{ + TCGArg a0 = args[0]; + + switch (opc) { + case INDEX_op_mb: + tcg_out_mb(s, a0); + break; + + default: + g_assert_not_reached(); + } +} From patchwork Tue Dec 21 16:47:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526603 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5228192imb; Tue, 21 Dec 2021 08:56:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJypXcBvfOLfT8CUlWp7gAGJ0VlRTeHwA1cdBy3vAXkRl3ljm3R66Zzi7X3rImOxmceiNX66 X-Received: by 2002:a25:8b02:: with SMTP id i2mr5008921ybl.688.1640105803836; Tue, 21 Dec 2021 08:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105803; cv=none; d=google.com; s=arc-20160816; b=1K5ZF9vcpCYpA1NLxQPAGl6//yLCCeuJ2pro5YMUUoK9o65I3mr4Gnb/Vp7fi3R+VU Zvlnn3se6YApPXzmo+UO76CwULsuwQXMpJGPiK4PtwSysYAkUHMOOw9mxNQRomorHHmd Ho2FIh15MjnDCplz30Kn7lLpLwyfLeZpjD58Rj54OF91GyOlkFrTU7FOU2xMeLdIXOVf cw3XNfOh9cUdrs2/lwCftPAAmxNeA3+O8cUzPYsCk/SPqTTlA4SSfQVGKjcSyLeHMt4P dbOLCjWC+nYPRaAtxuFeeze+9VyFwLsALRPBBC6snpfdq4/rBVz/nOVEfldInG4mnabQ UBNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=/xVyuuUpWpjZuLGW0kevSwG/8cAXGRFDzbVxjAUHy5Q=; b=Ka/LBMbNSdXpFqqLAAkCTw/RXYKYLaJMdl38KODAswQm1K5ObTLKttor6HHGZmQ0bC 4ZWsHdigCKsya8vKw8yfxGTO9BU7XmFDeFTpXGVXNTRTIKciVD52FKMUDyLMu7WdRg9D P6zX0F2dGlK/IO5aPEuez5KeuI6FNJ+TsS3Ebwghtel2mttMu9jm4SkgjAZIz9AXB23x zhmxnMnym04r7tKQh+ytXsyBQb1xrYB/ZjSpa24jlbHZ/gvnrOFLXRPec0dilRf03pkE 0JyuFetO4+bhL6amFqzF7VhVcdh8EU8GLkbjktNbD2qIECa07Q1CAC0eJknh1Qg26NhL Wb6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yx9SWpXr; 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 f185si18850268ybc.739.2021.12.21.08.56.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:56:43 -0800 (PST) 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=yx9SWpXr; 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]:54478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziRP-00035u-Aj for patch@linaro.org; Tue, 21 Dec 2021 11:56:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIr-0008Rl-LI for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:53 -0500 Received: from [2607:f8b0:4864:20::630] (port=34685 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIo-0007cP-Of for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:53 -0500 Received: by mail-pl1-x630.google.com with SMTP id x15so10792581plg.1 for ; Tue, 21 Dec 2021 08:47:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/xVyuuUpWpjZuLGW0kevSwG/8cAXGRFDzbVxjAUHy5Q=; b=yx9SWpXrU71kdtl4gOausxcn/zMLK0ZX4VO7pLYXC5BZXwsb1FN/IGrzZaLNtBwgVO jcNURXcAvB+BukvlxPa5TbbvyQuoOKaCWf10PX5uP89HPv6ZzFsP9Q7Kd70zV4yBGXw5 c44kIh2k2tOrFkQ79Z49l6noxvEiHjtiMQs5MCGmOX5YWHSYvG8t2RmvvhyTfJ7jfcIl ILgLjUOEed00JSyCZeIvpF7T2ZuyhDXeU4p00IwISBoqna7k1uUqKLUs1lP0QINwQrHW lJVajyKO8kZxQbccE1EH/6bthz2f1T5WR3J8ZrzqLV0QRxSV4qGDw53CcefOd5+j0Cfe LdeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/xVyuuUpWpjZuLGW0kevSwG/8cAXGRFDzbVxjAUHy5Q=; b=VJoENWopqiCbKhwK8YxBZD6c0VVPeUr2jt2BP5m9BV0za4lZU7XYH4RuhStmEwWP5Q NPoGX/UkupDEmp5SYy0JmGAX1sYsdEMI6vAz25qMe9Zc8fTwSD39VNsUCNGGXYmAySOf Wx8b+KpPiLLLe1JS61TiFkECSJ7Pn5Z8BB3rWu0jyU+VgSNCx048SeWsneOw8Wxgf+wf tzXh/kIzCvrgK/UJznqY9+O6ClfNJa6p2T2Ns1cM+w7tT11+vtXs21D6aAB5x+I+UV1/ LmOTDgDbK0hF1bhRK8suKXl52cvsStexmM9VczoDGMcIGfhLGoqbFrGj/+K9WnngoELP sIGQ== X-Gm-Message-State: AOAM5320M3CCTGIym4orbE4M7+xyZ0MP/50MYg3HX8u+H+6RKNUKGGZM vp6ZQgi/FbChLbjnyZc5I1EDbuXUG51QmQ== X-Received: by 2002:a17:902:8544:b0:148:fef0:5736 with SMTP id d4-20020a170902854400b00148fef05736mr4175790plo.154.1640105267487; Tue, 21 Dec 2021 08:47:47 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/31] tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi Date: Tue, 21 Dec 2021 08:47:15 -0800 Message-Id: <20211221164737.1076007-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::630 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-10-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 137 +++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 615bed9096..bb45ea0fcf 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -247,6 +247,141 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) tcg_out_opc_dbar(s, 0); } +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +{ + if (ret == arg) { + return true; + } + switch (type) { + case TCG_TYPE_I32: + case TCG_TYPE_I64: + /* + * Conventional register-register move used in LoongArch is + * `or dst, src, zero`. + */ + tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO); + break; + default: + g_assert_not_reached(); + } + return true; +} + +static bool imm_part_needs_loading(bool high_bits_are_ones, + tcg_target_long part) +{ + if (high_bits_are_ones) { + return part != -1; + } else { + return part != 0; + } +} + +/* Loads a 32-bit immediate into rd, sign-extended. */ +static void tcg_out_movi_i32(TCGContext *s, TCGReg rd, int32_t val) +{ + tcg_target_long lo = sextreg(val, 0, 12); + tcg_target_long hi12 = sextreg(val, 12, 20); + + /* Single-instruction cases. */ + if (lo == val) { + /* val fits in simm12: addi.w rd, zero, val */ + tcg_out_opc_addi_w(s, rd, TCG_REG_ZERO, val); + return; + } + if (0x800 <= val && val <= 0xfff) { + /* val fits in uimm12: ori rd, zero, val */ + tcg_out_opc_ori(s, rd, TCG_REG_ZERO, val); + return; + } + + /* High bits must be set; load with lu12i.w + optional ori. */ + tcg_out_opc_lu12i_w(s, rd, hi12); + if (lo != 0) { + tcg_out_opc_ori(s, rd, rd, lo & 0xfff); + } +} + +static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, + tcg_target_long val) +{ + /* + * LoongArch conventionally loads 64-bit immediates in at most 4 steps, + * with dedicated instructions for filling the respective bitfields + * below: + * + * 6 5 4 3 + * 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 + * +-----------------------+---------------------------------------+... + * | hi52 | hi32 | + * +-----------------------+---------------------------------------+... + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * ...+-------------------------------------+-------------------------+ + * | hi12 | lo | + * ...+-------------------------------------+-------------------------+ + * + * Check if val belong to one of the several fast cases, before falling + * back to the slow path. + */ + + intptr_t pc_offset; + tcg_target_long val_lo, val_hi, pc_hi, offset_hi; + tcg_target_long hi32, hi52; + bool rd_high_bits_are_ones; + + /* Value fits in signed i32. */ + if (type == TCG_TYPE_I32 || val == (int32_t)val) { + tcg_out_movi_i32(s, rd, val); + return; + } + + /* PC-relative cases. */ + pc_offset = tcg_pcrel_diff(s, (void *)val); + if (pc_offset == sextreg(pc_offset, 0, 22) && (pc_offset & 3) == 0) { + /* Single pcaddu2i. */ + tcg_out_opc_pcaddu2i(s, rd, pc_offset >> 2); + return; + } + + if (pc_offset == (int32_t)pc_offset) { + /* Offset within 32 bits; load with pcalau12i + ori. */ + val_lo = sextreg(val, 0, 12); + val_hi = val >> 12; + pc_hi = (val - pc_offset) >> 12; + offset_hi = val_hi - pc_hi; + + tcg_debug_assert(offset_hi == sextreg(offset_hi, 0, 20)); + tcg_out_opc_pcalau12i(s, rd, offset_hi); + if (val_lo != 0) { + tcg_out_opc_ori(s, rd, rd, val_lo & 0xfff); + } + return; + } + + hi32 = sextreg(val, 32, 20); + hi52 = sextreg(val, 52, 12); + + /* Single cu52i.d case. */ + if (ctz64(val) >= 52) { + tcg_out_opc_cu52i_d(s, rd, TCG_REG_ZERO, hi52); + return; + } + + /* Slow path. Initialize the low 32 bits, then concat high bits. */ + tcg_out_movi_i32(s, rd, val); + rd_high_bits_are_ones = (int32_t)val < 0; + + if (imm_part_needs_loading(rd_high_bits_are_ones, hi32)) { + tcg_out_opc_cu32i_d(s, rd, hi32); + rd_high_bits_are_ones = hi32 < 0; + } + + if (imm_part_needs_loading(rd_high_bits_are_ones, hi52)) { + tcg_out_opc_cu52i_d(s, rd, rd, hi52); + } +} + /* * Entry-points */ @@ -262,6 +397,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_mb(s, a0); break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ + case INDEX_op_mov_i64: default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526613 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5234779imb; Tue, 21 Dec 2021 09:04:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNI+rTYkCu61VPVTp6l/euSwCBfaZ5N1pCypWg2mGbhMYYcwBO37B2TAhHA3phu4akvJvn X-Received: by 2002:a05:622a:110e:: with SMTP id e14mr3030597qty.419.1640106252806; Tue, 21 Dec 2021 09:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106252; cv=none; d=google.com; s=arc-20160816; b=SMvxGhT/vQzPDjbdkNaghPDF4mzE+bTQ9vVzSE+vnCP2dRdxF9yYg4z1IQ2EqKDVxc 9jFIAOUXpRJ+Cy9CEUq8eW6ZeU7zndWWS+pONyO1s5pbhuSORrSpv045PT0u+FEoldRq 8OLF4E7g8yGjAE9Z+kyOA8NoiEbHtff4qQNo6k4ALkdNw5LkcY6B4IfDJZhLiSlktaz/ lXwgElVjFBcTm95EQBVUhVf5twiQ7i3YHq9n8Yco/SNuIjzf5DWEmM1ErtEa8isYmhxp ubQUI7s+R9vMv/wIt5QNTsfEEDBiKltDP9rCs5E+Ci3qpSDG5WZIpvt4RxiyvxLpfPUX 7O7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=aRDFGEdRx4gKiMYB6nK14fb+uw0O+ZvZTgYpZPI8a7w=; b=FkPO6CJd1KAaPSEp0nIxLOd5icO/i9RTABjduRvMfDUu6zMdw8f+wPAgayDt7CO5W/ jzXO9/gmaBRn8R6UkZI21GIs77f2xUeWDR0KHJE+wRu9J95dj3avXNWlwWOc9+k1dy5X ezaA3UVEBxR69IselwVY757zYl1QBpXmfsGxy5Cwx6pUgsP2PGLUXCm4L1AMiDOSOPOV 3OP0IlUdZ+PuhYo52DE6itKvBTt+8SqYa8jk9pKzaidjA/e2v2qhS4BL8i/sa7lnR1Pu eKzaOhZB6rHIGDKtIVmS5WFpN15pRs/TG1jqN1BVajrLhBaKIkAi3DZIjVEt7CQxyF75 NHPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MGaSxePd; 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 az30si7779964qkb.487.2021.12.21.09.04.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:04:12 -0800 (PST) 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=MGaSxePd; 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]:46570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziYe-0000GW-9O for patch@linaro.org; Tue, 21 Dec 2021 12:04:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ6-0000n9-GY for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:08 -0500 Received: from [2607:f8b0:4864:20::536] (port=42676 helo=mail-pg1-x536.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIo-0007cT-Oj for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:08 -0500 Received: by mail-pg1-x536.google.com with SMTP id g2so10253043pgo.9 for ; Tue, 21 Dec 2021 08:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aRDFGEdRx4gKiMYB6nK14fb+uw0O+ZvZTgYpZPI8a7w=; b=MGaSxePdYAS/uXlXuM0qZlv8vJBVxV1z90+Sv7DOmk6i37ypInUejUYZgytpU71qG+ cM8GFtAb4cebn7tu4mbX7oFhCtN+dh0skr863kd9jnO7Wl5U4po8eo4B6L0CFT2oCmZb 55KdzeBqwjHqUaPTXKeRHuihvprlLYhPfwTI+DFmpNI6lDRTZKLXwJlm+D7cQcgPC9M+ pvQbq69rMZOuSDl7172AbOO1qh2hLfxZZfnpIeSVAZ/yMdIUC9rVzQ/Hlw0eO/Fbko0o NhiO1nDheLkOnk4yS10NFvv5D3aaLgaScxkcFPKfbd4zTPb5pUuT6RiZVemh+KCvArSi StjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aRDFGEdRx4gKiMYB6nK14fb+uw0O+ZvZTgYpZPI8a7w=; b=KtD3s0e1a0KloODmNyAhkooI1gopnoXVacX6DmQgoCWHEHVAoROTRfhEDQuHYuHg1p x0HnG05WhVHWhJgClsAsWZiUiqWvL0brySzqdZ1FQlN9JeW3oInsmFtv+dI2ViKG+5iP 29Sd43P6sVmPTJEByh3P9+Gq/uHzlkl1FwF1U0IbiY4c5XRfJkxNJMR7myYD0WAaDIW0 dqTx4wYcQC2rQKmVx87ZKeWbLZkpnAm4rszugTDK9RDiJfiF0zcxvXS/IBGuD0gE86w2 bbThd0/s6T0q+WOihBwukheou7YFyy2bNd4OWUZjmm6jfRt+rkwGWfXxSoE9BLOXFEpT 3vvg== X-Gm-Message-State: AOAM530ckuZZGuS/oCmmZ+CIFO7nMoUF0gNX3SIFePSuDFaqHgvpjIMK x44FnJPuIsXLKisWCU2IlXnhe0EQMLNdVQ== X-Received: by 2002:a63:f30b:: with SMTP id l11mr1453872pgh.272.1640105268253; Tue, 21 Dec 2021 08:47:48 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/31] tcg/loongarch64: Implement goto_ptr Date: Tue, 21 Dec 2021 08:47:16 -0800 Message-Id: <20211221164737.1076007-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::536 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-11-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 17 +++++++++++++++++ tcg/loongarch64/tcg-target.c.inc | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tcg/loongarch64/tcg-target-con-set.h diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h new file mode 100644 index 0000000000..5cc4407367 --- /dev/null +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Define LoongArch target-specific constraint sets. + * + * Copyright (c) 2021 WANG Xuerui + * + * Based on tcg/riscv/tcg-target-con-set.h + * + * Copyright (c) 2021 Linaro + */ + +/* + * C_On_Im(...) defines a constraint set with outputs and inputs. + * Each operand should be a sequence of constraint letters as defined by + * tcg-target-con-str.h; the constraint combination is inclusive or. + */ +C_O0_I1(r) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index bb45ea0fcf..3a8c52465b 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -397,9 +397,24 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_mb(s, a0); break; + case INDEX_op_goto_ptr: + tcg_out_opc_jirl(s, TCG_REG_ZERO, a0, 0); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: g_assert_not_reached(); } } + +static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) +{ + switch (op) { + case INDEX_op_goto_ptr: + return C_O0_I1(r); + + default: + g_assert_not_reached(); + } +} From patchwork Tue Dec 21 16:47:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526615 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5237557imb; Tue, 21 Dec 2021 09:06:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVUhL1xs/PPv7Ie+aaG+q+4K0zZ+gdbF9h0V0iHEp9yvWhZ/akChrcO8wd63j5Pgvv0I+3 X-Received: by 2002:a05:622a:1aa5:: with SMTP id s37mr3018549qtc.377.1640106388272; Tue, 21 Dec 2021 09:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106388; cv=none; d=google.com; s=arc-20160816; b=nDSBiG/F2S61TZaEWJLPzZ8rdZa9clh2xm9CyZZt3F7icHoLaYhevUWKkk66SvrvSp JrR1inZyHV1Qe4kBLCuJ3Lm13ZECwmBmZVRYeLQ5UcIVd1xjTAkGtvGaoEErnLrwHeVn fcprccIvXlwv4LuBr9Be3Ho2/4yIk8IBEzDfpms+ms3kOV4ux8p/066848EVl7EfXNh5 2rD1BXWTpmPiEijco1skjKeamHEa9w6kdgwKJOxtAYHT7TW4mXyyC9qdzcRcSDEUdt77 8LCB6sENWt+zcDHqA9DoBso53B5WCZrqxlUmRKGa7QEwLJTMFJCw3MtLgeO9sky+Xhkl NXjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=s0y+0akqvYYTcupTY8XxL2LflJ/Ill4iG4i1E3yQ8vo=; b=tZuBFl3xZwTkTzoI9VRjYQOZdVPLMWqbpj8shYlSmQcB9/9zEKVzhLyiexAwvNr0U7 lMr/7emf2BmDjhq+AT+B7c+W6hY7+4Kn6XdvkphdARetie1V+AyJCRhV/VFCa9JjWDpy ORGddHWyayrKUpfNKJlrQ/1UXU/jVr7Lj7ZXZfbqzr+SHx0EC1+xnt06QXIqnMMOLzbl T6xOpXFAF/Vecxz/1wi+WRJAkmXiI4Or+aIcvbQY6F9bqGszThk3ARAgS9E5EQYBaiH/ qPUlchj/9eJFRvabKyfZcXve6gMxeYcmx1s5OyFoo0KbPzlZkVXa8c94AGjbeok3Xze9 9R6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iZYjncHX; 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 k4si8405372qko.362.2021.12.21.09.06.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:06:28 -0800 (PST) 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=iZYjncHX; 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]:52596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziao-0004LS-Vu for patch@linaro.org; Tue, 21 Dec 2021 12:06:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ4-0000hB-Q2 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:06 -0500 Received: from [2607:f8b0:4864:20::52b] (port=41668 helo=mail-pg1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIo-0007cV-Ok for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:06 -0500 Received: by mail-pg1-x52b.google.com with SMTP id k4so12837647pgb.8 for ; Tue, 21 Dec 2021 08:47:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s0y+0akqvYYTcupTY8XxL2LflJ/Ill4iG4i1E3yQ8vo=; b=iZYjncHXjtAOgXMx5SgAgQoIiAb24KJ6bcHhGtfc6dK8MJMLgFvr/DaVq1Ouufwb5r DRP9UWEdSv7Zb5/KNPmCNUulpSRltSJVzqdh7vGR+jBFcxgx5ImnnPzJE2Kq5pJFWSXE PdDzlFpWl/ShXWthlgQqsimJHYHUG0mjIan0y5exutA7QkUjixqAan2FliThP770RgcX RRcVvKuyW4pmnRFva77L3guZQ+K7U5nVsSwU4ep3TYwTM2a4V602jOLDlvcpVNuSAQ3n GgkjRV3ohanefeGo+By/yk8HHxQ1bcoQ25FJBeklubn4II9hlZUx9Fhpiy6LWPXBcrS0 ffHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s0y+0akqvYYTcupTY8XxL2LflJ/Ill4iG4i1E3yQ8vo=; b=S+6fmTcgWqF8pNRi72tdP/aNkfr0EdK/St7rEbl/sa5NlH8DY+L7RospArOSbA4WzV sZVQ6eR9MS9BEZvoq+XVfHMFj0bvKbnEprdBJbiapbZnoqWgdhw+e2s1qrOzdiOeNvFx dV2FO3fi9OMazZA+hExXdd4lPgeEhLZENmMuHOQTOaMD34yMID2oin1rYgVi+gJpZBAM aQJ6hX9ZakAcgnZSS0zpmxWUL/CrXPwNzCYRGMr2L5AKFxOma98eYPe70Mo4NZ7ugGP4 3n4vLnXFeXvOnZ6YEcumxV0pz20lSoVq7nALVecuSK2WDFL9f2QWQ0Rgk47wr03Xys+A j51w== X-Gm-Message-State: AOAM533Fee8kSqpwbAYbQLuft5ldfvZ73k43w7Os/rC7T7jE68vJ/fUf IMh24ITkJeUEsmaUL2O3zX+JhZqzJoC4tg== X-Received: by 2002:a63:1645:: with SMTP id 5mr3705980pgw.45.1640105269084; Tue, 21 Dec 2021 08:47:49 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/31] tcg/loongarch64: Implement sign-/zero-extension ops Date: Tue, 21 Dec 2021 08:47:17 -0800 Message-Id: <20211221164737.1076007-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-12-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 24 ++++---- tcg/loongarch64/tcg-target.c.inc | 82 ++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 12 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 5cc4407367..7e459490ea 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -15,3 +15,4 @@ * tcg-target-con-str.h; the constraint combination is inclusive or. */ C_O0_I1(r) +C_O1_I1(r, r) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 25328646f0..a6d9e036fc 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -107,10 +107,10 @@ typedef enum { #define TCG_TARGET_HAS_muls2_i32 0 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 -#define TCG_TARGET_HAS_ext8s_i32 0 -#define TCG_TARGET_HAS_ext16s_i32 0 -#define TCG_TARGET_HAS_ext8u_i32 0 -#define TCG_TARGET_HAS_ext16u_i32 0 +#define TCG_TARGET_HAS_ext8s_i32 1 +#define TCG_TARGET_HAS_ext16s_i32 1 +#define TCG_TARGET_HAS_ext8u_i32 1 +#define TCG_TARGET_HAS_ext16u_i32 1 #define TCG_TARGET_HAS_bswap16_i32 0 #define TCG_TARGET_HAS_bswap32_i32 0 #define TCG_TARGET_HAS_not_i32 0 @@ -138,14 +138,14 @@ typedef enum { #define TCG_TARGET_HAS_extract_i64 0 #define TCG_TARGET_HAS_sextract_i64 0 #define TCG_TARGET_HAS_extract2_i64 0 -#define TCG_TARGET_HAS_extrl_i64_i32 0 -#define TCG_TARGET_HAS_extrh_i64_i32 0 -#define TCG_TARGET_HAS_ext8s_i64 0 -#define TCG_TARGET_HAS_ext16s_i64 0 -#define TCG_TARGET_HAS_ext32s_i64 0 -#define TCG_TARGET_HAS_ext8u_i64 0 -#define TCG_TARGET_HAS_ext16u_i64 0 -#define TCG_TARGET_HAS_ext32u_i64 0 +#define TCG_TARGET_HAS_extrl_i64_i32 1 +#define TCG_TARGET_HAS_extrh_i64_i32 1 +#define TCG_TARGET_HAS_ext8s_i64 1 +#define TCG_TARGET_HAS_ext16s_i64 1 +#define TCG_TARGET_HAS_ext32s_i64 1 +#define TCG_TARGET_HAS_ext8u_i64 1 +#define TCG_TARGET_HAS_ext16u_i64 1 +#define TCG_TARGET_HAS_ext32u_i64 1 #define TCG_TARGET_HAS_bswap16_i64 0 #define TCG_TARGET_HAS_bswap32_i64 0 #define TCG_TARGET_HAS_bswap64_i64 0 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 3a8c52465b..25b58c7828 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -382,6 +382,36 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, } } +static void tcg_out_ext8u(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_andi(s, ret, arg, 0xff); +} + +static void tcg_out_ext16u(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_bstrpick_w(s, ret, arg, 0, 15); +} + +static void tcg_out_ext32u(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_bstrpick_d(s, ret, arg, 0, 31); +} + +static void tcg_out_ext8s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_sext_b(s, ret, arg); +} + +static void tcg_out_ext16s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_sext_h(s, ret, arg); +} + +static void tcg_out_ext32s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_addi_w(s, ret, arg, 0); +} + /* * Entry-points */ @@ -391,6 +421,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const int const_args[TCG_MAX_OP_ARGS]) { TCGArg a0 = args[0]; + TCGArg a1 = args[1]; switch (opc) { case INDEX_op_mb: @@ -401,6 +432,41 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_jirl(s, TCG_REG_ZERO, a0, 0); break; + case INDEX_op_ext8s_i32: + case INDEX_op_ext8s_i64: + tcg_out_ext8s(s, a0, a1); + break; + + case INDEX_op_ext8u_i32: + case INDEX_op_ext8u_i64: + tcg_out_ext8u(s, a0, a1); + break; + + case INDEX_op_ext16s_i32: + case INDEX_op_ext16s_i64: + tcg_out_ext16s(s, a0, a1); + break; + + case INDEX_op_ext16u_i32: + case INDEX_op_ext16u_i64: + tcg_out_ext16u(s, a0, a1); + break; + + case INDEX_op_ext32u_i64: + case INDEX_op_extu_i32_i64: + tcg_out_ext32u(s, a0, a1); + break; + + case INDEX_op_ext32s_i64: + case INDEX_op_extrl_i64_i32: + case INDEX_op_ext_i32_i64: + tcg_out_ext32s(s, a0, a1); + break; + + case INDEX_op_extrh_i64_i32: + tcg_out_opc_srai_d(s, a0, a1, 32); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -414,6 +480,22 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_goto_ptr: return C_O0_I1(r); + case INDEX_op_ext8s_i32: + case INDEX_op_ext8s_i64: + case INDEX_op_ext8u_i32: + case INDEX_op_ext8u_i64: + case INDEX_op_ext16s_i32: + case INDEX_op_ext16s_i64: + case INDEX_op_ext16u_i32: + case INDEX_op_ext16u_i64: + case INDEX_op_ext32s_i64: + case INDEX_op_ext32u_i64: + case INDEX_op_extu_i32_i64: + case INDEX_op_extrl_i64_i32: + case INDEX_op_extrh_i64_i32: + case INDEX_op_ext_i32_i64: + return C_O1_I1(r, r); + default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526607 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5230306imb; Tue, 21 Dec 2021 08:59:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP5GrL5e32NfOew8yjbS4V/UnMm5EXfl4WlpXDPzJcF1v6hl/5CTCf24kxHpa0sGH6/s27 X-Received: by 2002:a05:6214:2427:: with SMTP id gy7mr3178155qvb.38.1640105989855; Tue, 21 Dec 2021 08:59:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105989; cv=none; d=google.com; s=arc-20160816; b=PcF6hix1kW+oP4MskDGp5jiVQMZeeTsvR8zZ6CQhEZBaAQYBEt2QCBxtDSRwh77M3G gR7kHY0FGsOarWzqsqp7flxGz77eFjAD70pyYgVzzcjVq2RG/vlR3/T3u8/+E0dsjTSD MwLClDt4oz+49h6eeWqRP4AXejtvIQFr5HW1Dglct9qsevTStaZnNLPfFl+fr+ufvo8/ iFj4buxytwt47tuAw+opO8Y1yym66DlbfD4GyUs8BQVslnzSZvgIBiZ/t6wxdQCZCLon 7Z9vtbybKm9jEYNFkHHrlDG1aQV0EaAuYvPFpqx8wXIn7ZUo/wEFrVOw6xAhnY4mONlq CHbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=38jcf2PlHE3P8/FtnSNikJSiMqKktvlkbLxOvFn7Fjo=; b=Pqy2hUN+aw9cp8pV6K1T3f/VtQ9i7+PMDeu1I/CsrW6GUG06L3OYaXDcJ87KUA19Ij FDa6w8gFbuteI8y5d67j4gZIYpjc4+bVKSlAJIPAwUJ8W5a99l7XCD2em9PHHS8uMFcF K2xdk2Ny9UOZKh31N+WqCLfhko4CvtMGYbEJ2g3hSi9TiqsjDuOqLyXiQt30kLCTmAf9 xKl70YuzQD8Jy579Uy++MnQbGtcNo2a94ms3xduw/Eafu7hAK2T2Rq90Yq+9mRu+AjM+ pyYMNxBTe0jwUdVVGi83FdhZULw2ySVGhDG+CKxKPW7XSr5LA2V0ivoMWI2T2v42uiNa EdQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BAmegXQG; 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 l16si7393188qkk.627.2021.12.21.08.59.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:59:49 -0800 (PST) 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=BAmegXQG; 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]:35074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziUP-0000hp-8H for patch@linaro.org; Tue, 21 Dec 2021 11:59:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIw-0000Ma-Ue for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:58 -0500 Received: from [2607:f8b0:4864:20::434] (port=39537 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIp-0007ca-6P for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:58 -0500 Received: by mail-pf1-x434.google.com with SMTP id s15so1736936pfk.6 for ; Tue, 21 Dec 2021 08:47:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=38jcf2PlHE3P8/FtnSNikJSiMqKktvlkbLxOvFn7Fjo=; b=BAmegXQG4DdFxHS2cA8gMy2EA357z8NNAwENVM2360KQSPZ8U4zV3gu7sg2qXDQMf2 j8Wzwj3AfE0Rvs8CiTzUr7hjhaKGtuxgCEapoYoLlysSqji3K++KVFgnRQwRTpu8xzdR Q5RP+Z1hulIyHoHtvyBpqwoMgRo136JZBiqenLpzi2BWU7C+2l83e5zt44RCkvzNM7xz YaSvDYxyQFYMT+YR4tU2FsW2nI+520KZVw9p/FtQkI5a0qhku2mmnhpNqUvqXo18yh8H P6c2yo8tU7GPE5gDExSFlHCAXPFPgM32HMOrOwoRwvC0/Xs/oYx3Svfh6yHPBhX5XW7F YxDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=38jcf2PlHE3P8/FtnSNikJSiMqKktvlkbLxOvFn7Fjo=; b=JYiydUBnGHpwNJO2j1iRptsFWDlf+PWVtw2cduVwSnfZ1ztQM38j6GeGOnzZTldPWG DeKOwn35DMS8qNb+ePkwAbQh1jzh0dbR1UPp+TFGulT6u5TJucWGVBqXnZ05fKbrjZ7a Pqfx71kaT6e/Md3BNO72PAf8T7W3OWWtY8vD7MLnFMgd1aaPVb16F2By8uXUroEGTwfx JYlrZkmBSBmXNZxAmWQuTwquKFhEd7DOHwlUDAe+OHnJidw0rHqMNWqCxKPIVYTX9y6m U47vNxpqfpEje2jhWro2zurxCGOPYTbxjeyDA1gjjTFd4W7mbDQnFdJXW+VLuECrO+ii 3cRA== X-Gm-Message-State: AOAM530Uhkag1HA1bTln1LtiJqrp1D5ZDfbQ14j8On26i9QbrgY3k8jG qV/ZAEeLJXO1aUJHMyRJ0GcBZ5rOx2hf1g== X-Received: by 2002:a63:4409:: with SMTP id r9mr233479pga.271.1640105269957; Tue, 21 Dec 2021 08:47:49 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/31] tcg/loongarch64: Implement not/and/or/xor/nor/andc/orc ops Date: Tue, 21 Dec 2021 08:47:18 -0800 Message-Id: <20211221164737.1076007-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-13-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 2 + tcg/loongarch64/tcg-target.h | 16 ++--- tcg/loongarch64/tcg-target.c.inc | 88 ++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 8 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 7e459490ea..9ac24b8ad0 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -16,3 +16,5 @@ */ C_O0_I1(r) C_O1_I1(r, r) +C_O1_I2(r, r, rC) +C_O1_I2(r, r, rU) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index a6d9e036fc..cc9aecc681 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -113,13 +113,13 @@ typedef enum { #define TCG_TARGET_HAS_ext16u_i32 1 #define TCG_TARGET_HAS_bswap16_i32 0 #define TCG_TARGET_HAS_bswap32_i32 0 -#define TCG_TARGET_HAS_not_i32 0 +#define TCG_TARGET_HAS_not_i32 1 #define TCG_TARGET_HAS_neg_i32 0 -#define TCG_TARGET_HAS_andc_i32 0 -#define TCG_TARGET_HAS_orc_i32 0 +#define TCG_TARGET_HAS_andc_i32 1 +#define TCG_TARGET_HAS_orc_i32 1 #define TCG_TARGET_HAS_eqv_i32 0 #define TCG_TARGET_HAS_nand_i32 0 -#define TCG_TARGET_HAS_nor_i32 0 +#define TCG_TARGET_HAS_nor_i32 1 #define TCG_TARGET_HAS_clz_i32 0 #define TCG_TARGET_HAS_ctz_i32 0 #define TCG_TARGET_HAS_ctpop_i32 0 @@ -149,13 +149,13 @@ typedef enum { #define TCG_TARGET_HAS_bswap16_i64 0 #define TCG_TARGET_HAS_bswap32_i64 0 #define TCG_TARGET_HAS_bswap64_i64 0 -#define TCG_TARGET_HAS_not_i64 0 +#define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_neg_i64 0 -#define TCG_TARGET_HAS_andc_i64 0 -#define TCG_TARGET_HAS_orc_i64 0 +#define TCG_TARGET_HAS_andc_i64 1 +#define TCG_TARGET_HAS_orc_i64 1 #define TCG_TARGET_HAS_eqv_i64 0 #define TCG_TARGET_HAS_nand_i64 0 -#define TCG_TARGET_HAS_nor_i64 0 +#define TCG_TARGET_HAS_nor_i64 1 #define TCG_TARGET_HAS_clz_i64 0 #define TCG_TARGET_HAS_ctz_i64 0 #define TCG_TARGET_HAS_ctpop_i64 0 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 25b58c7828..d9508d5295 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -422,6 +422,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, { TCGArg a0 = args[0]; TCGArg a1 = args[1]; + TCGArg a2 = args[2]; + int c2 = const_args[2]; switch (opc) { case INDEX_op_mb: @@ -467,6 +469,68 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_srai_d(s, a0, a1, 32); break; + case INDEX_op_not_i32: + case INDEX_op_not_i64: + tcg_out_opc_nor(s, a0, a1, TCG_REG_ZERO); + break; + + case INDEX_op_nor_i32: + case INDEX_op_nor_i64: + if (c2) { + tcg_out_opc_ori(s, a0, a1, a2); + tcg_out_opc_nor(s, a0, a0, TCG_REG_ZERO); + } else { + tcg_out_opc_nor(s, a0, a1, a2); + } + break; + + case INDEX_op_andc_i32: + case INDEX_op_andc_i64: + if (c2) { + /* guaranteed to fit due to constraint */ + tcg_out_opc_andi(s, a0, a1, ~a2); + } else { + tcg_out_opc_andn(s, a0, a1, a2); + } + break; + + case INDEX_op_orc_i32: + case INDEX_op_orc_i64: + if (c2) { + /* guaranteed to fit due to constraint */ + tcg_out_opc_ori(s, a0, a1, ~a2); + } else { + tcg_out_opc_orn(s, a0, a1, a2); + } + break; + + case INDEX_op_and_i32: + case INDEX_op_and_i64: + if (c2) { + tcg_out_opc_andi(s, a0, a1, a2); + } else { + tcg_out_opc_and(s, a0, a1, a2); + } + break; + + case INDEX_op_or_i32: + case INDEX_op_or_i64: + if (c2) { + tcg_out_opc_ori(s, a0, a1, a2); + } else { + tcg_out_opc_or(s, a0, a1, a2); + } + break; + + case INDEX_op_xor_i32: + case INDEX_op_xor_i64: + if (c2) { + tcg_out_opc_xori(s, a0, a1, a2); + } else { + tcg_out_opc_xor(s, a0, a1, a2); + } + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -494,8 +558,32 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_extrl_i64_i32: case INDEX_op_extrh_i64_i32: case INDEX_op_ext_i32_i64: + case INDEX_op_not_i32: + case INDEX_op_not_i64: return C_O1_I1(r, r); + case INDEX_op_andc_i32: + case INDEX_op_andc_i64: + case INDEX_op_orc_i32: + case INDEX_op_orc_i64: + /* + * LoongArch insns for these ops don't have reg-imm forms, but we + * can express using andi/ori if ~constant satisfies + * TCG_CT_CONST_U12. + */ + return C_O1_I2(r, r, rC); + + case INDEX_op_and_i32: + case INDEX_op_and_i64: + case INDEX_op_nor_i32: + case INDEX_op_nor_i64: + case INDEX_op_or_i32: + case INDEX_op_or_i64: + case INDEX_op_xor_i32: + case INDEX_op_xor_i64: + /* LoongArch reg-imm bitops have their imms ZERO-extended */ + return C_O1_I2(r, r, rU); + default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526604 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5228244imb; Tue, 21 Dec 2021 08:56:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyI/gF1jUvjA2j9FmSGoBy4Vrrm8greWDwiZkqPGPleoDnuaizXw3W7etLuy2yLoPCnQaOL X-Received: by 2002:a5b:b90:: with SMTP id l16mr5710968ybq.632.1640105808174; Tue, 21 Dec 2021 08:56:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105808; cv=none; d=google.com; s=arc-20160816; b=lFzqfgchtM39tYTi8Alv1BMIt49jenT5cPsVwZjhl323UdIF9u6EjoY4/xst+qSGtA 9WqhRGPWMo04/CVyFavB8uYtMqx+g4vXWwYIkx06srY7Vrr9Beg3aPW3YIhLjsGgOf8e FzyXDmuTbDjVM4z+PQWTrCMQpndXqkp4elnRawWhf5uNL9AMJkQPUYnYJ9DOwkrxJSw2 0yY78sm2dvIRtBe1Wu61DeCX05NlgD62JPpjGBlBkfUIpsXSHbM3xng0JKIIG0MQQ7Ld kYZspyaWVFtmVJWzIZqdul3CEAvpFDG1eLUgiXaz4xT77JDFcem6lLDZM0BYBtS6tRj9 LLMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vbBqX8145SzL5fir9xbqnpl78evPfhWM7yUrolGINac=; b=ZYNQIxMELWIMaYI4y3XgvSKmyydDSDJxJSRaNBu/fhEe1flEqKU2lkgHfcbIGfDYBT rIzHP+gFcXTaaleiZOUpX30jjBdHU6ku4z0mCI+nJfJ3KeIQNJOaSDO8gnecjx+Yk0Cu tBLYnVvac/EzxTX31kf1avvEOSexUdFfUHFyKGIZ1YYh6sSx1vNUvvM/jDbVugDCQz4a P6EZ3PCJWA+eTM8QyYRCRBzdTkzB9kqVrjjbZAYgy4rZHRHwBczEiqMGCfu6mFtAh2eQ LbVPjitpia+rLbwDkQcUUcwOEH8eKi2K1vdAC46IscNfa73HgWqxyVLiV/8GFfTNSfaf NrEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTFqde6f; 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 193si20001900ybe.43.2021.12.21.08.56.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:56:48 -0800 (PST) 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=BTFqde6f; 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]:54564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziRT-000397-ID for patch@linaro.org; Tue, 21 Dec 2021 11:56:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIw-0000KR-Ad for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:58 -0500 Received: from [2607:f8b0:4864:20::534] (port=37441 helo=mail-pg1-x534.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIr-0007cp-4p for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:58 -0500 Received: by mail-pg1-x534.google.com with SMTP id a23so12831773pgm.4 for ; Tue, 21 Dec 2021 08:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vbBqX8145SzL5fir9xbqnpl78evPfhWM7yUrolGINac=; b=BTFqde6fmni3EdnA2Chh4wkAGej+CRmKKM4rxXiAuT6Pf0lyboEWChpxOyBATZ95b2 U5/SCOVqlLrDdCv4/wLdzL2g1t2qiXuXgPkcx73MBO9iBb58dxXxIqE34S45E+iXOICP VeHaAQv3WgshguhuFhItzd0HhDMd5pPCfatjrUZujunrygPUDFuO0I0d98yaU3n1n/E2 iaI03jhpmG80BrbkOfyWoGYGT56acFs4trSGvCbfKrkNHE2wbBoqz8EbLeQ6ptVEiLmU wdDBbyKB8I1TLxiFeN4csXBSWMb+5i9ihRxnT+LiRDp8jR2K5cG+FLvk4nlnkN06FHyO Po/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vbBqX8145SzL5fir9xbqnpl78evPfhWM7yUrolGINac=; b=umU6I8kQn4h2k1jhocKtUULA8uzxIFfoG98yBkypT3Ip+jFwq1DrD1lM7yqRr8qJeI eXGdcjjZAORwucnoG5qZyeLrkwQd+I+fVMKXz6rh2ueyHCRZkyhLdjJUQjSU5lqE8fDr 2wSv002EdBs5YXOQ1vb/Uqc3hr2Jyu8wwUYcJwUjcIkQa3ICXZy5euBMeIqjH3QXy1G9 waIheewIgzh0p20bHsuInp5aYty/lfgpuRZ+TDZL69CVxF7Zm53sCugyzfqDikMDfZqL Ql57L+CpdBl5cbpKRTnGwlpecDYNT8HRN0xfpVtIbFrpDt/oDl6AiUJlBznusIkrHxPf nmZA== X-Gm-Message-State: AOAM531KA+wYCe5AIes21ct2TK27p9ZMXL5/3KqU+jyOqudKzv/tkUi5 EMTnIuDio0pvj7zQ/3IxSBYa/Y76nD5w8g== X-Received: by 2002:a05:6a00:114d:b0:4a2:87bd:37f with SMTP id b13-20020a056a00114d00b004a287bd037fmr4167375pfm.82.1640105270805; Tue, 21 Dec 2021 08:47:50 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/31] tcg/loongarch64: Implement deposit/extract ops Date: Tue, 21 Dec 2021 08:47:19 -0800 Message-Id: <20211221164737.1076007-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::534 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-14-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 8 ++++---- tcg/loongarch64/tcg-target.c.inc | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 9ac24b8ad0..d958183020 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -18,3 +18,4 @@ C_O0_I1(r) C_O1_I1(r, r) C_O1_I2(r, r, rC) C_O1_I2(r, r, rU) +C_O1_I2(r, 0, rZ) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index cc9aecc681..1c9d0a9988 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -97,8 +97,8 @@ typedef enum { #define TCG_TARGET_HAS_rem_i32 0 #define TCG_TARGET_HAS_div2_i32 0 #define TCG_TARGET_HAS_rot_i32 0 -#define TCG_TARGET_HAS_deposit_i32 0 -#define TCG_TARGET_HAS_extract_i32 0 +#define TCG_TARGET_HAS_deposit_i32 1 +#define TCG_TARGET_HAS_extract_i32 1 #define TCG_TARGET_HAS_sextract_i32 0 #define TCG_TARGET_HAS_extract2_i32 0 #define TCG_TARGET_HAS_add2_i32 0 @@ -134,8 +134,8 @@ typedef enum { #define TCG_TARGET_HAS_rem_i64 0 #define TCG_TARGET_HAS_div2_i64 0 #define TCG_TARGET_HAS_rot_i64 0 -#define TCG_TARGET_HAS_deposit_i64 0 -#define TCG_TARGET_HAS_extract_i64 0 +#define TCG_TARGET_HAS_deposit_i64 1 +#define TCG_TARGET_HAS_extract_i64 1 #define TCG_TARGET_HAS_sextract_i64 0 #define TCG_TARGET_HAS_extract2_i64 0 #define TCG_TARGET_HAS_extrl_i64_i32 1 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index d9508d5295..9eba8f8146 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -531,6 +531,20 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; + case INDEX_op_extract_i32: + tcg_out_opc_bstrpick_w(s, a0, a1, a2, a2 + args[3] - 1); + break; + case INDEX_op_extract_i64: + tcg_out_opc_bstrpick_d(s, a0, a1, a2, a2 + args[3] - 1); + break; + + case INDEX_op_deposit_i32: + tcg_out_opc_bstrins_w(s, a0, a2, args[3], args[3] + args[4] - 1); + break; + case INDEX_op_deposit_i64: + tcg_out_opc_bstrins_d(s, a0, a2, args[3], args[3] + args[4] - 1); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -560,6 +574,8 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_ext_i32_i64: case INDEX_op_not_i32: case INDEX_op_not_i64: + case INDEX_op_extract_i32: + case INDEX_op_extract_i64: return C_O1_I1(r, r); case INDEX_op_andc_i32: @@ -584,6 +600,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) /* LoongArch reg-imm bitops have their imms ZERO-extended */ return C_O1_I2(r, r, rU); + case INDEX_op_deposit_i32: + case INDEX_op_deposit_i64: + /* Must deposit into the same register as input */ + return C_O1_I2(r, 0, rZ); + default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526605 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5228380imb; Tue, 21 Dec 2021 08:57:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXDESpHpV81v/zkOx5aLe+MPcW0Okk1c7JeSPDj0+bngV2fBu830Sqr+U5Xif8z1pqwj5D X-Received: by 2002:a05:6902:508:: with SMTP id x8mr5577790ybs.353.1640105820085; Tue, 21 Dec 2021 08:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105820; cv=none; d=google.com; s=arc-20160816; b=LWg6kC8lPDKBUzl8jLvctZxE/aMqYr0QbbzQHj4+hWw2ifcHNzYBiWO3nsjYf1Tgu9 JqnpaQYpRV8csbwxp459qpMU/tQLKi7qFEBFJqbI3eQmnCLcxH5dP9RbMuXrz2yeQtl3 T0urCdOHl7kHiCJffnKI+PXnarjDLGupaTrKqKbdDCGA/VuDXvnYewP/ue+i3jm4lhw8 wWU/5qDvXi9pWV+Obu61PjRtadm2OV7HzM3dhzqac9smmGGLgFZBGS2DJEpD5JPr6Jx4 I8ZoY2rNPPxnPOzzMn0owAPRVnHQLqYVXVndW9vYitUz4BLg+fXR/U4hUdy2rjPc04xP dUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cHpfaLVydfnDFFFHb5r43nae1+7GWHTxLwo4cKt6VDc=; b=N9YmRIjDP6BGsNhhr0KDjwFxT2K+tdi+oU47JqxrXAyv4LUP1WxygkE6KWhI2bPhyN Iric5n8R9EeuDNkOVhPmuf8jYPeAovwigtSx7z9wftzKECTKEfMki1U0LsCI4zSZIwNe 95z9SxmDo1RBf3cPVIA5odkvZqDn1PrtluV4Nuqlq7eURiiHO3vjKPeBwGsKCyf+OzKw T7Q3Ebm7pNGhpgAsBcGqyv0yYiOJavhv6/t4MfXzB2afFcKAu42v6Amjx0kurhpJ+8km fKNtccX2Y9Uy/44ZLmVUqDJziDxk2db/fcBsheat+xCkCJ5Q+mKNcI4cJBweEdBV61ae ziXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pXKNKqfZ; 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 z6si14511827ybn.234.2021.12.21.08.57.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:57:00 -0800 (PST) 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=pXKNKqfZ; 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]:54894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziRe-0003Ls-PR for patch@linaro.org; Tue, 21 Dec 2021 11:56:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIu-0000EP-Uu for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:56 -0500 Received: from [2607:f8b0:4864:20::52e] (port=38654 helo=mail-pg1-x52e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIr-0007ct-17 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:56 -0500 Received: by mail-pg1-x52e.google.com with SMTP id y9so12829083pgj.5 for ; Tue, 21 Dec 2021 08:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cHpfaLVydfnDFFFHb5r43nae1+7GWHTxLwo4cKt6VDc=; b=pXKNKqfZjsDQ+6yOh6nvQ0YaCZMGFCD3yJMRbDKJtfogwvOYeB4j0YgzL1ofrOc++5 AZIW7LDUZJfIzDyGgQ8Mhtm+ZfMSXriiWJySrlFcNKelkvidcWTU3VJSqVauWzLhLZZp f1CBL8gWMloQ8nY0GVmE2SqYJz0io1oo8kOicnj627B/33cBGog/lsAEQ65GbHBwO6UN JUaxN784UfykO5eojhI31JlCFn8S/9Naw0j7uDyFS6mop7tEIUbWlip5LN5jl/6q8i+3 w4VGi31MadTkcLemLxLx362j+Vv/WTxluSNaZiMGII7MY0YUGGoLkzGFe5mOMD2SRZD3 ESFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cHpfaLVydfnDFFFHb5r43nae1+7GWHTxLwo4cKt6VDc=; b=jSGB9QW1seWRo7SOzXkj7ysdxCoResEKjeKouAhCmIU+SKI0hrf3txziP341dXrV/p HhhcL99Oetx21X+5phwMO1NB+77Yc+qHlCXy3xbQ09n5LZFjsvNU8IJZir7dEJJNQwB/ 10evDIFkTO13T501HJ+eSYlr6UdiCoFBr402PW3wvuNoKPKmIsqc8W+duZwQ3FYvajvK 3UyQDadd96d2YBe7Q1KoXMe0FIeAJ00mNVgjgFisUDik9vSF7czE4OJi/xuCwgase9k8 BdYZ05b+6byKi4hDF5GyepInYdt7/09npb6oxc8b/oEHJX+kYSNuuqyjTaHsQambhcvg CSdQ== X-Gm-Message-State: AOAM533s0Bb4TtN4eZ2uB2jT7GtCZjsNx7KeFEv1Adfl241JVbV3/ssb CV4ROclAuMF4+r9ye7x4Nm4Hn/104EhaAg== X-Received: by 2002:a63:5250:: with SMTP id s16mr3741012pgl.202.1640105271789; Tue, 21 Dec 2021 08:47:51 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/31] tcg/loongarch64: Implement bswap{16,32,64} ops Date: Tue, 21 Dec 2021 08:47:20 -0800 Message-Id: <20211221164737.1076007-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-15-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.h | 10 +++++----- tcg/loongarch64/tcg-target.c.inc | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 1c9d0a9988..5303001653 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -111,8 +111,8 @@ typedef enum { #define TCG_TARGET_HAS_ext16s_i32 1 #define TCG_TARGET_HAS_ext8u_i32 1 #define TCG_TARGET_HAS_ext16u_i32 1 -#define TCG_TARGET_HAS_bswap16_i32 0 -#define TCG_TARGET_HAS_bswap32_i32 0 +#define TCG_TARGET_HAS_bswap16_i32 1 +#define TCG_TARGET_HAS_bswap32_i32 1 #define TCG_TARGET_HAS_not_i32 1 #define TCG_TARGET_HAS_neg_i32 0 #define TCG_TARGET_HAS_andc_i32 1 @@ -146,9 +146,9 @@ typedef enum { #define TCG_TARGET_HAS_ext8u_i64 1 #define TCG_TARGET_HAS_ext16u_i64 1 #define TCG_TARGET_HAS_ext32u_i64 1 -#define TCG_TARGET_HAS_bswap16_i64 0 -#define TCG_TARGET_HAS_bswap32_i64 0 -#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_bswap16_i64 1 +#define TCG_TARGET_HAS_bswap32_i64 1 +#define TCG_TARGET_HAS_bswap64_i64 1 #define TCG_TARGET_HAS_not_i64 1 #define TCG_TARGET_HAS_neg_i64 0 #define TCG_TARGET_HAS_andc_i64 1 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 9eba8f8146..3b056dd358 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -545,6 +545,33 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_bstrins_d(s, a0, a2, args[3], args[3] + args[4] - 1); break; + case INDEX_op_bswap16_i32: + case INDEX_op_bswap16_i64: + tcg_out_opc_revb_2h(s, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_ext16s(s, a0, a0); + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_ext16u(s, a0, a0); + } + break; + + case INDEX_op_bswap32_i32: + /* All 32-bit values are computed sign-extended in the register. */ + a2 = TCG_BSWAP_OS; + /* fallthrough */ + case INDEX_op_bswap32_i64: + tcg_out_opc_revb_2w(s, a0, a1); + if (a2 & TCG_BSWAP_OS) { + tcg_out_ext32s(s, a0, a0); + } else if ((a2 & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) == TCG_BSWAP_OZ) { + tcg_out_ext32u(s, a0, a0); + } + break; + + case INDEX_op_bswap64_i64: + tcg_out_opc_revb_d(s, a0, a1); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -576,6 +603,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_not_i64: case INDEX_op_extract_i32: case INDEX_op_extract_i64: + case INDEX_op_bswap16_i32: + case INDEX_op_bswap16_i64: + case INDEX_op_bswap32_i32: + case INDEX_op_bswap32_i64: + case INDEX_op_bswap64_i64: return C_O1_I1(r, r); case INDEX_op_andc_i32: From patchwork Tue Dec 21 16:47:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526608 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5230314imb; Tue, 21 Dec 2021 08:59:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwsb2TzLkxagOS3qHUQJJHE58vvRzej7TlNlQoYvkJIe0Gyy+sj6ZJ79WMIqGZDNTCTD72 X-Received: by 2002:a25:2f03:: with SMTP id v3mr5885196ybv.557.1640105991227; Tue, 21 Dec 2021 08:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105991; cv=none; d=google.com; s=arc-20160816; b=oEIHkHuRXXAhxLNcTGzf9zaWPHkSNNOJu3OCZ1ZKLoToV/KGUi5VHsvEkEgsFgXWa2 rByY9ydGjCR+nVkBz4kDTRNHIR75w5kfT3W6BUkdppO/+QHelN7A/Tr1wv1lDdvlaQjt aFHnmJw4P8WR2giW3C11XxmuqRhizQWAWy3AZ29k9/893wx9sd7WHhcsbPJOQ1PSQaLn qhWo0DgG+CzKvWIUyC4Oi/Y+re2z1Vn5HL655Ct94y70TG41VXyDZzRx3Uz+gPGisL3b uhF4xk4Ml6RvV/1N+sWbOFLqmgH7brj8qeC+0agImbOA+3CLdGtjlfUCoZuCv/HLaQdg iD9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=g/ZansEwFOaBtkGLkicA0MHIWwkeqDn07upI3aEefAs=; b=q/fHsU8PeCHnLLSiv9BGs5Z7jUPxpnwS6t+j0CFFiAwAp+flYa5hnDcn/LJWFtZAP1 mdH9Y2eHl2Z3QOZ52+cqB/jt6IBVblBbs8exzRG3+hGTxARCtdaYRKYVDs/gCoZDHwum ODYpLDiPAPXFekFu3R/yIINDYGVcdvcLVtfkuZBxUE8n/j0Bxea2qSxGKDiu+EUVznn3 w1GT42ZiH1Nnh7730gvu8fzT4SVp4QBFjWdxhNQuja1XJJPEWFJlcRjjgp1xT6Y9hnED OvYErwcnfLq5Zt2hB9Y3w2XhHjQLOidiNl2A5+cu7YDCAtgnPMVbcpsjJO35nHrz/oKi iMRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dMl0d/dz"; 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 o3si29302261ybu.554.2021.12.21.08.59.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:59:51 -0800 (PST) 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="dMl0d/dz"; 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]:35330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziUQ-0000ry-LL for patch@linaro.org; Tue, 21 Dec 2021 11:59:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIx-0000PI-QB for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:59 -0500 Received: from [2607:f8b0:4864:20::1029] (port=46644 helo=mail-pj1-x1029.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIs-0007d5-0e for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:47:59 -0500 Received: by mail-pj1-x1029.google.com with SMTP id rj2-20020a17090b3e8200b001b1944bad25so3726414pjb.5 for ; Tue, 21 Dec 2021 08:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g/ZansEwFOaBtkGLkicA0MHIWwkeqDn07upI3aEefAs=; b=dMl0d/dz9/sxfp6AhfKjZhMsortJICn0e9ROPeEgFNKVpMQ+zbqBSLZPhFi6X4P6Nm +lV09KeCR8UGM2em6LqY2CIXi0a5zHaqbCmEE7I3Y54VabM1/OQCY2xBc1p4Gx2Jc4+L 3636yFLtBPSR1JUF8/+Zn/ZrwG1N7OgUF+5suArV7m5KRXPRjoh8ITOFkrWD2/6PzHnj zcsSV03U7xabTL6gs5ZIJpcIRuAOIuiNR//5mT6HWAUU7D9LNlNekSUwQfjMtQRcwGhk 1kjPsFdWVkvdRMVzBCEChUFM54FhPmQfMleBVJNQ76Re6xmX0A0jhfwzyL6H7v0T1DHO uaxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g/ZansEwFOaBtkGLkicA0MHIWwkeqDn07upI3aEefAs=; b=zHsNj8B3CvtbYcqQ67Dn/kADd3paXDwYbfhLtCl0FEYZLWeggOtjKQrQfTK7Fq2x/a 7VQTirXPxrPAPLFHIcBycIxPmzVacuORZK4aCADTcCSXutxUZAW8HDNA2JP2QmpBWd38 4KJpQclUY699oX2sX2yFTIIX2ShfT9Tl3mUzeBFf6+Ph4xQp0aXqFnkDizL4rL66wtBG L/EtMXLeXQOl5MYA9yNsEzIh7ARtSAnuPfpev5DUH2o2yxUdQJsVjbRt4vvQt8nZyGMw bOdYB+GRc1N9d3xSC7BbI57xN7pKX/IQsf7GD5fYaTkZoo8E/Owk1TmPCPLWUhTBOC8h brOQ== X-Gm-Message-State: AOAM533CHxZAZ4QOdiGtvz0omb5J+TI0Y0Keyr62la6pk9H7ld32cmSc PamMHLrArCxpQmkKsKhh4cpfg+vE9fF5gQ== X-Received: by 2002:a17:90a:578b:: with SMTP id g11mr4908051pji.76.1640105272684; Tue, 21 Dec 2021 08:47:52 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/31] tcg/loongarch64: Implement clz/ctz ops Date: Tue, 21 Dec 2021 08:47:21 -0800 Message-Id: <20211221164737.1076007-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1029 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-16-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 8 +++--- tcg/loongarch64/tcg-target.c.inc | 42 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index d958183020..2975e03127 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -18,4 +18,5 @@ C_O0_I1(r) C_O1_I1(r, r) C_O1_I2(r, r, rC) C_O1_I2(r, r, rU) +C_O1_I2(r, r, rW) C_O1_I2(r, 0, rZ) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 5303001653..2fd2745b63 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -120,8 +120,8 @@ typedef enum { #define TCG_TARGET_HAS_eqv_i32 0 #define TCG_TARGET_HAS_nand_i32 0 #define TCG_TARGET_HAS_nor_i32 1 -#define TCG_TARGET_HAS_clz_i32 0 -#define TCG_TARGET_HAS_ctz_i32 0 +#define TCG_TARGET_HAS_clz_i32 1 +#define TCG_TARGET_HAS_ctz_i32 1 #define TCG_TARGET_HAS_ctpop_i32 0 #define TCG_TARGET_HAS_direct_jump 0 #define TCG_TARGET_HAS_brcond2 0 @@ -156,8 +156,8 @@ typedef enum { #define TCG_TARGET_HAS_eqv_i64 0 #define TCG_TARGET_HAS_nand_i64 0 #define TCG_TARGET_HAS_nor_i64 1 -#define TCG_TARGET_HAS_clz_i64 0 -#define TCG_TARGET_HAS_ctz_i64 0 +#define TCG_TARGET_HAS_clz_i64 1 +#define TCG_TARGET_HAS_ctz_i64 1 #define TCG_TARGET_HAS_ctpop_i64 0 #define TCG_TARGET_HAS_add2_i64 0 #define TCG_TARGET_HAS_sub2_i64 0 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 3b056dd358..39df2885b5 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -412,6 +412,28 @@ static void tcg_out_ext32s(TCGContext *s, TCGReg ret, TCGReg arg) tcg_out_opc_addi_w(s, ret, arg, 0); } +static void tcg_out_clzctz(TCGContext *s, LoongArchInsn opc, + TCGReg a0, TCGReg a1, TCGReg a2, + bool c2, bool is_32bit) +{ + if (c2) { + /* + * Fast path: semantics already satisfied due to constraint and + * insn behavior, single instruction is enough. + */ + tcg_debug_assert(a2 == (is_32bit ? 32 : 64)); + /* all clz/ctz insns belong to DJ-format */ + tcg_out32(s, encode_dj_insn(opc, a0, a1)); + return; + } + + tcg_out32(s, encode_dj_insn(opc, TCG_REG_TMP0, a1)); + /* a0 = a1 ? REG_TMP0 : a2 */ + tcg_out_opc_maskeqz(s, TCG_REG_TMP0, TCG_REG_TMP0, a1); + tcg_out_opc_masknez(s, a0, a2, a1); + tcg_out_opc_or(s, a0, TCG_REG_TMP0, a0); +} + /* * Entry-points */ @@ -572,6 +594,20 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_revb_d(s, a0, a1); break; + case INDEX_op_clz_i32: + tcg_out_clzctz(s, OPC_CLZ_W, a0, a1, a2, c2, true); + break; + case INDEX_op_clz_i64: + tcg_out_clzctz(s, OPC_CLZ_D, a0, a1, a2, c2, false); + break; + + case INDEX_op_ctz_i32: + tcg_out_clzctz(s, OPC_CTZ_W, a0, a1, a2, c2, true); + break; + case INDEX_op_ctz_i64: + tcg_out_clzctz(s, OPC_CTZ_D, a0, a1, a2, c2, false); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -632,6 +668,12 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) /* LoongArch reg-imm bitops have their imms ZERO-extended */ return C_O1_I2(r, r, rU); + case INDEX_op_clz_i32: + case INDEX_op_clz_i64: + case INDEX_op_ctz_i32: + case INDEX_op_ctz_i64: + return C_O1_I2(r, r, rW); + case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: /* Must deposit into the same register as input */ From patchwork Tue Dec 21 16:47:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526611 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5233787imb; Tue, 21 Dec 2021 09:03:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrim+3kvtLSj+g5voGB0whsXRWXWavHc7eoAbvlNCY27Q48YdpWtncXYTb3P3Q2us5zvRi X-Received: by 2002:a05:6638:22d6:: with SMTP id j22mr2415085jat.97.1640106197398; Tue, 21 Dec 2021 09:03:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106197; cv=none; d=google.com; s=arc-20160816; b=Fp549jnvw3gZAHLFoeYwXkYqh4OhTu7PnKAik7CQCSQ+6zgdKhrZHcr+iPVzauSNfk 8kTHnkxbHG69OQSqllQ0kYyGJn34n5WedgJLOJj/wYd3P54Qqn79RnPTkSGiaFuzsGHW VH8GkSs9fkowx1yUQDkVY2gi3UHGiQW6nZnAu7zCPz9loIDvwHMHJ/H4FvcQrDgjiRHx oCHHMTXsAUR4UajbQocDRcQ5dR+yH82CWX3ZEyexdcoIzSKHw+rqi1wB9OXMUnv2wezj eqjyQKJg9OM+pRlphERdtF+Y5WLKc9ZCzWoPzcxv/ryO2HtjQ3CGhknedWItKF+n/acz FGEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=7lh8DkVyt2XOdj/tVSgnWpNqZRWhx88hWU6njdp9RQk=; b=j3ABp7OFAeFxmgf0SWVIVIrEHuTqib5lRwZMUyU7Pb2N5BDrUekZ4YNdaf35c+TCb9 5N0ENy70FePgV+CupkblnfBZXn7ICP61wSbQaSjhpMNWJxuwkJGc4bwn1pDoYk8Sp8/V XRQbU9EwQXr9Uvy2Xl0V3sc3qLz9cB4dFt8pvtD82OIobho6Dtm5r29P2xQtScC9nLRy QBhWZQgRB4pRcj2WisYZfzxMnRXejWL8AB0GsZN4K117/4Gv3PFE1UB45KNiYOPXpuzh aEaRW5Oe+mCyWNqJcLlbypqCjMkpdXIgUDJuU0H1YRrixUyMMhBBRXTFz3nwJs+1ETSe 7n0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bg9306y+; 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 w132si2568955vkd.181.2021.12.21.09.03.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:03:17 -0800 (PST) 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=Bg9306y+; 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]:44020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziXk-0006yp-PQ for patch@linaro.org; Tue, 21 Dec 2021 12:03:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIy-0000Qe-A0 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:00 -0500 Received: from [2607:f8b0:4864:20::529] (port=35548 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIs-0007dK-VX for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:00 -0500 Received: by mail-pg1-x529.google.com with SMTP id v25so7743992pge.2 for ; Tue, 21 Dec 2021 08:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7lh8DkVyt2XOdj/tVSgnWpNqZRWhx88hWU6njdp9RQk=; b=Bg9306y+OdD6RGUuriQUnu6Z7IOJ0KEZWjsAeJjP8EJ4gjHl/Z7JS1F4XsZPE8Ga+d tG+6YP3Y6OUs0fCsEc/aobdpZJ1ZmdBpS1S3YxZHHYezh2kHDnrf40FNzLg2dwkNNSx6 9Ud27XJhnbVdwTXJx6QzCyZyf+8AUhG6trLNYfwkhPwIaHs8g7g3EP4H73mnKV3wXO2n S+gjYs7AOemNAtBLp0ZBb7pDLjUqH9/g2ZBm81C5LOEDQVDJtKPkVixIJxZUpjNGHVzd Rw+fYO14OdI15JwcLEjlkyQHlgR6dl9YHL6BVo+nerCY9XWc4WsF3lWT8gVnxAPnAAZ9 phVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7lh8DkVyt2XOdj/tVSgnWpNqZRWhx88hWU6njdp9RQk=; b=hUyDMr7kvQEODLfxwdFwEm2wnVuQDJbTNpssln0lmO5x8bqol6Sw1a9+ZXszuKPFmX PMtcItfPsdEGhRwlypZ7QeUdvL/oqLKLnkLrra1esyFXqdcmgJawVLim6aHw1p3FdQtr GgCPsqIl/IeXPrShsazJ+NyYbuArZTp4Wtz707jBpKKrr0CScFrKmjZ9qhRXpveqhyt+ VTzWFE48LSZV7xGNucodvaKWhzQAh+kWIBt5B0yvEmhimSXPARrctstlLQSX8j84SgMB PgmcqlTsiuZYEwuYcmYFK+jRODH23pK/bfADK/aReOZeDBhhnWaAaiJ7rkRBHFbi0giw ewdg== X-Gm-Message-State: AOAM531UBJ5WmGW0bwE9N7gRVMYVP9YE9K+SK0o5ZX4JsldbkPoj2JZ4 ZOju3Kv+T6+GI81B2sRkUPO+qUJDIekezA== X-Received: by 2002:a63:491a:: with SMTP id w26mr511149pga.110.1640105273615; Tue, 21 Dec 2021 08:47:53 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/31] tcg/loongarch64: Implement shl/shr/sar/rotl/rotr ops Date: Tue, 21 Dec 2021 08:47:22 -0800 Message-Id: <20211221164737.1076007-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-17-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 4 +- tcg/loongarch64/tcg-target.c.inc | 91 ++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 2975e03127..42f8e28741 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -17,6 +17,7 @@ C_O0_I1(r) C_O1_I1(r, r) C_O1_I2(r, r, rC) +C_O1_I2(r, r, ri) C_O1_I2(r, r, rU) C_O1_I2(r, r, rW) C_O1_I2(r, 0, rZ) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 2fd2745b63..d1ded50cb0 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -96,7 +96,7 @@ typedef enum { #define TCG_TARGET_HAS_div_i32 0 #define TCG_TARGET_HAS_rem_i32 0 #define TCG_TARGET_HAS_div2_i32 0 -#define TCG_TARGET_HAS_rot_i32 0 +#define TCG_TARGET_HAS_rot_i32 1 #define TCG_TARGET_HAS_deposit_i32 1 #define TCG_TARGET_HAS_extract_i32 1 #define TCG_TARGET_HAS_sextract_i32 0 @@ -133,7 +133,7 @@ typedef enum { #define TCG_TARGET_HAS_div_i64 0 #define TCG_TARGET_HAS_rem_i64 0 #define TCG_TARGET_HAS_div2_i64 0 -#define TCG_TARGET_HAS_rot_i64 0 +#define TCG_TARGET_HAS_rot_i64 1 #define TCG_TARGET_HAS_deposit_i64 1 #define TCG_TARGET_HAS_extract_i64 1 #define TCG_TARGET_HAS_sextract_i64 0 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 39df2885b5..2895769e68 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -608,6 +608,85 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_clzctz(s, OPC_CTZ_D, a0, a1, a2, c2, false); break; + case INDEX_op_shl_i32: + if (c2) { + tcg_out_opc_slli_w(s, a0, a1, a2 & 0x1f); + } else { + tcg_out_opc_sll_w(s, a0, a1, a2); + } + break; + case INDEX_op_shl_i64: + if (c2) { + tcg_out_opc_slli_d(s, a0, a1, a2 & 0x3f); + } else { + tcg_out_opc_sll_d(s, a0, a1, a2); + } + break; + + case INDEX_op_shr_i32: + if (c2) { + tcg_out_opc_srli_w(s, a0, a1, a2 & 0x1f); + } else { + tcg_out_opc_srl_w(s, a0, a1, a2); + } + break; + case INDEX_op_shr_i64: + if (c2) { + tcg_out_opc_srli_d(s, a0, a1, a2 & 0x3f); + } else { + tcg_out_opc_srl_d(s, a0, a1, a2); + } + break; + + case INDEX_op_sar_i32: + if (c2) { + tcg_out_opc_srai_w(s, a0, a1, a2 & 0x1f); + } else { + tcg_out_opc_sra_w(s, a0, a1, a2); + } + break; + case INDEX_op_sar_i64: + if (c2) { + tcg_out_opc_srai_d(s, a0, a1, a2 & 0x3f); + } else { + tcg_out_opc_sra_d(s, a0, a1, a2); + } + break; + + case INDEX_op_rotl_i32: + /* transform into equivalent rotr/rotri */ + if (c2) { + tcg_out_opc_rotri_w(s, a0, a1, (32 - a2) & 0x1f); + } else { + tcg_out_opc_sub_w(s, TCG_REG_TMP0, TCG_REG_ZERO, a2); + tcg_out_opc_rotr_w(s, a0, a1, TCG_REG_TMP0); + } + break; + case INDEX_op_rotl_i64: + /* transform into equivalent rotr/rotri */ + if (c2) { + tcg_out_opc_rotri_d(s, a0, a1, (64 - a2) & 0x3f); + } else { + tcg_out_opc_sub_w(s, TCG_REG_TMP0, TCG_REG_ZERO, a2); + tcg_out_opc_rotr_d(s, a0, a1, TCG_REG_TMP0); + } + break; + + case INDEX_op_rotr_i32: + if (c2) { + tcg_out_opc_rotri_w(s, a0, a1, a2 & 0x1f); + } else { + tcg_out_opc_rotr_w(s, a0, a1, a2); + } + break; + case INDEX_op_rotr_i64: + if (c2) { + tcg_out_opc_rotri_d(s, a0, a1, a2 & 0x3f); + } else { + tcg_out_opc_rotr_d(s, a0, a1, a2); + } + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -657,6 +736,18 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) */ return C_O1_I2(r, r, rC); + case INDEX_op_shl_i32: + case INDEX_op_shl_i64: + case INDEX_op_shr_i32: + case INDEX_op_shr_i64: + case INDEX_op_sar_i32: + case INDEX_op_sar_i64: + case INDEX_op_rotl_i32: + case INDEX_op_rotl_i64: + case INDEX_op_rotr_i32: + case INDEX_op_rotr_i64: + return C_O1_I2(r, r, ri); + case INDEX_op_and_i32: case INDEX_op_and_i64: case INDEX_op_nor_i32: From patchwork Tue Dec 21 16:47:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526606 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5228510imb; Tue, 21 Dec 2021 08:57:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyC9GQu2ZvxEhW59yFtPusJp6w3/ua262PyZOSdPHe99mgwyWlyH4YQgKFgK7RP17pUQWZ3 X-Received: by 2002:a05:6638:d46:: with SMTP id d6mr2586796jak.129.1640105831880; Tue, 21 Dec 2021 08:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105831; cv=none; d=google.com; s=arc-20160816; b=oqH9dwQx6kLJVeP4HMOvPv6wF+lPc9CseXeXL3lUNuXJ5r4iu29vJSSPmG4hjgfNiZ tUNyFzkOUGqNYwYRBmqA+NdI8Yk+ik8jHY790NluUr3nvKFjrS0g61vRvX0ktcpvDS1K sHuuTxTXwha/Ff+LpC5xt4WMBERKqXfTDqDeD+tNFUD9RTQK8KUq6VmNRkAOtZ2y7Hpy ZAUZWalYjLJErvqCeHbcGHiYLgiMzWlT8uaY2/tvRY2kZ3ky5+nFWFalB0hW4kOVSZlZ 5wC7JbjcDqHfotBmrzSFfX+3bYYAOKE7eQwTBLZLfIAnaBmg/x08urJp4yZrIRlgrfuc +zhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PjAarXq7rmQslFajUb9OO37bFQay55ayArd0DDEEb8g=; b=Tsmacw5ilYB5bwkv15inuoADj6vXO9kXjb6h4Nku6p20xnjdj/exNQNSwELyQAIi62 BA5S2c/MuBVq4JrNI8pGQeEqONhYC/bF4Gi+9ZP8Fzz14LKhs8faalrDS4GKy59FUBPK Eeune6mkgvNmdGZTYlVhpRM8u9/yVjYkjS91WoQDtyuIc6eE4VAUUBgpxg/7s917DWQV PKo9PlE0deZIoqKRhwDxS/g4BeeQoVWtHmhTkMVfNmFE+B7hpowv2NpbWs2CIIAcRET7 RxdmwPYIuhTGnBRRtb8TqEMJLAUIPa5ozQCCG3g0WbvurEIAyWrNJG2coEQc/cbwU3KI q2uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I43/09yT"; 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 i13si3280701ilv.97.2021.12.21.08.57.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:57:11 -0800 (PST) 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="I43/09yT"; 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]:55082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziRr-0003TV-BZ for patch@linaro.org; Tue, 21 Dec 2021 11:57:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIz-0000TM-6V for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:01 -0500 Received: from [2607:f8b0:4864:20::52d] (port=35552 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIt-0007dY-T7 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:00 -0500 Received: by mail-pg1-x52d.google.com with SMTP id v25so7744027pge.2 for ; Tue, 21 Dec 2021 08:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PjAarXq7rmQslFajUb9OO37bFQay55ayArd0DDEEb8g=; b=I43/09yTbP0FNRJVfxLrJ+OSagGrlqFPoiQugjy1YQQSHDKocx7ejSoxwCICzD/9wE ECVa24nHUeQcsoNU1lJwrLDd8yLoyBiTHPoRR14G2tf0V9wnLEc8d6t675C916FVNepu eXJWyOPs/36BzdVVgyjo23wFUVJiIBSKZhgiH9bDg6E+AGnpdNdaqlHVCCZNkPDnpOOy lqq5LcFBgUwgiJLLuOUE5+nHOpN8WzPTzUcxMhVwmgsZojgN0FTrBwXDXkrpOPqqxIcJ DTIg3x7bsLTcxFkh+GIgL8EZQJyrExT8qxj5f+zGnITBQbUP8AcBd/ulTyHHjmPQPWfP Rqqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PjAarXq7rmQslFajUb9OO37bFQay55ayArd0DDEEb8g=; b=gnJdqp1pFrup6Nm5mWpm73L7bq5A7ClT4A3SNzKaroDQOKD2h5Z3iiYWp+SEWmiVx3 hzm8RjqxDo+HVfN7/IzU22JxYTRhn68hRgMg3yJlJH9RGm4dNNLU+PcXJU7j/7IWNbmq YYXCadez0OUiIXMW3p3K01wPiMDi7nc4bCpp8YeekEAItvcvj9co8ei2LTutLlaMQBSf V4diVPBjsC7SdqXfLCsu7MpvtYmDJ/qedfCkHUPNhnoDxqRCrLKdds4Db95j4UqCBHzu GheXSJZu1YBmHHheXjY0X4waz0xx06U3xaLNo98CcV6rVaEzOLmuz8aVjL5z79wZuLEv vimg== X-Gm-Message-State: AOAM533BztHWXq/G5AaveOy1L1fklnDtRoYyvfk6L4y0PGxW3hSBwBcz yn7iNuw9WcP+kjNslbTiuGXLKMpnbjOxhQ== X-Received: by 2002:a05:6a00:1516:b0:4a0:2c42:7f17 with SMTP id q22-20020a056a00151600b004a02c427f17mr3852784pfu.74.1640105274688; Tue, 21 Dec 2021 08:47:54 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 17/31] tcg/loongarch64: Implement add/sub ops Date: Tue, 21 Dec 2021 08:47:23 -0800 Message-Id: <20211221164737.1076007-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui The neg_i{32,64} ops is fully expressible with sub, so omitted for simplicity. Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-18-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 2 ++ tcg/loongarch64/tcg-target.c.inc | 38 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 42f8e28741..4b8ce85897 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -18,6 +18,8 @@ C_O0_I1(r) C_O1_I1(r, r) C_O1_I2(r, r, rC) C_O1_I2(r, r, ri) +C_O1_I2(r, r, rI) C_O1_I2(r, r, rU) C_O1_I2(r, r, rW) C_O1_I2(r, 0, rZ) +C_O1_I2(r, rZ, rN) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 2895769e68..c71d25d3fe 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -687,6 +687,36 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; + case INDEX_op_add_i32: + if (c2) { + tcg_out_opc_addi_w(s, a0, a1, a2); + } else { + tcg_out_opc_add_w(s, a0, a1, a2); + } + break; + case INDEX_op_add_i64: + if (c2) { + tcg_out_opc_addi_d(s, a0, a1, a2); + } else { + tcg_out_opc_add_d(s, a0, a1, a2); + } + break; + + case INDEX_op_sub_i32: + if (c2) { + tcg_out_opc_addi_w(s, a0, a1, -a2); + } else { + tcg_out_opc_sub_w(s, a0, a1, a2); + } + break; + case INDEX_op_sub_i64: + if (c2) { + tcg_out_opc_addi_d(s, a0, a1, -a2); + } else { + tcg_out_opc_sub_d(s, a0, a1, a2); + } + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -748,6 +778,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_rotr_i64: return C_O1_I2(r, r, ri); + case INDEX_op_add_i32: + case INDEX_op_add_i64: + return C_O1_I2(r, r, rI); + case INDEX_op_and_i32: case INDEX_op_and_i64: case INDEX_op_nor_i32: @@ -770,6 +804,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) /* Must deposit into the same register as input */ return C_O1_I2(r, 0, rZ); + case INDEX_op_sub_i32: + case INDEX_op_sub_i64: + return C_O1_I2(r, rZ, rN); + default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526609 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5230332imb; Tue, 21 Dec 2021 08:59:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUVkfRVMbwnNX+MYTXLGPdL0CqnRd1rzE/ePdNKdC0xPb+v+byPAaRjxrOn069sAK+rXqq X-Received: by 2002:a25:cd47:: with SMTP id d68mr5837266ybf.537.1640105992917; Tue, 21 Dec 2021 08:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640105992; cv=none; d=google.com; s=arc-20160816; b=dn4M4gY3CkXA54YSbxulQQ8+hqKkc/cjx3H+A0dz4j8ZfA0Nx/RXQ/4v41H0rRLhVi xUa0vmhfHVK2tOl4erE2owfNxUFAC4mRhWNehOhAfP+nhd8Hqei24nRqRrSGms5BG2aZ hweReZkmxCWgubgC40o0SpJQrbskd0lUQPuI38uK0Mzs83IdOylEVwuLgRHrBQXSVxtb WoCeCBTBDc+NnZMf9CTppU+L4/X54Q9niRSOraMKkpP4wtjHLnM71q7Xox8k7YhxuiL4 htub7aJWAQe0FdLdKjQ6m8iPSmnAwDgdMFkqvUiD+7WGQAB0f6Or0EmFN0gZIFYk6GNt sF9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=h3IfsTdV++ttG/ya2ZB3/Tnu3hCKPlZE3g7VrtqS5qs=; b=0PT9PTNfFVN3TBSY0E//jftmx5n2fBlir5hL2o8KnSQe7N+xRvnyjeGCmVqBiBJLNF ERfSv7MW+zYNH3+9P15jY8PHvU3lZwongAlFggcROc5tM/ldo7CjH1I2azWeim72OF1Y D3O1g0wzYV/q9eb7nuQdLa2vos8PJTQXcozj8bbj9Is9bRFtO+5MWdqYM81kUNEXvbic OP96Ep5eHoH/pmaRYhFzVnjJyCvbps1jG6o8DjD+xwQs/Y0o6vHC0ncMSTlEwv9fokKM kjgLQac4Gw2MM17pXfnRP1yrZBWJ4KPsi2ZJSEg02BAvPj5hv29Ht6aEYvCCusEpQble CCpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yeg8AST4; 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 l3si31078237ybt.551.2021.12.21.08.59.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 08:59:52 -0800 (PST) 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=Yeg8AST4; 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]:35522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziUS-00010W-Bc for patch@linaro.org; Tue, 21 Dec 2021 11:59:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziIz-0000Ti-OK for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:01 -0500 Received: from [2607:f8b0:4864:20::630] (port=42659 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIu-0007dj-P7 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:01 -0500 Received: by mail-pl1-x630.google.com with SMTP id u16so5130121plg.9 for ; Tue, 21 Dec 2021 08:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h3IfsTdV++ttG/ya2ZB3/Tnu3hCKPlZE3g7VrtqS5qs=; b=Yeg8AST4CNOucOgTT6w+X4gPmPq5dcct0qbHq2JkL5nEHNHlh0dx+rISAlupygPxzt Ff2jVbxD/KF5PIQK9hxsSLWgH3W821ISL/bXTdcKK9XPZaxs9GVU4wBblVzO12Fq9IJ2 yYfKKy9+YtlNtfSSWTXpUMHHEEdou7NNbO+JvJt114QPkNRc20QSVpOptQUTRBGlRB4M hfr3hR9SlIwz7CZcF889CeqBwooRaBhZouLAcsvymdu2RZ2LreOKzOkkvyenugEELdzF mpuMptmYva963iBIqu1ELWPE73mDHSKZ8TQzCKZayjHuRPPP1gblXtdAeLzi1toUKftV zxdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h3IfsTdV++ttG/ya2ZB3/Tnu3hCKPlZE3g7VrtqS5qs=; b=xem4hCenScfQAczQX5kO2GG2ADnXbnE1OGRuvYEz3vWDunDD1DoM3VvCv8eB85QhJ+ Z13GrQqycccNCSHeZzyM2XQfWdn/3zqDDRtMahGLUxHtcjSd8BobUNpd9x5T0HjUYsqf NMQFaZnGGEpXoYleEBJmOHizCsZCLDOw/s9jwX5e20L9DxILklp1rXKJ0uM+oLEpR3f1 NjB2CEgsAPWCdYxH42qRtC/IJe16/fFYdg9Lz4/Jhsx/9pGKf1djRJCZwUqtc1AXzc3b e9PYoIsvMBaJWCXN9Vcf6u4tYqU4RKk/y4+RuY7ACVHwEMum+OK1hUiG7fHrK+3n6Vvw hmiA== X-Gm-Message-State: AOAM530Cup0PYcYfAxejewYNr88Q8RG4NU+H11mvhiNyDsKnkj0cSugD X60a9Ocux9ayg8CtTv3bnYL2pInmVm3unQ== X-Received: by 2002:a17:90b:3b81:: with SMTP id pc1mr5095709pjb.67.1640105275604; Tue, 21 Dec 2021 08:47:55 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/31] tcg/loongarch64: Implement mul/mulsh/muluh/div/divu/rem/remu ops Date: Tue, 21 Dec 2021 08:47:24 -0800 Message-Id: <20211221164737.1076007-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::630 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-19-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.h | 16 +++---- tcg/loongarch64/tcg-target.c.inc | 65 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 4b8ce85897..fb56f3a295 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -23,3 +23,4 @@ C_O1_I2(r, r, rU) C_O1_I2(r, r, rW) C_O1_I2(r, 0, rZ) C_O1_I2(r, rZ, rN) +C_O1_I2(r, rZ, rZ) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index d1ded50cb0..05010805e7 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -93,8 +93,8 @@ typedef enum { /* optional instructions */ #define TCG_TARGET_HAS_movcond_i32 0 -#define TCG_TARGET_HAS_div_i32 0 -#define TCG_TARGET_HAS_rem_i32 0 +#define TCG_TARGET_HAS_div_i32 1 +#define TCG_TARGET_HAS_rem_i32 1 #define TCG_TARGET_HAS_div2_i32 0 #define TCG_TARGET_HAS_rot_i32 1 #define TCG_TARGET_HAS_deposit_i32 1 @@ -105,8 +105,8 @@ typedef enum { #define TCG_TARGET_HAS_sub2_i32 0 #define TCG_TARGET_HAS_mulu2_i32 0 #define TCG_TARGET_HAS_muls2_i32 0 -#define TCG_TARGET_HAS_muluh_i32 0 -#define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_muluh_i32 1 +#define TCG_TARGET_HAS_mulsh_i32 1 #define TCG_TARGET_HAS_ext8s_i32 1 #define TCG_TARGET_HAS_ext16s_i32 1 #define TCG_TARGET_HAS_ext8u_i32 1 @@ -130,8 +130,8 @@ typedef enum { /* 64-bit operations */ #define TCG_TARGET_HAS_movcond_i64 0 -#define TCG_TARGET_HAS_div_i64 0 -#define TCG_TARGET_HAS_rem_i64 0 +#define TCG_TARGET_HAS_div_i64 1 +#define TCG_TARGET_HAS_rem_i64 1 #define TCG_TARGET_HAS_div2_i64 0 #define TCG_TARGET_HAS_rot_i64 1 #define TCG_TARGET_HAS_deposit_i64 1 @@ -163,8 +163,8 @@ typedef enum { #define TCG_TARGET_HAS_sub2_i64 0 #define TCG_TARGET_HAS_mulu2_i64 0 #define TCG_TARGET_HAS_muls2_i64 0 -#define TCG_TARGET_HAS_muluh_i64 0 -#define TCG_TARGET_HAS_mulsh_i64 0 +#define TCG_TARGET_HAS_muluh_i64 1 +#define TCG_TARGET_HAS_mulsh_i64 1 /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index c71d25d3fe..0ae193fba5 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -717,6 +717,55 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; + case INDEX_op_mul_i32: + tcg_out_opc_mul_w(s, a0, a1, a2); + break; + case INDEX_op_mul_i64: + tcg_out_opc_mul_d(s, a0, a1, a2); + break; + + case INDEX_op_mulsh_i32: + tcg_out_opc_mulh_w(s, a0, a1, a2); + break; + case INDEX_op_mulsh_i64: + tcg_out_opc_mulh_d(s, a0, a1, a2); + break; + + case INDEX_op_muluh_i32: + tcg_out_opc_mulh_wu(s, a0, a1, a2); + break; + case INDEX_op_muluh_i64: + tcg_out_opc_mulh_du(s, a0, a1, a2); + break; + + case INDEX_op_div_i32: + tcg_out_opc_div_w(s, a0, a1, a2); + break; + case INDEX_op_div_i64: + tcg_out_opc_div_d(s, a0, a1, a2); + break; + + case INDEX_op_divu_i32: + tcg_out_opc_div_wu(s, a0, a1, a2); + break; + case INDEX_op_divu_i64: + tcg_out_opc_div_du(s, a0, a1, a2); + break; + + case INDEX_op_rem_i32: + tcg_out_opc_mod_w(s, a0, a1, a2); + break; + case INDEX_op_rem_i64: + tcg_out_opc_mod_d(s, a0, a1, a2); + break; + + case INDEX_op_remu_i32: + tcg_out_opc_mod_wu(s, a0, a1, a2); + break; + case INDEX_op_remu_i64: + tcg_out_opc_mod_du(s, a0, a1, a2); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -808,6 +857,22 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sub_i64: return C_O1_I2(r, rZ, rN); + case INDEX_op_mul_i32: + case INDEX_op_mul_i64: + case INDEX_op_mulsh_i32: + case INDEX_op_mulsh_i64: + case INDEX_op_muluh_i32: + case INDEX_op_muluh_i64: + case INDEX_op_div_i32: + case INDEX_op_div_i64: + case INDEX_op_divu_i32: + case INDEX_op_divu_i64: + case INDEX_op_rem_i32: + case INDEX_op_rem_i64: + case INDEX_op_remu_i32: + case INDEX_op_remu_i64: + return C_O1_I2(r, rZ, rZ); + default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526610 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5231451imb; Tue, 21 Dec 2021 09:01:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9CT4NUJGl3BvUm3uPU3ABB5jBbr4VsOD6r5Zx5PR1eGhbfAv/skCUZzjtqXH3crmdLuX8 X-Received: by 2002:a37:745:: with SMTP id 66mr2650078qkh.11.1640106062916; Tue, 21 Dec 2021 09:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106062; cv=none; d=google.com; s=arc-20160816; b=G3Seju/2FZoxSUaOa/5sbn7d0SyiFlL1wyl+YDe6nf16b5AJe4CvL1U5/q/zaefbuT wbOvaWd4Ecpp8DerVLoYV9yg9awSZx2q2qB7xXt9yNZeMBTvjIXnsZFD2ivytdHgJIA5 9jEHuGzbTKfSyaMrhBK5KaYDt941i3zSg0ZT/aMpPM7asLFBPEW8o/ZW6gI7YZEG1iit gaGi0B+e8IGWAhpxOUpln6ERtf75tSK07gMffi0CpID9nn8YiWGssZWvnJEgCfkGYJml ooFS28h32Uk6v5rqj6VPpvXDqN4VCFrPNDIVgdZGWh7dUvFzCUO6vOQF/MCatur+F9Js +rlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=adJz+s7jT6jWBFyUKxHXaxji8ihsHKTI4sYu6dNqkNg=; b=qJG7KOlt0DUXQS8fi1cq8XQcNjn7RgVJbj1iYpTWbIeOpoJW7NhivpIOGdHXQTOuPD AnAb/BGqo73MdWViJnx+Kg+AFTcluESr1psprMUWrUpdSZrN6V9VR+nOdkQw4I6Mrsed lrH+UVjKgW5bMhDNtMRNHK7agZGTL9BFYOQF7PbCInMe6cB1+fOg+YgbO24AA8clIdf7 EJ3LxqzzQOejw8XRQnM7PTXvLrik4Z+eG9lH09oVIDXKVMd63BFt/gH8eYNQL4nbUZQY tWKWPvvjTnPHuXQJvhoJuXGyDEi+K5ByJ0wMvnVrRY+FImyPgl5m9C3rA/7/c4yqXlwc Gdbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z8lhaD7J; 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 p11si7119734qkm.571.2021.12.21.09.01.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:01:02 -0800 (PST) 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=Z8lhaD7J; 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]:37906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziVZ-0002aN-Qb for patch@linaro.org; Tue, 21 Dec 2021 12:01:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ0-0000WE-KC for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:02 -0500 Received: from [2607:f8b0:4864:20::529] (port=42665 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIv-0007dv-OH for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:02 -0500 Received: by mail-pg1-x529.google.com with SMTP id g2so10253385pgo.9 for ; Tue, 21 Dec 2021 08:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=adJz+s7jT6jWBFyUKxHXaxji8ihsHKTI4sYu6dNqkNg=; b=Z8lhaD7JXY/wwzF8yPR1RIrs+L37g8ZBW6d2vGpP1vp1NLKHvSrbAxK+xg5/gBki+r lH+t6WRYqLYVU4HHnwyNAnI1b7RvmbqhF8Tt3PS5PH1KG5eGylFJCzo4U/oWsnyiRaJU uj0TX6ldRWKskUK6dRIaw2ICnHKL5Q1e+/+1VyR06aMlEW1JnbZNnbQUCMldqOSqBRfA 6gSyOGQqAQRTMpBxu2v5DTojdvroQLyyeTjtVR4TzGlap/KfS6oWx68gTUrghjY+yyxJ Spg85rhRCXt4U3bV8jOGiSG8FXbOo2gJGa0/uy2cRwYMJZUAC+yoPBCGCD99dZdvq1Yp rCgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=adJz+s7jT6jWBFyUKxHXaxji8ihsHKTI4sYu6dNqkNg=; b=4RJQmzrHogaRJksU8WM1CpksBsfS3Sn5NK0uYo6PDTl3kbBH7eJ1631eCQAkuOET3b jWNJmClHX+cXBE9MB72zNBcZR784ijiom7JazzvjJGktiGOUYTlOs1JmQNvpA/SD8sxJ 8maxsAIwk6KPS6xCg0fcg+YQxrk9lsjnUWcZFun3hKCmq1dx7tSE/BljDrsS45m3sVJy ZKIcPtpx+VEJLNXJ4T6cT+y7WKZi7zYoCXHFoCC48j2LyqovXU2BFNZcFJQxLGiMRJqT 17lbd7Kffn9zJSCDFtpTuFdwrlUkDKUvRPvpV0Wdi4NTk6n8J7JobBpwSYI54+Ne/LIo Lqgw== X-Gm-Message-State: AOAM531fQeaIKlgVji1y3fh/3vFN9iXPV0g1SfJajh30flJzFbFy3bjD 1dGtc+TT56KXacMb9NP7QGn66XHOdGcdww== X-Received: by 2002:aa7:8219:0:b0:4a4:bec7:ef10 with SMTP id k25-20020aa78219000000b004a4bec7ef10mr4159947pfi.37.1640105276505; Tue, 21 Dec 2021 08:47:56 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 19/31] tcg/loongarch64: Implement br/brcond ops Date: Tue, 21 Dec 2021 08:47:25 -0800 Message-Id: <20211221164737.1076007-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-20-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.c.inc | 53 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index fb56f3a295..367689c2e2 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -15,6 +15,7 @@ * tcg-target-con-str.h; the constraint combination is inclusive or. */ C_O0_I1(r) +C_O0_I2(rZ, rZ) C_O1_I1(r, r) C_O1_I2(r, r, rC) C_O1_I2(r, r, ri) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 0ae193fba5..aedfc0df84 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -434,6 +434,44 @@ static void tcg_out_clzctz(TCGContext *s, LoongArchInsn opc, tcg_out_opc_or(s, a0, TCG_REG_TMP0, a0); } +/* + * Branch helpers + */ + +static const struct { + LoongArchInsn op; + bool swap; +} tcg_brcond_to_loongarch[] = { + [TCG_COND_EQ] = { OPC_BEQ, false }, + [TCG_COND_NE] = { OPC_BNE, false }, + [TCG_COND_LT] = { OPC_BGT, true }, + [TCG_COND_GE] = { OPC_BLE, true }, + [TCG_COND_LE] = { OPC_BLE, false }, + [TCG_COND_GT] = { OPC_BGT, false }, + [TCG_COND_LTU] = { OPC_BGTU, true }, + [TCG_COND_GEU] = { OPC_BLEU, true }, + [TCG_COND_LEU] = { OPC_BLEU, false }, + [TCG_COND_GTU] = { OPC_BGTU, false } +}; + +static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, + TCGReg arg2, TCGLabel *l) +{ + LoongArchInsn op = tcg_brcond_to_loongarch[cond].op; + + tcg_debug_assert(op != 0); + + if (tcg_brcond_to_loongarch[cond].swap) { + TCGReg t = arg1; + arg1 = arg2; + arg2 = t; + } + + /* all conditional branch insns belong to DJSk16-format */ + tcg_out_reloc(s, s->code_ptr, R_LOONGARCH_BR_SK16, l, 0); + tcg_out32(s, encode_djsk16_insn(op, arg1, arg2, 0)); +} + /* * Entry-points */ @@ -456,6 +494,17 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_jirl(s, TCG_REG_ZERO, a0, 0); break; + case INDEX_op_br: + tcg_out_reloc(s, s->code_ptr, R_LOONGARCH_BR_SD10K16, arg_label(a0), + 0); + tcg_out_opc_b(s, 0); + break; + + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + tcg_out_brcond(s, a2, a0, a1, arg_label(args[3])); + break; + case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: tcg_out_ext8s(s, a0, a1); @@ -779,6 +828,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_goto_ptr: return C_O0_I1(r); + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + return C_O0_I2(rZ, rZ); + case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: case INDEX_op_ext8u_i32: From patchwork Tue Dec 21 16:47:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526616 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5237687imb; Tue, 21 Dec 2021 09:06:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1srezgeRIrmHcGtZXB2jWsvvW8MDaCwctfM6aed3LnFvOVdzSkTAld6epGSjp/P03uoAO X-Received: by 2002:a05:622a:4e:: with SMTP id y14mr3082403qtw.106.1640106394639; Tue, 21 Dec 2021 09:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106394; cv=none; d=google.com; s=arc-20160816; b=oGyI32lOQqeWq4fbRFt83h7+IC6l+rnvAdhFWUA7qmzVP+txPVUg2WMIlFnzqakjQ8 PLOo+T28E2FKP1S7zGa6Ug3qriEAqYcsy9ik7csiRhE2UZVb3rhfQRFQhbvTs9jE3lOX I7Iv++VMN6TTGO6jOhIO7jNKVAOc4w7MB5l0qNGcvrEB9PofoiXHuW9h21jnNYhvSSMH kXWNHqYffxyDpZXtKwpw/wGtt+9QZKAzxXUlumBcx8H56wDaaql6yr2HS7gk6vpdbmqv 9pQcvt1dZhAy8tsZxC2Oqvx8TxNUkUO+PvB/Vnhu2liE4M9wU05zclkk+xCturLRjfwT i8ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zozyKTalGzaNsX7sRaTPXbvLzGeDnY64efJNy5c8mNI=; b=LOHRh83fLAJldDBSOMge1de/DlEIsIpxqQZe6jO4LZs6NZPca0saGtqxHWWpdMvOsl RQeUQWYOT82Ubll79XHUVMuPCFNpA99qaq1yQS1aXclnq8bQbUbEl9g4OEYvIrFsuihl cTz14GFgo2bCjBBpr6k0U4wUHeSxi0ke3mhAp2TWWGpHrYIIYfkHVz/LV9zQMAjLC+Yh 6lrYp5a8yHiamMH5UsmMzhwJRWthIcBJAT7sXAdUfnmvAijXXURp3kJbW8hk6Jref54U bKRz9kVu2AdLCVD+58j9+M440IBeoTDe9ktM/AjzlPf1Zw5jDNiEhnh6nySJME/TkS55 7VbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sUBGTFML; 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 12si8025277qvh.54.2021.12.21.09.06.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:06:34 -0800 (PST) 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=sUBGTFML; 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]:52936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziav-0004Zc-Em for patch@linaro.org; Tue, 21 Dec 2021 12:06:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ7-0000qM-Vp for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:09 -0500 Received: from [2607:f8b0:4864:20::52d] (port=45848 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIw-0007e3-LJ for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:09 -0500 Received: by mail-pg1-x52d.google.com with SMTP id 2so6016855pgb.12 for ; Tue, 21 Dec 2021 08:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zozyKTalGzaNsX7sRaTPXbvLzGeDnY64efJNy5c8mNI=; b=sUBGTFML4qY2wz2qFthdH7oEbO4Pb7FXaScfAs+hdvqiw9fnbiCCl38w4lRDmCd4oU k3x1BY5LVNOF+ZVd69nDXvvCEDX4fOUr/UT+rajsFLTXSFEj9KkxnIT8MLFiHpMX+bAW tgMnj1QoTW0Cq7CUv7YzmDP0Wyfi4yHaa0eV6UmEQXMS+MBgZH8s3Sn377t7/Ql7bCyF MnbyxTtow0JzUq/oTVv2AvuEfLgXoL8NHFlUjvmhoQIwrLgf4mVMxGSpH1WJrHvOmwD7 yuPoVfp+VDb0R2K7FlfCNXEF8dPubKUGU8IwVWpg3z9z7uAx3wIW+PP0oC2LCHQ3dJH4 W6gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zozyKTalGzaNsX7sRaTPXbvLzGeDnY64efJNy5c8mNI=; b=dOz3x9ovbYJ4WxFqGxFrZj2XthMnRaufWR5Kigi7JiGe++uLFwmX3VSOIz+QcqSsdR WR08NBcDRh1My3FAP30cDWjBXtNRLh1VtfH5hSBl8vV5S7S2Zn6JQty5gbrRQ2ObafK8 jFltke+CUln8Zxqeuskr3Hk7zNWAB6Y0Gs3Y7vKb0cyOD6dIl4YIFgPHfkuSHB7Dyxsu 3diaG8uUnvDK1N1dm0THC4XfNFVnpX0hdnRAj04e0N0EJSWgqppYOLZVzk1K8aNEmIst pKMCN/uPSFIAma1VxyWyOlORtnuqj7sVBzE5apo5uom3aUxaf06yvs7dfUJ6cducP+K2 3LIw== X-Gm-Message-State: AOAM531a92pVlHavBJs6tjiFNMDOWRYlxvHcPUDKKSzbFmQ8GjWdHTj/ 1MJPB+GsInmN3MYzGhxMwDcLZA6o69SUYg== X-Received: by 2002:a63:5651:: with SMTP id g17mr3679821pgm.275.1640105277412; Tue, 21 Dec 2021 08:47:57 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/31] tcg/loongarch64: Implement setcond ops Date: Tue, 21 Dec 2021 08:47:26 -0800 Message-Id: <20211221164737.1076007-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-21-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.c.inc | 69 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index 367689c2e2..a2ec61237e 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -22,6 +22,7 @@ C_O1_I2(r, r, ri) C_O1_I2(r, r, rI) C_O1_I2(r, r, rU) C_O1_I2(r, r, rW) +C_O1_I2(r, r, rZ) C_O1_I2(r, 0, rZ) C_O1_I2(r, rZ, rN) C_O1_I2(r, rZ, rZ) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index aedfc0df84..23c151f473 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -434,6 +434,66 @@ static void tcg_out_clzctz(TCGContext *s, LoongArchInsn opc, tcg_out_opc_or(s, a0, TCG_REG_TMP0, a0); } +static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg arg1, TCGReg arg2, bool c2) +{ + TCGReg tmp; + + if (c2) { + tcg_debug_assert(arg2 == 0); + } + + switch (cond) { + case TCG_COND_EQ: + if (c2) { + tmp = arg1; + } else { + tcg_out_opc_sub_d(s, ret, arg1, arg2); + tmp = ret; + } + tcg_out_opc_sltui(s, ret, tmp, 1); + break; + case TCG_COND_NE: + if (c2) { + tmp = arg1; + } else { + tcg_out_opc_sub_d(s, ret, arg1, arg2); + tmp = ret; + } + tcg_out_opc_sltu(s, ret, TCG_REG_ZERO, tmp); + break; + case TCG_COND_LT: + tcg_out_opc_slt(s, ret, arg1, arg2); + break; + case TCG_COND_GE: + tcg_out_opc_slt(s, ret, arg1, arg2); + tcg_out_opc_xori(s, ret, ret, 1); + break; + case TCG_COND_LE: + tcg_out_setcond(s, TCG_COND_GE, ret, arg2, arg1, false); + break; + case TCG_COND_GT: + tcg_out_setcond(s, TCG_COND_LT, ret, arg2, arg1, false); + break; + case TCG_COND_LTU: + tcg_out_opc_sltu(s, ret, arg1, arg2); + break; + case TCG_COND_GEU: + tcg_out_opc_sltu(s, ret, arg1, arg2); + tcg_out_opc_xori(s, ret, ret, 1); + break; + case TCG_COND_LEU: + tcg_out_setcond(s, TCG_COND_GEU, ret, arg2, arg1, false); + break; + case TCG_COND_GTU: + tcg_out_setcond(s, TCG_COND_LTU, ret, arg2, arg1, false); + break; + default: + g_assert_not_reached(); + break; + } +} + /* * Branch helpers */ @@ -815,6 +875,11 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_mod_du(s, a0, a1, a2); break; + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + tcg_out_setcond(s, args[3], a0, a1, a2, c2); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: default: @@ -901,6 +966,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_ctz_i64: return C_O1_I2(r, r, rW); + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + return C_O1_I2(r, r, rZ); + case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: /* Must deposit into the same register as input */ From patchwork Tue Dec 21 16:47:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526617 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5238315imb; Tue, 21 Dec 2021 09:07:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXhm6hiKSD4HTKyB87rM0BuBePkCvQbUMJMdYPzMvJChNIkz9N1gP3efMJBu5eiimWG0ue X-Received: by 2002:a05:6214:c81:: with SMTP id r1mr3382916qvr.111.1640106432690; Tue, 21 Dec 2021 09:07:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106432; cv=none; d=google.com; s=arc-20160816; b=hvbsGh15jTaoH2dOW+46CkmYaKgTLsbI7s6qoQuYYLx4cqauVEALomCTTMdc6oP92M H3mc+bYmpB1JDNVHG5QH7GswAasjiR70cDiNAh/Jh0hEi2MxM5n0aGOYf6uKTPYFhnz2 yolweh21lxPifRjMD8imdj/x3jUnsl5lZkkH6PT/tbDaDaoYAAEFdIUOMnEzLQ73domH gE9P4wOoCRvli0W9KlBlUu8zEnI5xO+GT8sJOGA/yGnwGDfgBRDpDB1XxcXPPgyELUG2 GSrt9yX2IuYb6KqtzzoT4CjeaLK2RY8vdn7hdjCsRFgWjbLLh/KzdCU6funQssU/w0Ku hUIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FxXmSlGOk/9Dm6KmrtZ80VxSHDJ4OcOjOwKCOUUserI=; b=r0Vl8SYO/8keapb+hQfRqphp9A5Po3065EmLyjYluP5mbuUiGJdGFZQR7OA91ZVFPO BdbD5yn4SDYg3An4/36gyjjOdANW/Yk9JHcsZVR+V9Zm5QHJtGxkxrPtuCiVDea30DF0 hOaaMjnRkg9MwzPaGoT2lSQeV+2r/fkGdoyag8ktNLgJRcrDJMVNrghQ63mdOsMB/hLC MZ3voHc9lufH/eBRWLJYpggvAtRhOtjOZQBMXJqC8QFsAjlf17WDXqLN5ml/kTOHa4CI T5VpH1p4wnsvZr8xpdzOGf6w8UtY4GwdLW3gnQg/C1oMes3znb+UJ1/yPJmWNblFprJ5 9yjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kNS5MkhX; 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 iy6si8640630qvb.397.2021.12.21.09.07.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:07:12 -0800 (PST) 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=kNS5MkhX; 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]:54966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzibY-0005wP-47 for patch@linaro.org; Tue, 21 Dec 2021 12:07:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJE-0001DA-87 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:16 -0500 Received: from [2607:f8b0:4864:20::42c] (port=43923 helo=mail-pf1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIx-0007eF-LO for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:15 -0500 Received: by mail-pf1-x42c.google.com with SMTP id 196so8739821pfw.10 for ; Tue, 21 Dec 2021 08:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FxXmSlGOk/9Dm6KmrtZ80VxSHDJ4OcOjOwKCOUUserI=; b=kNS5MkhXoZslnCL0zt/K1WfqMFWVQ/PyWrMwVM6Dxp+CY/Gt9o3zT8Gyp/8mwjgVnN SeL3MXEX6IvKw7fWw38Zr0V2JSyXdYFCyQ4WUpeHk+meTg4QpeVMCIew0KZcmnqKR+PP A5VYaJYoFw7lSWsHS0hIiwLhJZJUz8etqBr5oa46OYmPlO20m+rhW8koRn/jB4yTNmre eG6hJfoyTxyBaAO32p1/fNZ7SxF25chXH0gr08Y8GgRkFNSesehGCagwVu4UC9tEqUkK oPvtTVHcq7sPNrHsgrIrYpl9LOpUB3qsU1lAB5DHAAHi3Ml0MvNRTqtfwzHftjbytjf7 GWhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FxXmSlGOk/9Dm6KmrtZ80VxSHDJ4OcOjOwKCOUUserI=; b=VuKJZt3kF4HF4TQ+REDOViae+pHAMIxRwN88yE4P/1xXTqGdZDlqwrYfvnI6dzrW58 YENSbZex26A/K50Yy7A/YSA0+bXutmflneWSE644qKH8jtaf8ithqDb1oc0c9FwfQzuk 5wYNSFi1sLcvgKaNKPDts1g6kSBRjJPS69p8//ujOxdrb9+Op4RMD9VeVF4I8qz+u812 eyZUHnv3wH8WFIJvwpVAZa3PO0AuBOu31lCkJUsiE128XWaapYYcm3rfAN/UWDx61Xyk 1Afbk7KO7XBT4GhPLdxB5nv1StRqNa2zRoFvYaGPaFb7IUTaCN2CK+po3L0pPctKDIfS xJ5Q== X-Gm-Message-State: AOAM530LMbrmmLrfDH82BKzNhSNMYIRwmpAHPe6GQLSJe6WLh7a/sMgx 31I4+69F2R4ZRCaPWOdKbwldsVEmU+4vEQ== X-Received: by 2002:a63:255:: with SMTP id 82mr3704342pgc.167.1640105278349; Tue, 21 Dec 2021 08:47:58 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 21/31] tcg/loongarch64: Implement tcg_out_call Date: Tue, 21 Dec 2021 08:47:27 -0800 Message-Id: <20211221164737.1076007-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42c (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-22-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 23c151f473..151d3308ea 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -532,6 +532,39 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out32(s, encode_djsk16_insn(op, arg1, arg2, 0)); } +static void tcg_out_call_int(TCGContext *s, const tcg_insn_unit *arg, bool tail) +{ + TCGReg link = tail ? TCG_REG_ZERO : TCG_REG_RA; + ptrdiff_t offset = tcg_pcrel_diff(s, arg); + + tcg_debug_assert((offset & 3) == 0); + if (offset == sextreg(offset, 0, 28)) { + /* short jump: +/- 256MiB */ + if (tail) { + tcg_out_opc_b(s, offset >> 2); + } else { + tcg_out_opc_bl(s, offset >> 2); + } + } else if (offset == sextreg(offset, 0, 38)) { + /* long jump: +/- 256GiB */ + tcg_target_long lo = sextreg(offset, 0, 18); + tcg_target_long hi = offset - lo; + tcg_out_opc_pcaddu18i(s, TCG_REG_TMP0, hi >> 18); + tcg_out_opc_jirl(s, link, TCG_REG_TMP0, lo >> 2); + } else { + /* far jump: 64-bit */ + tcg_target_long lo = sextreg((tcg_target_long)arg, 0, 18); + tcg_target_long hi = (tcg_target_long)arg - lo; + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP0, hi); + tcg_out_opc_jirl(s, link, TCG_REG_TMP0, lo >> 2); + } +} + +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) +{ + tcg_out_call_int(s, arg, false); +} + /* * Entry-points */ @@ -882,6 +915,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: + case INDEX_op_call: /* Always emitted via tcg_out_call. */ default: g_assert_not_reached(); } From patchwork Tue Dec 21 16:47:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526612 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5233851imb; Tue, 21 Dec 2021 09:03:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcLeMF7JtZChjSiKUpr8n24rB/U6GuwAMsoUzpyWvOhtJwzEXd0f1KUy1mI4wjWACrOW20 X-Received: by 2002:a05:622a:4ce:: with SMTP id q14mr3049711qtx.627.1640106200566; Tue, 21 Dec 2021 09:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106200; cv=none; d=google.com; s=arc-20160816; b=Skm+jz2aOi5pzI+Xz/YbRwpjsis9dKqy+abdKmi0kFX6nqMxcZt32sOwhmgvZWGUjT 3hIuBWRyXbZ0hDwV/r1yDvQrXCrsSq2/wwHgc4ZGk5xJZ+zl4QlCvSuZyzAy2n2ec/3k td2pJMae2/Q6wOx6MtAmK/T3YyNuM+tGieBb2JmwTsSu8tfsgu/tu+XhrHAI6z6oP9JW CMbwacg0JVTPG6mJeS/1Z57E5e2z8OHPUtLOaokPohdDVkRq/ALLYhn+thyJ4J6PEQA4 IW5hQrJuwbC+iL9x5QH83qFE32tBzwO8se06XrfHKu9kQ0pmu0kWkK1NhaNtS70jwlNF gCUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Xsk+2FSM9qIPtR1lzU6kn4T2/GDRxZA6hkAgcKdEqyM=; b=Lpq2ZvhHAmw94RELid7aIgfYJXXIJX/Hc6FWPk7yAzGH6f0nEsAN0IXZarhQkA301V K+tl/B5r3gl+GZuXWItUf/47fwjo5pj72W90U+0F4guKANuhw1FF2PqC6YQDWfmomy4O t/2PI+q0/RKu8XGRA0gwHKD0doEF9288m+izdCcKlBoi9i5uELd2KQ5rjj1srbA9Ctos GT+Q5gpJ+bj2EIF4kEWn9WMaAR7KlzMqRTEZguuhdRLbUZ+bHiQcGkApeGsEoXkqdKg1 /Upq9g6SezjSmcSeAsemjyUgKyg/+3nTgQc/Z5kn8jEoPnykgy5H2hA6D8e67EbpTwu0 OXFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g4Ifrn6x; 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 11si8862875qvx.487.2021.12.21.09.03.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:03:20 -0800 (PST) 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=g4Ifrn6x; 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]:44134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziXo-00073s-0U for patch@linaro.org; Tue, 21 Dec 2021 12:03:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ6-0000lk-1c for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:08 -0500 Received: from [2607:f8b0:4864:20::52d] (port=46861 helo=mail-pg1-x52d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIy-0007eR-Fv for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:07 -0500 Received: by mail-pg1-x52d.google.com with SMTP id r138so12808968pgr.13 for ; Tue, 21 Dec 2021 08:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xsk+2FSM9qIPtR1lzU6kn4T2/GDRxZA6hkAgcKdEqyM=; b=g4Ifrn6x8aS4UPjCHhWoBsSjeEa8InJLLljGQolyzKG/5sSNpT529I5bp2YQ5weHJ9 jxyzEg6IZWdt8A7jjGtSdgc7jv6ktACky+8Hno06dqzSgWQvR/doY9dsXzo05dGIC9GY DDXgGGQ7EovgUbvX3Xb5i04eKfn9de+PviYwOsIA5u0i82FTMAc0kt0Li3UrQvHmb655 o0GrmMU54FHrdC0MxscD/jwGy9sAVb6p7LiCC1cUr6IxcuLt4zU76Xp+ehDme9PrRQkC POrB8TJNdh41qFG2tq45NhFbdncMF/sKkjlvocczVgT+eGBwKBKwvj+xjPd9/0BLTL1L WHMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xsk+2FSM9qIPtR1lzU6kn4T2/GDRxZA6hkAgcKdEqyM=; b=MppwKh7LhnPcYnQoBqSjKoZt5fpUf7S3rCOEk6AWd+k79JWgFArkZM8kYWskhfA8tQ XO2+45b9EV6qngZLJtGnGiaAxkha3aWq7Itu43kJwl3Q0TvpwkTqdSj8wrYXTBuyUCKM mVI6a/6z6dq0ydsQD6JbgCB05AL+Ywq22Zb0GkxhvOCVwfwb8ZrkPtth3fMDYzCfzwHv l6xB8i33b0+gRLnuZUO0xwyWV/1hj/jYmcg5bkysQ4pO4mi1J2u3Fn8TzaOZ6EfDoxt1 wayztT6zcKw4eiDEQo1hAYQ8lV34ZdG6z05pz7ffgEShI08R6rDubP8VsLCCXp4hyAxQ O4lQ== X-Gm-Message-State: AOAM533jHG2KN8FDSiecb3ceH6X9vCaW5H/De0m84wKLJRD+Yp/1GQOO GLzctcwSP3Eto7sdPH1UH/sJPmRpcJCbKg== X-Received: by 2002:a62:6497:0:b0:4ba:737c:8021 with SMTP id y145-20020a626497000000b004ba737c8021mr3828049pfb.18.1640105279229; Tue, 21 Dec 2021 08:47:59 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/31] tcg/loongarch64: Implement simple load/store ops Date: Tue, 21 Dec 2021 08:47:28 -0800 Message-Id: <20211221164737.1076007-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::52d (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-23-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 1 + tcg/loongarch64/tcg-target.c.inc | 131 +++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index a2ec61237e..e54ca9b2de 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -15,6 +15,7 @@ * tcg-target-con-str.h; the constraint combination is inclusive or. */ C_O0_I1(r) +C_O0_I2(rZ, r) C_O0_I2(rZ, rZ) C_O1_I1(r, r) C_O1_I2(r, r, rC) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 151d3308ea..3d1d7c33c0 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -565,6 +565,73 @@ static void tcg_out_call(TCGContext *s, const tcg_insn_unit *arg) tcg_out_call_int(s, arg, false); } +/* + * Load/store helpers + */ + +static void tcg_out_ldst(TCGContext *s, LoongArchInsn opc, TCGReg data, + TCGReg addr, intptr_t offset) +{ + intptr_t imm12 = sextreg(offset, 0, 12); + + if (offset != imm12) { + intptr_t diff = offset - (uintptr_t)s->code_ptr; + + if (addr == TCG_REG_ZERO && diff == (int32_t)diff) { + imm12 = sextreg(diff, 0, 12); + tcg_out_opc_pcaddu12i(s, TCG_REG_TMP2, (diff - imm12) >> 12); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP2, offset - imm12); + if (addr != TCG_REG_ZERO) { + tcg_out_opc_add_d(s, TCG_REG_TMP2, TCG_REG_TMP2, addr); + } + } + addr = TCG_REG_TMP2; + } + + switch (opc) { + case OPC_LD_B: + case OPC_LD_BU: + case OPC_LD_H: + case OPC_LD_HU: + case OPC_LD_W: + case OPC_LD_WU: + case OPC_LD_D: + case OPC_ST_B: + case OPC_ST_H: + case OPC_ST_W: + case OPC_ST_D: + tcg_out32(s, encode_djsk12_insn(opc, data, addr, imm12)); + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, + TCGReg arg1, intptr_t arg2) +{ + bool is_32bit = type == TCG_TYPE_I32; + tcg_out_ldst(s, is_32bit ? OPC_LD_W : OPC_LD_D, arg, arg1, arg2); +} + +static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, + TCGReg arg1, intptr_t arg2) +{ + bool is_32bit = type == TCG_TYPE_I32; + tcg_out_ldst(s, is_32bit ? OPC_ST_W : OPC_ST_D, arg, arg1, arg2); +} + +static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, + TCGReg base, intptr_t ofs) +{ + if (val == 0) { + tcg_out_st(s, type, TCG_REG_ZERO, base, ofs); + return true; + } + return false; +} + /* * Entry-points */ @@ -913,6 +980,49 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_setcond(s, args[3], a0, a1, a2, c2); break; + case INDEX_op_ld8s_i32: + case INDEX_op_ld8s_i64: + tcg_out_ldst(s, OPC_LD_B, a0, a1, a2); + break; + case INDEX_op_ld8u_i32: + case INDEX_op_ld8u_i64: + tcg_out_ldst(s, OPC_LD_BU, a0, a1, a2); + break; + case INDEX_op_ld16s_i32: + case INDEX_op_ld16s_i64: + tcg_out_ldst(s, OPC_LD_H, a0, a1, a2); + break; + case INDEX_op_ld16u_i32: + case INDEX_op_ld16u_i64: + tcg_out_ldst(s, OPC_LD_HU, a0, a1, a2); + break; + case INDEX_op_ld_i32: + case INDEX_op_ld32s_i64: + tcg_out_ldst(s, OPC_LD_W, a0, a1, a2); + break; + case INDEX_op_ld32u_i64: + tcg_out_ldst(s, OPC_LD_WU, a0, a1, a2); + break; + case INDEX_op_ld_i64: + tcg_out_ldst(s, OPC_LD_D, a0, a1, a2); + break; + + case INDEX_op_st8_i32: + case INDEX_op_st8_i64: + tcg_out_ldst(s, OPC_ST_B, a0, a1, a2); + break; + case INDEX_op_st16_i32: + case INDEX_op_st16_i64: + tcg_out_ldst(s, OPC_ST_H, a0, a1, a2); + break; + case INDEX_op_st_i32: + case INDEX_op_st32_i64: + tcg_out_ldst(s, OPC_ST_W, a0, a1, a2); + break; + case INDEX_op_st_i64: + tcg_out_ldst(s, OPC_ST_D, a0, a1, a2); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: case INDEX_op_call: /* Always emitted via tcg_out_call. */ @@ -927,6 +1037,15 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_goto_ptr: return C_O0_I1(r); + case INDEX_op_st8_i32: + case INDEX_op_st8_i64: + case INDEX_op_st16_i32: + case INDEX_op_st16_i64: + case INDEX_op_st32_i64: + case INDEX_op_st_i32: + case INDEX_op_st_i64: + return C_O0_I2(rZ, r); + case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: return C_O0_I2(rZ, rZ); @@ -954,6 +1073,18 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_bswap32_i32: case INDEX_op_bswap32_i64: case INDEX_op_bswap64_i64: + case INDEX_op_ld8s_i32: + case INDEX_op_ld8s_i64: + case INDEX_op_ld8u_i32: + case INDEX_op_ld8u_i64: + case INDEX_op_ld16s_i32: + case INDEX_op_ld16s_i64: + case INDEX_op_ld16u_i32: + case INDEX_op_ld16u_i64: + case INDEX_op_ld32s_i64: + case INDEX_op_ld32u_i64: + case INDEX_op_ld_i32: + case INDEX_op_ld_i64: return C_O1_I1(r, r); case INDEX_op_andc_i32: From patchwork Tue Dec 21 16:47:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526621 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5243322imb; Tue, 21 Dec 2021 09:12:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOxmOd/3UXfdM7FuLINqmBR8g1QaAey32KxjrGzylkCuauroWj2td9uS3tfq+N2MbaGVZt X-Received: by 2002:a05:6214:252a:: with SMTP id gg10mr3533867qvb.19.1640106747567; Tue, 21 Dec 2021 09:12:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106747; cv=none; d=google.com; s=arc-20160816; b=t69OIo7RDSUF448jcbzBzrOXgUuxuqovS+9ZZeU5oZmRBm/qtZLckvDkmYiva9aJIS eJ+5+eLTysN/4O/E/nv/6HDdvBFpoaWOt14WIJY44Y7cJOg2O1sedg7fugDZCz4rJABr qL9qzngqFelxTNHt5+O/dvIO04sQ8rCxT2QYFAEs+ik3b37+jvj0A1gDz/H30ymlsGCQ aS57h5AZbd/0F9Zum9qRKN3LWya1y6NxKEzL9F5RVhV3kymoApcsYeDQFn3v9dzopBEu AqAZUSNYR8+6yxW71/gtEG5J2RHkyDZLLdRM6T7ejQb5HTmLRJAtYRPDp0+5uQXYikNM X/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=csDkV2A6VW7PSchAvPx50pxKFBvXv87Mu1z9BJkzMUU=; b=Fh9NZfT7e6ofzPxggYdEZn2XJxEGe3ET0zKQHw4jg/fMca+7RrXake6i3F42MG3jCz TWrbnPiuB2ymhpN5n4ulfHHuzO3Btlpf31Jgw0Oz3um2BmtH4FY0sDaLFgyWRv4HM1x9 II4anuaD3YNIk8htFtbf93brG3GvqIjaelegiDfgTfns1QAE0Yv9aN8iXYGC5pEoFtKA 4GKJhWiet6OqFNkvm1gCkuWT4Ii6Ml6ROHDxHlWkbU6lh+XgQ52WNYdqlZMT1XwAH5g2 /+l22q/nZ0GAknWEiHXRao8g+HaI1Fd1wv7ipyXdDsjaePjazm27CfV6GJ/6wnU+kiCg /ECQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cFC9VjE5; 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 d18si8586007qtx.469.2021.12.21.09.12.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:12:27 -0800 (PST) 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=cFC9VjE5; 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]:40954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzigc-0007IT-U3 for patch@linaro.org; Tue, 21 Dec 2021 12:12:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ7-0000qH-SX for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:09 -0500 Received: from [2607:f8b0:4864:20::435] (port=42585 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziIz-0007eg-H6 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:09 -0500 Received: by mail-pf1-x435.google.com with SMTP id t19so5970422pfg.9 for ; Tue, 21 Dec 2021 08:48:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=csDkV2A6VW7PSchAvPx50pxKFBvXv87Mu1z9BJkzMUU=; b=cFC9VjE5UX3HjJzWXyaaRhqEgnCTaJwM0vJZa5SUT4x+I2Tp+nhWlsX1Pzsv7bEZPy LL2YpE+fvTIdaP+F6FhcK95RBBKe28IuKEZ+9dP/bkeOqCWQxYDkmKtIs477ioAkL8JK 8gi/Mm5mbd87wxILWtD6iUVxKZgk8V/8PGZwbaoLu1dwFqZ3yOGMUBrwa9y/NWRNilV4 gWnwgxV1nnx/jhb3m5LMknnYzwWUSysawYvzCKrmQpYsvRKKzl18nw4dW3VgGR+jNiz3 EExnYxIgjB4QbxazrtvrTCK5IIHjQdHcviAM0zQHuMEoQPX3yxqB9SVtzoiW2XOnHjFW 2Ypg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=csDkV2A6VW7PSchAvPx50pxKFBvXv87Mu1z9BJkzMUU=; b=AkrukLRYaX4GIJdqgPFU9QouETWOTwPscyN38mVCCfRtKMS1Zp2Vy4gE1YPwrAGYx/ 8W4yTKwzXCygEbAFC59egLrVtz4zJY21Z2+Ncx56B8Bvx6StYv8OdQg+mwzt0nJHDEOD rp9brVzjUTefaNNYryz/MCWSeccmOxBSoDLhfG3Sdx1rDznxCEy0g2/x0W9OVWHy1GcQ qsp+vF+o8zhdCe30nSdfTz2cEkP4Rk1e5tmOI6kVrR1L+MCfuHyVdE0f5hR0XvNT6tlZ 8oZj90anIwcCulh9CNUHJf+QYBlmC2D0F0Kn9k/5WIpzN/RYs2Z6tVPulAnAiSr905Lm fCog== X-Gm-Message-State: AOAM533V8W4s3QDZqZ+wwYqSFlTTDTVhxo10msbs+fnhQBXpz9kMRvet Qkh6+yfumP5JCIyRU1bA37c6HNF9g92Dtg== X-Received: by 2002:a05:6a00:248a:b0:4b0:b882:dfc4 with SMTP id c10-20020a056a00248a00b004b0b882dfc4mr4076077pfv.37.1640105280238; Tue, 21 Dec 2021 08:48:00 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:47:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 23/31] tcg/loongarch64: Add softmmu load/store helpers, implement qemu_ld/qemu_st ops Date: Tue, 21 Dec 2021 08:47:29 -0800 Message-Id: <20211221164737.1076007-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-24-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target-con-set.h | 2 + tcg/loongarch64/tcg-target.c.inc | 353 +++++++++++++++++++++++++++ 2 files changed, 355 insertions(+) diff --git a/tcg/loongarch64/tcg-target-con-set.h b/tcg/loongarch64/tcg-target-con-set.h index e54ca9b2de..349c672687 100644 --- a/tcg/loongarch64/tcg-target-con-set.h +++ b/tcg/loongarch64/tcg-target-con-set.h @@ -17,7 +17,9 @@ C_O0_I1(r) C_O0_I2(rZ, r) C_O0_I2(rZ, rZ) +C_O0_I2(LZ, L) C_O1_I1(r, r) +C_O1_I1(r, L) C_O1_I2(r, r, rC) C_O1_I2(r, r, ri) C_O1_I2(r, r, rI) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 3d1d7c33c0..f67d5fa110 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -117,6 +117,11 @@ static const int tcg_target_call_oarg_regs[] = { TCG_REG_A1, }; +#ifndef CONFIG_SOFTMMU +#define USE_GUEST_BASE (guest_base != 0) +#define TCG_GUEST_BASE_REG TCG_REG_S1 +#endif + #define TCG_CT_CONST_ZERO 0x100 #define TCG_CT_CONST_S12 0x200 #define TCG_CT_CONST_N12 0x400 @@ -632,6 +637,333 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } +/* + * Load/store helpers for SoftMMU, and qemu_ld/st implementations + */ + +#if defined(CONFIG_SOFTMMU) +#include "../tcg-ldst.c.inc" + +/* + * helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, + * MemOpIdx oi, uintptr_t ra) + */ +static void * const qemu_ld_helpers[4] = { + [MO_8] = helper_ret_ldub_mmu, + [MO_16] = helper_le_lduw_mmu, + [MO_32] = helper_le_ldul_mmu, + [MO_64] = helper_le_ldq_mmu, +}; + +/* + * helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, + * uintxx_t val, MemOpIdx oi, + * uintptr_t ra) + */ +static void * const qemu_st_helpers[4] = { + [MO_8] = helper_ret_stb_mmu, + [MO_16] = helper_le_stw_mmu, + [MO_32] = helper_le_stl_mmu, + [MO_64] = helper_le_stq_mmu, +}; + +/* We expect to use a 12-bit negative offset from ENV. */ +QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); +QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 11)); + +static bool tcg_out_goto(TCGContext *s, const tcg_insn_unit *target) +{ + tcg_out_opc_b(s, 0); + return reloc_br_sd10k16(s->code_ptr - 1, target); +} + +/* + * Emits common code for TLB addend lookup, that eventually loads the + * addend in TCG_REG_TMP2. + */ +static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, MemOpIdx oi, + tcg_insn_unit **label_ptr, bool is_load) +{ + MemOp opc = get_memop(oi); + unsigned s_bits = opc & MO_SIZE; + unsigned a_bits = get_alignment_bits(opc); + tcg_target_long compare_mask; + int mem_index = get_mmuidx(oi); + int fast_ofs = TLB_MASK_TABLE_OFS(mem_index); + int mask_ofs = fast_ofs + offsetof(CPUTLBDescFast, mask); + int table_ofs = fast_ofs + offsetof(CPUTLBDescFast, table); + + tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, TCG_AREG0, mask_ofs); + tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP1, TCG_AREG0, table_ofs); + + tcg_out_opc_srli_d(s, TCG_REG_TMP2, addrl, + TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); + tcg_out_opc_and(s, TCG_REG_TMP2, TCG_REG_TMP2, TCG_REG_TMP0); + tcg_out_opc_add_d(s, TCG_REG_TMP2, TCG_REG_TMP2, TCG_REG_TMP1); + + /* Load the tlb comparator and the addend. */ + tcg_out_ld(s, TCG_TYPE_TL, TCG_REG_TMP0, TCG_REG_TMP2, + is_load ? offsetof(CPUTLBEntry, addr_read) + : offsetof(CPUTLBEntry, addr_write)); + tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP2, TCG_REG_TMP2, + offsetof(CPUTLBEntry, addend)); + + /* We don't support unaligned accesses. */ + if (a_bits < s_bits) { + a_bits = s_bits; + } + /* Clear the non-page, non-alignment bits from the address. */ + compare_mask = (tcg_target_long)TARGET_PAGE_MASK | ((1 << a_bits) - 1); + tcg_out_movi(s, TCG_TYPE_TL, TCG_REG_TMP1, compare_mask); + tcg_out_opc_and(s, TCG_REG_TMP1, TCG_REG_TMP1, addrl); + + /* Compare masked address with the TLB entry. */ + label_ptr[0] = s->code_ptr; + tcg_out_opc_bne(s, TCG_REG_TMP0, TCG_REG_TMP1, 0); + + /* TLB Hit - addend in TCG_REG_TMP2, ready for use. */ +} + +static void add_qemu_ldst_label(TCGContext *s, int is_ld, MemOpIdx oi, + TCGType type, + TCGReg datalo, TCGReg addrlo, + void *raddr, tcg_insn_unit **label_ptr) +{ + TCGLabelQemuLdst *label = new_ldst_label(s); + + label->is_ld = is_ld; + label->oi = oi; + label->type = type; + label->datalo_reg = datalo; + label->datahi_reg = 0; /* unused */ + label->addrlo_reg = addrlo; + label->addrhi_reg = 0; /* unused */ + label->raddr = tcg_splitwx_to_rx(raddr); + label->label_ptr[0] = label_ptr[0]; +} + +static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) +{ + MemOpIdx oi = l->oi; + MemOp opc = get_memop(oi); + MemOp size = opc & MO_SIZE; + TCGType type = l->type; + + /* resolve label address */ + if (!reloc_br_sk16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + /* call load helper */ + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A1, l->addrlo_reg); + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A2, oi); + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A3, (tcg_target_long)l->raddr); + + tcg_out_call(s, qemu_ld_helpers[size]); + + switch (opc & MO_SSIZE) { + case MO_SB: + tcg_out_ext8s(s, l->datalo_reg, TCG_REG_A0); + break; + case MO_SW: + tcg_out_ext16s(s, l->datalo_reg, TCG_REG_A0); + break; + case MO_SL: + tcg_out_ext32s(s, l->datalo_reg, TCG_REG_A0); + break; + case MO_UL: + if (type == TCG_TYPE_I32) { + /* MO_UL loads of i32 should be sign-extended too */ + tcg_out_ext32s(s, l->datalo_reg, TCG_REG_A0); + break; + } + /* fallthrough */ + default: + tcg_out_mov(s, type, l->datalo_reg, TCG_REG_A0); + break; + } + + return tcg_out_goto(s, l->raddr); +} + +static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) +{ + MemOpIdx oi = l->oi; + MemOp opc = get_memop(oi); + MemOp size = opc & MO_SIZE; + + /* resolve label address */ + if (!reloc_br_sk16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + /* call store helper */ + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A1, l->addrlo_reg); + switch (size) { + case MO_8: + tcg_out_ext8u(s, TCG_REG_A2, l->datalo_reg); + break; + case MO_16: + tcg_out_ext16u(s, TCG_REG_A2, l->datalo_reg); + break; + case MO_32: + tcg_out_ext32u(s, TCG_REG_A2, l->datalo_reg); + break; + case MO_64: + tcg_out_mov(s, TCG_TYPE_I64, TCG_REG_A2, l->datalo_reg); + break; + default: + g_assert_not_reached(); + break; + } + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A3, oi); + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A4, (tcg_target_long)l->raddr); + + tcg_out_call(s, qemu_st_helpers[size]); + + return tcg_out_goto(s, l->raddr); +} +#endif /* CONFIG_SOFTMMU */ + +/* + * `ext32u` the address register into the temp register given, + * if target is 32-bit, no-op otherwise. + * + * Returns the address register ready for use with TLB addend. + */ +static TCGReg tcg_out_zext_addr_if_32_bit(TCGContext *s, + TCGReg addr, TCGReg tmp) +{ + if (TARGET_LONG_BITS == 32) { + tcg_out_ext32u(s, tmp, addr); + return tmp; + } + return addr; +} + +static void tcg_out_qemu_ld_indexed(TCGContext *s, TCGReg rd, TCGReg rj, + TCGReg rk, MemOp opc, TCGType type) +{ + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); + + switch (opc & MO_SSIZE) { + case MO_UB: + tcg_out_opc_ldx_bu(s, rd, rj, rk); + break; + case MO_SB: + tcg_out_opc_ldx_b(s, rd, rj, rk); + break; + case MO_UW: + tcg_out_opc_ldx_hu(s, rd, rj, rk); + break; + case MO_SW: + tcg_out_opc_ldx_h(s, rd, rj, rk); + break; + case MO_UL: + if (type == TCG_TYPE_I64) { + tcg_out_opc_ldx_wu(s, rd, rj, rk); + break; + } + /* fallthrough */ + case MO_SL: + tcg_out_opc_ldx_w(s, rd, rj, rk); + break; + case MO_Q: + tcg_out_opc_ldx_d(s, rd, rj, rk); + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, TCGType type) +{ + TCGReg addr_regl; + TCGReg data_regl; + MemOpIdx oi; + MemOp opc; +#if defined(CONFIG_SOFTMMU) + tcg_insn_unit *label_ptr[1]; +#endif + TCGReg base; + + data_regl = *args++; + addr_regl = *args++; + oi = *args++; + opc = get_memop(oi); + +#if defined(CONFIG_SOFTMMU) + tcg_out_tlb_load(s, addr_regl, oi, label_ptr, 1); + base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); + tcg_out_qemu_ld_indexed(s, data_regl, base, TCG_REG_TMP2, opc, type); + add_qemu_ldst_label(s, 1, oi, type, + data_regl, addr_regl, + s->code_ptr, label_ptr); +#else + base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); + TCGReg guest_base_reg = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; + tcg_out_qemu_ld_indexed(s, data_regl, base, guest_base_reg, opc, type); +#endif +} + +static void tcg_out_qemu_st_indexed(TCGContext *s, TCGReg data, + TCGReg rj, TCGReg rk, MemOp opc) +{ + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((opc & MO_BSWAP) == 0); + + switch (opc & MO_SIZE) { + case MO_8: + tcg_out_opc_stx_b(s, data, rj, rk); + break; + case MO_16: + tcg_out_opc_stx_h(s, data, rj, rk); + break; + case MO_32: + tcg_out_opc_stx_w(s, data, rj, rk); + break; + case MO_64: + tcg_out_opc_stx_d(s, data, rj, rk); + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args) +{ + TCGReg addr_regl; + TCGReg data_regl; + MemOpIdx oi; + MemOp opc; +#if defined(CONFIG_SOFTMMU) + tcg_insn_unit *label_ptr[1]; +#endif + TCGReg base; + + data_regl = *args++; + addr_regl = *args++; + oi = *args++; + opc = get_memop(oi); + +#if defined(CONFIG_SOFTMMU) + tcg_out_tlb_load(s, addr_regl, oi, label_ptr, 0); + base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); + tcg_out_qemu_st_indexed(s, data_regl, base, TCG_REG_TMP2, opc); + add_qemu_ldst_label(s, 0, oi, + 0, /* type param is unused for stores */ + data_regl, addr_regl, + s->code_ptr, label_ptr); +#else + base = tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); + TCGReg guest_base_reg = USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_REG_ZERO; + tcg_out_qemu_st_indexed(s, data_regl, base, guest_base_reg, opc); +#endif +} + /* * Entry-points */ @@ -1023,6 +1355,19 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_ldst(s, OPC_ST_D, a0, a1, a2); break; + case INDEX_op_qemu_ld_i32: + tcg_out_qemu_ld(s, args, TCG_TYPE_I32); + break; + case INDEX_op_qemu_ld_i64: + tcg_out_qemu_ld(s, args, TCG_TYPE_I64); + break; + case INDEX_op_qemu_st_i32: + tcg_out_qemu_st(s, args); + break; + case INDEX_op_qemu_st_i64: + tcg_out_qemu_st(s, args); + break; + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ case INDEX_op_mov_i64: case INDEX_op_call: /* Always emitted via tcg_out_call. */ @@ -1050,6 +1395,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i64: return C_O0_I2(rZ, rZ); + case INDEX_op_qemu_st_i32: + case INDEX_op_qemu_st_i64: + return C_O0_I2(LZ, L); + case INDEX_op_ext8s_i32: case INDEX_op_ext8s_i64: case INDEX_op_ext8u_i32: @@ -1087,6 +1436,10 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_ld_i64: return C_O1_I1(r, r); + case INDEX_op_qemu_ld_i32: + case INDEX_op_qemu_ld_i64: + return C_O1_I1(r, L); + case INDEX_op_andc_i32: case INDEX_op_andc_i64: case INDEX_op_orc_i32: From patchwork Tue Dec 21 16:47:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526623 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5245101imb; Tue, 21 Dec 2021 09:14:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwhT1sfytS3vrmJmtlyZTMvNAZAqDpZYoVC/LQKTmgwFu0XVNTJxQ1oxraOEIgZbFRXtoP X-Received: by 2002:ac8:7fc5:: with SMTP id b5mr3065789qtk.351.1640106875022; Tue, 21 Dec 2021 09:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106875; cv=none; d=google.com; s=arc-20160816; b=zae1PwKrgsoLjRUP/qNDppDK6WX1lrTok05DjRj4bKlU/j+x2/5F0GlfKUDEsKGy/f WEs7zV8GPmnV/mUi2pTxn/6fR93fmat2SeaeSasHRu2WkqvPPmZvA/mGBnCM82DuOiwl Kh2BXNw9eTBrGptPGRiJWxqBd/ZbNGu1lXmZh5GghK4cNtxPY4FMkYEUezu8M51BCgjg xKpGGHN2XvYU39OmSH58W5P2oseFFcME5QLznx7A5UxZgsOb2Zq00Wp6NWPmT/sRPdNk pfKVoBuZwvQAW8FlDOq58BrHPnNVf79G50Joi/oVRs/snANanZgZ9b8KW+O4vgdbYGTA xQpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=i235Rzd3sllWY1/hcVlI1mYBAs2gRi1oFaIpyAT4e3A=; b=lZec9Pre5a5bXOOQnyPouzMggTLmtJz1bVZSrkYXbxSCVMNWKa9zfX9UV4i23AZ5py mfyowsC7TaIUcd3YfDsGITfi/fKdyc0uaQ0Xh6bGHgAD3oA4cu3Zx4RnvcyBWpJfrblA YK9JytnKBtJZ/LgGVpCNYvcREoMz8sppybCbBBqFLO7sdeoyBYPC1j5eqg5g9bdux1mM hh8creuUBJA5HklxFEg6BU2CuR+yFnwHac6loJTqgC9z1tmy9rRcuSfQg0p8Im2xLvUI ZXMxCj8/mYHvO/UXJKwXue37qlc/GSCzfCFn0Pvuayb51e5WxIPh5A8oZDVfVhZOih8n jMCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHT9stQT; 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 l9si7934250qtx.660.2021.12.21.09.14.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:14:35 -0800 (PST) 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=DHT9stQT; 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]:47538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziig-0003GX-Gq for patch@linaro.org; Tue, 21 Dec 2021 12:14:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ9-0000w0-Dl for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:11 -0500 Received: from [2607:f8b0:4864:20::633] (port=35722 helo=mail-pl1-x633.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ1-0007er-FA for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:11 -0500 Received: by mail-pl1-x633.google.com with SMTP id n16so10442473plc.2 for ; Tue, 21 Dec 2021 08:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i235Rzd3sllWY1/hcVlI1mYBAs2gRi1oFaIpyAT4e3A=; b=DHT9stQTWVcepwiD7n0cRNATqxqffM/HlawXcGeyalhka0zj2FVoHPklp/R8lQy0W7 oGKjLAUy+Z5cfnenrzjIzsAkNz9H/WfFpiqYGHFzAIYk2mUIB+Bgh9fzE7kI7+lMGQy7 YORHYUCBpOBW7K0F55UtaFEQmu4Y/q5n03b5mmw7v/58JrsRLa/aS1pcnx22aodt4gMx f/IzNFIyOuIMRCqS65MYLUoM9vfIvFktbnXpg1U5GunPzQKOPC5QO4RqvMtuGOZjOhzy tHWtjY9sC8kWd3K6EpmbHRklsQJS5aqywQ2vcdGU1xUh7tcIBjvEuWsfJw/uHy1xdD4u gf+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i235Rzd3sllWY1/hcVlI1mYBAs2gRi1oFaIpyAT4e3A=; b=etZkZibAZTUf7ozUalXQt8sz0ho37FzYqLbLWjjr3Y14vlP1EZIcNGdGM/g87uwhCy 0Ywf/FDhju7Q3VoPec8NjdfTLh5d9eVgGpixCNWPhcdTzD7oZa7bXPRb8Q/cKT7mda+L L495tzCoRollWvaO0OxWx4StcxQmOPagE19EoBl1vcsNDTyjnV6O+Zi1DgoglcWFgYeJ Yh5qyIM6icP0e1opGQVSHN6znOkie4WxLgI6mbs4g3x/NEIVgiJ91G+f9pfC5GxeYBKH AaW7jRcErVCuNxUf0fNZHsnNGUml1eaEfQUrbcKJ+4aTgzUimPz6LLdE5Qu2mPE9uteZ R64g== X-Gm-Message-State: AOAM531eHIYc2rX9AvUjsSMpcTuWAGi282+0bGH2c82ZjYxiF2be+tyl Ep/oSGJ3ZfYifg2GBqn08YjePA7DT/9ZHg== X-Received: by 2002:a17:90a:5d0e:: with SMTP id s14mr4858920pji.136.1640105281104; Tue, 21 Dec 2021 08:48:01 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/31] tcg/loongarch64: Implement tcg_target_qemu_prologue Date: Tue, 21 Dec 2021 08:47:30 -0800 Message-Id: <20211221164737.1076007-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::633 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-25-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index f67d5fa110..0b7d6458c5 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -968,6 +968,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args) * Entry-points */ +static const tcg_insn_unit *tb_ret_addr; + static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg args[TCG_MAX_OP_ARGS], const int const_args[TCG_MAX_OP_ARGS]) @@ -1517,3 +1519,69 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) g_assert_not_reached(); } } + +static const int tcg_target_callee_save_regs[] = { + TCG_REG_S0, /* used for the global env (TCG_AREG0) */ + TCG_REG_S1, + TCG_REG_S2, + TCG_REG_S3, + TCG_REG_S4, + TCG_REG_S5, + TCG_REG_S6, + TCG_REG_S7, + TCG_REG_S8, + TCG_REG_S9, + TCG_REG_RA, /* should be last for ABI compliance */ +}; + +/* Stack frame parameters. */ +#define REG_SIZE (TCG_TARGET_REG_BITS / 8) +#define SAVE_SIZE ((int)ARRAY_SIZE(tcg_target_callee_save_regs) * REG_SIZE) +#define TEMP_SIZE (CPU_TEMP_BUF_NLONGS * (int)sizeof(long)) +#define FRAME_SIZE ((TCG_STATIC_CALL_ARGS_SIZE + TEMP_SIZE + SAVE_SIZE \ + + TCG_TARGET_STACK_ALIGN - 1) \ + & -TCG_TARGET_STACK_ALIGN) +#define SAVE_OFS (TCG_STATIC_CALL_ARGS_SIZE + TEMP_SIZE) + +/* We're expecting to be able to use an immediate for frame allocation. */ +QEMU_BUILD_BUG_ON(FRAME_SIZE > 0x7ff); + +/* Generate global QEMU prologue and epilogue code */ +static void tcg_target_qemu_prologue(TCGContext *s) +{ + int i; + + tcg_set_frame(s, TCG_REG_SP, TCG_STATIC_CALL_ARGS_SIZE, TEMP_SIZE); + + /* TB prologue */ + tcg_out_opc_addi_d(s, TCG_REG_SP, TCG_REG_SP, -FRAME_SIZE); + for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { + tcg_out_st(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], + TCG_REG_SP, SAVE_OFS + i * REG_SIZE); + } + +#if !defined(CONFIG_SOFTMMU) + if (USE_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); + } +#endif + + /* Call generated code */ + tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); + tcg_out_opc_jirl(s, TCG_REG_ZERO, tcg_target_call_iarg_regs[1], 0); + + /* Return path for goto_ptr. Set return value to 0 */ + tcg_code_gen_epilogue = tcg_splitwx_to_rx(s->code_ptr); + tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); + + /* TB epilogue */ + tb_ret_addr = tcg_splitwx_to_rx(s->code_ptr); + for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { + tcg_out_ld(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], + TCG_REG_SP, SAVE_OFS + i * REG_SIZE); + } + + tcg_out_opc_addi_d(s, TCG_REG_SP, TCG_REG_SP, FRAME_SIZE); + tcg_out_opc_jirl(s, TCG_REG_ZERO, TCG_REG_RA, 0); +} From patchwork Tue Dec 21 16:47:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526620 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5242635imb; Tue, 21 Dec 2021 09:11:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyySVfr6SY2VsnWV5P+PjPfWun7NHcOq5X/NKr2t7B0D+BWCQq7r5yUEwIecTW6O5BYpwx/ X-Received: by 2002:a1f:a68a:: with SMTP id p132mr1643751vke.31.1640106698161; Tue, 21 Dec 2021 09:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106698; cv=none; d=google.com; s=arc-20160816; b=M1ncLZQEC0ZMRJxfBttYZpCw2Vyt1TI8+4kxVoOT9EN01qJ7g4OxSGSXZiJa8JX+oT A6jNujUfD887Lj/YgVEpT3fwWo3Fgh2EeBDgMzf7m27EO/zTBYLmCCuCxiBr75JWqt+R ZSWewYAkLWbEt95hgqA35rbVWSzv50o+fm/N5Oyd7nglG9++BiWTEzzq6DX53bLI0ydv iK1hGm+CDF44JAim7zkJspOBbsKCi04EKNI+DBRhHaaTEZDmAyQic5XWZCPxpk2mHpH2 +0FLKTV2pMGBNL1OgJxzlit2lMVFgYjlZJ6tjZAOeTEixG9DhMCC2/mY0RyLjZM6ntOP po/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NtulYz0vZ5KnXAsfRYqp5VTF0oSZb47z69E1p8MpidQ=; b=D0S5MGDUFwW+yuX02KxtBoC7tFRzLgbblgxBTj5rHzAgWqBGFgGzJAfWH3FlfMKfXg 0tfoQHgy+id3+6zMusP4G77L/hCpJMOxZXpqovLLM/YrUzaDp8cMj8D+cUjviJJHQYPP HlKwhXTpqpG/6YtCzgytgZg9CR4OEuO62RjWSuUv0HA4NruXDBBMQjMomT4x31Q3/Gob sGQcfiPBPuZXbQNpVIdfkXYAezdPzskGzFkq7HBDN5WoE+c7poT7XnoJTVBNXegHSsBo r5ypUd9rsx0UoWHbpOiFC5Leil6mQXM8nU/Tig/MjMURu8Y8d4XeH1PV31aN1NrPxhra imag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tv6V0O3f; 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 i3si1829294vkp.19.2021.12.21.09.11.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:11:38 -0800 (PST) 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=tv6V0O3f; 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]:37974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzifp-0005Bu-KJ for patch@linaro.org; Tue, 21 Dec 2021 12:11:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJC-00014e-2T for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:14 -0500 Received: from [2607:f8b0:4864:20::1032] (port=34536 helo=mail-pj1-x1032.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ1-0007f5-Ac for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:13 -0500 Received: by mail-pj1-x1032.google.com with SMTP id v13-20020a17090a088d00b001b0e3a74cf7so2365064pjc.1 for ; Tue, 21 Dec 2021 08:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NtulYz0vZ5KnXAsfRYqp5VTF0oSZb47z69E1p8MpidQ=; b=tv6V0O3fpElQYZGFQcY/jgwB8BAyP/RpdYjZJ6IOF7Jt9m8F8bpC2ky1tZG01a/cNl I9LD2ZG72yRXn7yh+ymOK4JixE1LPmDDJRKO2X4YjzRelfnR5HKUQrgJdmttbMB65AMO aylpirK1D4kcuVYF8YC35/1dRg2g/jc6l3saN2cXUoUdRorZ1gx/I+LJ5ZoOan8XLNMJ AE9XgxqPrpUPV7XKJBnKX+BFsVoU35dY1nCmEWjVhZwOXCnwPm7Sd/z6QDLmViXGZKKx o7qchZ0d1V06yOKwMKfm2f4HQkMkGBHCMYPXDahN72sJWny5a/LBMIM+v55mFcSNC1ex SgNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NtulYz0vZ5KnXAsfRYqp5VTF0oSZb47z69E1p8MpidQ=; b=F/nFkvF2j1TroELRvO1SX4FDuZttWlfqzKpOBYsJ7iwsiL6B69+fWdlCNOfH4LUPZw we5Qu1wfWO1AJKm0UEjYFzN0VFB1R3AYJhPfDr3kSHbknUUSLV2IS/7bH2ou5KP3csdN U82axKlTnktUkHCbPczti0EHjntHz6vtQ8H7D+DqJSikIZc4//F4QUeIe6q6vGlJ6E5u YsD4Zk+GT2121pwgCexlGK0dVXK1lfJVFD9Zzop89oq/Ld322A3si71YSqCLPl/Gc66m sMmn2inOEuBJTziaj5RNiWiWANbwkYGj6dq3jem0oCfxb1ND+DtXNGHN/vsqMNp61tGb ei6Q== X-Gm-Message-State: AOAM533t6xGUigSz9LyNSJwDQXrE3CpB7ONanGeyZ6SzoWFlPXx3zo3A fcN3WwfhsQzvWEwn2jJEUo7WYBL6lV152A== X-Received: by 2002:a17:903:1cf:b0:149:b6f:4e98 with SMTP id e15-20020a17090301cf00b001490b6f4e98mr4199167plh.118.1640105281913; Tue, 21 Dec 2021 08:48:01 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/31] tcg/loongarch64: Implement exit_tb/goto_tb Date: Tue, 21 Dec 2021 08:47:31 -0800 Message-Id: <20211221164737.1076007-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1032 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-26-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 0b7d6458c5..92a30b791a 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -980,6 +980,25 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, int c2 = const_args[2]; switch (opc) { + case INDEX_op_exit_tb: + /* Reuse the zeroing that exists for goto_ptr. */ + if (a0 == 0) { + tcg_out_call_int(s, tcg_code_gen_epilogue, true); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, a0); + tcg_out_call_int(s, tb_ret_addr, true); + } + break; + + case INDEX_op_goto_tb: + assert(s->tb_jmp_insn_offset == 0); + /* indirect jump method */ + tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, TCG_REG_ZERO, + (uintptr_t)(s->tb_jmp_target_addr + a0)); + tcg_out_opc_jirl(s, TCG_REG_ZERO, TCG_REG_TMP0, 0); + set_jmp_reset_offset(s, a0); + break; + case INDEX_op_mb: tcg_out_mb(s, a0); break; From patchwork Tue Dec 21 16:47:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526614 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5236313imb; Tue, 21 Dec 2021 09:05:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxUZDd/Q40t2x/E7I6sRcadSdEOy/mqoKACDkeCZ0APhrJS4nhmIW7Ox5DqeljGmXKPeRK X-Received: by 2002:a05:620a:4103:: with SMTP id j3mr2732974qko.737.1640106329080; Tue, 21 Dec 2021 09:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106329; cv=none; d=google.com; s=arc-20160816; b=n2h8RflVRVp5zuV14qH8Ln3UgIDEWx7hxOZ82Kr7t6VmP9bT5C9tWBLN+QLbvWSpum 8P8s5E7XW3ZcTDeSAB/4O+XMmJp7s1sAicDVnAe8aD2P59mouNoB4OQSPJha53fUaniH V2lU+a9rPz80cK7BGh6V4vTM7W+BtZ2KecxCWfPv2lfj//MGMVJAZ9XwBbDkGnSgAbQB 5YLB28RnDtga3pCQotgGCTmUYWEiJg6Fnori4D0IuZ/esKv39ZkCEgCENyhT/pPTl+a6 EfbIRkTGZZu/wXFiWmdNZuMP3Uh2juV2T62GRRBmrqZ2zBKmJBsFZszVA8oz3ZVXJmLm TGHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WO96uXzs2VxZy6qk1muZlkJ5WfUhWuzvPvum8pCRR/k=; b=nxk2EHDHEH+x3NFyNT+SF465rzvVWpIm5lAgEKVDLYFgYSQCfj5udIPDG+EqQYuswQ kEnjZZAACV7CH9VWRlZVzKjrnG+Xnogpuz63FAq24xX8rwcORx208pn0MkT8HjDTCCiM icPpSbDtvzB2Eh+Ek0DEDUl/k1xuSYP2Q0eLsYqMoSoUVQaOXWoVT4iL+mJ42TMLQz7c dpKP6tmZ4YN4MbwKYUq1gJbyhXPslexcrApaSPmwwjuFTJ8+W5vEU+078/jTi4Hf+gr9 HvYIkMygBfPUZ4bJql2kQ9TOIZ0rT1U50UTSklGaCbnjRTYxYZmNF527jluG15W+oNco irnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=os88Votl; 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 2si7731905qtz.333.2021.12.21.09.05.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:05:29 -0800 (PST) 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=os88Votl; 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]:49086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziZs-0001z1-H3 for patch@linaro.org; Tue, 21 Dec 2021 12:05:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJ9-0000y4-SD for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:12 -0500 Received: from [2607:f8b0:4864:20::633] (port=46944 helo=mail-pl1-x633.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ1-0007fM-U8 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:11 -0500 Received: by mail-pl1-x633.google.com with SMTP id p18so11172045pld.13 for ; Tue, 21 Dec 2021 08:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WO96uXzs2VxZy6qk1muZlkJ5WfUhWuzvPvum8pCRR/k=; b=os88VotlpOqV+XS2P8fKZEB81adjI1fTOCkStvCG1wvTDLD5O+l/wW5srrnm2WDimR AYW9IF70w3KB57xFuBs8X99v/EmedGpKujuxuPEGv/AWAfLgcfMd4kdgDEAGVIpJE4K4 qqCLdJnIkkJZtg1z4LxRSa06HP23oW3W7dsOA/y4rKzlYEqnRgjGWi6ZeOwYHp06tVX5 cLdh1vTW8PWYTBJGf4rpriR6ABaJoGDNJYtePdoupTOwPL/jFrtu8d6HURz/KEHZ/NB5 dz+qL9Z9LnYZtvd9M1DY22m3KN+B0N+fovXqk/fDeMvwpdLhizZVNg+isTBc3Lu8K4I/ J6GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WO96uXzs2VxZy6qk1muZlkJ5WfUhWuzvPvum8pCRR/k=; b=y92qWHYfTOrFPcBv3rhsfdgUzERkpyayW0qfIOn/zDmf1Y988Om7rW/npLmA6a6XDb JO5kdUzMVNf07BMmkxBexdPlMuTLRNjaet73iAQFVFKduDT94c/w8Y9z5pNwpPeK0Tp5 AR0Byj5Kt7Oy64FPKnuk1EviSWAK1Xbfm9Y5xXEh0i0O9ADPu38l+94ur7/rS9yUYy67 Qm1Li/kB05m4fQyMaR6YQXVsU7OELWVSkWmn/YNQ3evNTbiI6giAle+R9otThcaGv0uk zlT3Bou3XJHdN9XUZVsaqlGF4wMNpRxupX5u3IAwGSBwvE3cCT2rBNDhTSAsEnM/3dTC D9dQ== X-Gm-Message-State: AOAM531vriuogoKFfjJnoclEElsZy52+EfJ5JTwubHUj7A+k11+2rwKu kcPwVq4EX51ndpyIg+bdCjEIotL8+llerA== X-Received: by 2002:a17:90a:fd95:: with SMTP id cx21mr5096720pjb.54.1640105282693; Tue, 21 Dec 2021 08:48:02 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/31] tcg/loongarch64: Implement tcg_target_init Date: Tue, 21 Dec 2021 08:47:32 -0800 Message-Id: <20211221164737.1076007-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::633 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SPACE_RATIO=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-27-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 92a30b791a..19bfc135f6 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -1604,3 +1604,30 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_addi_d(s, TCG_REG_SP, TCG_REG_SP, FRAME_SIZE); tcg_out_opc_jirl(s, TCG_REG_ZERO, TCG_REG_RA, 0); } + +static void tcg_target_init(TCGContext *s) +{ + tcg_target_available_regs[TCG_TYPE_I32] = ALL_GENERAL_REGS; + tcg_target_available_regs[TCG_TYPE_I64] = ALL_GENERAL_REGS; + + tcg_target_call_clobber_regs = ALL_GENERAL_REGS; + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S0); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S1); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S2); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S3); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S4); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S5); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S6); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S7); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S8); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S9); + + s->reserved_regs = 0; + tcg_regset_set_reg(s->reserved_regs, TCG_REG_ZERO); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP0); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP1); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP2); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TP); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_RESERVED); +} From patchwork Tue Dec 21 16:47:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526618 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5238681imb; Tue, 21 Dec 2021 09:07:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcGMWLfdRPDdA13/mcZDPWxulyVrvryZH8tBqDgC0+PVDHLLRmEf0dSERJ9M9UKEhSMuTe X-Received: by 2002:a05:6102:31ad:: with SMTP id d13mr1759070vsh.55.1640106457534; Tue, 21 Dec 2021 09:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106457; cv=none; d=google.com; s=arc-20160816; b=YVe+QvIYC5exBCs9B8pFsqj/eNX9aE06E+elFKeKmI2wnDWCYpowtmZyX9r81ZQ2E/ EoN+nHhccahdXNPTJaAyaQtc9AoCLF/I1yKuDJ6/N8lJlwUhNjV5H8HmZn4+r1Rvf9Yd drqJuHER+7faz7fh58d+UOdz3SVcpyLwi2omEWv50ioTDhUf01LeGDSoC4stLGrRzjOK RpwZ60n1d+7PWBfJQDg0ak9GkuGTNSMTq375JMVDneWZUmyANdOLrMqO/SWAoQaBg3DO JiREOryMobOhsLbz6NccMgeHi9pt48jceEba8MHN8zBR04bF8K6bMnLHOCxuNGcMcW42 u19g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qQ0I9rAWgkrU2eJcY8Ph2P35NmJRfaSlHBZfKDlj2Eg=; b=TkVSDWCmpfmTYBLAlEwU5bh8NceTI6UJrcVSNthvZT4VzwjcRvoSHtIkLoSNJ53oAT Arp63DS3Xe//2No90M0EY4QG0BM4NiQVzGjAEbHleAlQFKIW7ia4m1pKuwIvxNA1ppq8 R9PbJ8vOKYSlHfVnwQujbzUb1LDTzaBzVg7HKvTTOyoj/uaZWiatAfQUa37+gGiGXQas SXQqf5b3qS7XMRBR+IaLvx81OGgT/sJlkLqkGsmO2K5EU3C1je2SRK9yz5mah1by67s/ t+uv7P9kcHUkUEdx0VUlqwh6Biu9POQbJgfF1ICPB8qTorEQBor6aD323CkmsOfHb6wE uJug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qn6aKaHo; 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 g23si2800113uam.240.2021.12.21.09.07.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:07:37 -0800 (PST) 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=Qn6aKaHo; 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]:57554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzibw-0007kW-SO for patch@linaro.org; Tue, 21 Dec 2021 12:07:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJA-0000zx-G3 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:12 -0500 Received: from [2607:f8b0:4864:20::436] (port=43933 helo=mail-pf1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ3-0007fT-0t for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:12 -0500 Received: by mail-pf1-x436.google.com with SMTP id 196so8740020pfw.10 for ; Tue, 21 Dec 2021 08:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qQ0I9rAWgkrU2eJcY8Ph2P35NmJRfaSlHBZfKDlj2Eg=; b=Qn6aKaHo1B1zexQcQcGKT/CaKUoQ9v7EBksw3r4cAZ+yuMYr3YWTAYP2ykntSbaXEm 1bhGL/lMoeDBB+QjTztcGnNUxb2esBOy6apn4hT8QhVZ5kziTdD8D3Nq48/giDgdNIZE CPh5KyhNUWocXPYM1PvCUrWI6liqbKh2t7Cdq2ht+aKrU0D1uTHkW8bzfU/8pOktthlr dxClANQPGVbEBjei8Qf/c/i+JUrowwkzI7cA6fUlnLkp5OCoLCCa3nA7deuRm5m1aoKg phuRtiURMpZddNEWD4NyYaSdPVor6IHbVAGKygmoH3BYCO+xGUkw7WBKCiqCSkj9re8q jqmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qQ0I9rAWgkrU2eJcY8Ph2P35NmJRfaSlHBZfKDlj2Eg=; b=4kCUgSpSBolydKzmecr6gDFrnmbg0to3oKlfunbbrR1qoz4bmessUJUtk9RnsAdWMM KQseuZIYKOAUPFnfahe8GIoV3yKrHlq8QAAiqBXymXmacsH2qlQ3IiEdiegzdWOgSGny Lm4VEQTyP3j9ogpcA/L9VJGxiDt70NJ0RNsmkAiAoFy2cAddB7SFuZFjPLn1mmsHi6Fk bZKIHIoN6fkAVBrh5vG/UFEJq2tj91Vqu1yNEJZvQA+ROmoR9LHVB12L/VYjRGDxVu2r 8yfevCIlSizhs2yBZbQwpiUOiZD69KbyKA/4+/I0fkL3ZSsWOltYRpruSiJtwjtmB+8g /Rtg== X-Gm-Message-State: AOAM530nDdgQU0SEb4KnJUzyJjC8p6Ao9Mf/UD7ukw3jY7qIK5Qh7Vci WBxNaTqedCsYDh1kGUryJ/6mnbBl9w/t3Q== X-Received: by 2002:a63:284:: with SMTP id 126mr3639180pgc.328.1640105283613; Tue, 21 Dec 2021 08:48:03 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 27/31] tcg/loongarch64: Register the JIT Date: Tue, 21 Dec 2021 08:47:33 -0800 Message-Id: <20211221164737.1076007-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::436 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-28-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index 19bfc135f6..9cd46c9be3 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -1631,3 +1631,47 @@ static void tcg_target_init(TCGContext *s) tcg_regset_set_reg(s->reserved_regs, TCG_REG_TP); tcg_regset_set_reg(s->reserved_regs, TCG_REG_RESERVED); } + +typedef struct { + DebugFrameHeader h; + uint8_t fde_def_cfa[4]; + uint8_t fde_reg_ofs[ARRAY_SIZE(tcg_target_callee_save_regs) * 2]; +} DebugFrame; + +#define ELF_HOST_MACHINE EM_LOONGARCH + +static const DebugFrame debug_frame = { + .h.cie.len = sizeof(DebugFrameCIE) - 4, /* length after .len member */ + .h.cie.id = -1, + .h.cie.version = 1, + .h.cie.code_align = 1, + .h.cie.data_align = -(TCG_TARGET_REG_BITS / 8) & 0x7f, /* sleb128 */ + .h.cie.return_column = TCG_REG_RA, + + /* Total FDE size does not include the "len" member. */ + .h.fde.len = sizeof(DebugFrame) - offsetof(DebugFrame, h.fde.cie_offset), + + .fde_def_cfa = { + 12, TCG_REG_SP, /* DW_CFA_def_cfa sp, ... */ + (FRAME_SIZE & 0x7f) | 0x80, /* ... uleb128 FRAME_SIZE */ + (FRAME_SIZE >> 7) + }, + .fde_reg_ofs = { + 0x80 + 23, 11, /* DW_CFA_offset, s0, -88 */ + 0x80 + 24, 10, /* DW_CFA_offset, s1, -80 */ + 0x80 + 25, 9, /* DW_CFA_offset, s2, -72 */ + 0x80 + 26, 8, /* DW_CFA_offset, s3, -64 */ + 0x80 + 27, 7, /* DW_CFA_offset, s4, -56 */ + 0x80 + 28, 6, /* DW_CFA_offset, s5, -48 */ + 0x80 + 29, 5, /* DW_CFA_offset, s6, -40 */ + 0x80 + 30, 4, /* DW_CFA_offset, s7, -32 */ + 0x80 + 31, 3, /* DW_CFA_offset, s8, -24 */ + 0x80 + 22, 2, /* DW_CFA_offset, s9, -16 */ + 0x80 + 1 , 1, /* DW_CFA_offset, ra, -8 */ + } +}; + +void tcg_register_jit(const void *buf, size_t buf_size) +{ + tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); +} From patchwork Tue Dec 21 16:47:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526624 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5246738imb; Tue, 21 Dec 2021 09:16:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPa1emkD3MxIyr8eJKCKY1Angle+wjTEHXccpQtZrrpRE9JcgzAsk+JKSsHeS9prdja7v/ X-Received: by 2002:ad4:4423:: with SMTP id e3mr3377329qvt.55.1640106992894; Tue, 21 Dec 2021 09:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106992; cv=none; d=google.com; s=arc-20160816; b=mrzH6Jt/UhySHdgzaNvewJfQLfLoh9XAkkkUOhC/ZkdI2DGnKYwrBLfJUn/Rd9PBFa D6JVrvro2kcRfq191V+pxzr+n4bfLU6R12FUE/uPIHlbCZwUnHJpcE7wpAGX+/jNkNQn VHrG7rcYpDWX+qsfPnoTDlFyWTUVBUT6axm+EQbjiNQvfKkBZddnIDC8H5Go/fRG6sCu kzyli0SzLkZrI0w8aoDybpKlDw/CTFA0sl/hP/B784jczml5FuEHXy6+Ng+y7J0RZQ9o Wqs3sW/42GJDeO7Il9+j7Qj5ZEC/ADFTSk2HrXoLbg3UNOUejZkEHxZeBdB4wT0WphiC X4SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=NXitDDn0ZGVh6q/FUUAQ/qESIDgx/GkwWKwAawsJ6kU=; b=mGX+SA9Nxjt+KZqH7/PsEu7kSt8ZTsvCZdM1wgBDSG9FOMxOei1BlsERLuuGavCWUZ n7z0Lkm5GCngBaH5v9UB1jAJ2ZgLFXOPPyld77iEJQfuQZuFeVlSrFRQTDdhl+ab209o Nn60u+8V1/9E8nOnWhdX1eAjYlSpwbhAPeCWUNU/3EL1WEze5Kctpq72Q9J5folO6r9v N8pO0gBvxFOto5NvuXFH70hsBfUWNP9JZ/MLwCTA+p1UcHQjLNMU2DgTRHgNMzwSLXeu mbEUyN6dQS7+L/2gHIwbt3J5kuYSjN3riZY5//ED208AdZFo3BYA257eDExtYRVwLK7a cEhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iCcO7UI8; 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 s123si7620854qkf.742.2021.12.21.09.16.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:16:32 -0800 (PST) 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=iCcO7UI8; 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]:52178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzika-0006PS-A6 for patch@linaro.org; Tue, 21 Dec 2021 12:16:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJA-00010j-NX for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:12 -0500 Received: from [2607:f8b0:4864:20::42b] (port=43923 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ3-0007fY-OH for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:12 -0500 Received: by mail-pf1-x42b.google.com with SMTP id 196so8740052pfw.10 for ; Tue, 21 Dec 2021 08:48:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NXitDDn0ZGVh6q/FUUAQ/qESIDgx/GkwWKwAawsJ6kU=; b=iCcO7UI8hnnozrRaBK3DoglDt43UlLzkBXfI5I4+Br0Ci7iPj4Y2LvyPlwtDIDNgO5 XC+p2lIaP9h0jjXtb91E/5cIi/2uqX8/nHyxXG8zRqKvz8JZIiMra/WzwdULGxZBlTpn T1jMo+SFwOwGyH+dRuMDBKFrifBqP0Ojus7tg8p1qfGRmQu/mDzqAxmlqVcWSiop2j3G kE1s7JMnVaN/IKbUTg0Q8OVvWbNjZ4ROKATzmMXmfDMvXsJMdxUItRn/pXb38t1ljOQE o7Ih4DcmhhBZTvvkKaIQMTViOn9YtxfHbisE+B/vuDYr79SUx4hvPuKAkuRO44It2XC6 ITOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXitDDn0ZGVh6q/FUUAQ/qESIDgx/GkwWKwAawsJ6kU=; b=7KDj6iHVwqOHHT2XuiLYMbUgQCYgX3h7Rb9ezi23gzifqCUtigsbUVEgjatCi5Ywtu 21x2UTHAyx5J8E3PJHsYQ0lZRdU6gF1OK5SYv8Ps5O1oXJ0whXZR2DGx9IByVeaMGWlN W5TJnV9qVgvtWLUzV+RNDCeyiFqb8z8dLTW92Z6j2TYmmKD+nTXzJWwrA2V51VhHVFdv BcTiHX6xlF9F3dvbZ2YZCwgJA6bIgtDi+C97zj4+JQoLb26FhZgyYoUb7FxKS5Ldm7g4 xDABXONJI73bJiIuBCISf363os8s8XJd7KqfvmD2gwIyOo+mau690YAYQ55NkCS1BE2e QKEg== X-Gm-Message-State: AOAM531IEUEzHcyxO6WHvs0Qwt4N4kWRQRWqUN3lzVuzyUDMZUIDusLl W+xhO/iZKA8Qy84LOeNSNglbwEQwjX/XBQ== X-Received: by 2002:a63:1158:: with SMTP id 24mr3655380pgr.193.1640105284430; Tue, 21 Dec 2021 08:48:04 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 28/31] common-user: Add safe syscall handling for loongarch64 hosts Date: Tue, 21 Dec 2021 08:47:34 -0800 Message-Id: <20211221164737.1076007-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42b (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20211221054105.178795-29-git@xen0n.name> Signed-off-by: Richard Henderson --- .../host/loongarch64/safe-syscall.inc.S | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 common-user/host/loongarch64/safe-syscall.inc.S diff --git a/common-user/host/loongarch64/safe-syscall.inc.S b/common-user/host/loongarch64/safe-syscall.inc.S new file mode 100644 index 0000000000..b88a069c45 --- /dev/null +++ b/common-user/host/loongarch64/safe-syscall.inc.S @@ -0,0 +1,90 @@ +/* + * safe-syscall.inc.S : host-specific assembly fragment + * to handle signals occurring at the same time as system calls. + * This is intended to be included by common-user/safe-syscall.S + * + * Ported to LoongArch by WANG Xuerui + * + * Based on safe-syscall.inc.S code for RISC-V, + * originally written by Richard Henderson + * Copyright (C) 2018 Linaro, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + + .global safe_syscall_base + .global safe_syscall_start + .global safe_syscall_end + .type safe_syscall_base, @function + .type safe_syscall_start, @function + .type safe_syscall_end, @function + + /* + * This is the entry point for making a system call. The calling + * convention here is that of a C varargs function with the + * first argument an 'int *' to the signal_pending flag, the + * second one the system call number (as a 'long'), and all further + * arguments being syscall arguments (also 'long'). + */ +safe_syscall_base: + .cfi_startproc + /* + * The syscall calling convention is nearly the same as C: + * we enter with a0 == &signal_pending + * a1 == syscall number + * a2 ... a7 == syscall arguments + * and return the result in a0 + * and the syscall instruction needs + * a7 == syscall number + * a0 ... a5 == syscall arguments + * and returns the result in a0 + * Shuffle everything around appropriately. + */ + move $t0, $a0 /* signal_pending pointer */ + move $t1, $a1 /* syscall number */ + move $a0, $a2 /* syscall arguments */ + move $a1, $a3 + move $a2, $a4 + move $a3, $a5 + move $a4, $a6 + move $a5, $a7 + move $a7, $t1 + + /* + * We need to preserve the signal_pending pointer but t0 is + * clobbered by syscalls on LoongArch, so we need to move it + * somewhere else, ideally both preserved across syscalls and + * clobbered by procedure calls so we don't have to allocate a + * stack frame; a6 is just the register we want here. + */ + move $a6, $t0 + + /* + * This next sequence of code works in conjunction with the + * rewind_if_safe_syscall_function(). If a signal is taken + * and the interrupted PC is anywhere between 'safe_syscall_start' + * and 'safe_syscall_end' then we rewind it to 'safe_syscall_start'. + * The code sequence must therefore be able to cope with this, and + * the syscall instruction must be the final one in the sequence. + */ +safe_syscall_start: + /* If signal_pending is non-zero, don't do the call */ + ld.w $t1, $a6, 0 + bnez $t1, 2f + syscall 0 +safe_syscall_end: + /* code path for having successfully executed the syscall */ + li.w $t2, -4096 + bgtu $a0, $t2, 0f + jr $ra + + /* code path setting errno */ +0: sub.d $a0, $zero, $a0 + b safe_syscall_set_errno_tail + + /* code path when we didn't execute the syscall */ +2: li.w $a0, QEMU_ERESTARTSYS + b safe_syscall_set_errno_tail + .cfi_endproc + .size safe_syscall_base, .-safe_syscall_base From patchwork Tue Dec 21 16:47:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526625 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5248307imb; Tue, 21 Dec 2021 09:18:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxdE7xysKcWYLmXJow5B/2o4RuIslEggzjUJq45qW78CDlEeWU/8qtLQk1GkAG8oc5yO2x X-Received: by 2002:ac8:5b82:: with SMTP id a2mr3065133qta.519.1640107103134; Tue, 21 Dec 2021 09:18:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640107103; cv=none; d=google.com; s=arc-20160816; b=Ib2Y+hA7K/ozr+LmKep2nGOIKbdVpWHZb73CMs/W0xOjZJW63Dz9PSQDnxXgxtBWbT oXgKmBKasM6AQQZvyDG0OKFsuxA6T/Uoj3TD7jPoJcdT6j2Kc7JDB1tY4VFUGsygDZ8T yj9SFfmKRsDWBR5OBb71ixhuMnskvfkScN0OGBMcC2QnITlB8L01D3bNtx5VyjFAGQRQ cDn/vfeSOUHY6fNb2kET3GnnQHMEQRJ5MqGRROvKuDzJZpZ2lnA3okRqHIUxeFcX7mjJ D9MnENUpuwI5r5B9XUM9xLcMUD8w50nLiyS3RBwpSeJGh9SpaXcKGN9Ce830vavhHzjG DEWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jwD0nklpaMv6uE7sTv0yiM3eKKOOZulK+Q3tBkY247E=; b=p8hdOrSjs5VDPZfBgJG0umdBkVV6Bzo3GM2upRc8ksAO7VC/vjqxD+6GOT23ryWU6I s+DdlEhl8gtn0zYOxUMJRieAVAPeHH2WsLEa3ATPmMYHl7HIDMnn0juph74ySFMAs42n CyiEhjwk2qiQxT/jrGXWR5AtK8Ic9sfQc3qgGw5aBJHhfCUKINYCE8/cYR4YIxlwRpA/ CVZEMpvjlK9IUiFh+KxbFT/D8+Ar67h4sf5O/0YL+aoM4VSPba36vdsrQAozPWpLV+Tk PTm778ID0lI8Y5McCm3culLZOilzgUbQigUIAfVF4dYI2E2qceJeyNqhuZsUscM+A/OA i0ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uJFJstex; 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 d2si8265778qtd.508.2021.12.21.09.18.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:18:23 -0800 (PST) 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=uJFJstex; 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]:56642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzimM-0000zn-IO for patch@linaro.org; Tue, 21 Dec 2021 12:18:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJC-00014s-4V for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:14 -0500 Received: from [2607:f8b0:4864:20::1029] (port=42940 helo=mail-pj1-x1029.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ4-0007fe-Hu for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:13 -0500 Received: by mail-pj1-x1029.google.com with SMTP id lr15-20020a17090b4b8f00b001b19671cbebso3741717pjb.1 for ; Tue, 21 Dec 2021 08:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jwD0nklpaMv6uE7sTv0yiM3eKKOOZulK+Q3tBkY247E=; b=uJFJstexeq5GyyAea3BtYp+1ddbSGHn+35lI0dlRzqJ1TcDB83TWGD17+2MgLabllP t2CrsfztYjjN1U7Vc/hWVnPmcodaU0pN+8rdDOemcVE/uqmfbZWE1gW1FwNZMO32KK9S JUn4Pgb+jsM5iKtydfHHVb+ufM71iefuQ63apI+1jn95XcZ8YxJYp4z3+Qs3wGm8SdNQ DbMi3MCNQ43FJWAHDoT3HZB4skCrDWWRzeZAXiWsOuj7Wxvtakt0cf6UuPZXiZuI+R0g 0qJ6NbbO/Lj9AzvtL9EahepjU0z+V5dlLyHkpgM6XH/qokyxf353Ua0Y/z/0uPKpGzFS mAwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jwD0nklpaMv6uE7sTv0yiM3eKKOOZulK+Q3tBkY247E=; b=4AU+LRmBZMKDbF6AsE8b+iqQ2z+tpU5C0RB45J2Q9V86be8SqSfeyOGPNpbDd6KLMq uLiRCbScC3pTxrcvn2XMD/X71KaNNsMB9yzvA7wNrEpU94GtfiPsbNggFmhTU7ecMsku XxtCRmq3rwylQDUzdDefYRGdCJXxTc1/c9V2jzosqOlE0p0eCH2hHxFTHlp1VQoIwTjU v3SZ1MH3m/pHIqhkboMK8lOznvlzl1lXT7Ia/Vfn1BDZnBU53QCcuxWL3giEzToDMqKl 6MFcDpr9qIKI/I1BjNLpSSp6KjMuN0Gb0VQUi+LcHNDEZTjuHWbl3qo8if7OZNoccpf5 NEdg== X-Gm-Message-State: AOAM532aeOLFgFhYjt9NMSZCPbhrenzsbMsPUQ6CV7JMZsc3hnGpJmn5 VHzYdtEitRaRgCr78ZxeOvB2J80tfnKNVg== X-Received: by 2002:a17:90a:c68a:: with SMTP id n10mr4911607pjt.119.1640105285294; Tue, 21 Dec 2021 08:48:05 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/31] linux-user: Implement CPU-specific signal handler for loongarch64 hosts Date: Tue, 21 Dec 2021 08:47:35 -0800 Message-Id: <20211221164737.1076007-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1029 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-30-git@xen0n.name> Signed-off-by: Richard Henderson --- linux-user/host/loongarch64/host-signal.h | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 linux-user/host/loongarch64/host-signal.h diff --git a/linux-user/host/loongarch64/host-signal.h b/linux-user/host/loongarch64/host-signal.h new file mode 100644 index 0000000000..05e2c82371 --- /dev/null +++ b/linux-user/host/loongarch64/host-signal.h @@ -0,0 +1,87 @@ +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 WANG Xuerui + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef LOONGARCH64_HOST_SIGNAL_H +#define LOONGARCH64_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.__pc; +} + +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.__pc = pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc); + uint32_t insn = pinsn[0]; + + /* Detect store by reading the instruction at the program counter. */ + switch ((insn >> 26) & 0b111111) { + case 0b001000: /* {ll,sc}.[wd] */ + switch ((insn >> 24) & 0b11) { + case 0b01: /* sc.w */ + case 0b11: /* sc.d */ + return true; + } + break; + case 0b001001: /* {ld,st}ox4.[wd] ({ld,st}ptr.[wd]) */ + switch ((insn >> 24) & 0b11) { + case 0b01: /* stox4.w (stptr.w) */ + case 0b11: /* stox4.d (stptr.d) */ + return true; + } + break; + case 0b001010: /* {ld,st}.* family */ + switch ((insn >> 22) & 0b1111) { + case 0b0100: /* st.b */ + case 0b0101: /* st.h */ + case 0b0110: /* st.w */ + case 0b0111: /* st.d */ + case 0b1101: /* fst.s */ + case 0b1111: /* fst.d */ + return true; + } + break; + case 0b001110: /* indexed, atomic, bounds-checking memory operations */ + uint32_t sel = (insn >> 15) & 0b11111111111; + + switch (sel) { + case 0b00000100000: /* stx.b */ + case 0b00000101000: /* stx.h */ + case 0b00000110000: /* stx.w */ + case 0b00000111000: /* stx.d */ + case 0b00001110000: /* fstx.s */ + case 0b00001111000: /* fstx.d */ + case 0b00011101100: /* fstgt.s */ + case 0b00011101101: /* fstgt.d */ + case 0b00011101110: /* fstle.s */ + case 0b00011101111: /* fstle.d */ + case 0b00011111000: /* stgt.b */ + case 0b00011111001: /* stgt.h */ + case 0b00011111010: /* stgt.w */ + case 0b00011111011: /* stgt.d */ + case 0b00011111100: /* stle.b */ + case 0b00011111101: /* stle.h */ + case 0b00011111110: /* stle.w */ + case 0b00011111111: /* stle.d */ + case 0b00011000000 ... 0b00011100011: /* am* insns */ + return true; + } + break; + } + + return false; +} + +#endif From patchwork Tue Dec 21 16:47:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526622 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5244461imb; Tue, 21 Dec 2021 09:13:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGOyTXcQyao37LdjAwy7ybMRppDbJmK7ctvD6I7tHRvwVIBrTpTlVk5z4x2RlRDR8aF6RQ X-Received: by 2002:a05:6638:2725:: with SMTP id m37mr2667903jav.266.1640106826185; Tue, 21 Dec 2021 09:13:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640106826; cv=none; d=google.com; s=arc-20160816; b=YOsM/ikx+LlZ/wmdU2GEiqaqyhoklkGzPnNqhXKPkNC5iH7tFT148SOTNbPws5dsmt 7rbiwrB2xKTbDIIVDQ64O7X3vBnlM/mFYjypnWoOjfqMy9qpsV5t1zroKogEI0q9bCfu aLejcc9sEARw8H5RtAIAiw//YE+95TUFkc6l0VPXl6dIQRlKts5vPfS4pFLLEyPgCOk+ jh6voyr+evfa8gPIdbP697t2SpBy7mxuTxnHBWMsBFmHXeYsXOd6K6kLepTPEOfQvmjO cUWzPueuA7CcWHfP9nbt/n2Voe7aCmh814ALvzYUtZ7UwbfCglKHmO6De/R9WaWTPx4h boMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=bsfEKlYqYyVVIZAQxrO42ZoY7uXuqNeBFTeiKhl2LqI=; b=fN9wksewzsn29fONrKqjISYwjLnd4+WM1Fvn4nogsroXrklNCrY8ckdMvn1Rqac2Vq RTiRFWcy3GL2gzvKrIXhQj8Yg8M5d5THS3iGBxGMZXmDTe0aCW9l91m5KZ0OsGXRJ/XS xFMWddA/cRtzU7Xn+VkgiYExcQtEJ6ukuykG62X9HInBB5o5yThRRPTaSVN1bGr5m7vF U67uFv04b+BYCh6e2Dm2VCAi9gKAF+Hnuxtqbtd2i7DbitHr/afmYh2QB6JLcjEdjb9T G/gGIwmm5jdoH6fMek4G271sw1ijcPiCHHnwqYgCseevfnNgQNdkSDOfzXGEOzn6KvQE Dr8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bFwnFJsi; 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 d10si19021172iow.33.2021.12.21.09.13.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:13:46 -0800 (PST) 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=bFwnFJsi; 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]:44764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mziht-0001QB-N8 for patch@linaro.org; Tue, 21 Dec 2021 12:13:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJC-00014a-2h for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:14 -0500 Received: from [2607:f8b0:4864:20::529] (port=34560 helo=mail-pg1-x529.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ5-0007fn-BX for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:13 -0500 Received: by mail-pg1-x529.google.com with SMTP id g22so1065902pgn.1 for ; Tue, 21 Dec 2021 08:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bsfEKlYqYyVVIZAQxrO42ZoY7uXuqNeBFTeiKhl2LqI=; b=bFwnFJsi7hGliIJK+j4FHZsusrSxSBIavzzPuUiC+wp8dw7KnWAKuDHRaSOfi4kJ+u HfQKvKQY//R6V8LAGpTfr7dnsqk/2Uw3FQTYUmR175Riby7XZdzbTOxPoa2Qh79ZAxvl bofZqTNR489OtFYteMUrFcLPm7xBqtUIeP8Ej+YMoButWARIL5TcJ9fANRYKbb+CkKwb SHVLevjeLMOa/qpoVa9sbsv2mQXUrNMtDovr2Eh+K186xEPO1kYA76I1S/ORiOliKoQz lxYlSKY/PcmfxlXOd9rVlh59/6zZULU6PCQk3FWC7221bCUc1w26TFKh3VetF9ndyL7d oohQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bsfEKlYqYyVVIZAQxrO42ZoY7uXuqNeBFTeiKhl2LqI=; b=n7FUtbeSc3FunRJDv4AQVllYobRTh8bQdVxqbfmVuZAnQBgQXlCr+CuKu08JYXBCGv ZJpBjd+lb3r3rzfEqlDAjzYFHXOmUYtm3FU4L9TRXNqFWBvTZ8fo2aXvLUt+r6u/ZbxQ 3qo/lSMyjb+lJzOIrc80osDOBQENDsumcDRdm4aucaZOaLElU4+V3JMzWtvt7CVWkNIv MHcP+5D4hX46OjFZfrMMA4P9YFXbyiqBzqL+VFUa1KcnJBGeJfvXDm70klaix2oLHJY+ UvsKN2GKLstDiTXiWLhaaQLc1C7wZ7xRi5RrKb3tslMAkYCs0wV8HtUHKCS8VZXP/G9B k7fw== X-Gm-Message-State: AOAM531j9/1jWTW36fmn15IK7le+r/vfplkUbYztMof6ergSvmltVyZx qZ+blUTHHxbyRaR31SWuEJ6kQpNrZ4Wipg== X-Received: by 2002:a65:6488:: with SMTP id e8mr3662440pgv.416.1640105286148; Tue, 21 Dec 2021 08:48:06 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 30/31] configure, meson.build: Mark support for loongarch64 hosts Date: Tue, 21 Dec 2021 08:47:36 -0800 Message-Id: <20211221164737.1076007-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::529 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Example output of `uname -a` on an initial Gentoo LA64 port, running the upstream submission version of Linux (with some very minor patches not influencing output here): > Linux 5.14.0-10342-g37a00851b145 #5 SMP PREEMPT Tue Aug 10 12:56:24 PM CST 2021 loongarch64 GNU/Linux And the same on the vendor-supplied Loongnix 20 system, with an early in-house port of Linux, and using the old-world ABI: > Linux 4.19.167-rc5.lnd.1-loongson-3 #1 SMP Sat Apr 17 07:32:32 UTC 2021 loongarch64 loongarch64 loongarch64 GNU/Linux So a name of "loongarch64" matches both, fortunately. Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-31-git@xen0n.name> Signed-off-by: Richard Henderson --- configure | 5 +++++ meson.build | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 8ccfe51673..9724631609 100755 --- a/configure +++ b/configure @@ -631,6 +631,8 @@ elif check_define __arm__ ; then cpu="arm" elif check_define __aarch64__ ; then cpu="aarch64" +elif check_define __loongarch64 ; then + cpu="loongarch64" else cpu=$(uname -m) fi @@ -3719,6 +3721,9 @@ if test "$linux" = "yes" ; then aarch64) linux_arch=arm64 ;; + loongarch*) + linux_arch=loongarch + ;; mips64) linux_arch=mips ;; diff --git a/meson.build b/meson.build index f45ecf31bd..6d7c02bad7 100644 --- a/meson.build +++ b/meson.build @@ -56,7 +56,7 @@ python = import('python').find_installation() supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux'] supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64', - 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64'] + 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc', 'sparc64'] cpu = host_machine.cpu_family() From patchwork Tue Dec 21 16:47:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526626 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5250025imb; Tue, 21 Dec 2021 09:20:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBsqOwKvPT7UCJIScXhtG5WdPyHi4icikJoNlhPX0K6Q4qwYYDIGxsRdMYDRTWEMyRpc+f X-Received: by 2002:a05:620a:148d:: with SMTP id w13mr2809523qkj.656.1640107208347; Tue, 21 Dec 2021 09:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640107208; cv=none; d=google.com; s=arc-20160816; b=QSavbSx1ruehe7KI4MAwGkeHmdk1b+Uz62GFpis56A9N3GyUP8hAjvRanzaxWmWHAk NSV5in/T5ok9DBy7C12s0d2J5Ta0+YhyPXlCSbhC8h10Mz2GT5YLNVX4cVLQqy7OBgHQ XWaS1LO9/vSTmfLna1XrKxYmOGk/6rbqCrJfgWf7e8voBZ2+coqhCDle/HyNXHOfPguM AxvQ8HGM4paAo4fpB++WpX2PFdwtB2SPu/9LW8mpoJCZyQuK0FRyRJg547RQ7PsaGaP4 6SG1y2rBjvXM2U+nMC4/+Jd2MIs7gB+wwQIOXVvWwlXzOqo1TOMSllGdoyDI36LxU8zo co2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hQH/TbBJ6tfIM+iClHzixTSrIAvP0jiu4/hFtK8hQSo=; b=QDB92dmaQXmizHhGddin7ATPN4Apgq2hvjC4T5JDr/pTYSqYl3f7gBF0MtmicqTl+J GL9bvyRH6HdfLwWvn0s8XiDT42lcDnRGj6mztoOfZuopsjNdyEsfdIJs3/+i1ogtT9Gp H9k/pf1pianMJBP1TYA+wySpD5G+hjvaOumptljFxGZkh+9thVlekB1UxWMFJWODQWw9 A99BwZ8ins/oWDgo7AbPb3HeKCVXyHzPrTeTzG0CFFiqSE2Jn5sM2f3NK/of0xGKO1IL 05rR3Bl0falWO++HNl9KgRLBoRhC0XQWG4nLAqcAEACFOGs0Nj/ZCScG/Q/LaFlO66qF TFWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uZ2TvxPE; 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 h16si8258413qtx.117.2021.12.21.09.20.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Dec 2021 09:20:08 -0800 (PST) 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=uZ2TvxPE; 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]:33026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzio3-00047d-P7 for patch@linaro.org; Tue, 21 Dec 2021 12:20:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mziJD-0001BU-M7 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:15 -0500 Received: from [2607:f8b0:4864:20::632] (port=45055 helo=mail-pl1-x632.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mziJ6-0007fz-Fm for qemu-devel@nongnu.org; Tue, 21 Dec 2021 11:48:15 -0500 Received: by mail-pl1-x632.google.com with SMTP id q17so11186277plr.11 for ; Tue, 21 Dec 2021 08:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hQH/TbBJ6tfIM+iClHzixTSrIAvP0jiu4/hFtK8hQSo=; b=uZ2TvxPEnl1pca/xapbQWBFa2Bz2pIeFH1CBNI72nQVUBx3LntRp/CB5W7jdWP0wSV 7BRznnljh+tJa8kTML7hFTzFEPy8Pi9H0ZGl6aNers2n6Yx31MXbEkJU/VIJnQG3QWjk BOxQglPk2rQmvqpj5VHH7bhOOcVXjD+X2dCvf3vzD6zWP0Ddcv34Ba/LKr2U9EGyIqZf gV0JRDMrbXth+MtrVLE2La/XVKfQGYedFFfWXvB0KRvpeDlzoTpCqne+cHSUZ+0wzliZ ZBF66jasZO/5oFJBFc2kk/iYxvr/RCrI05aXz7HSXdGa75fvC+cMWMsl7Dx7aA+h1iRs MrrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hQH/TbBJ6tfIM+iClHzixTSrIAvP0jiu4/hFtK8hQSo=; b=bWyD1odULvmBjxUA/qAY94EAQmtAH8o8KDHFs9bzFFRMdTt6zbuJVpLtKwDI1Jg0Xt 5M5SscPsf33Zt6+bniJBlkVb89q+OGeVOr1XrDjDw+LFYMvf8MeISvXTPtQnvcr5EvAu h/7lkX8VJxLvTJ6KULc1AeU8foTUYj+oPJ6XFlGWQaTHQt2W3vnyDVAAbxMvSiwFYCOW NRrS3g8SqpoTZcUrUGLJgedvyda/fUKdGDA87DTE2OeMgfvMSmA2mtFAL9kIbEN8molV 7T1iXkqPEwmbKaNNYpUXPZDMDQx6DzPTq+1j/ZjHVnFEgkomVXIvXz7Mld2gwQVDYRS8 uyfw== X-Gm-Message-State: AOAM5311lEvBULFVoXLugsmoafrEyS/hzT+XzcW5u3CYV3tbKs96RkqC nsKwwj2o1vZOJDbMRiYUc8tj1rNPJHmMFw== X-Received: by 2002:a17:90a:b387:: with SMTP id e7mr5027147pjr.45.1640105287058; Tue, 21 Dec 2021 08:48:07 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id b192sm2256818pga.35.2021.12.21.08.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 08:48:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 31/31] tests/docker: Add gentoo-loongarch64-cross image and run cross builds in GitLab Date: Tue, 21 Dec 2021 08:47:37 -0800 Message-Id: <20211221164737.1076007-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211221164737.1076007-1-richard.henderson@linaro.org> References: <20211221164737.1076007-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::632 (failed) 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WANG Xuerui , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: WANG Xuerui Normally this would be based on qemu/debian10 or qemu/ubuntu2004, but after a week-long struggle, I still cannot build stage2 gcc with the known-good LoongArch toolchain sources, so I chose the least-resistance path with Gentoo as base image. As this image is not expected to be re-built by CI, like hexagon, it should not take much maintenance effort; also it's expected to be replaced as soon as Debian is available. As the LoongArch *target* has not been merged yet, a check-tcg job is not added at the moment, but cross builds with the TCG *host* port are already possible, and added to CI matrix. Due to constant flux of the toolchain sources used (especially that of glibc), the binaries built with this image may or may not work when run on actual hardware, but still useful for ensuring things correctly build. This image is expected to be updated every once in a while, before everything settles down. As a reference, the image takes about 25 minutes to rebuild on a Threadripper 3990X system with Docker operating on HDD; YMMV but it probably wouldn't become significantly shorter, as everything needs to be built from source in our case. Signed-off-by: WANG Xuerui Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211221054105.178795-32-git@xen0n.name> Signed-off-by: Richard Henderson --- .gitlab-ci.d/container-cross.yml | 27 ++++ .gitlab-ci.d/crossbuilds.yml | 19 +++ MAINTAINERS | 2 + tests/docker/Makefile.include | 21 +++ .../gentoo-loongarch64-cross.docker | 21 +++ .../build-toolchain.sh | 128 ++++++++++++++++++ 6 files changed, 218 insertions(+) create mode 100644 tests/docker/dockerfiles/gentoo-loongarch64-cross.docker create mode 100755 tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/build-toolchain.sh diff --git a/.gitlab-ci.d/container-cross.yml b/.gitlab-ci.d/container-cross.yml index a3b5b90552..7a8cc556cc 100644 --- a/.gitlab-ci.d/container-cross.yml +++ b/.gitlab-ci.d/container-cross.yml @@ -82,6 +82,33 @@ hppa-debian-cross-container: variables: NAME: debian-hppa-cross +# Similar to hexagon, we don't want to build loongarch64 in the CI either. +loongarch64-cross-container: + image: docker:stable + stage: containers + rules: + - if: '$CI_PROJECT_NAMESPACE == "qemu-project"' + when: never + - when: always + variables: + NAME: gentoo-loongarch64-cross + GIT_DEPTH: 1 + services: + - docker:dind + before_script: + - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest" + - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest" + - docker info + - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" + script: + - echo "TAG:$TAG" + - echo "COMMON_TAG:$COMMON_TAG" + - docker pull $COMMON_TAG + - docker tag $COMMON_TAG $TAG + - docker push "$TAG" + after_script: + - docker logout + m68k-debian-cross-container: extends: .container_job_template stage: containers-layer2 diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml index 17d6cb3e45..b1cbc9cc43 100644 --- a/.gitlab-ci.d/crossbuilds.yml +++ b/.gitlab-ci.d/crossbuilds.yml @@ -68,6 +68,25 @@ cross-i386-tci: EXTRA_CONFIGURE_OPTS: --target-list=i386-softmmu,i386-linux-user,aarch64-softmmu,aarch64-linux-user,ppc-softmmu,ppc-linux-user MAKE_CHECK_ARGS: check check-tcg +# Upstream LoongArch support is still incomplete, but toolchain is already +# usable and partially merged, so the host support is already testable; but +# don't let failures block CI. +cross-loongarch64-system: + extends: .cross_system_build_job + allow_failure: true + needs: + job: loongarch64-cross-container + variables: + IMAGE: gentoo-loongarch64-cross + +cross-loongarch64-user: + extends: .cross_user_build_job + allow_failure: true + needs: + job: loongarch64-cross-container + variables: + IMAGE: gentoo-loongarch64-cross + cross-mips-system: extends: .cross_system_build_job needs: diff --git a/MAINTAINERS b/MAINTAINERS index 4f6e0de3fb..8da7071b01 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3143,6 +3143,8 @@ LoongArch64 TCG target M: WANG Xuerui S: Maintained F: tcg/loongarch64/ +F: tests/docker/dockerfiles/gentoo-loongarch64-cross.docker +F: tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/ MIPS TCG target M: Philippe Mathieu-Daudé diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index f1a0c5db7a..a2cdf193bb 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -176,6 +176,27 @@ docker-image-debian-hexagon-cross: $(DOCKER_FILES_DIR)/debian-hexagon-cross.dock qemu/debian-hexagon-cross --add-current-user, \ "PREPARE", "debian-hexagon-cross")) +# +# Same for loongarch64-cross. +# +docker-image-gentoo-loongarch64-cross: $(DOCKER_FILES_DIR)/gentoo-loongarch64-cross.docker + $(if $(NOCACHE), \ + $(call quiet-command, \ + $(DOCKER_SCRIPT) build -t qemu/gentoo-loongarch64-cross -f $< \ + $(if $V,,--quiet) --no-cache \ + --registry $(DOCKER_REGISTRY) --extra-files \ + $(DOCKER_FILES_DIR)/gentoo-loongarch64-cross.docker.d/build-toolchain.sh, \ + "BUILD", "gentoo-loongarch64-cross"), \ + $(call quiet-command, \ + $(DOCKER_SCRIPT) fetch $(if $V,,--quiet) \ + qemu/gentoo-loongarch64-cross $(DOCKER_REGISTRY), \ + "FETCH", "gentoo-loongarch64-cross") \ + $(call quiet-command, \ + $(DOCKER_SCRIPT) update $(if $V,,--quiet) \ + qemu/gentoo-loongarch64-cross --add-current-user, \ + "PREPARE", "gentoo-loongarch64-cross")) + + debian-toolchain-run = \ $(if $(NOCACHE), \ $(call quiet-command, \ diff --git a/tests/docker/dockerfiles/gentoo-loongarch64-cross.docker b/tests/docker/dockerfiles/gentoo-loongarch64-cross.docker new file mode 100644 index 0000000000..80d7ddace1 --- /dev/null +++ b/tests/docker/dockerfiles/gentoo-loongarch64-cross.docker @@ -0,0 +1,21 @@ +# +# Docker LoongArch64 cross-compiler target +# +# This docker target is used for building loongarch64 tests. As it also +# needs to be able to build QEMU itself in CI we include it's +# build-deps. It is also a "stand-alone" image so as not to be +# triggered by re-builds on other base images given it takes a long +# time to build. +# + +FROM docker.io/gentoo/stage3:20211215 + +ADD build-toolchain.sh /root/build-toolchain.sh +RUN cd /root && ./build-toolchain.sh + +# Specify the cross prefix for this image (see tests/docker/common.rc) +# Also gcc 12 currently produces spurious warnings under our condition so +# disable Werror as well +ENV QEMU_CONFIGURE_OPTS --cross-prefix=loongarch64-unknown-linux-gnu- --disable-werror +# We don't have target support at the moment, so just verify that things build +ENV DEF_TARGET_LIST x86_64-softmmu,x86_64-linux-user diff --git a/tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/build-toolchain.sh b/tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/build-toolchain.sh new file mode 100755 index 0000000000..3986db72ed --- /dev/null +++ b/tests/docker/dockerfiles/gentoo-loongarch64-cross.docker.d/build-toolchain.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +set -e + +TRIPLE=loongarch64-unknown-linux-gnu +CROSSDEV_OV=/opt/crossdev-overlay +LOONGSON_OV=/opt/loongson-overlay +CROSS_EMERGE="${TRIPLE}-emerge" + +# this will break on non-SMP machines, but no one should build this image +# on such machine in the first place +J=$(expr $(nproc) / 2) +echo "MAKEOPTS=\"-j${J} -l${J}\"" >> /etc/portage/make.conf +echo "EGIT_CLONE_TYPE=shallow" >> /etc/portage/make.conf + +# these features are not supported in Docker +export FEATURES="-ipc-sandbox -network-sandbox" + +# populate Portage tree +GENTOO_MIRROR='https://bouncer.gentoo.org/fetch/root/all' +PORTAGE_SNAPSHOT_FILE=gentoo-20211214.tar.xz +pushd /tmp + wget "${GENTOO_MIRROR}/snapshots/${PORTAGE_SNAPSHOT_FILE}" + + mkdir -p /var/db/repos/gentoo + pushd /var/db/repos/gentoo + tar -xf "/tmp/${PORTAGE_SNAPSHOT_FILE}" --strip-components=1 + popd + + rm "$PORTAGE_SNAPSHOT_FILE" +popd + +emerge -j crossdev dev-vcs/git + +# prepare for crossdev +mkdir /etc/portage/repos.conf +crossdev -t "$TRIPLE" --ov-output "$CROSSDEV_OV" --init-target + +git clone https://github.com/xen0n/loongson-overlay.git "$LOONGSON_OV" +pushd "$LOONGSON_OV" + git checkout 4bf659f8f6a24794cfd34cc7724bbfc965817689 +popd + +pushd "${CROSSDEV_OV}/cross-${TRIPLE}" + rm binutils gcc glibc linux-headers + ln -s "${LOONGSON_OV}/sys-devel/binutils" . + ln -s "${LOONGSON_OV}/sys-devel/gcc" . + ln -s "${LOONGSON_OV}/sys-libs/glibc" . + ln -s "${LOONGSON_OV}/sys-kernel/linux-headers" . +popd + +cat > "${CROSSDEV_OV}/metadata/layout.conf" < repos.conf/loongson.conf <