Statistics
| Branch: | Revision:

root / tests / tcg / cris / crisutils.h @ c09015dd

History | View | Annotate | Download (1.5 kB)

1 dd43edf4 ths
static char *tst_cc_loc = NULL;
2 dd43edf4 ths
3 dd43edf4 ths
#define cris_tst_cc_init() \
4 dd43edf4 ths
do { tst_cc_loc = "test_cc failed at " CURRENT_LOCATION; } while(0)
5 dd43edf4 ths
6 dd43edf4 ths
/* We need a real symbol to signal error.  */
7 bd3a8454 edgar_igl
void _err(void) {
8 dd43edf4 ths
        if (!tst_cc_loc)
9 dd43edf4 ths
                tst_cc_loc = "tst_cc_failed\n";
10 dd43edf4 ths
        _fail(tst_cc_loc);
11 dd43edf4 ths
}
12 dd43edf4 ths
13 4a6648f4 Blue Swirl
static inline void cris_tst_cc_n1(void)
14 dd43edf4 ths
{
15 dd43edf4 ths
        asm volatile ("bpl _err\n"
16 dd43edf4 ths
                      "nop\n");
17 dd43edf4 ths
}
18 4a6648f4 Blue Swirl
static inline void cris_tst_cc_n0(void)
19 dd43edf4 ths
{
20 dd43edf4 ths
        asm volatile ("bmi _err\n"
21 dd43edf4 ths
                      "nop\n");
22 dd43edf4 ths
}
23 dd43edf4 ths
24 4a6648f4 Blue Swirl
static inline void cris_tst_cc_z1(void)
25 dd43edf4 ths
{
26 dd43edf4 ths
        asm volatile ("bne _err\n"
27 dd43edf4 ths
                      "nop\n");
28 dd43edf4 ths
}
29 4a6648f4 Blue Swirl
static inline void cris_tst_cc_z0(void)
30 dd43edf4 ths
{
31 dd43edf4 ths
        asm volatile ("beq _err\n"
32 dd43edf4 ths
                      "nop\n");
33 dd43edf4 ths
}
34 4a6648f4 Blue Swirl
static inline void cris_tst_cc_v1(void)
35 dd43edf4 ths
{
36 dd43edf4 ths
        asm volatile ("bvc _err\n"
37 dd43edf4 ths
                      "nop\n");
38 dd43edf4 ths
}
39 4a6648f4 Blue Swirl
static inline void cris_tst_cc_v0(void)
40 dd43edf4 ths
{
41 dd43edf4 ths
        asm volatile ("bvs _err\n"
42 dd43edf4 ths
                      "nop\n");
43 dd43edf4 ths
}
44 dd43edf4 ths
45 4a6648f4 Blue Swirl
static inline void cris_tst_cc_c1(void)
46 dd43edf4 ths
{
47 dd43edf4 ths
        asm volatile ("bcc _err\n"
48 dd43edf4 ths
                      "nop\n");
49 dd43edf4 ths
}
50 4a6648f4 Blue Swirl
static inline void cris_tst_cc_c0(void)
51 dd43edf4 ths
{
52 dd43edf4 ths
        asm volatile ("bcs _err\n"
53 dd43edf4 ths
                      "nop\n");
54 dd43edf4 ths
}
55 dd43edf4 ths
56 4a6648f4 Blue Swirl
static inline void cris_tst_mov_cc(int n, int z)
57 dd43edf4 ths
{
58 dd43edf4 ths
        if (n) cris_tst_cc_n1(); else cris_tst_cc_n0();
59 dd43edf4 ths
        if (z) cris_tst_cc_z1(); else cris_tst_cc_z0();
60 dd43edf4 ths
        asm volatile ("" : : "g" (_err));
61 dd43edf4 ths
}
62 dd43edf4 ths
63 4a6648f4 Blue Swirl
static inline void cris_tst_cc(const int n, const int z,
64 dd43edf4 ths
                               const int v, const int c)
65 dd43edf4 ths
{
66 dd43edf4 ths
        if (n) cris_tst_cc_n1(); else cris_tst_cc_n0();
67 dd43edf4 ths
        if (z) cris_tst_cc_z1(); else cris_tst_cc_z0();
68 dd43edf4 ths
        if (v) cris_tst_cc_v1(); else cris_tst_cc_v0();
69 dd43edf4 ths
        if (c) cris_tst_cc_c1(); else cris_tst_cc_c0();
70 dd43edf4 ths
        asm volatile ("" : : "g" (_err));
71 dd43edf4 ths
}