public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Add testcase for testing li pseudo instruction
@ 2019-08-23  9:13 Kito Cheng
  2019-08-23 22:39 ` Jim Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Kito Cheng @ 2019-08-23  9:13 UTC (permalink / raw)
  To: gcc-patches, kito.cheng, jimw; +Cc: Kito Cheng

gcc/testsuite/ChangeLog:

	gcc.target/riscv/li.c: New test.
---
 gcc/testsuite/gcc.target/riscv/li.c | 36 +++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/riscv/li.c

diff --git a/gcc/testsuite/gcc.target/riscv/li.c b/gcc/testsuite/gcc.target/riscv/li.c
new file mode 100644
index 00000000000..fa5c02caee8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/li.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+#include <stdlib.h>
+#define LOAD_IMM(var, val) \
+        asm ("li %0, %1\n": "=r"(var): "i" (val))
+
+#define CHECK_LI(type, val) \
+  { \
+    type var; \
+    LOAD_IMM(var, val); \
+    if (var != val) \
+      abort(); \
+  }
+
+#define CHECK_LI32(val) CHECK_LI(int, val)
+#define CHECK_LI64(val) CHECK_LI(long long, val)
+
+int main()
+{
+  CHECK_LI32(0x8001);
+  CHECK_LI32(0x1f01);
+  CHECK_LI32(0x12345001);
+  CHECK_LI32(0xf2345001);
+#if __riscv_xlen == 64
+  CHECK_LI64(0x8001ll);
+  CHECK_LI64(0x1f01ll);
+  CHECK_LI64(0x12345001ll);
+  CHECK_LI64(0xf2345001ll);
+  CHECK_LI64(0xf12345001ll);
+  CHECK_LI64(0xff00ff00ff001f01ll);
+  CHECK_LI64(0x7ffffffff2345001ll);
+  CHECK_LI64(0x7f0f243ff2345001ll);
+  CHECK_LI64(0x1234567887654321ll);
+#endif
+  return 0;
+}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] RISC-V: Add testcase for testing li pseudo instruction
  2019-08-23  9:13 [PATCH] RISC-V: Add testcase for testing li pseudo instruction Kito Cheng
@ 2019-08-23 22:39 ` Jim Wilson
  2019-08-26  7:06   ` Kito Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Wilson @ 2019-08-23 22:39 UTC (permalink / raw)
  To: Kito Cheng; +Cc: GCC Patches, Kito Cheng

On Fri, Aug 23, 2019 at 12:13 AM Kito Cheng <kito.cheng@sifive.com> wrote:
> gcc/testsuite/ChangeLog:
>         gcc.target/riscv/li.c: New test.

Thanks.  This looks good.

This is incidentally a test for a new binutils patch that improves the
li macro to emit compressed instructions when possible.  We need an
execution test to verify it is right, and we can't easily put that in
binutils, so it is going here.

Jim

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] RISC-V: Add testcase for testing li pseudo instruction
  2019-08-23 22:39 ` Jim Wilson
@ 2019-08-26  7:06   ` Kito Cheng
  0 siblings, 0 replies; 3+ messages in thread
From: Kito Cheng @ 2019-08-26  7:06 UTC (permalink / raw)
  To: Jim Wilson; +Cc: GCC Patches, Kito Cheng

Committed as r274920


On Sat, Aug 24, 2019 at 6:08 AM Jim Wilson <jimw@sifive.com> wrote:
>
> On Fri, Aug 23, 2019 at 12:13 AM Kito Cheng <kito.cheng@sifive.com> wrote:
> > gcc/testsuite/ChangeLog:
> >         gcc.target/riscv/li.c: New test.
>
> Thanks.  This looks good.
>
> This is incidentally a test for a new binutils patch that improves the
> li macro to emit compressed instructions when possible.  We need an
> execution test to verify it is right, and we can't easily put that in
> binutils, so it is going here.
>
> Jim

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-26  2:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-23  9:13 [PATCH] RISC-V: Add testcase for testing li pseudo instruction Kito Cheng
2019-08-23 22:39 ` Jim Wilson
2019-08-26  7:06   ` Kito Cheng

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).