From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 73CEE3851409 for ; Thu, 30 Mar 2023 10:30:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73CEE3851409 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-wm1-x32a.google.com with SMTP id bg13-20020a05600c3c8d00b003ef90adc168so3658401wmb.5 for ; Thu, 30 Mar 2023 03:30:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1680172241; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zym/B54uZPoNoax/EEEPluH2scg+sZgs9RdroEhAqnk=; b=WZWTcU/eANfNND5QryiYizkhIyPugUTfR6/A5qtaqusGgcZy1XJBqepXw0PQS9rz5b uOTYMaMwXbnkMUZzHFP26gl+uYf6RyRyHwTJ9Mb5WhQ6wVsfXWpBSVIl9abycy7hBgTm wdZJ3vz6cgL2AVbVG+oVmoZGW5zVGd6rckLN7BCArqI5a4MtsetczSQdNyc0OFDR1595 cPeny4GtOO9Njk7p+Sxl4asL3LjnjMTTIkaLZGv1hn1rU5TyHFguhVNRRTTEcfSi9hXy 5vnv0J0PB2mgmM+88jNijqdXser3C+yd0jkCgjfVn3nX/cV5cxa4xZMM2x92XF/peDde URUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680172241; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zym/B54uZPoNoax/EEEPluH2scg+sZgs9RdroEhAqnk=; b=5V+JG2gTaNw8jKLFATDrxvqHSDxvrsWctQvbU46AQnOhSgJOl2vcCFr7TO0AduACA7 GeNPkPLY/Berx+wziela23JpLNDuHUnpc1pBSrBo2ytgwwXDsUSR80QqPMCenshw9gOk fe41isV8F7gey+KFRSBIe/dNc/r7vouOgohIxwVSycPVOAnne0L38QIAlEWb7R0zpwuj A9qsX2S5xqN1G4othmEbuaXidicNZDthh6ql4/DN67NMt/8FWVxvHnDOIUsDFrzq3xXa AnfJX5WEzIiLrxp9PDwUnkSmJQXEYo3Z/RyZhOB2o0vM8vLQLemvMYElx7dvn41l5+N0 LBlg== X-Gm-Message-State: AO0yUKUKBmP5OUIg9fOmBvVxyDgCslCX/nThWLzEc71Vuj26S1GDDpux 3SdiycvPQimj39XD57K2+mpOygqRal4to+GA07l0mg== X-Google-Smtp-Source: AK7set9tDjD1WxfVp+IUGJB5yc/csdxZM2LWPuo46Z/A2/dOVMQ+8OPfrhuP1Vio5jVmjhCNskOS36hsvTB8e/uc3cM= X-Received: by 2002:a7b:ce8f:0:b0:3ed:c669:8a13 with SMTP id q15-20020a7bce8f000000b003edc6698a13mr4942331wmj.8.1680172241125; Thu, 30 Mar 2023 03:30:41 -0700 (PDT) MIME-Version: 1.0 References: <20230327080107.3266866-1-christoph.muellner@vrull.eu> <20230327080107.3266866-3-christoph.muellner@vrull.eu> <981c0ad5-3e84-d2f3-c14a-4c7bb70749a9@suse.com> In-Reply-To: From: =?UTF-8?Q?Christoph_M=C3=BCllner?= Date: Thu, 30 Mar 2023 12:30:27 +0200 Message-ID: Subject: Re: [RFC PATCH v2 2/2] RISC-V: Add support for the Zfa extension To: Jan Beulich Cc: Kito Cheng , binutils@sourceware.org, Nelson Chu , Andrew Waterman , Palmer Dabbelt , Jim Wilson , Philipp Tomsich , Jeff Law , Tsukasa OI Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Mar 27, 2023 at 11:54=E2=80=AFAM Jan Beulich wr= ote: > > On 27.03.2023 10:53, Kito Cheng wrote: > > Wait, I mean the hex floating point format defined in C99/C++17, not > > the raw hex value. > > so something like 0x1p-16 (0.0000152587890625), 0x1p-2 (0.25) 0x1p+0, > > -0x1p+0 could be used for fli.* instruction. > > > > You could use printf with %a to get those values. > > > > https://gcc.gnu.org/onlinedocs/gcc/Hex-Floats.html > > https://developer.arm.com/documentation/dui0375/latest/Compiler-Coding-= Practices/Hexadecimal-floating-point-numbers-in-C99 > > Sure, my (secondary) suggestion ... > > > On Mon, Mar 27, 2023 at 4:39=E2=80=AFPM Jan Beulich via Binutils > > wrote: > >> > >> On 27.03.2023 10:01, Christoph Muellner wrote: > >>> --- a/opcodes/riscv-opc.c > >>> +++ b/opcodes/riscv-opc.c > >>> @@ -110,6 +110,16 @@ const char * const riscv_vma[2] =3D > >>> "mu", "ma" > >>> }; > >>> > >>> +/* The FLI.[HSDQ] value constants. */ > >>> +const char * const riscv_fli_value[32] =3D > >>> +{ > >>> + "-1.0", "min", "0.0000152587890625", "0.000030517578125", > >>> + "0.00390625", "0.0078125", "0.0625", "0.125", > >>> + "0.25", "0.3125", "0.375", "0.4375", "0.5", "0.625", "0.75", "0.87= 5", > >>> + "1.0", "1.25", "1.5", "1.75", "2.0", "2.5", "3.0", "4.0", > >>> + "8.0", "16.0", "128.0", "256.0", "32768.0", "65536.0", "inf", "na= n", > >>> +}; > >> > >> Especially for values like 1.0x2^^-n (entries 2 and onwards) I questio= n > >> the spelled out numbers to be the most suitable ones usability wise. A= t > >> least some alternative spelling (e.g. 2.e-16) ought to be recognized a= s > >> well. But since there are meany reasonable spellings (leading 0 omitte= d > >> in 0. or trailing zero omitted in .0), I guess I'd pref= er > >> if values were actually parsed as a floating point number (e.g. via > >> ieee_md_atof()), and then matched against values stored in the table. > >> One might further consider to also permit the 2nd form accepted > >> elsewhere, see read.c:parse_one_float(). > > ... here wasn't meant to collide with yours. What you're asking for is > covered by my primary suggestion (to actually parse the values), extended > by the need to actually recognize C99 hex float in the parser then (leavi= ng > aside for now whether that's feasible in the first place). Thanks for all the suggestions! I worked my way through this and I believe that the following would be a reasonable solution: * constants min, inf and nan must be symbols (as stated in the specificatio= n) * other constants are parsed by scanf("%f") as floats and compared (float compare in C) against the numeric constants in the table * output in the disassembly uses symbols for min/inf/nan and %a (hex FP literals) for other constants So we support every format that '%f' accepts including hex FP literals (e.g. -0x1p0, 0x1p+0, ...) and normal FP constants (e.g. 0.0000152587890625, 25E-4). Patch is ready and will be sent in a few minutes. BR Christoph