From e7e55966cb50b4f5b8b05d6d484b5cda8bcf2a3e Mon Sep 17 00:00:00 2001 From: pcpa Date: Thu, 6 Dec 2012 10:00:30 -0200 Subject: [PATCH] Add new ldst variant test cases to check base/index register clobber. * check/ldstr-c.ok, check/ldstr-c.tst, check/ldstxi-c.ok, check/ldstxi-c.tst, check/ldstxr-c.ok, check/ldstxr-c.tst: New test case files testing load clobbering the base and/or index register; * check/ldst.inc: New file with common definition for all the ldst* test cases. check/Makefile.am, check/ldsti.tst, check/ldstr.tst, check/ldstxi.tst, check/ldstxr.tst: Update for new common definitions file and new register clobber ldst tests. --- ChangeLog | 14 +++ check/Makefile.am | 12 ++- check/ldst.inc | 101 +++++++++++++++++++++ check/ldsti.tst | 101 +-------------------- check/ldstr-c.ok | 1 + check/ldstr-c.tst | 157 ++++++++++++++++++++++++++++++++ check/ldstr.tst | 113 +---------------------- check/ldstxi-c.ok | 1 + check/ldstxi-c.tst | 160 ++++++++++++++++++++++++++++++++ check/ldstxi.tst | 113 +---------------------- check/ldstxr-c.ok | 1 + check/ldstxr-c.tst | 221 +++++++++++++++++++++++++++++++++++++++++++++ check/ldstxr.tst | 113 +---------------------- 13 files changed, 682 insertions(+), 426 deletions(-) create mode 100644 check/ldst.inc create mode 100644 check/ldstr-c.ok create mode 100644 check/ldstr-c.tst create mode 100644 check/ldstxi-c.ok create mode 100644 check/ldstxi-c.tst create mode 100644 check/ldstxr-c.ok create mode 100644 check/ldstxr-c.tst diff --git a/ChangeLog b/ChangeLog index f5b3a7c03..18c41062c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2012-12-05 Paulo Andrade + + * check/ldstr-c.ok, check/ldstr-c.tst, check/ldstxi-c.ok, + check/ldstxi-c.tst, check/ldstxr-c.ok, check/ldstxr-c.tst: + New test case files testing load clobbering the base and/or + index register; + + * check/ldst.inc: New file with common definition for all the + ldst* test cases. + + check/Makefile.am, check/ldsti.tst, check/ldstr.tst, + check/ldstxi.tst, check/ldstxr.tst: Update for new common + definitions file and new register clobber ldst tests. + 2012-12-05 Paulo Andrade * lib/jit_mips-fpu.c: Correct wrong register order in stxr_{f,d} diff --git a/check/Makefile.am b/check/Makefile.am index c380279be..0292d4d7c 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -32,14 +32,22 @@ EXTRA_DIST = \ divi.tst divi.ok \ fib.tst fib.ok \ rpn.tst rpn.ok \ + ldst.inc \ ldstr.tst ldstr.ok \ ldsti.tst ldsti.ok \ - ldstxi.tst ldstxi.ok \ ldstxr.tst ldstxr.ok \ + ldstxi.tst ldstxi.ok \ + ldstr-c.tst ldstr-c.ok \ + ldstxr-c.tst ldstxr-c.ok \ + ldstxi-c.tst ldstxi-c.ok \ check.sh run-test \ all.tst -TESTS = 3to2 add allocai bp divi fib rpn ldstr ldsti ldstxi ldstxr +TESTS = 3to2 add allocai \ + bp divi fib rpn \ + ldstr ldsti \ + ldstxr ldstxi \ + ldstr-c ldstxr-c ldstxi-c CLEANFILES = $(TESTS) diff --git a/check/ldst.inc b/check/ldst.inc new file mode 100644 index 000000000..51eb2a47f --- /dev/null +++ b/check/ldst.inc @@ -0,0 +1,101 @@ +#if __WORDSIZE == 64 +# define L0 0x8000000000000001 +# define LL0 L0 +# define LC0 0xffffffffffffff81 +# define LS0 0xffffffffffff8001 +# define LI0 0xffffffff80000001 +# define L1 0x8000000000000000 +# define LL1 L1 +# define LC1 0xffffffffffffff80 +# define LS1 0xffffffffffff8000 +# define LI1 0xffffffff80000000 +# define L2 0x7fffffffffffffff +# define LL2 L2 +# define LC2 0x000000000000007f +# define LS2 0x0000000000007fff +# define LI2 0x000000007fffffff +# define L3 0xffffffffffffffff +# define LL3 L3 +# define LC3 0xffffffffffffffff +# define LS3 0xffffffffffffffff +# define LI3 0xffffffffffffffff +# define XC LC0 +# define XS LS0 +# define XI LI0 +#else +# define XC IC0 +# define XS IS0 +# define XI II0 +#endif +#define I0 0x80000001 +#define II0 I0 +#define IC0 0xffffff81 +#define IS0 0xffff8001 +#define I1 0x80000000 +#define II1 I1 +#define IC1 0xffffff80 +#define IS1 0xffff8000 +#define I2 0x7fffffff +#define II2 I2 +#define IC2 0x0000007f +#define IS2 0x00007fff +#define I3 0xffffffff +#define II3 I3 +#define IC3 0xffffffff +#define IS3 0xffffffff +#define S0 0x8001 +#define S1 0x8000 +#define S2 0x7fff +#define S3 0xffff +#define C0 0x81 +#define C1 0x80 +#define C2 0x7f +#define C3 0xff +#define F0 0.25 +#define F1 0.75 +#define F2 -0.25 +#define F3 -0.75 +#define D0 0.25 +#define D1 0.75 +#define D2 -0.25 +#define D3 -0.75 + +.data 512 +ok: +.c "ok\n" +t0: +c0: +.c 0 +uc0: +.c 0 +s0: +.s 0 +us0: +.s 0 +.align 4 +i0: +.i 0 +#if __WORDSIZE == 64 +ui0: +.i 0 +.align 8 +l0: +.l 0 +#endif +f0: +.f 0 +.align 8 +d0: +.d 0 + +. $($offc = c0 - t0) +. $($offuc = uc0 - t0) +. $($offs = s0 - t0) +. $($offus = us0 - t0) +. $($offi = i0 - t0) +#if __WORDSIZE == 64 +. $($offui = ui0 - t0) +. $($offl = l0 - t0) +#endif +. $($offf = f0 - t0) +. $($offd = d0 - t0) diff --git a/check/ldsti.tst b/check/ldsti.tst index 120e16a4a..3fd7f31e9 100644 --- a/check/ldsti.tst +++ b/check/ldsti.tst @@ -1,85 +1,4 @@ -#if __WORDSIZE == 64 -# define L0 0x8000000000000001 -# define LL0 L0 -# define LC0 0xffffffffffffff81 -# define LS0 0xffffffffffff8001 -# define LI0 0xffffffff80000001 -# define L1 0x8000000000000000 -# define LL1 L1 -# define LC1 0xffffffffffffff80 -# define LS1 0xffffffffffff8000 -# define LI1 0xffffffff80000000 -# define L2 0x7fffffffffffffff -# define LL2 L2 -# define LC2 0x000000000000007f -# define LS2 0x0000000000007fff -# define LI2 0x000000007fffffff -# define L3 0xffffffffffffffff -# define LL3 L3 -# define LC3 0xffffffffffffffff -# define LS3 0xffffffffffffffff -# define LI3 0xffffffffffffffff -#endif -#define I0 0x80000001 -#define II0 I0 -#define IC0 0xffffff81 -#define IS0 0xffff8001 -#define I1 0x80000000 -#define II1 I1 -#define IC1 0xffffff80 -#define IS1 0xffff8000 -#define I2 0x7fffffff -#define II2 I2 -#define IC2 0x0000007f -#define IS2 0x00007fff -#define I3 0xffffffff -#define II3 I3 -#define IC3 0xffffffff -#define IS3 0xffffffff -#define S0 0x8001 -#define S1 0x8000 -#define S2 0x7fff -#define S3 0xffff -#define C0 0x81 -#define C1 0x80 -#define C2 0x7f -#define C3 0xff -#define F0 0.25 -#define F1 0.75 -#define F2 -0.25 -#define F3 -0.75 -#define D0 0.25 -#define D1 0.75 -#define D2 -0.25 -#define D3 -0.75 - -.data 512 -ok: -.c "ok\n" -t0: -c0: -.c 0 -uc0: -.c 0 -s0: -.s 0 -us0: -.s 0 -.align 4 -i0: -.i 0 -#if __WORDSIZE == 64 -ui0: -.i 0 -.align 8 -l0: -.l 0 -#endif -f0: -.f 0 -.align 8 -d0: -.d 0 +#include "ldst.inc" #if __WORDSIZE == 64 # define LDSTL(N, R0) \ @@ -182,11 +101,7 @@ main: movi_d %f0 0.25 sti_d d0 %f0 ldi_c %r1 c0 -#if __WORDSIZE == 32 - beqi Lc %r1 0xffffff81 -#else - beqi Lc %r1 0xffffffffffffff81 -#endif + beqi Lc %r1 XC calli @abort Lc: ldi_uc %r1 uc0 @@ -194,11 +109,7 @@ Lc: calli @abort Luc: ldi_s %r1 s0 -#if __WORDSIZE == 32 - beqi Ls %r1 0xffff8001 -#else - beqi Ls %r1 0xffffffffffff8001 -#endif + beqi Ls %r1 XS calli @abort Ls: ldi_us %r1 us0 @@ -206,11 +117,7 @@ Ls: calli @abort Lus: ldi_i %r1 i0 -#if __WORDSIZE == 32 - beqi Li %r1 0x80000001 -#else - beqi Li %r1 0xffffffff80000001 -#endif + beqi Li %r1 XI calli @abort Li: #if __WORDSIZE == 64 diff --git a/check/ldstr-c.ok b/check/ldstr-c.ok new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/check/ldstr-c.ok @@ -0,0 +1 @@ +ok diff --git a/check/ldstr-c.tst b/check/ldstr-c.tst new file mode 100644 index 000000000..6644f9830 --- /dev/null +++ b/check/ldstr-c.tst @@ -0,0 +1,157 @@ +#include "ldst.inc" + +#if __WORDSIZE == 64 +# define LDSTL(N, R0, R1) \ + movi %R0 $(t0 + $offui) \ + str_i %R0 %R1 \ + movi %R0 $(t0 + $offl) \ + movi %R1 L##N \ + str_l %R0 %R1 + +# define SI(C, N, x, X, R0) \ + movi %R0 $(t0 + $off##x) \ + ldr_##x %R0 %R0 \ + beqi L##x##C %R0 L##X##N \ + calli @abort \ +L##x##C: + +# define LDRL(C, N, R0, R1) \ + UI(C, N, i, I, R0) \ + SI(C, N, l, L, R0) +#else +# define LDSTL(C, R0, R1) +# define SI(C, N, x, X, R0) \ + movi %R0 $(t0 + $off##x) \ + ldr_##x %R0 %R0 \ + beqi L##x##C %R0 I##X##N \ + calli @abort \ +L##x##C: + +# define LDRL(C, N, R0, R1) + +#endif + +#define UI(C, N, x, X, R0) \ + movi %R0 $(t0 + $offu##x) \ + ldr_u##x %R0 %R0 \ + beqi Lu##x##C %R0 X##N \ + calli @abort \ +Lu##x##C: + +#define LDST1(X, N, R0, R1) \ + movi %R0 $(t0 + $offc) \ + movi %R1 C##N \ + str_c %R0 %R1 \ + movi %R0 $(t0 + $offuc) \ + str_c %R0 %R1 \ + movi %R0 $(t0 + $offs) \ + movi %R1 S##N \ + str_s %R0 %R1 \ + movi %R0 $(t0 + $offus) \ + str_s %R0 %R1 \ + movi %R0 $(t0 + $offi) \ + movi %R1 I##N \ + str_i %R0 %R1 \ + LDSTL(N, R0, R1) \ + movi %R0 $(t0 + $offf) \ + SI(X, N, c, C, R0) \ + UI(X, N, c, C, R0) \ + SI(X, N, s, S, R0) \ + UI(X, N, s, S, R0) \ + SI(X, N, i, I, R0) \ + LDRL(X, N, R0, R1) \ + +#define LDST0(R0, R1) \ + LDST1(0_##R0##_##R1, 0, R0, R1) \ + LDST1(1_##R0##_##R1, 1, R0, R1) \ + LDST1(2_##R0##_##R1, 2, R0, R1) \ + LDST1(3_##R0##_##R1, 3, R0, R1) + +#define LDST(V0, V1, V2, R0, R1, R2) \ + LDST0(V0, V1) \ + LDST0(V0, V2) \ + LDST0(V0, R0) \ + LDST0(V0, R1) \ + LDST0(V0, R2) \ + LDST0(V1, V0) \ + LDST0(V1, V2) \ + LDST0(V1, R0) \ + LDST0(V1, R1) \ + LDST0(V1, R2) \ + LDST0(V2, R0) \ + LDST0(V2, R1) \ + LDST0(V2, R2) + +.code + jmpi main + +main: + prolog + + /* Simple test to simplify validating encodings before + * brute force tests */ + movi %r0 $(t0 + $offc) + movi %r1 0x81 + str_c %r0 %r1 + movi %r0 $(t0 + $offuc) + str_c %r0 %r1 + movi %r0 $(t0 + $offs) + movi %r1 0x8001 + str_s %r0 %r1 + movi %r0 $(t0 + $offus) + str_s %r0 %r1 + movi %r0 $(t0 + $offi) + movi %r1 0x80000001 + str_i %r0 %r1 +#if __WORDSIZE == 64 + movi %r0 $(t0 + $offui) + str_i %r0 %r1 + movi %r0 $(t0 + $offl) + movi %r1 0x8000000000000001 + str_l %r0 %r1 +#endif + movi %r0 $(t0 + $offc) + ldr_c %r0 %r0 + beqi Lc %r0 XC + calli @abort +Lc: + movi %r0 $(t0 + $offuc) + ldr_uc %r0 %r0 + beqi Luc %r0 0x81 + calli @abort +Luc: + movi %r0 $(t0 + $offs) + ldr_s %r0 %r0 + beqi Ls %r0 XS + calli @abort +Ls: + movi %r0 $(t0 + $offus) + ldr_us %r0 %r0 + beqi Lus %r0 0x8001 + calli @abort +Lus: + movi %r0 $(t0 + $offi) + ldr_i %r0 %r0 + beqi Li %r0 XI + calli @abort +Li: +#if __WORDSIZE == 64 + movi %r0 $(t0 + $offui) + ldr_ui %r0 %r0 + beqi Lui %r0 0x80000001 + calli @abort +Lui: + movi %r0 $(t0 + $offl) + ldr_l %r0 %r0 + beqi Ll %r0 0x8000000000000001 + calli @abort +Ll: +#endif + + LDST(v0, v1, v2, r0, r1, r2) + // just to know did not abort + prepare 1 + pushargi ok + finishi @printf + ret + epilog diff --git a/check/ldstr.tst b/check/ldstr.tst index 5ab255d2f..2b9fd0dd1 100644 --- a/check/ldstr.tst +++ b/check/ldstr.tst @@ -1,97 +1,4 @@ -#if __WORDSIZE == 64 -# define L0 0x8000000000000001 -# define LL0 L0 -# define LC0 0xffffffffffffff81 -# define LS0 0xffffffffffff8001 -# define LI0 0xffffffff80000001 -# define L1 0x8000000000000000 -# define LL1 L1 -# define LC1 0xffffffffffffff80 -# define LS1 0xffffffffffff8000 -# define LI1 0xffffffff80000000 -# define L2 0x7fffffffffffffff -# define LL2 L2 -# define LC2 0x000000000000007f -# define LS2 0x0000000000007fff -# define LI2 0x000000007fffffff -# define L3 0xffffffffffffffff -# define LL3 L3 -# define LC3 0xffffffffffffffff -# define LS3 0xffffffffffffffff -# define LI3 0xffffffffffffffff -#endif -#define I0 0x80000001 -#define II0 I0 -#define IC0 0xffffff81 -#define IS0 0xffff8001 -#define I1 0x80000000 -#define II1 I1 -#define IC1 0xffffff80 -#define IS1 0xffff8000 -#define I2 0x7fffffff -#define II2 I2 -#define IC2 0x0000007f -#define IS2 0x00007fff -#define I3 0xffffffff -#define II3 I3 -#define IC3 0xffffffff -#define IS3 0xffffffff -#define S0 0x8001 -#define S1 0x8000 -#define S2 0x7fff -#define S3 0xffff -#define C0 0x81 -#define C1 0x80 -#define C2 0x7f -#define C3 0xff -#define F0 0.25 -#define F1 0.75 -#define F2 -0.25 -#define F3 -0.75 -#define D0 0.25 -#define D1 0.75 -#define D2 -0.25 -#define D3 -0.75 - -.data 512 -ok: -.c "ok\n" -t0: -c0: -.c 0 -uc0: -.c 0 -s0: -.s 0 -us0: -.s 0 -.align 4 -i0: -.i 0 -#if __WORDSIZE == 64 -ui0: -.i 0 -.align 8 -l0: -.l 0 -#endif -f0: -.f 0 -.align 8 -d0: -.d 0 - -. $($offc = c0 - t0) -. $($offuc = uc0 - t0) -. $($offs = s0 - t0) -. $($offus = us0 - t0) -. $($offi = i0 - t0) -#if __WORDSIZE == 64 -. $($offui = ui0 - t0) -. $($offl = l0 - t0) -#endif -. $($offf = f0 - t0) -. $($offd = d0 - t0) +#include "ldst.inc" #if __WORDSIZE == 64 # define LDSTL(N, R0, R1) \ @@ -223,11 +130,7 @@ main: str_d %r0 %f0 movi %r0 $(t0 + $offc) ldr_c %r1 %r0 -#if __WORDSIZE == 32 - beqi Lc %r1 0xffffff81 -#else - beqi Lc %r1 0xffffffffffffff81 -#endif + beqi Lc %r1 XC calli @abort Lc: movi %r0 $(t0 + $offuc) @@ -237,11 +140,7 @@ Lc: Luc: movi %r0 $(t0 + $offs) ldr_s %r1 %r0 -#if __WORDSIZE == 32 - beqi Ls %r1 0xffff8001 -#else - beqi Ls %r1 0xffffffffffff8001 -#endif + beqi Ls %r1 XS calli @abort Ls: movi %r0 $(t0 + $offus) @@ -251,11 +150,7 @@ Ls: Lus: movi %r0 $(t0 + $offi) ldr_i %r1 %r0 -#if __WORDSIZE == 32 - beqi Li %r1 0x80000001 -#else - beqi Li %r1 0xffffffff80000001 -#endif + beqi Li %r1 XI calli @abort Li: #if __WORDSIZE == 64 diff --git a/check/ldstxi-c.ok b/check/ldstxi-c.ok new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/check/ldstxi-c.ok @@ -0,0 +1 @@ +ok diff --git a/check/ldstxi-c.tst b/check/ldstxi-c.tst new file mode 100644 index 000000000..7951a6068 --- /dev/null +++ b/check/ldstxi-c.tst @@ -0,0 +1,160 @@ +#include "ldst.inc" + +#if __WORDSIZE == 64 +# define LDSTL(N, R0, R1) \ + stxi_i $offui %R0 %R1 \ + movi %R1 L##N \ + stxi_l $offl %R0 %R1 + +# define SI(C, N, x, X, R0) \ + ldxi_##x %R0 %R0 $off##x \ + beqi L##x##C %R0 L##X##N \ + calli @abort \ +L##x##C: + +# define LDRL(C, N, R0, R1) \ + UI(C, N, i, I, R0) \ + movi %R0 t0 \ + SI(C, N, l, L, R0) +#else +# define LDSTL(C, R0, R1) +# define SI(C, N, x, X, R0) \ + ldxi_##x %R0 %R0 $off##x \ + beqi L##x##C %R0 I##X##N \ + calli @abort \ +L##x##C: + +# define LDRL(C, N, R0, R1) + +#endif + +#define UI(C, N, x, X, R0) \ + ldxi_u##x %R0 %R0 $offu##x \ + beqi Lu##x##C %R0 X##N \ + calli @abort \ +Lu##x##C: + +#define LDST1(X, N, R0, R1) \ + movi %R0 t0 \ + movi %R1 C##N \ + stxi_c $offc %R0 %R1 \ + stxi_c $offuc %R0 %R1 \ + movi %R1 S##N \ + stxi_s $offs %R0 %R1 \ + stxi_s $offus %R0 %R1 \ + movi %R1 I##N \ + stxi_i $offi %R0 %R1 \ + LDSTL(N, R0, R1) \ + SI(X, N, c, C, R0) \ + movi %R0 t0 \ + UI(X, N, c, C, R0) \ + movi %R0 t0 \ + SI(X, N, s, S, R0) \ + movi %R0 t0 \ + UI(X, N, s, S, R0) \ + movi %R0 t0 \ + SI(X, N, i, I, R0) \ + movi %R0 t0 \ + LDRL(X, N, R0, R1) \ + +#define LDST0(R0, R1) \ + LDST1(0_##R0##_##R1, 0, R0, R1) \ + LDST1(1_##R0##_##R1, 1, R0, R1) \ + LDST1(2_##R0##_##R1, 2, R0, R1) \ + LDST1(3_##R0##_##R1, 3, R0, R1) + +#define LDST(V0, V1, V2, R0, R1, R2) \ + LDST0(V0, V1) \ + LDST0(V0, V2) \ + LDST0(V0, R0) \ + LDST0(V0, R1) \ + LDST0(V0, R2) \ + LDST0(V1, V2) \ + LDST0(V1, R0) \ + LDST0(V1, R1) \ + LDST0(V1, R2) \ + LDST0(V2, R0) \ + LDST0(V2, R1) \ + LDST0(V2, R2) \ + LDST0(R0, V0) \ + LDST0(R0, V1) \ + LDST0(R0, V2) \ + LDST0(R0, R1) \ + LDST0(R0, R2) \ + LDST0(R1, V0) \ + LDST0(R1, V1) \ + LDST0(R1, V2) \ + LDST0(R1, R0) \ + LDST0(R1, R2) \ + LDST0(R2, V0) \ + LDST0(R2, V1) \ + LDST0(R2, V2) \ + LDST0(R2, R0) \ + LDST0(R2, R1) + +.code + jmpi main + +main: + prolog + + /* Simple test to simplify validating encodings before + * brute force tests */ + movi %r0 t0 + movi %r1 0x81 + stxi_c $offc %r0 %r1 + stxi_c $offuc %r0 %r1 + movi %r1 0x8001 + stxi_s $offs %r0 %r1 + stxi_s $offus %r0 %r1 + movi %r1 0x80000001 + stxi_i $offi %r0 %r1 +#if __WORDSIZE == 64 + stxi_i $offui %r0 %r1 + movi %r1 0x8000000000000001 + stxi_l $offl %r0 %r1 +#endif + ldxi_c %r0 %r0 $offc + beqi Lc %r0 XC + calli @abort +Lc: + movi %r0 t0 + ldxi_uc %r0 %r0 $offuc + beqi Luc %r0 0x81 + calli @abort +Luc: + movi %r0 t0 + ldxi_s %r0 %r0 $offs + beqi Ls %r0 XS + calli @abort +Ls: + movi %r0 t0 + ldxi_us %r0 %r0 $offus + beqi Lus %r0 0x8001 + calli @abort +Lus: + movi %r0 t0 + ldxi_i %r0 %r0 $offi + beqi Li %r0 XI + calli @abort +Li: +#if __WORDSIZE == 64 + movi %r0 t0 + ldxi_ui %r0 %r0 $offui + beqi Lui %r0 0x80000001 + calli @abort +Lui: + movi %r0 t0 + ldxi_l %r0 %r0 $offl + beqi Ll %r0 0x8000000000000001 + calli @abort +Ll: +#endif + + LDST(v0, v1, v2, r0, r1, r2) + // just to know did not abort + prepare 1 + pushargi ok + finishi @printf + ret + epilog diff --git a/check/ldstxi.tst b/check/ldstxi.tst index 710ee42c7..5dc224f80 100644 --- a/check/ldstxi.tst +++ b/check/ldstxi.tst @@ -1,97 +1,4 @@ -#if __WORDSIZE == 64 -# define L0 0x8000000000000001 -# define LL0 L0 -# define LC0 0xffffffffffffff81 -# define LS0 0xffffffffffff8001 -# define LI0 0xffffffff80000001 -# define L1 0x8000000000000000 -# define LL1 L1 -# define LC1 0xffffffffffffff80 -# define LS1 0xffffffffffff8000 -# define LI1 0xffffffff80000000 -# define L2 0x7fffffffffffffff -# define LL2 L2 -# define LC2 0x000000000000007f -# define LS2 0x0000000000007fff -# define LI2 0x000000007fffffff -# define L3 0xffffffffffffffff -# define LL3 L3 -# define LC3 0xffffffffffffffff -# define LS3 0xffffffffffffffff -# define LI3 0xffffffffffffffff -#endif -#define I0 0x80000001 -#define II0 I0 -#define IC0 0xffffff81 -#define IS0 0xffff8001 -#define I1 0x80000000 -#define II1 I1 -#define IC1 0xffffff80 -#define IS1 0xffff8000 -#define I2 0x7fffffff -#define II2 I2 -#define IC2 0x0000007f -#define IS2 0x00007fff -#define I3 0xffffffff -#define II3 I3 -#define IC3 0xffffffff -#define IS3 0xffffffff -#define S0 0x8001 -#define S1 0x8000 -#define S2 0x7fff -#define S3 0xffff -#define C0 0x81 -#define C1 0x80 -#define C2 0x7f -#define C3 0xff -#define F0 0.25 -#define F1 0.75 -#define F2 -0.25 -#define F3 -0.75 -#define D0 0.25 -#define D1 0.75 -#define D2 -0.25 -#define D3 -0.75 - -.data 512 -ok: -.c "ok\n" -t0: -c0: -.c 0 -uc0: -.c 0 -s0: -.s 0 -us0: -.s 0 -.align 4 -i0: -.i 0 -#if __WORDSIZE == 64 -ui0: -.i 0 -.align 8 -l0: -.l 0 -#endif -f0: -.f 0 -.align 8 -d0: -.d 0 - -. $($offc = c0 - t0) -. $($offuc = uc0 - t0) -. $($offs = s0 - t0) -. $($offus = us0 - t0) -. $($offi = i0 - t0) -#if __WORDSIZE == 64 -. $($offui = ui0 - t0) -. $($offl = l0 - t0) -#endif -. $($offf = f0 - t0) -. $($offd = d0 - t0) +#include "ldst.inc" #if __WORDSIZE == 64 # define LDSTL(N, R0, R1) \ @@ -202,11 +109,7 @@ main: movi_d %f0 0.25 stxi_d $offd %r0 %f0 ldxi_c %r1 %r0 $offc -#if __WORDSIZE == 32 - beqi Lc %r1 0xffffff81 -#else - beqi Lc %r1 0xffffffffffffff81 -#endif + beqi Lc %r1 XC calli @abort Lc: ldxi_uc %r1 %r0 $offuc @@ -214,11 +117,7 @@ Lc: calli @abort Luc: ldxi_s %r1 %r0 $offs -#if __WORDSIZE == 32 - beqi Ls %r1 0xffff8001 -#else - beqi Ls %r1 0xffffffffffff8001 -#endif + beqi Ls %r1 XS calli @abort Ls: ldxi_us %r1 %r0 $offus @@ -226,11 +125,7 @@ Ls: calli @abort Lus: ldxi_i %r1 %r0 $offi -#if __WORDSIZE == 32 - beqi Li %r1 0x80000001 -#else - beqi Li %r1 0xffffffff80000001 -#endif + beqi Li %r1 XI calli @abort Li: #if __WORDSIZE == 64 diff --git a/check/ldstxr-c.ok b/check/ldstxr-c.ok new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/check/ldstxr-c.ok @@ -0,0 +1 @@ +ok diff --git a/check/ldstxr-c.tst b/check/ldstxr-c.tst new file mode 100644 index 000000000..bf85416e4 --- /dev/null +++ b/check/ldstxr-c.tst @@ -0,0 +1,221 @@ +#include "ldst.inc" + +#if __WORDSIZE == 64 +# define LDSTL(N, R0, R1, R2) \ + movi %R2 $offui \ + stxr_i %R2 %R0 %R1 \ + movi %R1 L##N \ + movi %R2 $offl \ + stxr_l %R2 %R0 %R1 + +# define SI(C, N, x, X, R0, R1) \ + movi %R1 $off##x \ + ldxr_##x %R1 %R0 %R1 \ + beqi L##x##C##0 %R1 L##X##N \ + calli @abort \ +L##x##C##0: \ + movi %R1 $off##x \ + ldxr_##x %R0 %R0 %R1 \ + beqi L##x##C##1 %R0 L##X##N \ + calli @abort \ +L##x##C##1: + +# define LDRL(C, N, R0, R1, R2) \ + UI(C, N, i, I, R0, R1) \ + movi %R0 t0 \ + SI(C, N, l, L, R0, R1) +#else +# define LDSTL(C, R0, R1, R2) +# define SI(C, N, x, X, R0, R1) \ + movi %R1 $off##x \ + ldxr_##x %R1 %R0 %R1 \ + beqi L##x##C##0 %R1 I##X##N \ + calli @abort \ +L##x##C##0: \ + movi %R1 $off##x \ + ldxr_##x %R0 %R0 %R1 \ + beqi L##x##C##1 %R0 I##X##N \ + calli @abort \ +L##x##C##1: + +# define LDRL(C, N, R0, R1, R2) + +#endif + +#define UI(C, N, x, X, R0, R1) \ + movi %R1 $offu##x \ + ldxr_u##x %R1 %R0 %R1 \ + beqi Lu##x##C##0 %R1 X##N \ + calli @abort \ +Lu##x##C##0: \ + movi %R1 $offu##x \ + ldxr_u##x %R0 %R0 %R1 \ + beqi Lu##x##C##1 %R0 X##N \ + calli @abort \ +Lu##x##C##1: + +#define LDST1(X, N, R0, R1, R2) \ + movi %R0 t0 \ + movi %R1 C##N \ + movi %R2 $offc \ + stxr_c %R2 %R0 %R1 \ + movi %R2 $offuc \ + stxr_c %R2 %R0 %R1 \ + movi %R1 S##N \ + movi %R2 $offs \ + stxr_s %R2 %R0 %R1 \ + movi %R2 $offus \ + stxr_s %R2 %R0 %R1 \ + movi %R1 I##N \ + movi %R2 $offi \ + stxr_i %R2 %R0 %R1 \ + LDSTL(N, R0, R1, R2) \ + SI(X, N, c, C, R0, R1) \ + movi %R0 t0 \ + UI(X, N, c, C, R0, R1) \ + movi %R0 t0 \ + SI(X, N, s, S, R0, R1) \ + movi %R0 t0 \ + UI(X, N, s, S, R0, R1) \ + movi %R0 t0 \ + SI(X, N, i, I, R0, R1) \ + movi %R0 t0 \ + LDRL(X, N, R0, R1, R2) \ + +#define LDST0(R0, R1, R2) \ + LDST1(0_##R0##_##R1##_##R2, 0, R0, R1, R2) \ + LDST1(1_##R0##_##R1##_##R2, 1, R0, R1, R2) \ + LDST1(2_##R0##_##R1##_##R2, 2, R0, R1, R2) \ + LDST1(3_##R0##_##R1##_##R2, 3, R0, R1, R2) + +#define LDST(V0, V1, V2, R0, R1, R2) \ + LDST0(V1, V2, V0) \ + LDST0(V1, R0, V0) \ + LDST0(V1, R1, V0) \ + LDST0(V1, R2, V0) \ + LDST0(V0, R0, V1) \ + LDST0(V0, R1, V1) \ + LDST0(V0, R2, V1) \ + LDST0(V0, V2, V1) \ + LDST0(V2, V0, V1) \ + LDST0(V2, R0, V1) \ + LDST0(V2, R1, V1) \ + LDST0(V2, R2, V1) \ + LDST0(R0, R1, V2) \ + LDST0(R0, R2, V2) + +.code + jmpi main + +main: + prolog + + /* Simple test to simplify validating encodings before + * brute force tests */ + movi %r0 t0 + movi %r1 0x81 + movi %r2 $offc + stxr_c %r2 %r0 %r1 + movi %r2 $offuc + stxr_c %r2 %r0 %r1 + movi %r1 0x8001 + movi %r2 $offs + stxr_s %r2 %r0 %r1 + movi %r2 $offus + stxr_s %r2 %r0 %r1 + movi %r1 0x80000001 + movi %r2 $offi + stxr_i %r2 %r0 %r1 +#if __WORDSIZE == 64 + movi %r2 $offui + stxr_i %r2 %r0 %r1 + movi %r1 0x8000000000000001 + movi %r2 $offl + stxr_l %r2 %r0 %r1 +#endif + movi %r1 $offc + ldxr_c %r1 %r0 %r1 + beqi Lc0 %r1 XC + calli @abort +Lc0: + movi %r1 $offc + ldxr_c %r0 %r0 %r1 + beqi Lc1 %r0 XC + calli @abort +Lc1: + movi %r0 t0 + movi %r1 $offuc + ldxr_uc %r1 %r0 %r1 + beqi Luc0 %r1 0x81 + calli @abort +Luc0: + movi %r1 $offuc + ldxr_uc %r0 %r0 %r1 + beqi Luc1 %r0 0x81 + calli @abort +Luc1: + movi %r0 t0 + movi %r1 $offs + ldxr_s %r1 %r0 %r1 + beqi Ls0 %r1 XS + calli @abort +Ls0: + movi %r1 $offs + ldxr_s %r0 %r0 %r1 + beqi Ls1 %r0 XS + calli @abort +Ls1: + movi %r0 t0 + movi %r1 $offus + ldxr_us %r1 %r0 %r1 + beqi Lus0 %r1 0x8001 + calli @abort +Lus0: + movi %r1 $offus + ldxr_us %r0 %r0 %r1 + beqi Lus1 %r0 0x8001 + calli @abort +Lus1: + movi %r0 t0 + movi %r1 $offi + ldxr_i %r1 %r0 %r1 + beqi Li0 %r1 XI + calli @abort +Li0: + movi %r1 $offi + ldxr_i %r0 %r0 %r1 + beqi Li1 %r0 XI + calli @abort +Li1: +#if __WORDSIZE == 64 + movi %r0 t0 + movi %r1 $offui + ldxr_ui %r1 %r0 %r1 + beqi Lui0 %r1 0x80000001 + calli @abort +Lui0: + movi %r1 $offui + ldxr_ui %r0 %r0 %r1 + beqi Lui1 %r0 0x80000001 + calli @abort +Lui1: + movi %r0 t0 + movi %r1 $offl + ldxr_l %r1 %r0 %r1 + beqi Ll0 %r1 0x8000000000000001 + calli @abort +Ll0: + movi %r1 $offl + ldxr_l %r0 %r0 %r1 + beqi Ll1 %r0 0x8000000000000001 + calli @abort +Ll1: +#endif + + LDST(v0, v1, v2, r0, r1, r2) + // just to know did not abort + prepare 1 + pushargi ok + finishi @printf + ret + epilog diff --git a/check/ldstxr.tst b/check/ldstxr.tst index 6fb7d7d81..32ddd2412 100644 --- a/check/ldstxr.tst +++ b/check/ldstxr.tst @@ -1,97 +1,4 @@ -#if __WORDSIZE == 64 -# define L0 0x8000000000000001 -# define LL0 L0 -# define LC0 0xffffffffffffff81 -# define LS0 0xffffffffffff8001 -# define LI0 0xffffffff80000001 -# define L1 0x8000000000000000 -# define LL1 L1 -# define LC1 0xffffffffffffff80 -# define LS1 0xffffffffffff8000 -# define LI1 0xffffffff80000000 -# define L2 0x7fffffffffffffff -# define LL2 L2 -# define LC2 0x000000000000007f -# define LS2 0x0000000000007fff -# define LI2 0x000000007fffffff -# define L3 0xffffffffffffffff -# define LL3 L3 -# define LC3 0xffffffffffffffff -# define LS3 0xffffffffffffffff -# define LI3 0xffffffffffffffff -#endif -#define I0 0x80000001 -#define II0 I0 -#define IC0 0xffffff81 -#define IS0 0xffff8001 -#define I1 0x80000000 -#define II1 I1 -#define IC1 0xffffff80 -#define IS1 0xffff8000 -#define I2 0x7fffffff -#define II2 I2 -#define IC2 0x0000007f -#define IS2 0x00007fff -#define I3 0xffffffff -#define II3 I3 -#define IC3 0xffffffff -#define IS3 0xffffffff -#define S0 0x8001 -#define S1 0x8000 -#define S2 0x7fff -#define S3 0xffff -#define C0 0x81 -#define C1 0x80 -#define C2 0x7f -#define C3 0xff -#define F0 0.25 -#define F1 0.75 -#define F2 -0.25 -#define F3 -0.75 -#define D0 0.25 -#define D1 0.75 -#define D2 -0.25 -#define D3 -0.75 - -.data 512 -ok: -.c "ok\n" -t0: -c0: -.c 0 -uc0: -.c 0 -s0: -.s 0 -us0: -.s 0 -.align 4 -i0: -.i 0 -#if __WORDSIZE == 64 -ui0: -.i 0 -.align 8 -l0: -.l 0 -#endif -f0: -.f 0 -.align 8 -d0: -.d 0 - -. $($offc = c0 - t0) -. $($offuc = uc0 - t0) -. $($offs = s0 - t0) -. $($offus = us0 - t0) -. $($offi = i0 - t0) -#if __WORDSIZE == 64 -. $($offui = ui0 - t0) -. $($offl = l0 - t0) -#endif -. $($offf = f0 - t0) -. $($offd = d0 - t0) +#include "ldst.inc" #if __WORDSIZE == 64 # define LDSTL(N, R0, R1, R2) \ @@ -249,11 +156,7 @@ main: stxr_d %r2 %r0 %f0 movi %r2 $offc ldxr_c %r1 %r0 %r2 -#if __WORDSIZE == 32 - beqi Lc %r1 0xffffff81 -#else - beqi Lc %r1 0xffffffffffffff81 -#endif + beqi Lc %r1 XC calli @abort Lc: movi %r2 $offuc @@ -263,11 +166,7 @@ Lc: Luc: movi %r2 $offs ldxr_s %r1 %r0 %r2 -#if __WORDSIZE == 32 - beqi Ls %r1 0xffff8001 -#else - beqi Ls %r1 0xffffffffffff8001 -#endif + beqi Ls %r1 XS calli @abort Ls: movi %r2 $offus @@ -277,11 +176,7 @@ Ls: Lus: movi %r2 $offi ldxr_i %r1 %r0 %r2 -#if __WORDSIZE == 32 - beqi Li %r1 0x80000001 -#else - beqi Li %r1 0xffffffff80000001 -#endif + beqi Li %r1 XI calli @abort Li: #if __WORDSIZE == 64