From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by sourceware.org (Postfix) with ESMTPS id EC6F73858D33 for ; Sun, 10 Sep 2023 17:41:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC6F73858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=jacob.remcomp.fr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=jacob.remcomp.fr Received: from smtpclient.apple ([90.22.252.13]) by smtp.orange.fr with ESMTPS id fOR4qvnxF1XYufOR4q7RWC; Sun, 10 Sep 2023 19:41:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1694367686; bh=39dGA2kUxhuJQFmoHNCWzgnWUv4TlU6fkTxwMgPgSro=; h=From:Subject:Date:To; b=EWH3aSF7sRM7innZtLIyuUjiF8HO2uEMfrN9iLjjI98EmOOO5wHgCo/SOyACD5RHx 9/NZXrXoLQWm09GoIa/sqreO9ZX2RBe1mudHYJEW5s05bwk3XkzEXvE9/Z8OZ6tK1r xTOG+819YikQDqn67e3sj4Rrxzbzafcq/beVcKQAtjOQ5MKpKpgyzuS97AA7EdX731 FAX0BXkEPiBEL3SkpSvyFLRaOCNu0Vr2eoHfxdLR8HhACj+UqFvrGPEQHY02OLvo0t Yg1BexBFb+hInJmyjc6iEu9+orXCzzFxDBSSsh7uJwmp1RpflcjCnfaAQ7D8Jo97eK Ree1NpN6n4TbA== X-ME-Helo: smtpclient.apple X-ME-Date: Sun, 10 Sep 2023 19:41:26 +0200 X-ME-IP: 90.22.252.13 From: jacob navia Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Elimination of all floating point code in the tiny assembler Message-Id: <8E4F032D-71CD-4F39-9610-D7D63274662F@jacob.remcomp.fr> Date: Sun, 10 Sep 2023 19:41:15 +0200 To: binutils@sourceware.org X-Mailer: Apple Mail (2.3731.700.6) X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE,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: GAS has its own floating point code in very high precision. This code is = quite cumbersome, and never used. All compilers emit floating point = numbers as 32 or 64 bit integers, so, the directives for reading = floating point numbers go unused. Still, I maintained all those directives just in case. Internally, they = all lead to a call to strtold(), that does all the work done previously = by the floating point code in the assembler. The resulting long double = is then down-casted to the appropriate precision (double, single, half). This will cater all the needs of an assembler. The gains are impressive: Around 1500 lines of floating point code are = gone. =46rom the standpoint of the maintaining GAS this should make = quite a difference, since the code that was erased is completely = incomprehensible unless you get into it after at least a week of work. = True, it is running, but it could become a big maintenance problem = somewhere in the future. And, above all, it is never used! I have yet to see any compiler that = uses it. For people using GAS, the directives .double, etc are largely = enough. True, back when this code was written, maybe the C library wasn=E2=80=99t = as advanced as it is today, strtold I think it is C99, and the floating = point code is way older. This situation is clearly described in the (funny) comments: /* * Seems atof_machine can backscan through generic_bignum and hit = whatever * happens to be loaded before it in memory. And its way too = complicated for * me to fix right. Thus a hack. JF: Just make generic_bignum = bigger,and * never write into the early words,thus they'll always be zero. I hate = Dean's * floating-point code. Bleh. */ That is a very old comment. GNU developers have fought long battles to = maintain this code=E2=80=A6 let=E2=80=99s forget it. Of course these are personal thoughts, no need to do anything right now. = But if anyone is interested, here is my new version of parse_one_float: /* DISCLAIMER:=20 * Here I give up any copyright rights that I may or may not have for = this code and declare it property of GNU=20 */ static int parse_one_float(int float_type,char = temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT]) { int length; SKIP_WHITESPACE(); /* Accept :xxxx,where the x's are hex digits,for a floating point * with the exact digits specified. */ if (input_line_pointer[0] =3D=3D ':') { ++input_line_pointer; length =3D hex_float(float_type,temp); if (length < 0) { ignore_rest_of_line(); return length; } =20 } else { // New code long double ld; double d; float f; _Float16 f16; =20 errno=3D0; ld =3D strtold(input_line_pointer,&input_line_pointer); = = =20 if (errno) goto err; switch (float_type) { case 'H': case 'h': f16 =3D ld;=20 length =3D 2; memcpy(temp,&f16,2); break; case 'f': case 'F': case 's': case 'S': f =3D ld;=20 length =3D 4; memcpy(temp,&f,4); break; case 'd': case 'D': case 'r': case 'R': d =3D ld;=20 length =3D 8; memcpy(temp,&d,8); break; =20 default: err: as_bad("bad floating point literal"); ignore_rest_of_line(); return (-1);=20 } =20 } SKIP_WHITESPACE(); return length; } You see? It is TRIVIAL to follow, and even a total noob will understand it! Jacob=