From patchwork Sun Aug 11 06:03:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 818420 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp906406wrv; Sat, 10 Aug 2024 23:04:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5Sdviqg8DWzZNqfqXD376OF56O8SAgVOEI6rP9gBT9M61oFk2rE4zwPrs9e2DtnPNsBlCt3PQtemRhsLXAyg2 X-Google-Smtp-Source: AGHT+IH9FrSNdRGRdCVMc132RtwuF9IbL2oSUtz/Pd8rmBgzQgDvAUU1rHhoHhvKg4XSlJhPEdmo X-Received: by 2002:a05:6358:5f03:b0:1af:4626:7e42 with SMTP id e5c5f4694b2df-1b17719595cmr794124455d.25.1723356287742; Sat, 10 Aug 2024 23:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723356287; cv=none; d=google.com; s=arc-20160816; b=Q8ZeHjuZKuQFX6UO5qOPsRq+kB5CxTN7cwlOKsg6Ukzhd39QvJTgRKv8Efnmhn4LyC 6k6Im5YiOMCsFYTPS8b6pUPXp0Xl85dIj58HLzdvwwokYWLm0kVP1ER2tMJKhd58bxa+ lzVhZD8Jp0OpbQ/to6+lFuTrm83fimJefp8HTXLg+ufcQa0AUzll+JcIXE1F9cttywMl j9zR+pII2AoUE92vNonzWAckBsigz4OTPEg+FFd7Cni5r4BJaODAlq2rAGR4pTmVHZJj /p6ikPkszkZzy1/f8k2wqS3UfVxxoAKN3wgLqsVd0206eaQ5ZlXloivJ3MsDC9Z6ojWx +f9A== 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=aG6Wn5JGKqOVYo7oiDwgDKG/Csj9cM6r0yseNWt8qsc=; fh=2uesxoqJjyRqtkk3yTfcnBSFtAUtxw8KzQZeBUAogpM=; b=N+b6VdvDWSgq30S/vrMuZJusezTGO9vRFPgiYuBwbbL0kWWfFKN2GuOuPjs4fL4xiD zZTZyN1rzHCw2qV7nRvPOBAd5xFMU2ARnhfTHlK4Flak1lLLxYVJVo57of9dNCyioU2x TP6Z9ThiEAv1G8f+SU33PTn94p4S02xTTE+vIKmE8FkWQyTWTyWCyp8fve15RguUO8eh by89JGmcy8/NdWlyJZfmbsS/g85HOF07wVea1suKGUGp2pIyAzfEuQimJcDFlmuxm4wy Wp/xzC42KUFR5r0JU5je59V9whWXivHHXq3IYy/giCZslr2MlDW4mg2r7euoHeTRDbok yZWA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QLd88T+z; 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-6bd82e58c75si33517056d6.351.2024.08.10.23.04.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Aug 2024 23:04:47 -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=QLd88T+z; 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 1sd1fw-0001p8-9I; Sun, 11 Aug 2024 02:03:32 -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 1sd1fv-0001oC-35 for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:31 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sd1ft-0003Js-Hr for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:30 -0400 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3db1657c0fdso2382545b6e.1 for ; Sat, 10 Aug 2024 23:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723356208; x=1723961008; 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=aG6Wn5JGKqOVYo7oiDwgDKG/Csj9cM6r0yseNWt8qsc=; b=QLd88T+zwnKINYetrJd1utXJT1JhDHbL+cASaooMERPTE6Kd1cB9+KrsC8cnac4rkj gySqF6xNIgYx0nllP6yr4qUL/hqm/rG3cimTMJsdtKoVJJsuUkbwMF9hFXhSKwrd871D HIkKb5VQ1Z8t442SnX9bsb2BjvKWxQW8tQG5gl7qx8pCrzluR5UNTUIZDUpGqKVIU9qF pRDgrHC2ST6gngdjVK+tDLUC1z+Q8j+WbVg6dUVqCf9+YHU+PnI31Iq6sev9EgK1gxMi r2mihPR3XW+1y8a6be4OHLlrifbSsUVVcZFjcXuXml061e/4VSnDEIC034tZQ4EL8tYI I6Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723356208; x=1723961008; 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=aG6Wn5JGKqOVYo7oiDwgDKG/Csj9cM6r0yseNWt8qsc=; b=R+SbP7dryCRxzP7/uMHHWwjn1SKnNL4HqLIqb4n9zbCPd5UVR27rFZaGMEQFSd8I+d 9K8oFFRgRwoSZ+pTkfSlKKt2BO/nZ8ecPkQI1dsKjRI9im2h3LUFstEq533pIroxDJGd ksXMlMVcMX9NJqvMX9AgQ33TmK++2ibbXCNWJXblYnen8Nv8jN05ykjqG+vWw4bZbkJG 4JiVz+FSK0D3xOiq3OyEdIn4ZluFj0zOtr/WVnhW2EiGdxd5zwLp1MyrEXyZo2KGE2XS zZgRW33mPznX15roh7sFIR6wWtbsXk+rP5G6KR9YWyVmuegzOh/9flsqJnyiyek0K46O PsjQ== X-Gm-Message-State: AOJu0Yy/6ha6G032GM33VkCBSwWicolCH8SFeuRTG3bI8v86BjxYbLcr OLeEtLREgNLpVJlkcl7qEwNPgS21+HPAm3dTaYTeQEotKrlSlTkPljyYFOvfa4Xh/pctKaiBhqb 5dKFxEQ== X-Received: by 2002:a05:6808:1993:b0:3da:b341:bbbb with SMTP id 5614622812f47-3dc41691784mr7637931b6e.26.1723356207651; Sat, 10 Aug 2024 23:03:27 -0700 (PDT) Received: from stoup.. ([172.58.106.160]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3dd060b5388sm835591b6e.43.2024.08.10.23.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Aug 2024 23:03:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 1/4] target/m68k: Introduce M68K_FEATURE_FPU_PACKED_DECIMAL Date: Sun, 11 Aug 2024 16:03:10 +1000 Message-ID: <20240811060313.730410-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240811060313.730410-1-richard.henderson@linaro.org> References: <20240811060313.730410-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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 Set for 68020 and 68030, but does nothing so far. Signed-off-by: Richard Henderson --- target/m68k/cpu.h | 2 ++ target/m68k/cpu.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index b5bbeedb7a..7114324e4d 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -553,6 +553,8 @@ enum m68k_features { M68K_FEATURE_MOVEFROMSR_PRIV, /* Exception frame with format+vector (from 68010) */ M68K_FEATURE_EXCEPTION_FORMAT_VEC, + /* FPU supports packed decimal real format */ + M68K_FEATURE_FPU_PACKED_DECIMAL, }; static inline bool m68k_feature(CPUM68KState *env, int feature) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 1d49f4cb23..65058dd052 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -182,6 +182,7 @@ static void m68020_cpu_initfn(Object *obj) m68k_set_feature(env, M68K_FEATURE_MSP); m68k_set_feature(env, M68K_FEATURE_UNALIGNED_DATA); m68k_set_feature(env, M68K_FEATURE_TRAPCC); + m68k_set_feature(env, M68K_FEATURE_FPU_PACKED_DECIMAL); } /* @@ -224,6 +225,7 @@ static void m68040_cpu_initfn(Object *obj) m68030_cpu_initfn(obj); m68k_unset_feature(env, M68K_FEATURE_M68030); + m68k_unset_feature(env, M68K_FEATURE_FPU_PACKED_DECIMAL); m68k_set_feature(env, M68K_FEATURE_M68040); } From patchwork Sun Aug 11 06:03:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 818421 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp906410wrv; Sat, 10 Aug 2024 23:04:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV+aObdL8EUnhSsWttx5Ws656xXQaidQgMme21zAYlIq81V10Xv4S20hnoN5zuPPnqBhbnuXVqRUAcXMYw5qGpc X-Google-Smtp-Source: AGHT+IElCmKm762bwtQGZEyccSJygBsmW8pcZFZ1kn3ZHq7CXcDpOOQ0jovfcZQyovfu9qF1tztF X-Received: by 2002:ac8:584e:0:b0:447:e003:ed8f with SMTP id d75a77b69052e-451d5926984mr187676591cf.19.1723356289120; Sat, 10 Aug 2024 23:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723356289; cv=none; d=google.com; s=arc-20160816; b=ildHJjQQfIXX5Hctd0hV2zzjXyPOpe2LqfSlh+LuqcmC/t1lFUnEkjV0s7bPZQkKob fycVkKTWr1qP4ajd/UbDEMiPx6hVaQzzLNC29cFBmHmC+WqQWPrDB535V2YPsbCCMQxe H6drLxH94CPEj2bksioRzc/vHjrs7qEUYVnav12PyUfJHuYbAl6vddPUQFhIvQ73IDC6 J6So/dxsioPQr/z3u5lxxsP0nIcCghC+10jnuDIw9jZWXLehzMHDIj+eys1VMn9WBTnV BvoZZA3PHZUvL+AITpX6KO/2Y9/CteIFzSm2vS1jRBybkdzmOrb8UUQbKRFWw2zd2J+S pZsw== 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=1DmwpPh0HuvQouOcnmqzDiaoQNQqQeUssp+FOFv7Ick=; fh=2uesxoqJjyRqtkk3yTfcnBSFtAUtxw8KzQZeBUAogpM=; b=SgsoaULH46+1jXtD4hSCUWGyl5LTOIs8WYO8g8QLg31H9ZJK1Rbuifoh9o1aN6dnVV qTt6Bg8/Tu/1w4hA0MqSK3r6P+HSXHaQfBHtVCckh/hW++M7cSV22lyE8fJHGxAzcADY MFpM90ID3xLdUuwJgl2d6R9cDEe+z/GJ0+9EEQZu+dA6U9moN7wwVurTHH3aJWb+iQP6 1dNVb9YkBPnLGyDmJB1FIv0QAw+kFVmc2c+rbUvui94S2Jj2Wo/w0ahU0G3Kc1Zs8eYQ EsYyV3tswXfyaSnSUo0h8/cPtsS1TnGpexLAs4zuTSgeOVIzv1eQVFskfftWnEZYKJ16 3fIQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNS0RPzB; 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 d75a77b69052e-4531c289094si32168851cf.453.2024.08.10.23.04.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Aug 2024 23:04:49 -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=cNS0RPzB; 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 1sd1g2-00020g-ND; Sun, 11 Aug 2024 02:03:38 -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 1sd1fz-000202-RV for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:36 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sd1fy-0003LQ-0B for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:35 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3db51b8ec15so2216459b6e.1 for ; Sat, 10 Aug 2024 23:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723356212; x=1723961012; 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=1DmwpPh0HuvQouOcnmqzDiaoQNQqQeUssp+FOFv7Ick=; b=cNS0RPzBWcQGUMQ9Qa0+C8HnY4ljW4vqwQd8xjUvTWp53upJlBHUR492xqZ2SHjvYM 6UdI7GuMb/GCPgIxKFK+MzPZbWes4/PhtI9JkdMZ9C0FJDBHt7fh0Q8Q5hvs+Rvv5zv1 kxyyS3XSrEPmXupxUV5VsXVXKcQe7ppB9b72Me1wUm/eFRx49OQoFrBBa/JMNIVa4jAw cQxpSs6GaeRj62eQ/fV+JXAQGP6RNTnE+8yBjGHyuATVp1gm8mU22KLCxKrYgGu35Qc1 zgHzOnL+xU65el6lUU8O/Zj3ESZfrgucZSwuWsJGXfyOTd+z2cuyn1++54v01LljFETO cYGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723356212; x=1723961012; 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=1DmwpPh0HuvQouOcnmqzDiaoQNQqQeUssp+FOFv7Ick=; b=AwrKJs1uTBEckQlLz3yFQcMljKJAjpwj3AwTcalwIgUA1rVk0XjIOEiMfCmd+0Jky6 K+EspR5JeDMhMuCAzJj7DvSXWZ1VhOeCaZogPeJASUtFs/eElS70vLYH+l8e3RDPYhnX 9D+DjA8tdZSeDuXGDIT9eL9iHKduO87MN9Lhsy6BuMOxDt3hWl2dyLg87tVCpGSc9flF /eKncnEmrsZpkMfIdRTmk24OYAvPKsS8lVMWAQQuF5QZkcTFR6MBJjuQtSvPDkPtdEkp zoCoyCOXay4Rc+b8r7B1fpm9B6lZceJqGN+K3N2RL0MvjWGxG9AEhgqegmeQSx4mLEG1 3yXw== X-Gm-Message-State: AOJu0YwYQK1Vn+0SMCC4Fy9l72DQB7KGUV9vqywtIvaGYwUNypS3WZah 6ZE8M5h0cjX0wIedxfb2v7nMtI+5tUHhB6NaqyOycbEQovgr1n8Osj9F2CTDUVrA1EQsUeSuTaL DUHvDYw== X-Received: by 2002:a05:6808:14c4:b0:3d9:2baa:9fd3 with SMTP id 5614622812f47-3dc417a7de8mr2439840b6e.20.1723356212448; Sat, 10 Aug 2024 23:03:32 -0700 (PDT) Received: from stoup.. ([172.58.106.160]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3dd060b5388sm835591b6e.43.2024.08.10.23.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Aug 2024 23:03:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 2/4] target/m68k: Implement packed decimal real loads Date: Sun, 11 Aug 2024 16:03:11 +1000 Message-ID: <20240811060313.730410-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240811060313.730410-1-richard.henderson@linaro.org> References: <20240811060313.730410-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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 Signed-off-by: Richard Henderson --- target/m68k/helper.h | 2 + target/m68k/fpu_helper.c | 137 +++++++++++++++++++++++++++++++++++++++ target/m68k/translate.c | 22 ++++--- 3 files changed, 151 insertions(+), 10 deletions(-) diff --git a/target/m68k/helper.h b/target/m68k/helper.h index 95aa5e53bb..2c71361451 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -126,6 +126,8 @@ DEF_HELPER_FLAGS_4(bfffo_mem, TCG_CALL_NO_WG, i64, env, i32, s32, i32) DEF_HELPER_3(chk, void, env, s32, s32) DEF_HELPER_4(chk2, void, env, s32, s32, s32) +DEF_HELPER_FLAGS_3(load_pdr_to_fx80, TCG_CALL_NO_RWG, void, env, fp, tl) + #if !defined(CONFIG_USER_ONLY) DEF_HELPER_3(ptest, void, env, i32, i32) DEF_HELPER_3(pflush, void, env, i32, i32) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 8314791f50..dd80943153 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -749,3 +749,140 @@ void HELPER(fcosh)(CPUM68KState *env, FPReg *res, FPReg *val) { res->d = floatx80_cosh(val->d, &env->fp_status); } + +/* From m68k float.h, LDBL_MAX_10_EXP. */ +#define FX80_MAX_10_EXP 4932 + +/* 10**0 through 10**18 */ +static const int64_t i64_pow10[] = { + 1ll, + 10ll, + 100ll, + 1000ll, + 10000ll, + 100000ll, + 1000000ll, + 10000000ll, + 100000000ll, + 1000000000ll, + 10000000000ll, + 100000000000ll, + 1000000000000ll, + 10000000000000ll, + 100000000000000ll, + 1000000000000000ll, + 10000000000000000ll, + 100000000000000000ll, + 1000000000000000000ll, +}; + +/* Form 10**exp */ +static floatx80 floatx80_exp10i(int exp, float_status *status) +{ + static floatx80 cache[FX80_MAX_10_EXP + 1]; + + floatx80 ret; + + assert(exp >= 0 && exp <= FX80_MAX_10_EXP); + + ret = cache[exp]; + if (ret.high) { + if (exp >= ARRAY_SIZE(i64_pow10)) { + float_raise(float_flag_inexact, status); + } + } else { + FloatRoundMode old_round = get_float_rounding_mode(status); + set_float_rounding_mode(float_round_nearest_even, status); + + if (exp < ARRAY_SIZE(i64_pow10)) { + ret = int64_to_floatx80(i64_pow10[exp], status); + } else { + int e0 = exp / 2; + int e1 = exp - e0; + ret = floatx80_mul(floatx80_exp10i(e0, status), + floatx80_exp10i(e1, status), status); + } + + set_float_rounding_mode(old_round, status); + cache[exp] = ret; + } + return ret; +} + +void HELPER(load_pdr_to_fx80)(CPUM68KState *env, FPReg *res, target_ulong addr) +{ + uint64_t lo; + uint32_t hi; + int64_t mant; + int exp; + floatx80 fexp; + + hi = cpu_ldl_be_data_ra(env, addr, GETPC()); + lo = cpu_ldq_be_data_ra(env, addr + 4, GETPC()); + + if (unlikely((hi & 0x7fff0000) == 0x7fff0000)) { + /* NaN or Inf */ + res->l.lower = lo; + res->l.upper = hi >> 16; + return; + } + + /* Initialize mant with the integer digit. */ + mant = hi & 0xf; + if (!mant && !lo) { + /* +/- 0, regardless of exponent. */ + res->l.lower = 0; + res->l.upper = (hi >> 16) & 0x8000; + return; + } + + /* + * Accumulate the 16 decimal fraction digits into mant. + * With 17 decimal digits, the maximum value is 10**17 - 1, + * which is less than 2**57. + */ + for (int i = 60; i >= 0; i -= 4) { + /* + * From 1.6.6 Data Format and Type Summary: + * The fpu does not detect non-decimal digits in any of the exponent, + * integer, or fraction digits. These non-decimal digits are converted + * in the same manner as decimal digits; the result is probably useless + * although it is repeatable. + */ + mant = mant * 10 + ((lo >> i) & 0xf); + } + + /* Apply the mantissa sign. */ + if (hi & 0x80000000) { + mant = -mant; + } + + /* Convert the 3 digit decimal exponent to binary. */ + exp = ((hi >> 24) & 0xf) + + ((hi >> 20) & 0xf) * 10 + + ((hi >> 16) & 0xf) * 100; + + /* Apply the exponent sign. */ + if (hi & 0x40000000) { + exp = -exp; + } + + /* + * Our representation of mant is integral, whereas the decimal point + * belongs between the integer and fractional components. + * Adjust the exponent to compensate. + */ + exp -= 16; + + /* Convert mantissa. */ + res->d = int64_to_floatx80(mant, &env->fp_status); + + /* Apply exponent. */ + if (exp > 0) { + fexp = floatx80_exp10i(exp, &env->fp_status); + res->d = floatx80_mul(res->d, fexp, &env->fp_status); + } else if (exp < 0) { + fexp = floatx80_exp10i(-exp, &env->fp_status); + res->d = floatx80_div(res->d, fexp, &env->fp_status); + } +} diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 445966fb6a..59e7d27393 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -963,11 +963,11 @@ static void gen_load_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp, tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower)); break; case OS_PACKED: - /* - * unimplemented data type on 68040/ColdFire - * FIXME if needed for another FPU - */ - gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + if (!m68k_feature(s->env, M68K_FEATURE_FPU_PACKED_DECIMAL)) { + gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + break; + } + gen_helper_load_pdr_to_fx80(tcg_env, fp, addr); break; default: g_assert_not_reached(); @@ -1142,11 +1142,13 @@ static int gen_ea_mode_fp(CPUM68KState *env, DisasContext *s, int mode, tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower)); break; case OS_PACKED: - /* - * unimplemented data type on 68040/ColdFire - * FIXME if needed for another FPU - */ - gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + if (!m68k_feature(s->env, M68K_FEATURE_FPU_PACKED_DECIMAL)) { + gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + break; + } + tmp = tcg_constant_tl(s->pc); + s->pc += 12; + gen_helper_load_pdr_to_fx80(tcg_env, fp, tmp); break; default: g_assert_not_reached(); From patchwork Sun Aug 11 06:03:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 818418 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp906337wrv; Sat, 10 Aug 2024 23:04:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1ZSmohODRfxFw7r0bfFcPCAsc0Q+JFAAaY/u69wa1Xu+0rQH97TYnpo+wpj5Da1dvDZOpCHhvW63ozeJEuv+a X-Google-Smtp-Source: AGHT+IGBEG6k8oqODAHgJ7QGPROpPiKD5gm5zEuTgE/NeVpvicYBOjylkf1RO+h92VGN15YpsQ+e X-Received: by 2002:a05:6830:4992:b0:708:455a:8f03 with SMTP id 46e09a7af769-70b7bfb3049mr8302298a34.34.1723356274783; Sat, 10 Aug 2024 23:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723356274; cv=none; d=google.com; s=arc-20160816; b=E8d/LTJ91OQSPO5GPPLX3ttwcsQOsGvYUXcSkq4bN2cIPcpekJPfwPe+47hjhdnCUc tXBB5GrK+Ke3vQeay6GKcqtdbq3J2siEFP5k4IVnYnMf/4+Ev5xhCA+X2olvgo1NVYUY oYGY40ikiVmHzaS+qsEBUb0ARLOXv7vvFaphOk4K3dbUZOYsfGIUoYZCCkT30v1sA9Nt dJwR8jGu+FKB8RqLQM/DPhg7yLzFreqrv1k7fReBzfwGI/Up5pq6K/kZCJokyZzzJorH k6ny3RObOdw/IMzQDvOxpA47OFan2PViESbMDblOGzWSNjn84inW4A2PF8NwBF4RWqWl goaQ== 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=kWnw21B5/msj5JNhDBa2OCjipT/LJ9pbKxvm18kEXiE=; fh=2uesxoqJjyRqtkk3yTfcnBSFtAUtxw8KzQZeBUAogpM=; b=FSqlpWeXQowzAjTWzLQeU0H4gQxUQscx66sxxyW0xxXWe9t4xvlvqzCVaBtehl1/ku +lTOr1Q+tOGMgkKRR5HdBJqDws78Ml2QD6wnLh1NM24A60mh3zDEEZSRbmuLu41ELm8i KLlS2nk78n9fs7RnSJYVg9bbQK+nrOPkMjX+iclP1Xo4Cn9m0ZDu+CBYwaybjfope1+E FgwjZPkrLfIsfvx3UDzu7O9XFNdSHX1Vbpz7oBuo8eVOwq174X6OTXLVVWMC2BeEhxKD zMl+ILd6VbPZ1tif5thsLS4rYv+hZcWi4era0tDFy0H4qGIBgAr0r6HvWRnR/kKJXRP1 IeYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o8/qsg41"; 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 af79cd13be357-7a4c7d64f8asi325699085a.6.2024.08.10.23.04.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Aug 2024 23:04:34 -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="o8/qsg41"; 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 1sd1g5-0002Av-Lw; Sun, 11 Aug 2024 02:03:41 -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 1sd1g4-00026J-6Z for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:40 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sd1g1-0003La-SB for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:39 -0400 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-3db14cc9066so2379633b6e.3 for ; Sat, 10 Aug 2024 23:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723356216; x=1723961016; 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=kWnw21B5/msj5JNhDBa2OCjipT/LJ9pbKxvm18kEXiE=; b=o8/qsg41tAIiWBa75ivI4uPb9mpYitJpbsrYoHPsHJFWmJwQV+jnkZwtii+GjhMEPk ++TkLH4hq6mNnnCMsos7ZBq9crVfaUIM1MakHOGHWZ1AczPuoHozzwEKFxDt54Al6N9b C+AcXLEMo2Iyc9zwlsFtm6tzh2VCXwfVy5UX4zTwEECYA0EooZq2DY2d4Ls32vxuURGo RCvdJiBMryMJ8uu3JetKEHwUJ1m1Ky1mZWFAzf7iiaKPtXQOcvI1sRylKTdgE5cqaM3w phfxMx85QoQMDkpdjvrss/vK+n5yjVDogG3X5kFrjV7DhoZJhmeoIU/o8KToJJFOhtpX 11Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723356216; x=1723961016; 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=kWnw21B5/msj5JNhDBa2OCjipT/LJ9pbKxvm18kEXiE=; b=pHh8vce7bvGqsjs2GUt6NeEDWyazTigRnmgXcD5TRW31o1NYpkVUJMEDaXVuB4A4dJ SdtIpjZ4HPBy2KwRKSfUImYYSMuHuHbPZgSApuN1evcVmy3x24fq/O8T5qm/YOJbfk/C 8On1CD/qlBgDmYCNav5l+2qyfa09T9OYpJMCKnVVRJYooqDEyZjTX3x6E/3y8ZygXU97 xDQB0GGTA66XtCY5RZdvdWUkhcT32asqmGowqo5JKe2jazL/gxoqwFvqerSzuvwBgt7l 9jXUVs27RtDFa3VXwZ3dFbtZ8aqExUSSNWI3xNz5xC/5rtLfoAwyx83D/VE4PtESOB5g S9CQ== X-Gm-Message-State: AOJu0YyUTbj+HZaHrYPrkxC/w9R9cGzqscePqdQOvFUEFYpqL//L37rc v3KULcZlr4JC7DgKj4zxktDHEE+8X2WVm/D21hm4YplVMyS5/+4aOdxXRQlc6/xyfs5DDSciP5q iVa1VLA== X-Received: by 2002:a05:6808:3993:b0:3d9:30a2:f8f9 with SMTP id 5614622812f47-3dc415e3fd2mr9159975b6e.0.1723356216337; Sat, 10 Aug 2024 23:03:36 -0700 (PDT) Received: from stoup.. ([172.58.106.160]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3dd060b5388sm835591b6e.43.2024.08.10.23.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Aug 2024 23:03:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 3/4] target/m68k: Implement packed decimal real stores Date: Sun, 11 Aug 2024 16:03:12 +1000 Message-ID: <20240811060313.730410-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240811060313.730410-1-richard.henderson@linaro.org> References: <20240811060313.730410-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x232.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 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2488 Signed-off-by: Richard Henderson --- target/m68k/helper.h | 1 + target/m68k/fpu_helper.c | 100 +++++++++++++++++++++++++++++++++++++++ target/m68k/translate.c | 27 +++++++++-- 3 files changed, 125 insertions(+), 3 deletions(-) diff --git a/target/m68k/helper.h b/target/m68k/helper.h index 2c71361451..21af6adb39 100644 --- a/target/m68k/helper.h +++ b/target/m68k/helper.h @@ -127,6 +127,7 @@ DEF_HELPER_3(chk, void, env, s32, s32) DEF_HELPER_4(chk2, void, env, s32, s32, s32) DEF_HELPER_FLAGS_3(load_pdr_to_fx80, TCG_CALL_NO_RWG, void, env, fp, tl) +DEF_HELPER_FLAGS_4(store_fx80_to_pdr, TCG_CALL_NO_RWG, void, env, tl, fp, int) #if !defined(CONFIG_USER_ONLY) DEF_HELPER_3(ptest, void, env, i32, i32) diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index dd80943153..6f37a165e2 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -886,3 +886,103 @@ void HELPER(load_pdr_to_fx80)(CPUM68KState *env, FPReg *res, target_ulong addr) res->d = floatx80_div(res->d, fexp, &env->fp_status); } } + +static floatx80 floatx80_scale10i(floatx80 x, int e, float_status *status) +{ + floatx80 t; + if (e >= 0) { + t = floatx80_exp10i(e, status); + t = floatx80_mul(x, t, status); + } else { + t = floatx80_exp10i(-e, status); + t = floatx80_div(x, t, status); + } + return t; +} + +void HELPER(store_fx80_to_pdr)(CPUM68KState *env, target_ulong addr, + FPReg *srcp, int kfactor) +{ + floatx80 t, x = srcp->d; + int len, exp2, exp10; + uint64_t res_lo; + uint32_t res_hi; + int64_t y; + + res_lo = x.low; + exp2 = x.high & 0x7fff; + if (unlikely(exp2 == 0x7fff)) { + /* NaN and Inf */ + res_hi = (uint32_t)x.high << 16; + goto done; + } + + /* Copy the sign bit to the output, and then x = abs(x). */ + res_hi = (x.high & 0x8000u) << 16; + x.high &= 0x7fff; + + if (exp2 == 0) { + if (res_lo == 0) { + /* +/- 0 */ + goto done; + } + /* denormal */ + exp2 = -0x3fff - clz64(res_lo); + } else { + exp2 -= 0x3fff; + } + + /* + * Begin with an approximation of log2(x) via the base 2 exponent. + * Adjust, so that we compute the value scaled by 10**17, which will + * allows an integer to be extracted to match the output digits. + */ + exp10 = (exp2 * 30102) / 100000; + while (1) { + /* kfactor controls the number of output digits */ + if (kfactor <= 0) { + /* kfactor is number of digits right of the decimal point. */ + len = exp10 - kfactor; + } else { + /* kfactor is number of significant digits */ + len = kfactor; + } + len = MIN(MAX(len, 1), 17); + + /* + * Scale, so that we have the requested number of digits + * left of the decimal point. Convert to integer, which + * handles the rounding (and may force adjustment of exp10). + */ + t = floatx80_scale10i(x, len - 1 - exp10, &env->fp_status); + y = floatx80_to_int64(t, &env->fp_status); + if (y < i64_pow10[len - 1]) { + exp10--; + } else if (y < i64_pow10[len]) { + break; + } else { + exp10++; + } + } + + /* Output the mantissa. */ + res_hi |= y / i64_pow10[len - 1]; + res_lo = 0; + for (int i = 1; i < len; ++i) { + int64_t d = (y / i64_pow10[len - 1 - i]) % 10; + res_lo |= d << (64 - i * 4); + } + + /* Output the exponent. */ + if (exp10 < 0) { + res_hi |= 0x40000000; + exp10 = -exp10; + } + for (int i = 24; exp10; i -= 4, exp10 /= 10) { + res_hi |= (exp10 % 10) << i; + } + + done: + cpu_stl_be_data_ra(env, addr, res_hi, GETPC()); + cpu_stq_be_data_ra(env, addr + 4, res_lo, GETPC()); +} diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 59e7d27393..fb5ecce0c3 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -119,6 +119,8 @@ typedef struct DisasContext { int done_mac; int writeback_mask; TCGv writeback[8]; + uint16_t insn; + uint16_t ext; bool ss_active; } DisasContext; @@ -671,6 +673,7 @@ static inline int ext_opsize(int ext, int pos) case 4: return OS_WORD; case 5: return OS_DOUBLE; case 6: return OS_BYTE; + case 7: return OS_PACKED; /* store, dynamic k-factor */ default: g_assert_not_reached(); } @@ -1010,11 +1013,25 @@ static void gen_store_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp, tcg_gen_qemu_st_i64(t64, tmp, index, MO_TEUQ); break; case OS_PACKED: + if (!m68k_feature(s->env, M68K_FEATURE_FPU_PACKED_DECIMAL)) { + gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + break; + } /* - * unimplemented data type on 68040/ColdFire - * FIXME if needed for another FPU + * For stores we must recover k-factor, either from an + * immediate or the low 7 bits of a D register. */ - gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + switch ((s->ext >> 10) & 7) { + case 3: + tcg_gen_movi_i32(tmp, sextract32(s->ext, 0, 7)); + break; + case 7: + tcg_gen_sextract_i32(tmp, DREG(s->ext, 4), 0, 7); + break; + default: + g_assert_not_reached(); + } + gen_helper_store_fx80_to_pdr(tcg_env, addr, fp, tmp); break; default: g_assert_not_reached(); @@ -4940,6 +4957,8 @@ DISAS_INSN(fpu) TCGv_ptr cpu_src, cpu_dest; ext = read_im16(env, s); + s->ext = ext; + opmode = ext & 0x7f; switch ((ext >> 13) & 7) { case 0: @@ -6042,6 +6061,8 @@ static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) CPUM68KState *env = cpu_env(cpu); uint16_t insn = read_im16(env, dc); + dc->insn = insn; + dc->ext = 0; opcode_table[insn](env, dc, insn); do_writebacks(dc); From patchwork Sun Aug 11 06:03:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 818417 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp906326wrv; Sat, 10 Aug 2024 23:04:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHqiXNlh9/ZKi3iSYJuC7TaFFFM9viRijpK8A3CfVSAsfgq1mNglAR953GzUrKPnK2mKIn70NGyXCXRNFbiE3v X-Google-Smtp-Source: AGHT+IE9Xz1GsxktOnVmbCrkucoIuipX9N4Ff5rZLD2lOCi5gLUBtvlRvaZBKFDbU+AuJbpTXqIf X-Received: by 2002:a05:6214:43c8:b0:6b5:dcda:bada with SMTP id 6a1803df08f44-6bd78e8296cmr69555206d6.55.1723356271425; Sat, 10 Aug 2024 23:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723356271; cv=none; d=google.com; s=arc-20160816; b=z65fSC5yOClEFSxViltVyjm2zt6jKReHBomdMLM1+2FWctvzrhTu9cqui93Jr7VOhS 6/BVzF2U/D19AirmVBywMVZLNmaNMwJaL8mB+xyuOOp7cFeIIrtwejT18w9QE90mb5Kd miIgZPNdZECGpF4hBle55vfgigiqLS+rRHffxcYCMOHhFDVapb+awGUGNEGRuCliWGFP GVP1uVkLPH4PAUO4YdVSQMaOT3F7eoXfAzhcsxyF1Eo7YuGXuqBJCEYJS4157KAN46Bz heZPduldlpf0hVn7c/H8MJzFPJuxNYfJal4U2H3vP7pDDPDnGpUmyThSLnmnzGYQf5HA zzyg== 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=Bj++j3YgBBTATBUE1Ix26t7YFSKIT6F98qGvdazeStQ=; fh=2uesxoqJjyRqtkk3yTfcnBSFtAUtxw8KzQZeBUAogpM=; b=dv3Z2G9iHBs9pcK0OXJMg7Q5tXQHzFfqvfO6GzTTBOYK8bzanrdLANbH62rHEEWrAJ MO9+dEEFtIk0YJJWYFYMvK9OQf5CvbjpTt4/1V0o6vOTCVETvdPMKhbruiYI49HmaJr/ KW9dFDmtnI3qYtjUS4xp4XHz/OVcSttE/BW/ePk9DAxTzFT+CYk6j3jqQSi1Vz9FDYiv dXvf1NS/t9eiBBhGeVzBjFaOZHJkbM9P0vUCDToFQqYhQgz9sAhWVxaylVRRauFqUu/D n+O/AcYQYV+/YaPNgN3qSvcJbd3L3o/kXUKOEkWdfUiR7MZD2eHL6QAv49I+Alsuq/Jd QsEg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VjRQ6HQR; 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-6bd82c5fc41si34198186d6.103.2024.08.10.23.04.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Aug 2024 23:04:31 -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=VjRQ6HQR; 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 1sd1g9-0002Ko-0D; Sun, 11 Aug 2024 02:03:45 -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 1sd1g7-0002GZ-87 for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:43 -0400 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sd1g5-0003M1-EI for qemu-devel@nongnu.org; Sun, 11 Aug 2024 02:03:42 -0400 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3db1eb76702so2605755b6e.0 for ; Sat, 10 Aug 2024 23:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723356220; x=1723961020; 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=Bj++j3YgBBTATBUE1Ix26t7YFSKIT6F98qGvdazeStQ=; b=VjRQ6HQRu7smSUrpFOQbuTRBdh3YRNlAeUwSSIhJjt+fp82PA/OqgehEbcqsd4pkuF cyAQA/xZqZzPwZHnNtyBUd6D/xlC7qauebNlFBT1IhrZ5DrABh9BkJ4WsUjUaGG3rawj AlBKmcNTYbnnTDbRL6hZC5N1IA0DRexSF9UB4u2DlkFXsDxaUnYOzmEwworsmwi5+Tbx X8TIPpQeA/3b3jqDl+aFC74BOapBkYhR5hgTAfsjIyv/LYWF59F8Zz2Io6Z/vHsBJr/L 4Ko4p4PUsysmoKwJDyY2YpHxFyc29lVPneAArEhiRnVlCNt/DMKPdFldNi+Ji7tIst22 fmIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723356220; x=1723961020; 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=Bj++j3YgBBTATBUE1Ix26t7YFSKIT6F98qGvdazeStQ=; b=tQYstqvGXFA85Nw7zFzIWiC46f047NkfmYPQ1y207Qn92wMU66I+LnU45bp186Spau FoGrtLHtVuAGDoRmGqGZQdq15qga6Q+NRhQI13qQKMu8WNEcAdVUoSthJ8nRk+r2pcJM A7KYIO/qPeud4IkE8usdkQQ58frxiXGNJdR5BMV2yQEfhQQPNK8rdMMIcKOaxLWphPp1 VBNvZ/7Umn4J/dv1k4pWq95W1SkL6MefneS4J6dW6IYVxc2lS9J82GW/EIlwPvmEOLhZ 4/0gDYAE89GPr/tUQCrIfwczipMFXaOJD3v43209cdJrAdyNqA1exj8YjyJUMRfRC7rV CFlw== X-Gm-Message-State: AOJu0YwEC7jAmkmXp/zshXALI06cz0JkO9b3wVA06fy8EcVB9Mc9OZP0 GTw4/3Kf5DIueeTebctNKAb4bMkA/ZrnuHson/DwzFAPIKgOFBboF0TRVEogacrW7M7svd/bxkN SItYApw== X-Received: by 2002:a05:6808:1a15:b0:3db:2afc:ad6 with SMTP id 5614622812f47-3dc416dd0e9mr8715951b6e.38.1723356220138; Sat, 10 Aug 2024 23:03:40 -0700 (PDT) Received: from stoup.. ([172.58.106.160]) by smtp.gmail.com with ESMTPSA id 5614622812f47-3dd060b5388sm835591b6e.43.2024.08.10.23.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Aug 2024 23:03:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH 4/4] tests/tcg/m68k: Add packed decimal tests Date: Sun, 11 Aug 2024 16:03:13 +1000 Message-ID: <20240811060313.730410-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240811060313.730410-1-richard.henderson@linaro.org> References: <20240811060313.730410-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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 Signed-off-by: Richard Henderson --- tests/tcg/m68k/packeddecimal-1.c | 45 ++++++++++++++++++++++++++++++++ tests/tcg/m68k/packeddecimal-2.c | 42 +++++++++++++++++++++++++++++ tests/tcg/m68k/Makefile.target | 2 +- 3 files changed, 88 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..812307402a --- /dev/null +++ b/tests/tcg/m68k/packeddecimal-1.c @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Test packed decimal real conversion to long double. */ + +#include + +struct T { + unsigned int d[3]; + 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 lf; + volatile double f; + + asm("fmove.p (%1),%0" : "=f"(lf) : "a"(t->d)); + + /* Round to double; as yet we cannot promise perfect rounding. */ + f = lf; + + if (f != t->f) { + fprintf(stderr, "Mismatch at %d: %.17e != %.17e\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..3547dc7b84 --- /dev/null +++ b/tests/tcg/m68k/packeddecimal-2.c @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Test packed decimal real conversion from long double, dynamic k-factor */ + +#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 }, +}; + +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..7587b8f249 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -4,4 +4,4 @@ # VPATH += $(SRC_PATH)/tests/tcg/m68k -TESTS += trap denormal +TESTS += trap denormal packeddecimal-1 packeddecimal-2