diff options
author | Zhen Wei <zhen.wei@sifive.com> | 2020-03-02 08:27:15 +0800 |
---|---|---|
committer | Chih-Min Chao <48193236+chihminchao@users.noreply.github.com> | 2020-03-05 17:16:19 +0800 |
commit | 7754a2adf8b3beedf726eccc05149c44be8cd17e (patch) | |
tree | beb60a489cf27a014dfbdd9e99935c7e2afd5262 /riscv/processor.cc | |
parent | d80ff6dfdda2e383e1720a8b9582e6c6515ec5ea (diff) | |
download | spike-7754a2adf8b3beedf726eccc05149c44be8cd17e.zip spike-7754a2adf8b3beedf726eccc05149c44be8cd17e.tar.gz spike-7754a2adf8b3beedf726eccc05149c44be8cd17e.tar.bz2 |
rvv: avoid redundant std::string comparison
Diffstat (limited to 'riscv/processor.cc')
-rw-r--r-- | riscv/processor.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc index ee9fbaa..07d3057 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -109,7 +109,7 @@ void processor_t::parse_varch_string(const char* s) int elen = 0; int slen = 0; int valu = 4; // default - std::string fredsum_impl("ordered"); // default + vectorUnit_t::fredsum_impl_t fredsum_impl = vectorUnit_t::ORDERED_FREDSUM_IMPL; // default while (pos < len) { std::string attr = get_string_token(str, ':', pos); @@ -124,9 +124,12 @@ void processor_t::parse_varch_string(const char* s) elen = get_int_token(str, ',', pos); else if (attr == "nalu") valu = get_int_token(str, ',', pos); - else if (attr == "fredsum-impl") - fredsum_impl = get_string_token(str, ',', pos); - else + else if (attr == "fredsum-impl") { + std::string temp = get_string_token(str, ',', pos); + if (temp == "ordered") VU.fredsum_impl = vectorUnit_t::ORDERED_FREDSUM_IMPL; + else if (temp == "parallel") VU.fredsum_impl = vectorUnit_t::PARALLEL_FREDSUM_IMPL; + else VU.fredsum_impl = vectorUnit_t::UNKNOWN_FREDSUM_IMPL; + } else bad_varch_string(s, "Unsupported token"); ++pos; @@ -135,7 +138,7 @@ void processor_t::parse_varch_string(const char* s) if (!check_pow2(vlen) || !check_pow2(elen) || !check_pow2(slen) || !check_pow2(valu)){ bad_varch_string(s, "The integer value should be the power of 2"); } - if (fredsum_impl != "ordered" && fredsum_impl != "parallel"){ + if (VU.fredsum_impl == vectorUnit_t::UNKNOWN_FREDSUM_IMPL) { bad_varch_string(s, "fredsum-impl now only supported ordered/parallel"); } @@ -160,7 +163,6 @@ void processor_t::parse_varch_string(const char* s) VU.ELEN = elen; VU.SLEN = slen; VU.VALU = valu; - VU.FREDSUM_IMPL = fredsum_impl; VU.vlenb = vlen / 8; } |