From: Branislav Brzak <Branislav.Brzak@Syrmia.com>
To: "binutils@sourceware.org" <binutils@sourceware.org>
Cc: Dragoslav Sicarov <Dragoslav.Sicarov@Syrmia.com>,
Djordje Todorovic <Djordje.Todorovic@syrmia.com>
Subject: [PATCH 0/2] riscv: Fix gas when encoding BE floats/doubles
Date: Thu, 15 Jun 2023 11:09:26 +0000 [thread overview]
Message-ID: <AM6PR03MB49843D0F7C0438ADEB19172E985BA@AM6PR03MB4984.eurprd03.prod.outlook.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1149 bytes --]
RISCV gas currently does not take into consideration -mbig-endian
directive when encoding floats and doubles. The effect is that when
-mbig-endian is supplied floats and doubles are endian flipped only
on 2-byte boundaries, for example:
.data:
.float 1.1
Compiled as LE will be encoded as: 0xcdcc8c3f
And BE encoded will be: 0x8c3fcdcc
The correct sequence is 0x3f8ccccd
This patch introduces a fix in float/double endian encoding and
set of tests that verify validity of LE and BE float and double
encoding.
Branislav Brzak (2):
gas: Fix float/double BE encoding in RISCV.
riscv: Add LE/BE float/double encoding tests.
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/double-be.d | 18 ++++++++++++++++++
gas/testsuite/gas/riscv/double-le.d | 18 ++++++++++++++++++
gas/testsuite/gas/riscv/double.s | 21 +++++++++++++++++++++
gas/testsuite/gas/riscv/float-be.d | 13 +++++++++++++
gas/testsuite/gas/riscv/float-le.d | 13 +++++++++++++
gas/testsuite/gas/riscv/float.s | 21 +++++++++++++++++++++
7 files changed, 105 insertions(+), 1 deletion(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-tc-riscv.c-md_atof-Use-target_big_endian-instead-of-.patch --]
[-- Type: text/x-patch; name="0001-tc-riscv.c-md_atof-Use-target_big_endian-instead-of-.patch", Size: 747 bytes --]
From 199f5871ca8d16d7f2e24cbc7a1b4d103a2eedef Mon Sep 17 00:00:00 2001
From: Branislav Brzak <branislav.brzak@syrmia.com>
Date: Thu, 15 Jun 2023 11:35:09 +0200
Subject: [PATCH 1/2] * tc-riscv.c (md_atof): Use target_big_endian instead
of constant
---
gas/config/tc-riscv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 7684fa7e06d..e915b82eafa 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -3693,7 +3693,7 @@ md_assemble (char *str)
const char *
md_atof (int type, char *litP, int *sizeP)
{
- return ieee_md_atof (type, litP, sizeP, TARGET_BYTES_BIG_ENDIAN);
+ return ieee_md_atof (type, litP, sizeP, target_big_endian);
}
void
--
2.34.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Add-LE-BE-float-double-encoding-tests.patch --]
[-- Type: text/x-patch; name="0002-Add-LE-BE-float-double-encoding-tests.patch", Size: 5211 bytes --]
From f6739b8abeaa054196e0b2e31807dea2d7e1ec8a Mon Sep 17 00:00:00 2001
From: Branislav Brzak <branislav.brzak@syrmia.com>
Date: Thu, 15 Jun 2023 11:42:32 +0200
Subject: [PATCH 2/2] Add LE/BE float/double encoding tests.
* testsuite/gas/riscv/float.s: New file.
* testsuite/gas/riscv/float-le.d: Likewise.
* testsuite/gas/riscv/float-be.d: Likewise.
* testsuite/gas/riscv/double.d: Likewise.
* testsuite/gas/riscv/double-le.d: Likewise.
* testsuite/gas/riscv/double-be.d: Likewise.
---
gas/testsuite/gas/riscv/double-be.d | 18 ++++++++++++++++++
gas/testsuite/gas/riscv/double-le.d | 18 ++++++++++++++++++
gas/testsuite/gas/riscv/double.s | 21 +++++++++++++++++++++
gas/testsuite/gas/riscv/float-be.d | 13 +++++++++++++
gas/testsuite/gas/riscv/float-le.d | 13 +++++++++++++
gas/testsuite/gas/riscv/float.s | 21 +++++++++++++++++++++
6 files changed, 104 insertions(+)
create mode 100644 gas/testsuite/gas/riscv/double-be.d
create mode 100644 gas/testsuite/gas/riscv/double-le.d
create mode 100755 gas/testsuite/gas/riscv/double.s
create mode 100644 gas/testsuite/gas/riscv/float-be.d
create mode 100644 gas/testsuite/gas/riscv/float-le.d
create mode 100755 gas/testsuite/gas/riscv/float.s
diff --git a/gas/testsuite/gas/riscv/double-be.d b/gas/testsuite/gas/riscv/double-be.d
new file mode 100644
index 00000000000..5f106e3b34f
--- /dev/null
+++ b/gas/testsuite/gas/riscv/double-be.d
@@ -0,0 +1,18 @@
+# source: double.s
+# objdump: -sj .data
+# as: -mbig-endian
+
+.*:[ ]+file format .*bigriscv
+
+Contents of section \.data:
+ 0000 40280000 00000000 3fbf7ced 916872b0.*
+ 0010 3f70624d d2f1a9fc 40effc00 00000000.*
+ 0020 3e700006 3fca1753 3f0ff80f 681f458d.*
+ 0030 3f0ffffa a19c4774 3ff00000 00000000.*
+ 0040 3ff00418 9374bc6a 7fffffff ffffffff.*
+ 0050 7ff00000 00000000 fff00000 00000000.*
+ 0060 00000000 00000000 80000000 00000000.*
+ 0070 bff00000 00000000 bfef9ad4 2c3c9eed.*
+ 0080 c0effc00 00000000 40080000 00000000.*
+ 0090 40280000 00000000 4080f8fb e76c8b44.*
+ 00a0 7e000000 00000000 7c010000 00000000.*
diff --git a/gas/testsuite/gas/riscv/double-le.d b/gas/testsuite/gas/riscv/double-le.d
new file mode 100644
index 00000000000..848b76d06ed
--- /dev/null
+++ b/gas/testsuite/gas/riscv/double-le.d
@@ -0,0 +1,18 @@
+# source: double.s
+# objdump: -sj .data
+# as: -mlittle-endian
+
+.*:[ ]+file format .*littleriscv
+
+Contents of section \.data:
+ 0000 00000000 00002840 b0726891 ed7cbf3f.*
+ 0010 fca9f1d2 4d62703f 00000000 00fcef40.*
+ 0020 5317ca3f 0600703e 8d451f68 0ff80f3f.*
+ 0030 74479ca1 faff0f3f 00000000 0000f03f.*
+ 0040 6abc7493 1804f03f ffffffff ffffff7f.*
+ 0050 00000000 0000f07f 00000000 0000f0ff.*
+ 0060 00000000 00000000 00000000 00000080.*
+ 0070 00000000 0000f0bf ed9e3c2c d49aefbf.*
+ 0080 00000000 00fcefc0 00000000 00000840.*
+ 0090 00000000 00002840 448b6ce7 fbf88040.*
+ 00a0 00000000 0000007e 00000000 0000017c.*
diff --git a/gas/testsuite/gas/riscv/double.s b/gas/testsuite/gas/riscv/double.s
new file mode 100755
index 00000000000..86d1f2f41e7
--- /dev/null
+++ b/gas/testsuite/gas/riscv/double.s
@@ -0,0 +1,21 @@
+.data
+ .double 12.0
+ .double 0.123
+ .double 0.004
+ .double 65504
+ .double 5.9605e-8
+ .double 6.0976e-5
+ .double 6.1035e-5
+ .double 1
+ .double 1.001
+ .double NaN
+ .double +Inf
+ .double -Inf
+ .double +0
+ .double -0
+ .double -1
+ .double -0.98765
+ .double -65504
+ .double 3.0, 12.0, 543.123
+ .double 0h:7e00 # qNaNh
+ .double 0h:7c01 # sNaNh
diff --git a/gas/testsuite/gas/riscv/float-be.d b/gas/testsuite/gas/riscv/float-be.d
new file mode 100644
index 00000000000..c7f3dcf39d1
--- /dev/null
+++ b/gas/testsuite/gas/riscv/float-be.d
@@ -0,0 +1,13 @@
+# source: float.s
+# objdump: -sj .data
+# as: -mbig-endian
+
+.*:[ ]+file format .*bigriscv
+
+Contents of section \.data:
+ 0000 41400000 3dfbe76d 3b83126f 477fe000.*
+ 0010 33800032 387fc07b 387fffd5 3f800000.*
+ 0020 3f8020c5 7fffffff 7f800000 ff800000.*
+ 0030 00000000 80000000 bf800000 bf7cd6a1.*
+ 0040 c77fe000 40400000 41400000 4407c7df.*
+ 0050 7e000000 7c010000.*
diff --git a/gas/testsuite/gas/riscv/float-le.d b/gas/testsuite/gas/riscv/float-le.d
new file mode 100644
index 00000000000..3aa2d45d017
--- /dev/null
+++ b/gas/testsuite/gas/riscv/float-le.d
@@ -0,0 +1,13 @@
+# source: float.s
+# objdump: -sj .data
+# as: -mlittle-endian
+
+.*:[ ]+file format .*littleriscv
+
+Contents of section \.data:
+ 0000 00004041 6de7fb3d 6f12833b 00e07f47.*
+ 0010 32008033 7bc07f38 d5ff7f38 0000803f.*
+ 0020 c520803f ffffff7f 0000807f 000080ff.*
+ 0030 00000000 00000080 000080bf a1d67cbf.*
+ 0040 00e07fc7 00004040 00004041 dfc70744.*
+ 0050 0000007e 0000017c.*
diff --git a/gas/testsuite/gas/riscv/float.s b/gas/testsuite/gas/riscv/float.s
new file mode 100755
index 00000000000..47c79c5b7e8
--- /dev/null
+++ b/gas/testsuite/gas/riscv/float.s
@@ -0,0 +1,21 @@
+.data
+ .float 12.0
+ .float 0.123
+ .float 0.004
+ .float 65504
+ .float 5.9605e-8
+ .float 6.0976e-5
+ .float 6.1035e-5
+ .float 1
+ .float 1.001
+ .float NaN
+ .float +Inf
+ .float -Inf
+ .float +0
+ .float -0
+ .float -1
+ .float -0.98765
+ .float -65504
+ .float 3.0, 12.0, 543.123
+ .float 0h:7e00 # qNaNh
+ .float 0h:7c01 # sNaNh
--
2.34.1
next reply other threads:[~2023-06-15 11:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 11:09 Branislav Brzak [this message]
2023-06-15 12:09 ` Jan Beulich
2023-06-15 12:14 ` Branislav Brzak
2023-06-16 0:38 ` Nelson Chu
2023-06-19 7:18 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM6PR03MB49843D0F7C0438ADEB19172E985BA@AM6PR03MB4984.eurprd03.prod.outlook.com \
--to=branislav.brzak@syrmia.com \
--cc=Djordje.Todorovic@syrmia.com \
--cc=Dragoslav.Sicarov@Syrmia.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).