From: Paul Iannetta <piannetta@kalrayinc.com>
To: binutils@sourceware.org
Cc: Paul Iannetta <piannetta@kalrayinc.com>
Subject: [PATCH 1/7] kvx: gas: fix the detection of negative powers of 2
Date: Fri, 16 Feb 2024 17:42:15 +0100 [thread overview]
Message-ID: <20240216164221.24165-2-piannetta@kalrayinc.com> (raw)
In-Reply-To: <20240216164221.24165-1-piannetta@kalrayinc.com>
The detection of negative powers of 2 was wrong and could lead to
well-formed bundles ending up taking more syllables than necessary.
gas/ChangeLog:
* config/kvx-parse.c (get_token_class): Use the signed value.
* testsuite/gas/kvx/np2-detection.d: New test.
* testsuite/gas/kvx/np2-detection.s: New test.
---
gas/config/kvx-parse.c | 2 +-
gas/testsuite/gas/kvx/np2-detection.d | 14 ++++++++++++++
gas/testsuite/gas/kvx/np2-detection.s | 5 +++++
3 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 gas/testsuite/gas/kvx/np2-detection.d
create mode 100644 gas/testsuite/gas/kvx/np2-detection.s
diff --git a/gas/config/kvx-parse.c b/gas/config/kvx-parse.c
index 5cfb1fb676c..0825b182319 100644
--- a/gas/config/kvx-parse.c
+++ b/gas/config/kvx-parse.c
@@ -525,7 +525,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_
: strtoull (tok + (tok[0] == '-') + (tok[0] == '+'), NULL, 0));
int64_t val = uval;
int64_t pval = val < 0 ? -uval : uval;
- int neg_power2_p = val < 0 && !(uval & (uval - 1));
+ int neg_power2_p = val < 0 && !(pval & (pval - 1));
unsigned len = pval ? 8 * sizeof (pval) - __builtin_clzll (pval) : 0;
while (class[cur].class_id != -1
&& ((unsigned) (class[cur].sz < 0
diff --git a/gas/testsuite/gas/kvx/np2-detection.d b/gas/testsuite/gas/kvx/np2-detection.d
new file mode 100644
index 00000000000..b612277f6fd
--- /dev/null
+++ b/gas/testsuite/gas/kvx/np2-detection.d
@@ -0,0 +1,14 @@
+#as: -march=kv3-1
+#source: np2-detection.s
+#objdump: -d
+
+.*\/np2-detection.o: file format elf64-kvx
+
+
+Disassembly of section .text:
+
+0000000000000000 <.text>:
+ 0: 00 80 00 e1 addd \$r0 = \$r0, -512 \(0xfffffe00\)
+ 4: 00 00 00 e0 make \$r0 = 0 \(0x0\)
+ 8: c0 ff 00 e0 c0 ff 00 e0 ff ff df 97 make \$r0 = 9223372034707292159 \(0x7fffffff7fffffff\)
+ 14: ff ff ff 93 ff ff df 9f ff ff ff 1b make \$r0 = 9223372034707292159 \(0x7fffffff7fffffff\);;
diff --git a/gas/testsuite/gas/kvx/np2-detection.s b/gas/testsuite/gas/kvx/np2-detection.s
new file mode 100644
index 00000000000..dfc3c264101
--- /dev/null
+++ b/gas/testsuite/gas/kvx/np2-detection.s
@@ -0,0 +1,5 @@
+ addd $r0 = $r0, -512
+ make $r0 = 0x7fffffff7fffffff
+ make $r0 = 0x7fffffff7fffffff
+ make $r0 = 0
+;;
--
2.35.1.500.gb896f729e2
next prev parent reply other threads:[~2024-02-16 16:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 16:42 [PATCH 0/7] kvx: Miscellaneous changes since last August Paul Iannetta
2024-02-16 16:42 ` Paul Iannetta [this message]
2024-02-16 16:42 ` [PATCH 2/7] kvx: Improve lexing & parsing Paul Iannetta
2024-02-16 16:42 ` [PATCH 3/7] kvx: gas: fix leak Paul Iannetta
2024-02-16 16:42 ` [PATCH 4/7] kvx: gas: move the splat modifier to the immediate Paul Iannetta
2024-02-16 16:42 ` [PATCH 5/7] kvx: gas: rename: or -> ior, xor -> eor Paul Iannetta
2024-02-16 16:42 ` [PATCH 6/7] kvx: enable magic immediates for integer multiply-accumulate and CMOVE* Paul Iannetta
2024-02-16 16:42 ` [PATCH 7/7] kvx: gas: missing aliases for $r14r15 in assembler Paul Iannetta
2024-02-19 11:35 ` [PATCH 0/7] kvx: Miscellaneous changes since last August Nick Clifton
2024-02-20 11:03 ` Paul Iannetta
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=20240216164221.24165-2-piannetta@kalrayinc.com \
--to=piannetta@kalrayinc.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).