Files
ftmemsim-valgrind/none/tests/mips64/rounding_mode.h
Petar Jovanovic d7adfcc772 mips64: set of mips64 specific tests
This is a set of mips64 programs that test mips64 instruction set.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13410
2013-05-28 16:51:27 +00:00

62 lines
1.4 KiB
C

typedef enum {
TO_NEAREST=0,
TO_ZERO,
TO_PLUS_INFINITY,
TO_MINUS_INFINITY
} round_mode_t;
char *round_mode_name[] = { "near", "zero", "+inf", "-inf" };
void set_rounding_mode(round_mode_t mode)
{
switch(mode) {
case TO_NEAREST:
__asm__ __volatile__(
"cfc1 $t0, $31" "\n\t"
"srl $t0, 2" "\n\t"
"sll $t0, 2" "\n\t"
"ctc1 $t0, $31" "\n\t"
:
:
: "t0"
);
break;
case TO_ZERO:
__asm__ __volatile__(
"cfc1 $t0, $31" "\n\t"
"srl $t0, 2" "\n\t"
"sll $t0, 2" "\n\t"
"addiu $t0, 1" "\n\t"
"ctc1 $t0, $31" "\n\t"
:
:
: "t0"
);
break;
case TO_PLUS_INFINITY:
__asm__ __volatile__(
"cfc1 $t0, $31" "\n\t"
"srl $t0, 2" "\n\t"
"sll $t0, 2" "\n\t"
"addiu $t0, 2" "\n\t"
"ctc1 $t0, $31" "\n\t"
:
:
: "t0"
);
break;
case TO_MINUS_INFINITY:
__asm__ __volatile__(
"cfc1 $t0, $31" "\n\t"
"srl $t0, 2" "\n\t"
"sll $t0, 2" "\n\t"
"addiu $t0, 3" "\n\t"
"ctc1 $t0, $31" "\n\t"
:
:
: "t0"
);
break;
}
}