2012-12-06 15:15:58 +04:00
|
|
|
#ifndef CRISUTILS_H
|
|
|
|
#define CRISUTILS_H 1
|
|
|
|
|
2007-10-08 17:32:20 +04:00
|
|
|
static char *tst_cc_loc = NULL;
|
|
|
|
|
|
|
|
#define cris_tst_cc_init() \
|
|
|
|
do { tst_cc_loc = "test_cc failed at " CURRENT_LOCATION; } while(0)
|
|
|
|
|
|
|
|
/* We need a real symbol to signal error. */
|
2008-06-06 15:00:04 +04:00
|
|
|
void _err(void) {
|
2007-10-08 17:32:20 +04:00
|
|
|
if (!tst_cc_loc)
|
|
|
|
tst_cc_loc = "tst_cc_failed\n";
|
|
|
|
_fail(tst_cc_loc);
|
|
|
|
}
|
|
|
|
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_n1(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bpl _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_n0(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bmi _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
|
|
|
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_z1(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bne _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_z0(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("beq _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_v1(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bvc _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_v0(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bvs _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
|
|
|
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_c1(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bcc _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc_c0(void)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
asm volatile ("bcs _err\n"
|
|
|
|
"nop\n");
|
|
|
|
}
|
|
|
|
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_mov_cc(int n, int z)
|
2007-10-08 17:32:20 +04:00
|
|
|
{
|
|
|
|
if (n) cris_tst_cc_n1(); else cris_tst_cc_n0();
|
|
|
|
if (z) cris_tst_cc_z1(); else cris_tst_cc_z0();
|
|
|
|
asm volatile ("" : : "g" (_err));
|
|
|
|
}
|
|
|
|
|
2016-08-23 17:34:59 +03:00
|
|
|
static always_inline void cris_tst_cc(const int n, const int z,
|
2007-10-08 17:32:20 +04:00
|
|
|
const int v, const int c)
|
|
|
|
{
|
|
|
|
if (n) cris_tst_cc_n1(); else cris_tst_cc_n0();
|
|
|
|
if (z) cris_tst_cc_z1(); else cris_tst_cc_z0();
|
|
|
|
if (v) cris_tst_cc_v1(); else cris_tst_cc_v0();
|
|
|
|
if (c) cris_tst_cc_c1(); else cris_tst_cc_c0();
|
|
|
|
asm volatile ("" : : "g" (_err));
|
|
|
|
}
|
2012-12-06 15:15:58 +04:00
|
|
|
|
|
|
|
#endif
|