From ea4a14c7a4943498f49c26824d68a8d4776c5ddc Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 14 Apr 2019 12:28:14 -0700 Subject: Initial support for loading/storing bit-fields --- tests/bitfield-load-signed.c | 7 +++++++ tests/bitfield-load-signed.qbe | 14 ++++++++++++++ tests/bitfield-load-unsigned.c | 7 +++++++ tests/bitfield-load-unsigned.qbe | 14 ++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 tests/bitfield-load-signed.c create mode 100644 tests/bitfield-load-signed.qbe create mode 100644 tests/bitfield-load-unsigned.c create mode 100644 tests/bitfield-load-unsigned.qbe (limited to 'tests') diff --git a/tests/bitfield-load-signed.c b/tests/bitfield-load-signed.c new file mode 100644 index 0000000..837ad24 --- /dev/null +++ b/tests/bitfield-load-signed.c @@ -0,0 +1,7 @@ +struct { + signed : 4, x : 15, : 13; +} s; + +void f(void) { + s.x; +} diff --git a/tests/bitfield-load-signed.qbe b/tests/bitfield-load-signed.qbe new file mode 100644 index 0000000..bc3f457 --- /dev/null +++ b/tests/bitfield-load-signed.qbe @@ -0,0 +1,14 @@ +export +function $f() { +@start.1 +@body.2 + %.1 =l copy $s + %.2 =l mul 0, 1 + %.3 =l add %.1, %.2 + %.4 =l copy %.3 + %.5 =w loadsw %.4 + %.6 =w shl %.5, 13 + %.7 =w sar %.6, 17 + ret +} +export data $s = align 4 { z 4 } diff --git a/tests/bitfield-load-unsigned.c b/tests/bitfield-load-unsigned.c new file mode 100644 index 0000000..5a9e5fa --- /dev/null +++ b/tests/bitfield-load-unsigned.c @@ -0,0 +1,7 @@ +struct { + unsigned : 4, x : 15, : 13; +} s; + +void f(void) { + s.x; +} diff --git a/tests/bitfield-load-unsigned.qbe b/tests/bitfield-load-unsigned.qbe new file mode 100644 index 0000000..c4ea94b --- /dev/null +++ b/tests/bitfield-load-unsigned.qbe @@ -0,0 +1,14 @@ +export +function $f() { +@start.1 +@body.2 + %.1 =l copy $s + %.2 =l mul 0, 1 + %.3 =l add %.1, %.2 + %.4 =l copy %.3 + %.5 =w loaduw %.4 + %.6 =w shl %.5, 13 + %.7 =w shr %.6, 17 + ret +} +export data $s = align 4 { z 4 } -- cgit v1.2.3