From: Luke Kenneth Casson Leighton Date: Fri, 19 Oct 2018 22:25:08 +0000 (+0100) Subject: use const& for operators in sv_reg_t X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d0ef4af827eb08a7feac609634c075ed2b5b365;p=riscv-isa-sim.git use const& for operators in sv_reg_t --- diff --git a/riscv/sv_insn_redirect.cc b/riscv/sv_insn_redirect.cc index f52b23a..c46b55c 100644 --- a/riscv/sv_insn_redirect.cc +++ b/riscv/sv_insn_redirect.cc @@ -38,12 +38,12 @@ void (sv_proc_t::WRITE_FRD)(freg_t value) // WRITE_REG(_insn->rvc_rs1s(), value ); //} -void (sv_proc_t::WRITE_RVC_RS1S)(sv_reg_t value) +void (sv_proc_t::WRITE_RVC_RS1S)(sv_reg_t const& value) { WRITE_REG(_insn->rvc_rs1s(), value ); } -void (sv_proc_t::WRITE_RVC_RS2S)(sv_reg_t value) +void (sv_proc_t::WRITE_RVC_RS2S)(sv_reg_t const& value) { WRITE_REG(_insn->rvc_rs2s(), value ); } @@ -53,7 +53,7 @@ void (sv_proc_t::WRITE_RVC_RS2S)(sv_reg_t value) // WRITE_REG(_insn->rvc_rs2s(), value ); //} -void (sv_proc_t::WRITE_RD)(sv_reg_t value) +void (sv_proc_t::WRITE_RD)(sv_reg_t const& value) { WRITE_REG( _insn->rd(), value ); // XXX TODO: replace properly } @@ -69,7 +69,7 @@ void (sv_proc_t::WRITE_RD)(sv_reg_t value) // STATE.XPR.write(reg, value); //} -void (sv_proc_t::WRITE_REG)(reg_t reg, sv_reg_t value) +void (sv_proc_t::WRITE_REG)(reg_t reg, sv_reg_t const& value) { //WRITE_REG( reg, value ); // XXX TODO: replace properly STATE.XPR.write(reg, value); @@ -154,21 +154,21 @@ sv_reg_t (sv_proc_t::sext_xlen)(uint64_t x) return sv_uint64_t(x); } */ -sv_sreg_t (sv_proc_t::sext_xlen)(sv_sreg_t v) +sv_sreg_t (sv_proc_t::sext_xlen)(sv_sreg_t const& v) { int64_t x = v; x = (((sreg_t)(x) << (64-xlen)) >> (64-xlen)); return sv_sreg_t(x); } -sv_sreg_t (sv_proc_t::sext_xlen)(sv_reg_t v) +sv_sreg_t (sv_proc_t::sext_xlen)(sv_reg_t const& v) { uint64_t x = v; x = (((sreg_t)(x) << (64-xlen)) >> (64-xlen)); return sv_sreg_t((sreg_t)x); } -sv_reg_t (sv_proc_t::zext_xlen)(sv_reg_t v) +sv_reg_t (sv_proc_t::zext_xlen)(sv_reg_t const& v) { uint64_t x = v; x = (((reg_t)(x) << (64-xlen)) >> (64-xlen)); @@ -181,21 +181,21 @@ sv_reg_t (sv_proc_t::sext32)(uint_fast32_t v) return sext32((uint64_t)v); // XXX TODO do properly } */ -sv_sreg_t (sv_proc_t::sext32)(sv_reg_t v) +sv_sreg_t (sv_proc_t::sext32)(sv_reg_t const& v) { uint64_t x = v; x = ((sreg_t)(int32_t)(x)); return sv_sreg_t((int64_t)x); } -//sv_sreg_t (sv_proc_t::sext32)(sv_sreg_t v) +//sv_sreg_t (sv_proc_t::sext32)(sv_sreg_t const& v) //{ // int64_t x = v; // x = ((sreg_t)(int32_t)(x)); // return sv_sreg_t(x); //} -sv_reg_t (sv_proc_t::zext32)(sv_reg_t v) +sv_reg_t (sv_proc_t::zext32)(sv_reg_t const& v) { uint64_t x = v; x = ((reg_t)(uint32_t)(x)); @@ -381,19 +381,19 @@ bool sv_proc_t::rv_ne(sv_reg_t const & lhs, sv_reg_t const & rhs) return (lhs != rhs); } -sv_sreg_t sv_proc_t::sv_reg_to_sreg(sv_reg_t v) +sv_sreg_t sv_proc_t::sv_reg_to_sreg(sv_reg_t const& v) { uint64_t x = v; return sv_sreg_t(sreg_t(x)); } -sv_reg_t sv_proc_t::sv_reg_int32(sv_reg_t v) +sv_reg_t sv_proc_t::sv_reg_int32(sv_reg_t const& v) { int32_t x = (int32_t)v; return sv_reg_t((uint64_t)x); } -sv_reg_t sv_proc_t::sv_reg_uint32(sv_reg_t v) +sv_reg_t sv_proc_t::sv_reg_uint32(sv_reg_t const& v) { uint32_t x = (uint32_t)v; return sv_reg_t((uint64_t)x); @@ -403,7 +403,7 @@ float32_t (sv_proc_t::f32)(freg_t x) { return ::f32(x); } -float32_t (sv_proc_t::f32)(sv_reg_t v) +float32_t (sv_proc_t::f32)(sv_reg_t const& v) { uint64_t x = v; return ::f32(x); @@ -414,7 +414,7 @@ float64_t (sv_proc_t::f64)(freg_t v) return ::f64(v); } -float64_t (sv_proc_t::f64)(sv_reg_t v) +float64_t (sv_proc_t::f64)(sv_reg_t const& v) { uint64_t x = v; return ::f64(x); @@ -435,73 +435,73 @@ sv_reg_t (sv_proc_t::f128_classify)(float128_t a) return sv_reg_t(::f128_classify(a)); } -float32_t (sv_proc_t::i32_to_f32)( sv_reg_t v ) +float32_t (sv_proc_t::i32_to_f32)( sv_reg_t const& v ) { uint64_t x = v; return ::i32_to_f32(x); } -float64_t (sv_proc_t::ui32_to_f64)( sv_reg_t v ) +float64_t (sv_proc_t::ui32_to_f64)( sv_reg_t const& v ) { uint64_t x = v; return ::ui32_to_f64(x); } -float64_t (sv_proc_t::i32_to_f64)( sv_reg_t v ) +float64_t (sv_proc_t::i32_to_f64)( sv_reg_t const& v ) { uint64_t x = v; return ::i32_to_f64(x); } -float32_t (sv_proc_t::ui32_to_f32)( sv_reg_t v ) +float32_t (sv_proc_t::ui32_to_f32)( sv_reg_t const& v ) { uint64_t x = v; return ::ui32_to_f32(x); } -float32_t (sv_proc_t::i64_to_f32)( sv_reg_t v ) +float32_t (sv_proc_t::i64_to_f32)( sv_reg_t const& v ) { uint64_t x = v; return ::i64_to_f32(x); } -float32_t (sv_proc_t::ui64_to_f32)( sv_reg_t v ) +float32_t (sv_proc_t::ui64_to_f32)( sv_reg_t const& v ) { uint64_t x = v; return ::ui64_to_f32(x); } -float64_t (sv_proc_t::i64_to_f64)( sv_reg_t v ) +float64_t (sv_proc_t::i64_to_f64)( sv_reg_t const& v ) { uint64_t x = v; return ::i64_to_f64(x); } -float64_t (sv_proc_t::ui64_to_f64)( sv_reg_t v ) +float64_t (sv_proc_t::ui64_to_f64)( sv_reg_t const& v ) { uint64_t x = v; return ::ui64_to_f64(x); } -float128_t (sv_proc_t::ui64_to_f128)( sv_reg_t v ) +float128_t (sv_proc_t::ui64_to_f128)( sv_reg_t const& v ) { uint64_t x = v; return ::ui64_to_f128(x); } -float128_t (sv_proc_t::i64_to_f128)( sv_reg_t v ) +float128_t (sv_proc_t::i64_to_f128)( sv_reg_t const& v ) { uint64_t x = v; return ::i64_to_f128(x); } -float128_t (sv_proc_t::i32_to_f128)( sv_reg_t v ) +float128_t (sv_proc_t::i32_to_f128)( sv_reg_t const& v ) { uint64_t x = v; return ::i32_to_f128(x); } -float128_t (sv_proc_t::ui32_to_f128)( sv_reg_t v ) +float128_t (sv_proc_t::ui32_to_f128)( sv_reg_t const& v ) { uint64_t x = v; return ::ui32_to_f128(x); diff --git a/riscv/sv_insn_redirect.h b/riscv/sv_insn_redirect.h index eb51945..8c4c9ef 100644 --- a/riscv/sv_insn_redirect.h +++ b/riscv/sv_insn_redirect.h @@ -55,14 +55,14 @@ public: //void (WRITE_RD)(sv_reg_t &value); //void (WRITE_RD)(int_fast64_t value); // XXX TODO investigate //void (WRITE_RD)(uint_fast64_t value); // XXX TODO investigate - void (WRITE_RD)(sv_reg_t value); // XXX TODO investigate + void (WRITE_RD)(sv_reg_t const& value); // XXX TODO investigate //void (WRITE_RD)(sv_sreg_t value); // XXX TODO investigate - void (WRITE_RVC_RS2S)(sv_reg_t value); // XXX TODO investigate + void (WRITE_RVC_RS2S)(sv_reg_t const& value); // XXX TODO investigate //void (WRITE_RVC_RS2S)(sv_sreg_t value); // XXX TODO investigate - void (WRITE_RVC_RS1S)(sv_reg_t value); // XXX TODO investigate + void (WRITE_RVC_RS1S)(sv_reg_t const& value); // XXX TODO investigate //void (WRITE_RVC_RS1S)(sv_sreg_t value); // XXX TODO investigate //void (WRITE_REG)(reg_t reg, uint64_t value); - void (WRITE_REG)(reg_t reg, sv_reg_t value); + void (WRITE_REG)(reg_t reg, sv_reg_t const& value); //void (WRITE_REG)(reg_t reg, sv_sreg_t value); void (WRITE_FRD)(freg_t value); void (WRITE_FRD)(float64_t value); @@ -108,15 +108,15 @@ public: freg_t get_frs1(); freg_t get_frs2(); - sv_sreg_t (sext_xlen)(sv_sreg_t v); // WARNING... - sv_sreg_t (sext_xlen)(sv_reg_t v); // WARNING... - sv_reg_t (zext_xlen)(sv_reg_t v); + sv_sreg_t (sext_xlen)(sv_sreg_t const& v); // WARNING... + sv_sreg_t (sext_xlen)(sv_reg_t const& v); // WARNING... + sv_reg_t (zext_xlen)(sv_reg_t const& v); //reg_t (sext_xlen)(sv_reg_t &v); //reg_t (sext32)(uint_fast32_t v); // XXX TODO - sv_sreg_t (sext32)(sv_reg_t v); + sv_sreg_t (sext32)(sv_reg_t const& v); //sv_sreg_t (sext32)(sv_sreg_t v); //reg_t (sext32)(sv_reg_t &v); - sv_reg_t (zext32)(sv_reg_t v); + sv_reg_t (zext32)(sv_reg_t const& v); sv_reg_t rv_add(sv_reg_t const & lhs, sv_reg_t const & rhs); sv_reg_t rv_sub(sv_reg_t const & lhs, sv_reg_t const & rhs); @@ -142,29 +142,29 @@ public: bool rv_eq(sv_reg_t const & lhs, sv_reg_t const & rhs); bool rv_ne(sv_reg_t const & lhs, sv_reg_t const & rhs); - sv_sreg_t sv_reg_to_sreg(sv_reg_t); - sv_reg_t sv_reg_uint32(sv_reg_t); - sv_reg_t sv_reg_int32(sv_reg_t); + sv_sreg_t sv_reg_to_sreg(sv_reg_t const&); + sv_reg_t sv_reg_uint32(sv_reg_t const&); + sv_reg_t sv_reg_int32(sv_reg_t const&); - float64_t (f64)(freg_t v); - float64_t (f64)(sv_reg_t v); - float32_t (f32)(sv_reg_t v); + float64_t (f64)(freg_t v); + float64_t (f64)(sv_reg_t const&v); + float32_t (f32)(sv_reg_t const&v); float32_t (f32)(freg_t v); - sv_reg_t (f32_classify)(float32_t a); - sv_reg_t (f64_classify)(float64_t a); - sv_reg_t (f128_classify)(float128_t a); - float32_t (i32_to_f32)(sv_reg_t a); - float32_t (i64_to_f32)(sv_reg_t a); - float32_t (ui64_to_f32)(sv_reg_t a); - float32_t (ui32_to_f32)(sv_reg_t a); - float64_t (i64_to_f64)(sv_reg_t a); - float64_t (ui64_to_f64)(sv_reg_t a); - float64_t (ui32_to_f64)(sv_reg_t a); - float64_t (i32_to_f64)(sv_reg_t a); - float128_t (i32_to_f128)(sv_reg_t a); - float128_t (ui32_to_f128)(sv_reg_t a); - float128_t (i64_to_f128)(sv_reg_t a); - float128_t (ui64_to_f128)(sv_reg_t a); + sv_reg_t (f32_classify)(float32_t a); + sv_reg_t (f64_classify)(float64_t a); + sv_reg_t (f128_classify)(float128_t a); + float32_t (i32_to_f32)(sv_reg_t const&a); + float32_t (i64_to_f32)(sv_reg_t const&a); + float32_t (ui64_to_f32)(sv_reg_t const&a); + float32_t (ui32_to_f32)(sv_reg_t const&a); + float64_t (i64_to_f64)(sv_reg_t const&a); + float64_t (ui64_to_f64)(sv_reg_t const&a); + float64_t (ui32_to_f64)(sv_reg_t const&a); + float64_t (i32_to_f64)(sv_reg_t const&a); + float128_t (i32_to_f128)(sv_reg_t const&a); + float128_t (ui32_to_f128)(sv_reg_t const&a); + float128_t (i64_to_f128)(sv_reg_t const&a); + float128_t (ui64_to_f128)(sv_reg_t const&a); sv_reg_t (f32_to_ui32)( float32_t a, uint_fast8_t roundingMode, bool exact ); sv_reg_t (f32_to_i32)( float32_t a, uint_fast8_t roundingMode,