• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン83b519b8a44d6b7d9b9d9763e7189061e116215d (tree)
日時2022-01-21 14:52:57
作者LIU Zhiwei <zhiwei_liu@c-sk...>
コミッターAlistair Francis

ログメッセージ

target/riscv: Adjust csr write mask with XLEN

Write mask is representing the bits we care about.

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20220120122050.41546-11-zhiwei_liu@c-sky.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

変更サマリ

差分

--- a/target/riscv/insn_trans/trans_rvi.c.inc
+++ b/target/riscv/insn_trans/trans_rvi.c.inc
@@ -924,7 +924,8 @@ static bool do_csrrw_i128(DisasContext *ctx, int rd, int rc,
924924
925925 static bool trans_csrrw(DisasContext *ctx, arg_csrrw *a)
926926 {
927- if (get_xl(ctx) < MXL_RV128) {
927+ RISCVMXL xl = get_xl(ctx);
928+ if (xl < MXL_RV128) {
928929 TCGv src = get_gpr(ctx, a->rs1, EXT_NONE);
929930
930931 /*
@@ -935,7 +936,8 @@ static bool trans_csrrw(DisasContext *ctx, arg_csrrw *a)
935936 return do_csrw(ctx, a->csr, src);
936937 }
937938
938- TCGv mask = tcg_constant_tl(-1);
939+ TCGv mask = tcg_constant_tl(xl == MXL_RV32 ? UINT32_MAX :
940+ (target_ulong)-1);
939941 return do_csrrw(ctx, a->rd, a->csr, src, mask);
940942 } else {
941943 TCGv srcl = get_gpr(ctx, a->rs1, EXT_NONE);
@@ -1013,7 +1015,8 @@ static bool trans_csrrc(DisasContext *ctx, arg_csrrc *a)
10131015
10141016 static bool trans_csrrwi(DisasContext *ctx, arg_csrrwi *a)
10151017 {
1016- if (get_xl(ctx) < MXL_RV128) {
1018+ RISCVMXL xl = get_xl(ctx);
1019+ if (xl < MXL_RV128) {
10171020 TCGv src = tcg_constant_tl(a->rs1);
10181021
10191022 /*
@@ -1024,7 +1027,8 @@ static bool trans_csrrwi(DisasContext *ctx, arg_csrrwi *a)
10241027 return do_csrw(ctx, a->csr, src);
10251028 }
10261029
1027- TCGv mask = tcg_constant_tl(-1);
1030+ TCGv mask = tcg_constant_tl(xl == MXL_RV32 ? UINT32_MAX :
1031+ (target_ulong)-1);
10281032 return do_csrrw(ctx, a->rd, a->csr, src, mask);
10291033 } else {
10301034 TCGv src = tcg_constant_tl(a->rs1);
--- a/target/riscv/op_helper.c
+++ b/target/riscv/op_helper.c
@@ -50,7 +50,8 @@ target_ulong helper_csrr(CPURISCVState *env, int csr)
5050
5151 void helper_csrw(CPURISCVState *env, int csr, target_ulong src)
5252 {
53- RISCVException ret = riscv_csrrw(env, csr, NULL, src, -1);
53+ target_ulong mask = env->xl == MXL_RV32 ? UINT32_MAX : (target_ulong)-1;
54+ RISCVException ret = riscv_csrrw(env, csr, NULL, src, mask);
5455
5556 if (ret != RISCV_EXCP_NONE) {
5657 riscv_raise_exception(env, ret, GETPC());