diff options
| -rw-r--r-- | test/mono/nonlinearpat.sail | 17 | ||||
| -rw-r--r-- | test/mono/pass/nonlinearpat | 1 | ||||
| -rw-r--r-- | test/mono/pass/union_split | 1 | ||||
| -rw-r--r-- | test/mono/union_split.sail | 23 |
4 files changed, 42 insertions, 0 deletions
diff --git a/test/mono/nonlinearpat.sail b/test/mono/nonlinearpat.sail new file mode 100644 index 00000000..e0aaeff3 --- /dev/null +++ b/test/mono/nonlinearpat.sail @@ -0,0 +1,17 @@ +default Order dec +$include <prelude.sail> + +val test : forall 'n, 'n in {8,16}. (int('n),int('n),bits(1)) -> bits(64) effect pure + +function test(x,y,b) = { + let 'z = x + y in + let v : bits('z) = sail_zero_extend(b,z) in + sail_zero_extend(v,64) +} + +val run : unit -> unit effect {escape} + +function run () = { + assert(test(8,8,0b0) == 0x0000000000000000); + assert(test(16,16,0b1) == 0x0000000000000001); +} diff --git a/test/mono/pass/nonlinearpat b/test/mono/pass/nonlinearpat new file mode 100644 index 00000000..3f235d60 --- /dev/null +++ b/test/mono/pass/nonlinearpat @@ -0,0 +1 @@ +nonlinearpat.sail -auto_mono diff --git a/test/mono/pass/union_split b/test/mono/pass/union_split new file mode 100644 index 00000000..cdd2763d --- /dev/null +++ b/test/mono/pass/union_split @@ -0,0 +1 @@ +union_split.sail -auto_mono diff --git a/test/mono/union_split.sail b/test/mono/union_split.sail new file mode 100644 index 00000000..2403e644 --- /dev/null +++ b/test/mono/union_split.sail @@ -0,0 +1,23 @@ +default Order dec +$include <prelude.sail> + +/* Simple case split example on a variant datatype */ + +union ast = { + SomeOp : {'n, 'n in {8,16}. (int('n),bits('n))} +} + +val execute : ast -> bits(32) + +function execute(SomeOp(n as int('n),v)) = { + a : bits('n) = sail_zero_extend(0x12,n); + b : bits('n) = and_vec(v, a); + sail_zero_extend(b,32) +} + +val run : unit -> unit effect {escape} + +function run () = { + assert(execute(SomeOp(8,0x11)) == 0x00000010); + assert(execute(SomeOp(16,0x3333)) == 0x00000012); +} |
