From patchwork Sat Jul 1 06:55:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 698309 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp813169wrs; Fri, 30 Jun 2023 23:56:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5jMzR2B0iVtKraB3QHN8/GLZdeOX6ZEMyoAMAA6X2uzmXeDi8BEfw205D8UN1yD5H1k1NK X-Received: by 2002:a05:620a:458d:b0:75d:4757:f492 with SMTP id bp13-20020a05620a458d00b0075d4757f492mr6324553qkb.1.1688194584517; Fri, 30 Jun 2023 23:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688194584; cv=none; d=google.com; s=arc-20160816; b=bjgPvScPKynFu9CnHsJgSzpBC+qP6eyp4oOwam8Z3IFGpLybvJ/Q0991ltNCjyk41o LYbi90uJYflk/c/IebeC87ZxmxZzZNoZ1vryaC0oS2ZFixhsEk2rWITbANcmTnuGYfGb T5NTkN2DAn5M0mR5aYoW/N4rs44Vn5Fr0mNCQpfLCrCUkQPMeAxmcLATSr8r9+hp3Z2f TEWSkDe7eSjoGtqTua8uy+djvQYA34ASBHQ31J7akCYueMGY9rAL8cDcl0WMDLnapX4z THPJsCx5kK4z2jvGIgvJkbXRZqC2ezDs3X4SrcXE/SEfsQko/lruLaUek01ctVoqWktf 0cew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mV8nHx5xU3W2QWS3dGtP3xyCoVtszahnj86o5dz8D9I=; fh=eu2DY09p+eeddYDiV+DalJS3Vr0kxK5BujclYkgWvDw=; b=XovaO8p030IiaQvKndf6zbiQ351D9UHt/gVqbjLZkPZCqj0srZ6Izo0+QeUNoDyeTN lfGrV0GhIOCMsOCtLWdfpUQAAeo5yk5H45wRrOUZaYUTNgdUp6KEKop87r/ey14rAvU8 9MwcqXeK/gUcCmdGOGsWZjhkHv76FNt0XuEl41yQt+ERtcBmm9aa3awNoP21rTMpBZLZ rq1MJH2YRsnow6dhpCRQVcpZ2rP+DeX9fIxhSgYsD9KQ5u1xb95nXVlDgOpkOm4yL6kj eMOBDwA8xFZxyi1sfoCe15eu/M5Z9/dTmyFwpWjXo69H8eaeEGTIocjVm9XQemSlPSE8 upkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AnxN3oqO; 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 w28-20020a05620a095c00b00765acf7ff28si7647296qkw.123.2023.06.30.23.56.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Jun 2023 23:56:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AnxN3oqO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUVt-0007Vj-Ul; Sat, 01 Jul 2023 02:55:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUVs-0007Uo-58 for qemu-devel@nongnu.org; Sat, 01 Jul 2023 02:55:20 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUVq-0007FH-DX for qemu-devel@nongnu.org; Sat, 01 Jul 2023 02:55:19 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc244d307so24076095e9.1 for ; Fri, 30 Jun 2023 23:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688194516; x=1690786516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mV8nHx5xU3W2QWS3dGtP3xyCoVtszahnj86o5dz8D9I=; b=AnxN3oqOfwThmH6eoaLqir2YFZqG0vpIuPWEjoN744ITryrMAkGICfSeyFqxAXRTOi ADDm6OG776ZXcjKlERD9WNEyFdz+Se5h/HgByD4oUuzWqWnIe3wkvx0DdkLMFf5RZRkB lltM/e4qCW3v4JO9/lqWz5CBX4ARqLpj1vGPMDywBobypvGtDV8YjUpfD01Fkx4C+1zO KexsWHpqMuYzllZYtSykzrtmPl67xEjj67QRq6ChV+DYS0e6tUID99y6xM1XPs8vt+3Z 96+P7m1a0I/UdJA94eLIH5o8j8v5hDWXO7nTkCYfi2PT034u+havJYmCJsqXORKZ6DbG Ik0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688194516; x=1690786516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mV8nHx5xU3W2QWS3dGtP3xyCoVtszahnj86o5dz8D9I=; b=BIeuyrQhsdtyRvwvOPYJIFaiCki9Ur5RHDjp1sPumznphYQ6QoaM8Du7YJSDr39S7Z vVV4LfIMN9n2gLIykUQM7TFrxCwK46UZyynaKsGl5HKj3ax6X32GpMl4R4T6IWOyLWcM 0USQHRfXwe4y750gAi+a+Q/ixoaHQJsm0i+J76cI2Mgj43IN6KBGbgdX2Q1dRb/r74Dd 7zCEnmAbiUnUtRv4jgjlb6PlRO/WnmLSh9MYi5/uZaVCa2Sg+qX3UlsDT/HRphsxuDof WOPpQCAz7MtaSfHpyg8pI2hEE66TJRY54ngV7K8MlaUCzI+SO+52RcYnc2VkjyDZylkZ bJuA== X-Gm-Message-State: AC+VfDwViUYqUpZXBu3V2pFUJPRNsMnywLMLfNHLj8l87EhIOncu6//q 76k4wDNy+c6NeRWu1mkYNhTf7FIDiDz8pC/zIbc0Vg== X-Received: by 2002:a05:600c:b54:b0:3f9:846:d892 with SMTP id k20-20020a05600c0b5400b003f90846d892mr3691581wmr.9.1688194516764; Fri, 30 Jun 2023 23:55:16 -0700 (PDT) Received: from localhost.localdomain ([139.47.41.96]) by smtp.gmail.com with ESMTPSA id w10-20020a1cf60a000000b003f9bd9e3226sm20874918wmc.7.2023.06.30.23.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 23:55:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 06/11] tests/tcg/alpha: Add test for cvttq Date: Sat, 1 Jul 2023 08:55:05 +0200 Message-Id: <20230701065510.514743-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230701065510.514743-1-richard.henderson@linaro.org> References: <20230701065510.514743-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Test for invalid, integer overflow, and inexact. Test for proper result, modulo 2**64. Signed-off-by: Richard Henderson Acked-by: Alex Bennée Message-Id: <20230527141910.1885950-3-richard.henderson@linaro.org> --- tests/tcg/alpha/test-cvttq.c | 78 +++++++++++++++++++++++++++++++++ tests/tcg/alpha/Makefile.target | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/alpha/test-cvttq.c diff --git a/tests/tcg/alpha/test-cvttq.c b/tests/tcg/alpha/test-cvttq.c new file mode 100644 index 0000000000..d1ad995312 --- /dev/null +++ b/tests/tcg/alpha/test-cvttq.c @@ -0,0 +1,78 @@ +#include + +#define FPCR_SUM (1UL << 63) +#define FPCR_INED (1UL << 62) +#define FPCR_UNFD (1UL << 61) +#define FPCR_UNDZ (1UL << 60) +#define FPCR_DYN_SHIFT 58 +#define FPCR_DYN_CHOPPED (0UL << FPCR_DYN_SHIFT) +#define FPCR_DYN_MINUS (1UL << FPCR_DYN_SHIFT) +#define FPCR_DYN_NORMAL (2UL << FPCR_DYN_SHIFT) +#define FPCR_DYN_PLUS (3UL << FPCR_DYN_SHIFT) +#define FPCR_DYN_MASK (3UL << FPCR_DYN_SHIFT) +#define FPCR_IOV (1UL << 57) +#define FPCR_INE (1UL << 56) +#define FPCR_UNF (1UL << 55) +#define FPCR_OVF (1UL << 54) +#define FPCR_DZE (1UL << 53) +#define FPCR_INV (1UL << 52) +#define FPCR_OVFD (1UL << 51) +#define FPCR_DZED (1UL << 50) +#define FPCR_INVD (1UL << 49) +#define FPCR_DNZ (1UL << 48) +#define FPCR_DNOD (1UL << 47) +#define FPCR_STATUS_MASK (FPCR_IOV | FPCR_INE | FPCR_UNF \ + | FPCR_OVF | FPCR_DZE | FPCR_INV) + +static long test_cvttq(long *ret_e, double d) +{ + unsigned long reset = (FPCR_INED | FPCR_UNFD | FPCR_OVFD | FPCR_DZED | + FPCR_INVD | FPCR_DYN_NORMAL); + long r, e; + + asm("excb\n\t" + "mt_fpcr %3\n\t" + "excb\n\t" + "cvttq/svic %2, %0\n\t" + "excb\n\t" + "mf_fpcr %1\n\t" + "excb\n\t" + : "=f"(r), "=f"(e) + : "f"(d), "f"(reset)); + + *ret_e = e & FPCR_STATUS_MASK; + return r; +} + +int main (void) +{ + static const struct { + double d; + long r; + long e; + } T[] = { + { 1.0, 1, 0 }, + { -1.0, -1, 0 }, + { 1.5, 1, FPCR_INE }, + { 0x1.0p32, 0x0000000100000000ul, 0 }, + { -0x1.0p63, 0x8000000000000000ul, 0 }, + { 0x1.0p63, 0x8000000000000000ul, FPCR_IOV | FPCR_INE }, + { 0x1.0p64, 0x0000000000000000ul, FPCR_IOV | FPCR_INE }, + { 0x1.cccp64, 0xccc0000000000000ul, FPCR_IOV | FPCR_INE }, + { __builtin_inf(), 0, FPCR_INV }, + { __builtin_nan(""), 0, FPCR_INV }, + }; + + int i, err = 0; + + for (i = 0; i < sizeof(T)/sizeof(T[0]); i++) { + long e, r = test_cvttq(&e, T[i].d); + + if (r != T[i].r || e != T[i].e) { + printf("Fail %a: expect (%016lx : %04lx) got (%016lx : %04lx)\n", + T[i].d, T[i].r, T[i].e >> 48, r, e >> 48); + err = 1; + } + } + return err; +} diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.target index a585080328..b94500a7d9 100644 --- a/tests/tcg/alpha/Makefile.target +++ b/tests/tcg/alpha/Makefile.target @@ -5,7 +5,7 @@ ALPHA_SRC=$(SRC_PATH)/tests/tcg/alpha VPATH+=$(ALPHA_SRC) -ALPHA_TESTS=hello-alpha test-cond test-cmov test-ovf +ALPHA_TESTS=hello-alpha test-cond test-cmov test-ovf test-cvttq TESTS+=$(ALPHA_TESTS) test-cmov: EXTRA_CFLAGS=-DTEST_CMOV