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(); }