summaryrefslogtreecommitdiff
path: root/test/c
diff options
context:
space:
mode:
authorAlasdair2019-03-05 03:09:16 +0000
committerAlasdair2019-03-05 03:09:16 +0000
commit8718a39778d4c673ceea1c7f9bb219b29788ebae (patch)
treebb1bbb4a90fa1332e6c6736e99177934ca0dfdab /test/c
parent15872b4c48d932a920ea6d22b69889ff32f6a446 (diff)
Additional optimizations for C compilation
Diffstat (limited to 'test/c')
-rw-r--r--test/c/extend_simple.expect2
-rw-r--r--test/c/extend_simple.sail10
-rw-r--r--test/c/fast_signed.expect12
-rw-r--r--test/c/fast_signed.sail30
4 files changed, 54 insertions, 0 deletions
diff --git a/test/c/extend_simple.expect b/test/c/extend_simple.expect
new file mode 100644
index 00000000..3a652eaf
--- /dev/null
+++ b/test/c/extend_simple.expect
@@ -0,0 +1,2 @@
+x = 0xFFFFFFFF
+y = 0x00000000FFFFFFFF
diff --git a/test/c/extend_simple.sail b/test/c/extend_simple.sail
new file mode 100644
index 00000000..23f14235
--- /dev/null
+++ b/test/c/extend_simple.sail
@@ -0,0 +1,10 @@
+default Order dec
+
+$include <prelude.sail>
+
+function main((): unit) -> unit = {
+ let x = sail_sign_extend(0xFF, 32);
+ let y = sail_zero_extend(x, 64);
+ print_bits("x = ", x);
+ print_bits("y = ", y)
+} \ No newline at end of file
diff --git a/test/c/fast_signed.expect b/test/c/fast_signed.expect
new file mode 100644
index 00000000..9fcfea23
--- /dev/null
+++ b/test/c/fast_signed.expect
@@ -0,0 +1,12 @@
+x = -1
+y = -1
+z = -1
+w = -1
+x = -128
+y = -32768
+z = -9223372036854775808
+w = -170141183460469231731687303715884105728
+x = 127
+y = 32767
+z = 9223372036854775807
+w = 170141183460469231731687303715884105727
diff --git a/test/c/fast_signed.sail b/test/c/fast_signed.sail
new file mode 100644
index 00000000..b0f16f89
--- /dev/null
+++ b/test/c/fast_signed.sail
@@ -0,0 +1,30 @@
+default Order dec
+
+$include <prelude.sail>
+
+function main((): unit) -> unit = {
+ let x = signed(0xFF);
+ let y = signed(0xFFFF);
+ let z = signed(0xFFFFFFFF_FFFFFFFF);
+ let w = signed(0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF);
+ print_int("x = ", x);
+ print_int("y = ", y);
+ print_int("z = ", z);
+ print_int("w = ", w);
+ let x = signed(0x80);
+ let y = signed(0x8000);
+ let z = signed(0x80000000_00000000);
+ let w = signed(0x80000000_00000000_00000000_00000000);
+ print_int("x = ", x);
+ print_int("y = ", y);
+ print_int("z = ", z);
+ print_int("w = ", w);
+ let x = signed(0x7F);
+ let y = signed(0x7FFF);
+ let z = signed(0x7FFFFFFF_FFFFFFFF);
+ let w = signed(0x7FFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF);
+ print_int("x = ", x);
+ print_int("y = ", y);
+ print_int("z = ", z);
+ print_int("w = ", w);
+} \ No newline at end of file