{"id":2225472,"url":"http://patchwork.ozlabs.org/api/patches/2225472/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421051346.41106-21-richard.henderson@linaro.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421051346.41106-21-richard.henderson@linaro.org>","list_archive_url":null,"date":"2026-04-21T05:13:29","name":"[20/37] fpu: Add conversions between float16 and float8 formats","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"21d5e60b091a9e1dcbfd3aa26955d6009c0a7552","submitter":{"id":72104,"url":"http://patchwork.ozlabs.org/api/people/72104/?format=json","name":"Richard Henderson","email":"richard.henderson@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421051346.41106-21-richard.henderson@linaro.org/mbox/","series":[{"id":500729,"url":"http://patchwork.ozlabs.org/api/series/500729/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500729","date":"2026-04-21T05:13:11","name":"target/arm: Implement FEAT_FAMINMAX, FEAT_FPMR, FEAT_FP8","version":1,"mbox":"http://patchwork.ozlabs.org/series/500729/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225472/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225472/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=AwG7b1Pq;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g09df0t95z1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 15:19:34 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wF3S6-0008Mb-Pi; Tue, 21 Apr 2026 01:15:15 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)\n id 1wF3Rf-00084e-J1\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 01:14:51 -0400","from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <richard.henderson@linaro.org>)\n id 1wF3Rb-0006YE-7l\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 01:14:46 -0400","by mail-pj1-x1036.google.com with SMTP id\n 98e67ed59e1d1-3590042fa8eso2927694a91.1\n for <qemu-devel@nongnu.org>; Mon, 20 Apr 2026 22:14:40 -0700 (PDT)","from stoup.. ([180.233.125.15]) by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b5fab0cddfsm174631715ad.49.2026.04.20.22.14.37\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 20 Apr 2026 22:14:39 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1776748479; x=1777353279; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=3n7fQN+iJBwqx2ETIvTw92Xcf+8pXw422MS+4i6nNsM=;\n b=AwG7b1PqEY5KAEXw7my+WFv9gnV1M8AYN8ewWiw6XBBOpxCnHVIhzJo/JexnqI94c3\n dmGEmoU3Kq5hbsxbToW1Ll3T/omlcJZlP771L0d443FzKl/ZJCKMW82StoF9oILm8rad\n s25B+iLZvXh0Evh6ETu8Ow/dx43fchO6JRogIIECReg/+V1Hr5lLLFFodeKqtMuJpuQZ\n n9Mo9Gr069ujiVofgksJfVkxMA8DTryE+y7Ciq5zXI5XTLrRPxKgIT4rnYwD1JS8FKTR\n TNSIudTmJkm/PU2YlsZEVZ2TNgWu9QzXtDqfXq8akodReMcXs229JUViYgEnKxLBzhHB\n OpTw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776748479; x=1777353279;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=3n7fQN+iJBwqx2ETIvTw92Xcf+8pXw422MS+4i6nNsM=;\n b=EZgKE+4EPNOjcL+GFThzxWkyZfgDzRIEGx6c1gIHdBwQu+f7SCywcEbektfR+J+AOb\n HiwETIHaHcMgTBdIm4CAe6/Wg3VQkJ6e6cGNCkLRqE18+vtIRdJkB56BR+fcSkaDLgim\n 86TaxuGH3O8rVeY6UT6v+SJXJGswaubgFUvlEQLHiuEeDOLp4cang6i7vdmV0CJmqHGO\n MCqiW8EbL/3Lk7jNUWlM27HSN1ZZh/jtE3L9hG39/iWMndoE6iA2UDk9uG0ADWRGdZYr\n yplaB4xSHChTmyHuZcbO2BbuhGMV6Mq8P0bWloXjRp5Fe898orfaZ547BAsXdHpXI4zg\n G3Eg==","X-Gm-Message-State":"AOJu0YyVJeSXHTiQaTA2421AD7OGMaaj50jnKkbdarsfUBqJHjYlZNVP\n R83ar0pw6scFRapdmmKSPdCr++aqANwDUA9bFoii+l9T6jI+6CAqBSSQbmgzLksu91xdjNYusra\n Ok6QO6tw=","X-Gm-Gg":"AeBDietLqMZBeSwYot9G8Pxw6d33Lojs/TIhWDwKjEGQB1flqHGK1/s1TM84M10v+pH\n Ysdu6PcXLdxOc91G3YLKvp8pd4EHxrImk58929RlBYli/XCkHzUxubC51RJD9Hc64YGwSDJ2Ip2\n tgMmS/nsrjsIG0qi183t9ivFzLkksOGEQREFMurqigaaeznCFg2nR6+XscjGAc29rDhxqAT0DNK\n pRJvnXxIpjOvIN1StFcuhnhTGhtJ44e1VajZD5C+vmMZn2a6MV8zDpH/k6SBIK29XvqzJV1sVQf\n RoPOZyrkMg6lwjiqZh4sJDnf1wY1tcw4MsgvFJW55hMEWpU3OBIjO8Gf80fHpGJiUhwPl33CBkd\n f8+3WJ77SxwsIkSakS3PHrIuHRdf4BJsLcQok3pOaYh3k/aSXxYdE6UM3F537qhju8LcthyDRt4\n Gpex5D06AlkzrS3s4HapMDLaAfMgDwfTX3MtbM+GXe","X-Received":"by 2002:a17:90a:d40d:b0:35b:e5ce:73bb with SMTP id\n 98e67ed59e1d1-361403d61d5mr16697701a91.1.1776748479388;\n Mon, 20 Apr 2026 22:14:39 -0700 (PDT)","From":"Richard Henderson <richard.henderson@linaro.org>","To":"qemu-devel@nongnu.org","Cc":"qemu-arm@nongnu.org","Subject":"[PATCH 20/37] fpu: Add conversions between float16 and float8 formats","Date":"Tue, 21 Apr 2026 15:13:29 +1000","Message-ID":"<20260421051346.41106-21-richard.henderson@linaro.org>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260421051346.41106-1-richard.henderson@linaro.org>","References":"<20260421051346.41106-1-richard.henderson@linaro.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=2607:f8b0:4864:20::1036;\n envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Signed-off-by: Richard Henderson <richard.henderson@linaro.org>\n---\n include/fpu/softfloat.h |  8 +++++++-\n fpu/softfloat.c         | 38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 45 insertions(+), 1 deletion(-)","diff":"diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h\nindex 6f86848b7e..70e25fa811 100644\n--- a/include/fpu/softfloat.h\n+++ b/include/fpu/softfloat.h\n@@ -196,16 +196,22 @@ float128 uint128_to_float128(Int128, float_status *status);\n float8_e4m3 float4_e2m1_to_float8_e4m3(float4_e2m1, float_status *status);\n \n bfloat16 float8_e4m3_to_bfloat16(float8_e4m3, int scale, float_status *status);\n+float16 float8_e4m3_to_float16(float8_e4m3, int scale, float_status *status);\n float8_e4m3 bfloat16_to_float8_e4m3(bfloat16, int scale,\n                                     bool sat, float_status *status);\n+float8_e4m3 float16_to_float8_e4m3(float16, int scale,\n+                                   bool sat, float_status *status);\n float8_e4m3 float32_to_float8_e4m3(float32, int scale,\n                                    bool sat, float_status *status);\n \n bfloat16 float8_e5m2_to_bfloat16(float8_e5m2, int scale, float_status *status);\n+float16 float8_e5m2_to_float16(float8_e5m2, int scale, float_status *status);\n float8_e5m2 bfloat16_to_float8_e5m2(bfloat16, int scale,\n                                     bool sat, float_status *status);\n+float8_e5m2 float16_to_float8_e5m2(float16, int scale,\n+                                   bool sat, float_status *status);\n float8_e5m2 float32_to_float8_e5m2(float32, int scale,\n-                                    bool sat, float_status *status);\n+                                   bool sat, float_status *status);\n \n /*----------------------------------------------------------------------------\n | Software half-precision conversion routines.\ndiff --git a/fpu/softfloat.c b/fpu/softfloat.c\nindex bcec7d38c8..013b6e1ee2 100644\n--- a/fpu/softfloat.c\n+++ b/fpu/softfloat.c\n@@ -2958,6 +2958,15 @@ float8_e4m3 float4_e2m1_to_float8_e4m3(float4_e2m1 a, float_status *s)\n     return float8_e4m3_round_pack_canonical(&p, s, false);\n }\n \n+float16 float8_e4m3_to_float16(float8_e4m3 a, int scale, float_status *s)\n+{\n+    FloatParts64 p;\n+\n+    float8_e4m3_unpack_canonical(&p, a, s);\n+    parts_scalbn(&p, scale, s);\n+    return float16_round_pack_canonical(&p, s);\n+}\n+\n bfloat16 float8_e4m3_to_bfloat16(float8_e4m3 a, int scale, float_status *s)\n {\n     FloatParts64 p;\n@@ -2967,6 +2976,15 @@ bfloat16 float8_e4m3_to_bfloat16(float8_e4m3 a, int scale, float_status *s)\n     return bfloat16_round_pack_canonical(&p, s);\n }\n \n+float16 float8_e5m2_to_float16(float8_e5m2 a, int scale, float_status *s)\n+{\n+    FloatParts64 p;\n+\n+    float8_e5m2_unpack_canonical(&p, a, s);\n+    parts_scalbn(&p, scale, s);\n+    return float16_round_pack_canonical(&p, s);\n+}\n+\n bfloat16 float8_e5m2_to_bfloat16(float8_e5m2 a, int scale, float_status *s)\n {\n     FloatParts64 p;\n@@ -2976,6 +2994,26 @@ bfloat16 float8_e5m2_to_bfloat16(float8_e5m2 a, int scale, float_status *s)\n     return bfloat16_round_pack_canonical(&p, s);\n }\n \n+float8_e4m3 float16_to_float8_e4m3(float16 a, int scale,\n+                                   bool saturate, float_status *s)\n+{\n+    FloatParts64 p;\n+\n+    float16_unpack_canonical(&p, a, s);\n+    parts_scalbn(&p, scale, s);\n+    return float8_e4m3_round_pack_canonical(&p, s, saturate);\n+}\n+\n+float8_e5m2 float16_to_float8_e5m2(float16 a, int scale,\n+                                   bool saturate, float_status *s)\n+{\n+    FloatParts64 p;\n+\n+    float16_unpack_canonical(&p, a, s);\n+    parts_float_to_e5m2(&p, s, scale, saturate);\n+    return float8_e5m2_round_pack_canonical(&p, s, saturate);\n+}\n+\n float32 float16_to_float32(float16 a, bool ieee, float_status *s)\n {\n     const FloatFmt *fmt16 = ieee ? &float16_params : &float16_params_ahp;\n","prefixes":["20/37"]}