• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #if defined(__mips_hard_float)
2 typedef enum {
3    TO_NEAREST=0,
4    TO_ZERO,
5    TO_PLUS_INFINITY,
6    TO_MINUS_INFINITY
7 } round_mode_t;
8 
9 char *round_mode_name[] = { "near", "zero", "+inf", "-inf" };
10 
set_rounding_mode(round_mode_t mode)11 void set_rounding_mode(round_mode_t mode)
12 {
13    switch(mode) {
14       case TO_NEAREST:
15          __asm__ __volatile__(
16             "cfc1 $t0, $31"  "\n\t"
17             "srl  $t0, 2"    "\n\t"
18             "sll  $t0, 2"    "\n\t"
19             "ctc1 $t0, $31"  "\n\t"
20             :
21             :
22             : "t0"
23          );
24          break;
25       case TO_ZERO:
26          __asm__ __volatile__(
27             "cfc1  $t0, $31"  "\n\t"
28             "srl   $t0, 2"    "\n\t"
29             "sll   $t0, 2"    "\n\t"
30             "addiu $t0, 1"    "\n\t"
31             "ctc1  $t0, $31"  "\n\t"
32             :
33             :
34             : "t0"
35          );
36          break;
37       case TO_PLUS_INFINITY:
38          __asm__ __volatile__(
39             "cfc1  $t0, $31"  "\n\t"
40             "srl   $t0, 2"    "\n\t"
41             "sll   $t0, 2"    "\n\t"
42             "addiu $t0, 2"    "\n\t"
43             "ctc1  $t0, $31"  "\n\t"
44             :
45             :
46             : "t0"
47          );
48          break;
49       case TO_MINUS_INFINITY:
50          __asm__ __volatile__(
51             "cfc1  $t0, $31"  "\n\t"
52             "srl   $t0, 2"    "\n\t"
53             "sll   $t0, 2"    "\n\t"
54             "addiu $t0, 3"    "\n\t"
55             "ctc1  $t0, $31"  "\n\t"
56             :
57             :
58             : "t0"
59          );
60          break;
61       }
62 }
63 
clear_fcc()64 void clear_fcc(){
65    __asm__ __volatile__(
66       "cfc1 $t0, $31"            "\n\t"
67       "and  $t0, $t0, 0x17FFFFF" "\n\t"
68       "ctc1 $t0, $31"            "\n\t"
69       :
70       :
71       : "t0"
72    );
73 }
74 #endif
75