diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-10-08 13:32:20 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-10-08 13:32:20 +0000 |
commit | dd43edf4e136bff05cbbb6b42b96c024c591dbb9 (patch) | |
tree | d1f03b9c92753846ba462c5a1583af5106333d58 /tests/cris/check_addcm.c | |
parent | 83fa1010ae342c5ad0392182fcdcce438c71b163 (diff) | |
download | qemu-dd43edf4e136bff05cbbb6b42b96c024c591dbb9.zip qemu-dd43edf4e136bff05cbbb6b42b96c024c591dbb9.tar.gz qemu-dd43edf4e136bff05cbbb6b42b96c024c591dbb9.tar.bz2 |
CRIS testsuite, based on the SIM testsuite, by Edgar E. Iglesias.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3365 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests/cris/check_addcm.c')
-rw-r--r-- | tests/cris/check_addcm.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/cris/check_addcm.c b/tests/cris/check_addcm.c new file mode 100644 index 0000000..9ffea29 --- /dev/null +++ b/tests/cris/check_addcm.c @@ -0,0 +1,83 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include "sys.h" +#include "crisutils.h" + +/* need to avoid acr as source here. */ +extern inline int cris_addc_m(int a, const int *b) { + asm volatile ("addc [%1], %0\n" : "+r" (a) : "r" (b)); + return a; +} + +/* 'b' is a crisv32 constrain to avoid postinc with $acr. */ +extern inline int cris_addc_pi_m(int a, int **b) { + asm volatile ("addc [%1+], %0\n" : "+r" (a), "+b" (*b)); + return a; +} + +#define verify_addc_m(a, b, res, n, z, v, c) \ +{ \ + int r; \ + r = cris_addc_m((a), (b)); \ + cris_tst_cc((n), (z), (v), (c)); \ + if (r != (res)) \ + err(); \ +} + +#define verify_addc_pi_m(a, b, res, n, z, v, c) \ +{ \ + int r; \ + r = cris_addc_pi_m((a), (b)); \ + cris_tst_cc((n), (z), (v), (c)); \ + if (r != (res)) \ + err(); \ +} + +int x[] = { 0, 0, 2, -1, 0xffff, -1, 0x5432f789}; + +int main(void) +{ + int *p = (void *)&x[0]; +#if 1 + cris_tst_cc_init(); + asm volatile ("clearf cz"); + verify_addc_m(0, p, 0, 0, 0, 0, 0); + + cris_tst_cc_init(); + asm volatile ("setf z"); + verify_addc_m(0, p, 0, 0, 1, 0, 0); + + cris_tst_cc_init(); + asm volatile ("setf c"); + verify_addc_m(0, p, 1, 0, 0, 0, 0); + + cris_tst_cc_init(); + asm volatile ("clearf c"); + verify_addc_pi_m(0, &p, 0, 0, 1, 0, 0); + + p = &x[1]; + cris_tst_cc_init(); + asm volatile ("setf c"); + verify_addc_pi_m(0, &p, 1, 0, 0, 0, 0); + + if (p != &x[2]) + err(); + + cris_tst_cc_init(); + asm volatile ("clearf c"); + verify_addc_pi_m(-1, &p, 1, 0, 0, 0, 1); + + if (p != &x[3]) + err(); +#endif + p = &x[3]; + /* TODO: investigate why this one fails. */ + cris_tst_cc_init(); + asm volatile ("setf c"); + verify_addc_m(2, p, 2, 0, 0, 0, 1); + p += 4; + + pass(); + return 0; +} |