target/microblaze: Tidy mb_tcg_init

All of the tcg globals can be recorded in the same table.
Drop the "r" prefix from "rpc" and "rmsr".  Obviates the
need for regnames[], which was incorrectly not const.

Tested-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2020-08-25 06:29:47 -07:00
parent 9b1585589d
commit 480d29a8fa
1 changed files with 27 additions and 35 deletions

View File

@ -95,14 +95,6 @@ typedef struct DisasContext {
int singlestep_enabled; int singlestep_enabled;
} DisasContext; } DisasContext;
static const char *regnames[] =
{
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
};
static inline void t_sync_flags(DisasContext *dc) static inline void t_sync_flags(DisasContext *dc)
{ {
/* Synch the tb dependent flags between translator and runtime. */ /* Synch the tb dependent flags between translator and runtime. */
@ -1846,36 +1838,36 @@ void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags)
void mb_tcg_init(void) void mb_tcg_init(void)
{ {
int i; #define R(X) { &cpu_R[X], offsetof(CPUMBState, regs[X]), "r" #X }
#define SP(X) { &cpu_##X, offsetof(CPUMBState, X), #X }
cpu_iflags = tcg_global_mem_new_i32(cpu_env, static const struct {
offsetof(CPUMBState, iflags), TCGv_i32 *var; int ofs; char name[8];
"iflags"); } i32s[] = {
cpu_imm = tcg_global_mem_new_i32(cpu_env, R(0), R(1), R(2), R(3), R(4), R(5), R(6), R(7),
offsetof(CPUMBState, imm), R(8), R(9), R(10), R(11), R(12), R(13), R(14), R(15),
"imm"); R(16), R(17), R(18), R(19), R(20), R(21), R(22), R(23),
cpu_btarget = tcg_global_mem_new_i32(cpu_env, R(24), R(25), R(26), R(27), R(28), R(29), R(30), R(31),
offsetof(CPUMBState, btarget),
"btarget"); SP(pc),
cpu_btaken = tcg_global_mem_new_i32(cpu_env, SP(msr),
offsetof(CPUMBState, btaken), SP(imm),
"btaken"); SP(iflags),
cpu_res_addr = tcg_global_mem_new(cpu_env, SP(btaken),
offsetof(CPUMBState, res_addr), SP(btarget),
"res_addr"); SP(res_val),
cpu_res_val = tcg_global_mem_new_i32(cpu_env, };
offsetof(CPUMBState, res_val),
"res_val"); #undef R
for (i = 0; i < ARRAY_SIZE(cpu_R); i++) { #undef SP
cpu_R[i] = tcg_global_mem_new_i32(cpu_env,
offsetof(CPUMBState, regs[i]), for (int i = 0; i < ARRAY_SIZE(i32s); ++i) {
regnames[i]); *i32s[i].var =
tcg_global_mem_new_i32(cpu_env, i32s[i].ofs, i32s[i].name);
} }
cpu_pc = cpu_res_addr =
tcg_global_mem_new_i32(cpu_env, offsetof(CPUMBState, pc), "rpc"); tcg_global_mem_new(cpu_env, offsetof(CPUMBState, res_addr), "res_addr");
cpu_msr =
tcg_global_mem_new_i32(cpu_env, offsetof(CPUMBState, msr), "rmsr");
} }
void restore_state_to_opc(CPUMBState *env, TranslationBlock *tb, void restore_state_to_opc(CPUMBState *env, TranslationBlock *tb,