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; +}