Home | History | Annotate | Download | only in mips64
      1 typedef enum {
      2    TO_NEAREST=0,
      3    TO_ZERO,
      4    TO_PLUS_INFINITY,
      5    TO_MINUS_INFINITY
      6 } round_mode_t;
      7 
      8 char *round_mode_name[] = { "near", "zero", "+inf", "-inf" };
      9 
     10 void set_rounding_mode(round_mode_t mode)
     11 {
     12    switch(mode) {
     13       case TO_NEAREST:
     14          __asm__ __volatile__(
     15             "cfc1 $t0, $31"  "\n\t"
     16             "srl  $t0, 2"    "\n\t"
     17             "sll  $t0, 2"    "\n\t"
     18             "ctc1 $t0, $31"  "\n\t"
     19             :
     20             :
     21             : "t0"
     22          );
     23          break;
     24       case TO_ZERO:
     25          __asm__ __volatile__(
     26             "cfc1  $t0, $31"  "\n\t"
     27             "srl   $t0, 2"    "\n\t"
     28             "sll   $t0, 2"    "\n\t"
     29             "addiu $t0, 1"    "\n\t"
     30             "ctc1  $t0, $31"  "\n\t"
     31             :
     32             :
     33             : "t0"
     34          );
     35          break;
     36       case TO_PLUS_INFINITY:
     37          __asm__ __volatile__(
     38             "cfc1  $t0, $31"  "\n\t"
     39             "srl   $t0, 2"    "\n\t"
     40             "sll   $t0, 2"    "\n\t"
     41             "addiu $t0, 2"    "\n\t"
     42             "ctc1  $t0, $31"  "\n\t"
     43             :
     44             :
     45             : "t0"
     46          );
     47          break;
     48       case TO_MINUS_INFINITY:
     49          __asm__ __volatile__(
     50             "cfc1  $t0, $31"  "\n\t"
     51             "srl   $t0, 2"    "\n\t"
     52             "sll   $t0, 2"    "\n\t"
     53             "addiu $t0, 3"    "\n\t"
     54             "ctc1  $t0, $31"  "\n\t"
     55             :
     56             :
     57             : "t0"
     58          );
     59          break;
     60       }
     61 }
     62