target/nios2: Introduce shadow register sets
commit945a5bd3f88729960c52393a9eb3ad701e2b6595
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 21 Apr 2022 15:17:24 +0000 (21 08:17 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 26 Apr 2022 15:17:05 +0000 (26 08:17 -0700)
treee7650565411fc3d724d9a08e513d3fda356e3b96
parent410c6aaa3b44d5bdd1af7c1a465be7d5df2dfbf0
target/nios2: Introduce shadow register sets

Do not actually enable them so far, in terms of being able
to change the current register set, but add all of the
plumbing to address them.  Do not enable them for user-only.

Add an env->regs pointer that handles the indirection to
the current register set.  The naming of the pointer hides
the difference between old and new, user-only and sysemu.

From the notes on wrprs, which states that r0 must be initialized
before use in shadow register sets, infer that R_ZERO is *not*
hardwired to zero in shadow register sets, but that it is still
read-only.  Introduce tbflags bit R0_0 to track that it has been
properly set to zero.  Adjust load_gpr to reflect this.

At the same time we might as well special case crs == 0 to avoid
the indirection through env->regs during translation as well; this
is intended to be the most common case for non-interrupt handlers.

Init env->regs at reset.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20220421151735.31996-54-richard.henderson@linaro.org>
target/nios2/cpu.c
target/nios2/cpu.h
target/nios2/translate.c