diff options
Diffstat (limited to 'arch/mips/isa_traits.cc')
-rw-r--r-- | arch/mips/isa_traits.cc | 108 |
1 files changed, 51 insertions, 57 deletions
diff --git a/arch/mips/isa_traits.cc b/arch/mips/isa_traits.cc index fcc3007ca..216a6e2ec 100644 --- a/arch/mips/isa_traits.cc +++ b/arch/mips/isa_traits.cc @@ -61,81 +61,75 @@ MipsISA::MiscRegFile::copyMiscRegs(ExecContext *xc) } uint64_t -MipsISA::convert_and_round(uint32_t fp_val, ConvertType cvt_type, int rnd_mode) +MipsISA::fpConvert(double fp_val, ConvertType cvt_type) { - uint64_t ret_val = 0; - switch (cvt_type) { case SINGLE_TO_DOUBLE: - uint64_t single_sign = fp_val & 0x80000000; - - uint64_t single_exp = (fp_val & 0x7F800000) >> 22; - single_exp -= 127; - - uint64_t single_mantissa = fp_val & 0x007FFFFF; - - uint64_t double_exp = single_exp + 1023; - double_exp = double_exp << 51; - - uint64_t double_val = single_sign << 63 | double_exp | single_mantissa; - - return double_val; + double sdouble_val = fp_val; + void *sdouble_ptr = &sdouble_val; + uint64_t sdp_bits = *(uint64_t *) sdouble_ptr; + return sdp_bits; + + case SINGLE_TO_WORD: + int32_t sword_val = (int32_t) fp_val; + void *sword_ptr = &sword_val; + uint64_t sword_bits= *(uint32_t *) sword_ptr; + return sword_bits; + + case WORD_TO_SINGLE: + float wfloat_val = fp_val; + void *wfloat_ptr = &wfloat_val; + uint64_t wfloat_bits = *(uint32_t *) wfloat_ptr; + return wfloat_bits; + + case WORD_TO_DOUBLE: + double wdouble_val = fp_val; + void *wdouble_ptr = &wdouble_val; + uint64_t wdp_bits = *(uint64_t *) wdouble_ptr; + return wdp_bits; default: - panic("Invalid Floating Point Conversion Type (%d) being used.\n",cvt_type); - return ret_val; + panic("Invalid Floating Point Conversion Type (%d). See \"types.hh\" for List of Conversions\n",cvt_type); + return 0; } } -uint64_t -MipsISA::convert_and_round(uint64_t fp_val, ConvertType cvt_type, int rnd_mode) +double +MipsISA::roundFP(double val, int digits) { + double digit_offset = pow(10.0,digits); + val = val * digit_offset; + val = val + 0.5; + val = floor(val); + val = val / digit_offset; + return val; +} - uint64_t ret_val = 0; - - switch (cvt_type) - { - case SINGLE_TO_DOUBLE: - uint64_t single_sign = fp_val & 0x80000000; - - uint64_t single_exp = (fp_val & 0x7F800000) >> 22; - single_exp -= 127; - - uint64_t single_mantissa = fp_val & 0x007FFFFF; - - uint64_t double_exp = single_exp + 1023; - double_exp = double_exp << 51; - - uint64_t double_val = single_sign << 63 | double_exp | single_mantissa; - - return double_val; - - default: - panic("Invalid Floating Point Conversion Type (%d) being used.\n",cvt_type); - return ret_val; - } +double +MipsISA::truncFP(double val) +{ + int trunc_val = (int) val; + return (double) trunc_val; } +bool +MipsISA::getFPConditionCode(uint32_t fcsr_reg, int cc) +{ + //uint32_t cc_bits = xc->readFloatReg(35); + return false;//regFile.floatRegfile.getConditionCode(cc); +} -uint64_t -MipsISA::convert_and_round(double fp_val, ConvertType cvt_type, int rnd_mode) +uint32_t +MipsISA::makeCCVector(uint32_t fcsr, int num, bool val) { - switch (cvt_type) - { - case SINGLE_TO_DOUBLE: - double double_val = fp_val; - void *double_ptr = &double_val; - uint64_t dp_bits = *(uint64_t *) double_ptr ; - return dp_bits; + int shift = (num == 0) ? 22 : num + 23; - default: - panic("Invalid Floating Point Conversion Type (%d) being used.\n",cvt_type); - return 0; - } -} + fcsr = fcsr | (val << shift); + return fcsr; +} #if FULL_SYSTEM |