From patchwork Mon Sep 9 17:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 826622 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp2129988wrb; Mon, 9 Sep 2024 10:29:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWp/s6BjonVoIcPj9prRt5IinqFhn/1nHpS8MfmDpb7AI9wySWU5aMtvZqxGxydBE0GBcz0Hw==@linaro.org X-Google-Smtp-Source: AGHT+IFERd4zClEjho4yKUPg3liSYAAk7V8iArYzTulEepPsnK3/tj6rGQ+k1FcEOVg9+ugSDPmj X-Received: by 2002:a05:6214:590d:b0:6c5:54ea:62d7 with SMTP id 6a1803df08f44-6c554ea6378mr3142766d6.36.1725902979341; Mon, 09 Sep 2024 10:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725902979; cv=none; d=google.com; s=arc-20240605; b=iA+JdFvJm0ZrNnRyjCs2fOolfm0/NHaR1lEq7aZQO+0nat9UwLVTDU37v+kKPFHIj6 rvEsorfjLKvIbAse1NbTTTlIH4r4gTZeOgfCZkOFl7Oywasd5IEO57/BNM0AzlkFAEHl UpGYbrggQ6+tWQaZFGf5uBS3Eyl2u1FMffBzMW86fWKtxpOVEbBMsSY5QQDsICqTMAGu CBfk3DlDUskQaTcJWwd/inqJi5kAlmsSdrTfQXXtVICH6Gk6zlLvueH7AZhEAHSomgOH LxEfD62Ti0s5BeyKevAEQ8hQEDsAmNKCIoltldcO3NqsGVppFmnlq+RTwINNGC/gZR9/ VVgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=JJE3DAs7T3oH0GbJsFZTv8MmDA7pEO0/Bzfp6DqKShg=; fh=vcwsOoqbz6OOwV49wjn5grcThaa1ddCD12N2st4CmAI=; b=Tj3Pl3K57uZZ5LZeOYy6hZhofKmfdRNjBuYfSsedxRw21w/Xd/D/7jdVF3ZZM6kBrZ 3JFjOc5Nxf0kBG+gGdHIePJ6TQ9uRfp6R3gypl8eCtVsxthvybQ05/StQEBkfghwzpur 1JAgMbDI+zh5fGsDyfOR+FhN4+8XS/Y2j9XUUBccbwxrp8W0+7qynlxCZCYZotuwkagV AAEol7CaWsJtVG8YZP03HFaCnfdZv/mutsanRQmHmuIIzTd+M5r0Pzu+005hphewer+S m7dioz0+DkiRWGAbqptX2kWIHhkGfL+xftn4XS5hbAjlyhJ3hJ842DPCvMXR28VorGl8 ZM0w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BYDooAgt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c5343300ccsi61139476d6.12.2024.09.09.10.29.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Sep 2024 10:29:39 -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=BYDooAgt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sniC9-0005q4-A9; Mon, 09 Sep 2024 13:28:57 -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 1sniC4-0005K2-29 for qemu-devel@nongnu.org; Mon, 09 Sep 2024 13:28:52 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sniC2-00064k-Br for qemu-devel@nongnu.org; Mon, 09 Sep 2024 13:28:51 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2055136b612so55186765ad.0 for ; Mon, 09 Sep 2024 10:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725902928; x=1726507728; darn=nongnu.org; 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=JJE3DAs7T3oH0GbJsFZTv8MmDA7pEO0/Bzfp6DqKShg=; b=BYDooAgt3WoJOXtetuCfHdnbbpYQep5CtShOaoZPfk8lIs3Lfql9miWvZDF80akOuI E7oT38XB44KtHUpiTeGmlFlNghdGQ8prILUHk8FArQLUksA4H8oKY0s7HgwyOnXNtMG4 +HDJxdOomHiQ6T7VHgVfDugTp0c13Qh+LEZcSq/OVK3+jWI2W5Q2FSCJHhyJVcT2dlQW uWsyajk0mFMLdSktMd7/32KqFVxFi4CN4dFdjWjaDN2byKsQL2Ii7oGjJF51QTz6l118 Xk3pYzHIvSGfNr4Iw3GqYH+yLs52SvOzSKMmhzWUR2iaQEvHl+xxx7Fe1fx+K0b25q93 kA0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725902928; x=1726507728; 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=JJE3DAs7T3oH0GbJsFZTv8MmDA7pEO0/Bzfp6DqKShg=; b=gSHg7uVEZJ6T++1IUXOd0Nf+elj0l94jSsjIrxggSB8L7MlVZuK5zTiCGBO06nMigh grHRh3Vekeh3w4lQNWXTpU+SuT6WQ0oZZ3pOfGSYxSMHiWOztjwWcUXCc4nYTJj+AEoW xY7Z41GPR1AqtlmQD3jYhgo9ao7+Mx029859xqzCoEY+TjGyRYRjNR6nh0Kl6NWashHe TwKNrmwlpm+xNZG2yU1PuH7Tl2vOhvJ9u7XqcRaTfrg0BqnKgYf1qQ6Y4IlFpS4mF0uc pbhs6VHkxQZq8qmQIsF/12Xusl5Krx+zQ2HsskNasvlisPQlm8nxJbXTal9ERgYR/Bgb lpqg== X-Gm-Message-State: AOJu0YyUINHFUByspxf0S31yhDRbv/CiutpuesyO5LKOWm8VMdtom45y l6/KkpU1QGfYavyuZS2JVedXlJBwQQADz54SwUymVZxD7gsjAMPBPM4iqNZep5mVQHyHrieUcOW T X-Received: by 2002:a17:902:c941:b0:205:7835:38dc with SMTP id d9443c01a7336-206f0654f62mr137132475ad.60.1725902927920; Mon, 09 Sep 2024 10:28:47 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710e11e02sm36539875ad.14.2024.09.09.10.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 10:28:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, daniel@0x0f.com, =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v3 24/26] tests/tcg/m68k: Add packed decimal tests Date: Mon, 9 Sep 2024 10:28:21 -0700 Message-ID: <20240909172823.649837-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909172823.649837-1-richard.henderson@linaro.org> References: <20240909172823.649837-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tests/tcg/m68k/packeddecimal-1.c | 41 ++++++++++++++++++++++++++++ tests/tcg/m68k/packeddecimal-2.c | 46 ++++++++++++++++++++++++++++++++ tests/tcg/m68k/Makefile.target | 4 ++- 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/m68k/packeddecimal-1.c create mode 100644 tests/tcg/m68k/packeddecimal-2.c diff --git a/tests/tcg/m68k/packeddecimal-1.c b/tests/tcg/m68k/packeddecimal-1.c new file mode 100644 index 0000000000..5433acd17b --- /dev/null +++ b/tests/tcg/m68k/packeddecimal-1.c @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Test packed decimal real conversion to long double. */ + +#include + +struct T { + unsigned int d[3]; + long double f; +}; + +static const struct T tests[] = { + { { 0x00000001, 0x00000000, 0x00000000 }, 1.0e0l }, + { { 0x01000001, 0x00000000, 0x00000000 }, 1.0e1l }, + { { 0x00100001, 0x00000000, 0x00000000 }, 1.0e10l }, + { { 0x00000000, 0x10000000, 0x00000000 }, 0.1e0l }, + { { 0x41000001, 0x00000000, 0x00000000 }, 1.0e-1l }, + { { 0x85000005, 0x55550000, 0x00000000 }, -5.5555e5l }, + { { 0x09990009, 0x99999999, 0x99999999 }, 9.9999999999999999e999l }, + { { 0x03210001, 0x23456789, 0x12345678 }, 1.2345678912345678e123l }, + { { 0x00000000, 0x00000000, 0x00000000 }, 0.0l }, + { { 0x80000000, 0x00000000, 0x00000000 }, -0.0l }, + { { 0x09990000, 0x00000000, 0x00000000 }, 0.0e999l }, +}; + +int main() +{ + int ret = 0; + + for (int i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + const struct T *t = &tests[i]; + long double f; + + asm("fmove.p (%1),%0" : "=f"(f) : "a"(t->d)); + + if (f != t->f) { + fprintf(stderr, "Mismatch at %d: %.17Le != %.17Le\n", i, f, t->f); + ret = 1; + } + } + return ret; +} diff --git a/tests/tcg/m68k/packeddecimal-2.c b/tests/tcg/m68k/packeddecimal-2.c new file mode 100644 index 0000000000..448e97ce89 --- /dev/null +++ b/tests/tcg/m68k/packeddecimal-2.c @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Test packed decimal real conversion from long double, dynamic k-factor */ + +#include +#include + +struct T { + unsigned int d[3]; + long double lf; + int kfactor; +}; + +static const struct T tests[] = { + { { 0x00000001, 0x00000000, 0x00000000 }, 1.0e0l, 0 }, + { { 0x00100001, 0x00000000, 0x00000000 }, 1.0e10l, 0 }, + { { 0x41000001, 0x00000000, 0x00000000 }, 1.0e-1l, 0 }, + { { 0x85000005, 0x55550000, 0x00000000 }, -5.5555e5l, 5 }, + { { 0x45000005, 0x55550000, 0x00000000 }, 5.5555e-5l, 5 }, + { { 0x05000002, 0x22220000, 0x00000000 }, 2.2222e5, 99 }, + { { 0x05000002, 0x22220000, 0x00000000 }, 2.2222e5, 5 }, + { { 0x05000002, 0x20000000, 0x00000000 }, 2.2222e5, 2 }, + { { 0x02394001, 0x18973149, 0x53572318 }, LDBL_MAX, 17 }, + { { 0x42394001, 0x68105157, 0x15560468 }, LDBL_MIN, 17 }, + { { 0x41594001, 0x82259976, 0x59412373 }, LDBL_TRUE_MIN, 17 }, +}; + +int main() +{ + int ret = 0; + + for (int i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { + const struct T *t = &tests[i]; + unsigned int out[3]; + + asm("fmove.p %1,(%0),%2" + : : "a"(out), "f"(t->lf), "d"(t->kfactor) : "memory"); + + if (out[0] != t->d[0] || out[1] != t->d[1] || out[2] != t->d[2]) { + fprintf(stderr, "Mismatch at %d: %08x%08x%08x != %08x%08x%08x\n", + i, out[0], out[1], out[2], + t->d[0], t->d[1], t->d[2]); + ret = 1; + } + } + return ret; +} diff --git a/tests/tcg/m68k/Makefile.target b/tests/tcg/m68k/Makefile.target index 33f7b1b127..b505260b79 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -4,4 +4,6 @@ # VPATH += $(SRC_PATH)/tests/tcg/m68k -TESTS += trap denormal +TESTS += trap denormal packeddecimal-1 packeddecimal-2 + +run-packeddecimal-%: QEMU_OPTS += -cpu m68020