From patchwork Thu Mar 7 14:41:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159851 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7524830jad; Thu, 7 Mar 2019 06:53:52 -0800 (PST) X-Google-Smtp-Source: APXvYqynDJBGO4FkAvLLXQP4qMFELFzeHPa6kr3C2tiobYuCeylYp6alNY0Uij76qDZXd1xB54CP X-Received: by 2002:a25:9346:: with SMTP id g6mr11153705ybo.259.1551970432459; Thu, 07 Mar 2019 06:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551970432; cv=none; d=google.com; s=arc-20160816; b=SMV9d7kAcANEq7733CIKIw4uwo2t3ToExqXPq8Hbus/N1tcp4/xORJ9+9qkb3GMPGj W65UtCncSkhyH63kFmLb7UQHems6Vd5NaG/cnz2L3y+W9RrZXc65UlLQ06C9fOVeXLUD HNZUZez5WGOXyTWg2BMYaTH9CArxeruJj9LC0H1h7YUc4Y0OGdq6WcnNIJFM+B9Eu4lB IRnjU9ze9LXTmh+TU3WEmruuRzKIq5k8LG3u4sK99NN8C8FcryPOY+4VKWTsMgs4/w13 qSS9MKcivT+fcYYKkD/tawOyFISVqYzlnEKIQgXeRUdtzsJHphdda2lajQCe5WESs/L8 T//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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=37ktCQpRGHMwh3SS8bLpCtlekBpDfpNOSJlXfFv+Uhs=; b=AUduu0yQvHIBnfMpL5B7hbW6GlxPYC1tKJ6t9AU2saCyLupOVHb3iw54ttvnImpH4K KDma89JmpIRDo/cJTqwz1UD6IqS3q/xCg5fzEvQYjnq1bAQqDI9twE+6y20Tv2JVLGYn MI6Wf/L+Mt7D8XdXWA1Yy/r3vx6mC6dwx7pTyYw2qWitoN1LyzkoWoJORje3T4bHTSAN 1loSYxquO5gveE1GppMctk8+TWl+VgiPM1mJp3/fZk8FT0AjUey4sSVcVKNy9o4JC92g NN2sfveiy+k42UuNq/QtKaeVxWdswE0cYWsiikbPj3FbG1GA+Xn/aOXaQya+vyVCVBHF 16mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SkHngYNB; 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=fail (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 x65si2846018ybb.400.2019.03.07.06.53.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Mar 2019 06:53: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=fail header.i=@linaro.org header.s=google header.b=SkHngYNB; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1uPA-0007m9-0h for patch@linaro.org; Thu, 07 Mar 2019 09:53:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1uDE-0006h6-Ec for qemu-devel@nongnu.org; Thu, 07 Mar 2019 09:41:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1uDD-0003Qy-9Z for qemu-devel@nongnu.org; Thu, 07 Mar 2019 09:41:32 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:33624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1uDD-0003QK-2c for qemu-devel@nongnu.org; Thu, 07 Mar 2019 09:41:31 -0500 Received: by mail-pf1-x433.google.com with SMTP id i19so11590751pfd.0 for ; Thu, 07 Mar 2019 06:41:31 -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; bh=37ktCQpRGHMwh3SS8bLpCtlekBpDfpNOSJlXfFv+Uhs=; b=SkHngYNBBdLWgtZPNaCj4yLMLYrxO85YQlzOj91muJ2f/USaAw4vTvux8h2h3hRi8t oTp+J2FnMoo6/PPzGi8Qku2pf5oYdo+ls5vKs2e9YS9VceDlvrQvgRw62kI/doaBFONN MODo4siJ/nqBJkaHRJe2uwuYmYcu6g6NE/bkL7zlm4AMMl5ef2ByliHeB96cvEQFWBMZ 9ErY5WjMCDY3ZWF4xZfSZudHMoRoTNzMbfqZcuLvLpaSNo1tl0ww2pSZ8n+6NrYFYRad mXXOawJ/GC7cyRYnwo6TZ6GhG0WfBmpU+Vcs91541+iB5KAKiAw0CXRq0ezjW836baVR JnVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=37ktCQpRGHMwh3SS8bLpCtlekBpDfpNOSJlXfFv+Uhs=; b=LUJ+ikGyT+ROd6INGj0FhQtB7+LsYunfOY+iWN6uri7NlCusgl/OjrTLkcEkDtF+Z+ BaUFsv340k7Xq8QbTHo4ZMIgZquHVR4rLWON2fHwd9aaEc74fgkIwkXeeVhTk6fC1EnR gIYY0yNMQ+zOYcn/VgySpiqI6t4UJi4/0bCias5rtqeMK1ySkXeVi/rwKmhu3cyKWo9D fuDeQbp2ebCXtPiCTbRaXCFnPWG08SXc3rVFgLDAgI19QmqAeg59sr5TtTfFhM2jcIe1 AtvzQy/q4jo1g22A+c4h/785RuFfsfZegXoWPbFQp/UI+6sWSO4PE8xvsiXQP8uH/Ldj mbXQ== X-Gm-Message-State: APjAAAW2k4elzgrW+qlvSMZQ3fGMYaD5o+QpziAi2H1uX4YzSF5x3CT4 KVtZvIxOc0H3wLiFq9fjAXjyb+o4Tss= X-Received: by 2002:a65:468f:: with SMTP id h15mr11843335pgr.391.1551969689642; Thu, 07 Mar 2019 06:41:29 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id p2sm6222838pgs.7.2019.03.07.06.41.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 06:41:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 06:41:18 -0800 Message-Id: <20190307144126.31847-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190307144126.31847-1-richard.henderson@linaro.org> References: <20190307144126.31847-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::433 Subject: [Qemu-devel] [PATCH 1/9] tcg: Implement tcg_gen_extract2_{i32, i64} X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand Will be helpful for s390x. Input 128 bit and output 64 bit only, which is sufficient for now. Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand Message-Id: <20190225154204.26751-1-david@redhat.com> [rth: Add matching tcg_gen_extract2_i32.] Signed-off-by: Richard Henderson --- tcg/tcg-op.h | 6 ++++++ tcg/tcg-op.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) -- 2.17.2 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index d3e51b15af..1f1824c30a 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -308,6 +308,8 @@ void tcg_gen_extract_i32(TCGv_i32 ret, TCGv_i32 arg, unsigned int ofs, unsigned int len); void tcg_gen_sextract_i32(TCGv_i32 ret, TCGv_i32 arg, unsigned int ofs, unsigned int len); +void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah, + unsigned int ofs); void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, TCGv_i32 arg2, TCGLabel *); void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1, int32_t arg2, TCGLabel *); void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret, @@ -501,6 +503,8 @@ void tcg_gen_extract_i64(TCGv_i64 ret, TCGv_i64 arg, unsigned int ofs, unsigned int len); void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg, unsigned int ofs, unsigned int len); +void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, + unsigned int ofs); void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2, TCGLabel *); void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, int64_t arg2, TCGLabel *); void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, @@ -1068,6 +1072,7 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_deposit_z_tl tcg_gen_deposit_z_i64 #define tcg_gen_extract_tl tcg_gen_extract_i64 #define tcg_gen_sextract_tl tcg_gen_sextract_i64 +#define tcg_gen_extract2_tl tcg_gen_extract2_i64 #define tcg_const_tl tcg_const_i64 #define tcg_const_local_tl tcg_const_local_i64 #define tcg_gen_movcond_tl tcg_gen_movcond_i64 @@ -1178,6 +1183,7 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); #define tcg_gen_deposit_z_tl tcg_gen_deposit_z_i32 #define tcg_gen_extract_tl tcg_gen_extract_i32 #define tcg_gen_sextract_tl tcg_gen_sextract_i32 +#define tcg_gen_extract2_tl tcg_gen_extract2_i32 #define tcg_const_tl tcg_const_i32 #define tcg_const_local_tl tcg_const_local_i32 #define tcg_gen_movcond_tl tcg_gen_movcond_i32 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 1bd7ef24af..7c56c92c8e 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -809,6 +809,28 @@ void tcg_gen_sextract_i32(TCGv_i32 ret, TCGv_i32 arg, tcg_gen_sari_i32(ret, ret, 32 - len); } +/* + * Extract 32-bits from a 64-bit input, ah:al, starting from ofs. + * Unlike tcg_gen_extract_i32 above, len is fixed at 32. + */ +void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah, + unsigned int ofs) +{ + tcg_debug_assert(ofs <= 32); + if (ofs == 0) { + tcg_gen_mov_i32(ret, al); + } else if (ofs == 32) { + tcg_gen_mov_i32(ret, ah); + } else if (al == ah) { + tcg_gen_rotri_i32(ret, al, ofs); + } else { + TCGv_i32 t0 = tcg_temp_new_i32(); + tcg_gen_shri_i32(t0, al, ofs); + tcg_gen_deposit_i32(ret, t0, ah, 32 - ofs, ofs); + tcg_temp_free_i32(t0); + } +} + void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret, TCGv_i32 c1, TCGv_i32 c2, TCGv_i32 v1, TCGv_i32 v2) { @@ -2297,6 +2319,28 @@ void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg, tcg_gen_sari_i64(ret, ret, 64 - len); } +/* + * Extract 64 bits from a 128-bit input, ah:al, starting from ofs. + * Unlike tcg_gen_extract_i64 above, len is fixed at 64. + */ +void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, + unsigned int ofs) +{ + tcg_debug_assert(ofs <= 64); + if (ofs == 0) { + tcg_gen_mov_i64(ret, al); + } else if (ofs == 64) { + tcg_gen_mov_i64(ret, ah); + } else if (al == ah) { + tcg_gen_rotri_i64(ret, al, ofs); + } else { + TCGv_i64 t0 = tcg_temp_new_i64(); + tcg_gen_shri_i64(t0, al, ofs); + tcg_gen_deposit_i64(ret, t0, ah, 64 - ofs, ofs); + tcg_temp_free_i64(t0); + } +} + void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, TCGv_i64 c1, TCGv_i64 c2, TCGv_i64 v1, TCGv_i64 v2) {