nios2: define tcg_env
PATCH 1/1 nios2: define tcg_env
This should be done by all target and, since commit 53f6672bcf ("gen-icount: use tcg_ctx.tcg_env instead of cpu_env", 2017-06-30), is causing the NIOS2 target to hang.
This is because the test for "should I exit to the main loop" was being done with the correct offset to the icount decrementer, but using TCG temporary 0 (the frame pointer) rather than the env pointer.
--- target/nios2/translate.c | 1 + 1 file changed, 1 insertion(+)
target/nios2/translate.c +1 -0
@@ -948,6 +948,7 @@ void nios2_tcg_init(void)int i; cpu_env =tcg_global_reg_new_ptr (TCG_AREG0 ,"env" ); + tcg_ctx.tcg_env = cpu_env;for (i =0 ; i <NUM_CORE_REGS ; i++) { cpu_R[i] = tcg_global_mem_new(cpu_env,
Signature · 1 line
2.14.2
Quoted 9 lines · Paolo Bonzini
This should be done by all target and, since commit
53f6672bcf("gen-icount: use tcg_ctx.tcg_env instead ofcpu_env", 2017-06-30), is causing the NIOS2 target to hang.This is because the test for "should I exit to the main loop" was being done with the correct offset to the icount decrementer, but using TCG temporary 0 (the frame pointer) rather than the env pointer.
Quoted 7 lines
Cc Marek Vasut <[email protected]>Reported-by Thomas Huth <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target/nios2/translate.c | 1 + 1 file changed, 1 insertion(+)
r~
Quoted 22 lines · Paolo Bonzini
This should be done by all target and, since commit
53f6672bcf("gen-icount: use tcg_ctx.tcg_env instead ofcpu_env", 2017-06-30), is causing the NIOS2 target to hang.This is because the test for "should I exit to the main loop" was being done with the correct offset to the icount decrementer, but using TCG temporary 0 (the frame pointer) rather than the env pointer.
Cc Marek Vasut <[email protected]>Reported-by Thomas Huth <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target/nios2/translate.c | 1 + 1 file changed, 1 insertion(+)target/nios2/translate.c +0
-0
target/nios2/translate.c void nios2_tcg_init(void)
Quoted 8 lines
target/nios2/translate.c +1
-1@@ -948,6 +948,7 @@ void nios2_tcg_init(void)int i; cpu_env =tcg_global_reg_new_ptr (TCG_AREG0 ,"env" ); + tcg_ctx.tcg_env = cpu_env;for (i =0 ; i <NUM_CORE_REGS ; i++) { cpu_R[i] = tcg_global_mem_new(cpu_env, --
Is there somewhere we could put an assert() so we can catch this error for future targets rather than them just silently generating bad code?
thanks
-- PMM
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Paolo Bonzini
This should be done by all target and, since commit
53f6672bcf("gen-icount: use tcg_ctx.tcg_env instead ofcpu_env", 2017-06-30), is causing the NIOS2 target to hang.This is because the test for "should I exit to the main loop" was being done with the correct offset to the icount decrementer, but using TCG temporary 0 (the frame pointer) rather than the env pointer.
Cc Marek Vasut <[email protected]>Reported-by Thomas Huth <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- target/nios2/translate.c | 1 + 1 file changed, 1 insertion(+)target/nios2/translate.c +1
-0@@ -948,6 +948,7 @@ void nios2_tcg_init(void)int i; cpu_env =tcg_global_reg_new_ptr (TCG_AREG0 ,"env" ); + tcg_ctx.tcg_env = cpu_env;
Quoted 7 lines
target/nios2/translate.c void nios2_tcg_init(void)
Quoted 3 lines
target/nios2/translate.c +0
-1for (i =0 ; i <NUM_CORE_REGS ; i++) { cpu_R[i] = tcg_global_mem_new(cpu_env, --Is there somewhere we could put an
assert()so we can catch this error for future targets rather than them just silently generating bad code?
Yes, I can arrange for this.
That said, probably the best change we could make is to eliminate cpu_env entirely, and create tcg_ctx.tcg_env generically (possibly renaming this to a standalone global variable called cpu_env, minimizing the changes within target/*). It is, after all, the same for every target, and there is no longer any other TCG_AREG* value that can be used.
r~