Re: [Qemu-devel] [PATCH 17/21] target-microblaze: switch to AREG0 free mode

2012-09-08 Thread Blue Swirl
On Thu, Sep 6, 2012 at 3:38 PM, Aurelien Jarno aurel...@aurel32.net wrote:
 On Sun, Sep 02, 2012 at 05:33:46PM +, Blue Swirl wrote:
 Add an explicit CPUState parameter instead of relying on AREG0
 and switch to AREG0 free mode.

 Signed-off-by: Blue Swirl blauwir...@gmail.com
 ---
  configure   |2 +-
  target-microblaze/Makefile.objs |2 -
  target-microblaze/helper.h  |   48 
  target-microblaze/op_helper.c   |  115 
 ++-
  target-microblaze/translate.c   |   56 +++-
  5 files changed, 108 insertions(+), 115 deletions(-)

 diff --git a/configure b/configure
 index efb5014..e464d2f 100755
 --- a/configure
 +++ b/configure
 @@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
 $target_dir/Makefile


  case $target_arch2 in
 -  alpha | arm* | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | 
 x86_64 | xtensa* | ppc*)
 +  alpha | arm* | i386 | lm32 | m68k | microblaze* | or32 | s390x | sparc* | 
 unicore32 | x86_64 | xtensa* | ppc*)
  echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
;;
  esac
 diff --git a/target-microblaze/Makefile.objs 
 b/target-microblaze/Makefile.objs
 index 4b09e8c..afb87bc 100644
 --- a/target-microblaze/Makefile.objs
 +++ b/target-microblaze/Makefile.objs
 @@ -1,4 +1,2 @@
  obj-y += translate.o op_helper.o helper.o cpu.o
  obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
 -
 -$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h
 index 9dcfb0f..a1a732c 100644
 --- a/target-microblaze/helper.h
 +++ b/target-microblaze/helper.h
 @@ -1,39 +1,39 @@
  #include def-helper.h

 -DEF_HELPER_1(raise_exception, void, i32)
 -DEF_HELPER_0(debug, void)
 +DEF_HELPER_2(raise_exception, void, env, i32)
 +DEF_HELPER_1(debug, void, env)
  DEF_HELPER_FLAGS_3(carry, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32, 
 i32)
  DEF_HELPER_2(cmp, i32, i32, i32)
  DEF_HELPER_2(cmpu, i32, i32, i32)
  DEF_HELPER_FLAGS_1(clz, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32)

 -DEF_HELPER_2(divs, i32, i32, i32)
 -DEF_HELPER_2(divu, i32, i32, i32)
 -
 -DEF_HELPER_2(fadd, i32, i32, i32)
 -DEF_HELPER_2(frsub, i32, i32, i32)
 -DEF_HELPER_2(fmul, i32, i32, i32)
 -DEF_HELPER_2(fdiv, i32, i32, i32)
 -DEF_HELPER_1(flt, i32, i32)
 -DEF_HELPER_1(fint, i32, i32)
 -DEF_HELPER_1(fsqrt, i32, i32)
 -
 -DEF_HELPER_2(fcmp_un, i32, i32, i32)
 -DEF_HELPER_2(fcmp_lt, i32, i32, i32)
 -DEF_HELPER_2(fcmp_eq, i32, i32, i32)
 -DEF_HELPER_2(fcmp_le, i32, i32, i32)
 -DEF_HELPER_2(fcmp_gt, i32, i32, i32)
 -DEF_HELPER_2(fcmp_ne, i32, i32, i32)
 -DEF_HELPER_2(fcmp_ge, i32, i32, i32)
 +DEF_HELPER_3(divs, i32, env, i32, i32)
 +DEF_HELPER_3(divu, i32, env, i32, i32)
 +
 +DEF_HELPER_3(fadd, i32, env, i32, i32)
 +DEF_HELPER_3(frsub, i32, env, i32, i32)
 +DEF_HELPER_3(fmul, i32, env, i32, i32)
 +DEF_HELPER_3(fdiv, i32, env, i32, i32)
 +DEF_HELPER_2(flt, i32, env, i32)
 +DEF_HELPER_2(fint, i32, env, i32)
 +DEF_HELPER_2(fsqrt, i32, env, i32)
 +
 +DEF_HELPER_3(fcmp_un, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_lt, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_eq, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_le, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_gt, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_ne, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_ge, i32, env, i32, i32)

  DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32)
  #if !defined(CONFIG_USER_ONLY)
 -DEF_HELPER_1(mmu_read, i32, i32)
 -DEF_HELPER_2(mmu_write, void, i32, i32)
 +DEF_HELPER_2(mmu_read, i32, env, i32)
 +DEF_HELPER_3(mmu_write, void, env, i32, i32)
  #endif

 -DEF_HELPER_4(memalign, void, i32, i32, i32, i32)
 -DEF_HELPER_1(stackprot, void, i32)
 +DEF_HELPER_5(memalign, void, env, i32, i32, i32, i32)
 +DEF_HELPER_2(stackprot, void, env, i32)

  DEF_HELPER_2(get, i32, i32, i32)
  DEF_HELPER_3(put, void, i32, i32, i32)
 diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
 index 3b1f072..c9789f4 100644
 --- a/target-microblaze/op_helper.c
 +++ b/target-microblaze/op_helper.c
 @@ -20,7 +20,6 @@

  #include assert.h
  #include cpu.h
 -#include dyngen-exec.h
  #include helper.h
  #include host-utils.h

 @@ -42,17 +41,12 @@
  /* Try to fill the TLB and return an exception if error. If retaddr is
 NULL, it means that the function was called in C code (i.e. not
 from generated code or from helper.c) */
 -/* XXX: fix it to restore all registers */
 -void tlb_fill(CPUMBState *env1, target_ulong addr, int is_write, int 
 mmu_idx,
 +void tlb_fill(CPUMBState *env, target_ulong addr, int is_write, int mmu_idx,
uintptr_t retaddr)
  {
  TranslationBlock *tb;
 -CPUMBState *saved_env;
  int ret;

 -saved_env = env;
 -env = env1;
 -
  ret = cpu_mb_handle_mmu_fault(env, addr, is_write, mmu_idx);
  if (unlikely(ret)) {
  if (retaddr) {
 @@ -66,7 +60,6 @@ void tlb_fill(CPUMBState *env1, target_ulong addr, int 
 is_write, int mmu_idx,
  }
 

Re: [Qemu-devel] [PATCH 17/21] target-microblaze: switch to AREG0 free mode

2012-09-06 Thread Aurelien Jarno
On Sun, Sep 02, 2012 at 05:33:46PM +, Blue Swirl wrote:
 Add an explicit CPUState parameter instead of relying on AREG0
 and switch to AREG0 free mode.
 
 Signed-off-by: Blue Swirl blauwir...@gmail.com
 ---
  configure   |2 +-
  target-microblaze/Makefile.objs |2 -
  target-microblaze/helper.h  |   48 
  target-microblaze/op_helper.c   |  115 
 ++-
  target-microblaze/translate.c   |   56 +++-
  5 files changed, 108 insertions(+), 115 deletions(-)
 
 diff --git a/configure b/configure
 index efb5014..e464d2f 100755
 --- a/configure
 +++ b/configure
 @@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
 $target_dir/Makefile
  
  
  case $target_arch2 in
 -  alpha | arm* | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | 
 x86_64 | xtensa* | ppc*)
 +  alpha | arm* | i386 | lm32 | m68k | microblaze* | or32 | s390x | sparc* | 
 unicore32 | x86_64 | xtensa* | ppc*)
  echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
;;
  esac
 diff --git a/target-microblaze/Makefile.objs b/target-microblaze/Makefile.objs
 index 4b09e8c..afb87bc 100644
 --- a/target-microblaze/Makefile.objs
 +++ b/target-microblaze/Makefile.objs
 @@ -1,4 +1,2 @@
  obj-y += translate.o op_helper.o helper.o cpu.o
  obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
 -
 -$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
 diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h
 index 9dcfb0f..a1a732c 100644
 --- a/target-microblaze/helper.h
 +++ b/target-microblaze/helper.h
 @@ -1,39 +1,39 @@
  #include def-helper.h
  
 -DEF_HELPER_1(raise_exception, void, i32)
 -DEF_HELPER_0(debug, void)
 +DEF_HELPER_2(raise_exception, void, env, i32)
 +DEF_HELPER_1(debug, void, env)
  DEF_HELPER_FLAGS_3(carry, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32, i32)
  DEF_HELPER_2(cmp, i32, i32, i32)
  DEF_HELPER_2(cmpu, i32, i32, i32)
  DEF_HELPER_FLAGS_1(clz, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32)
  
 -DEF_HELPER_2(divs, i32, i32, i32)
 -DEF_HELPER_2(divu, i32, i32, i32)
 -
 -DEF_HELPER_2(fadd, i32, i32, i32)
 -DEF_HELPER_2(frsub, i32, i32, i32)
 -DEF_HELPER_2(fmul, i32, i32, i32)
 -DEF_HELPER_2(fdiv, i32, i32, i32)
 -DEF_HELPER_1(flt, i32, i32)
 -DEF_HELPER_1(fint, i32, i32)
 -DEF_HELPER_1(fsqrt, i32, i32)
 -
 -DEF_HELPER_2(fcmp_un, i32, i32, i32)
 -DEF_HELPER_2(fcmp_lt, i32, i32, i32)
 -DEF_HELPER_2(fcmp_eq, i32, i32, i32)
 -DEF_HELPER_2(fcmp_le, i32, i32, i32)
 -DEF_HELPER_2(fcmp_gt, i32, i32, i32)
 -DEF_HELPER_2(fcmp_ne, i32, i32, i32)
 -DEF_HELPER_2(fcmp_ge, i32, i32, i32)
 +DEF_HELPER_3(divs, i32, env, i32, i32)
 +DEF_HELPER_3(divu, i32, env, i32, i32)
 +
 +DEF_HELPER_3(fadd, i32, env, i32, i32)
 +DEF_HELPER_3(frsub, i32, env, i32, i32)
 +DEF_HELPER_3(fmul, i32, env, i32, i32)
 +DEF_HELPER_3(fdiv, i32, env, i32, i32)
 +DEF_HELPER_2(flt, i32, env, i32)
 +DEF_HELPER_2(fint, i32, env, i32)
 +DEF_HELPER_2(fsqrt, i32, env, i32)
 +
 +DEF_HELPER_3(fcmp_un, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_lt, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_eq, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_le, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_gt, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_ne, i32, env, i32, i32)
 +DEF_HELPER_3(fcmp_ge, i32, env, i32, i32)
  
  DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32)
  #if !defined(CONFIG_USER_ONLY)
 -DEF_HELPER_1(mmu_read, i32, i32)
 -DEF_HELPER_2(mmu_write, void, i32, i32)
 +DEF_HELPER_2(mmu_read, i32, env, i32)
 +DEF_HELPER_3(mmu_write, void, env, i32, i32)
  #endif
  
 -DEF_HELPER_4(memalign, void, i32, i32, i32, i32)
 -DEF_HELPER_1(stackprot, void, i32)
 +DEF_HELPER_5(memalign, void, env, i32, i32, i32, i32)
 +DEF_HELPER_2(stackprot, void, env, i32)
  
  DEF_HELPER_2(get, i32, i32, i32)
  DEF_HELPER_3(put, void, i32, i32, i32)
 diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
 index 3b1f072..c9789f4 100644
 --- a/target-microblaze/op_helper.c
 +++ b/target-microblaze/op_helper.c
 @@ -20,7 +20,6 @@
  
  #include assert.h
  #include cpu.h
 -#include dyngen-exec.h
  #include helper.h
  #include host-utils.h
  
 @@ -42,17 +41,12 @@
  /* Try to fill the TLB and return an exception if error. If retaddr is
 NULL, it means that the function was called in C code (i.e. not
 from generated code or from helper.c) */
 -/* XXX: fix it to restore all registers */
 -void tlb_fill(CPUMBState *env1, target_ulong addr, int is_write, int mmu_idx,
 +void tlb_fill(CPUMBState *env, target_ulong addr, int is_write, int mmu_idx,
uintptr_t retaddr)
  {
  TranslationBlock *tb;
 -CPUMBState *saved_env;
  int ret;
  
 -saved_env = env;
 -env = env1;
 -
  ret = cpu_mb_handle_mmu_fault(env, addr, is_write, mmu_idx);
  if (unlikely(ret)) {
  if (retaddr) {
 @@ -66,7 +60,6 @@ void tlb_fill(CPUMBState *env1, target_ulong addr, int 
 is_write, int mmu_idx,
  }
  cpu_loop_exit(env);
  }
 -env = saved_env;
  }
  

[Qemu-devel] [PATCH 17/21] target-microblaze: switch to AREG0 free mode

2012-09-02 Thread Blue Swirl
Add an explicit CPUState parameter instead of relying on AREG0
and switch to AREG0 free mode.

Signed-off-by: Blue Swirl blauwir...@gmail.com
---
 configure   |2 +-
 target-microblaze/Makefile.objs |2 -
 target-microblaze/helper.h  |   48 
 target-microblaze/op_helper.c   |  115 ++-
 target-microblaze/translate.c   |   56 +++-
 5 files changed, 108 insertions(+), 115 deletions(-)

diff --git a/configure b/configure
index efb5014..e464d2f 100755
--- a/configure
+++ b/configure
@@ -3829,7 +3829,7 @@ symlink $source_path/Makefile.target 
$target_dir/Makefile
 
 
 case $target_arch2 in
-  alpha | arm* | i386 | lm32 | m68k | or32 | s390x | sparc* | unicore32 | 
x86_64 | xtensa* | ppc*)
+  alpha | arm* | i386 | lm32 | m68k | microblaze* | or32 | s390x | sparc* | 
unicore32 | x86_64 | xtensa* | ppc*)
 echo CONFIG_TCG_PASS_AREG0=y  $config_target_mak
   ;;
 esac
diff --git a/target-microblaze/Makefile.objs b/target-microblaze/Makefile.objs
index 4b09e8c..afb87bc 100644
--- a/target-microblaze/Makefile.objs
+++ b/target-microblaze/Makefile.objs
@@ -1,4 +1,2 @@
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-$(CONFIG_SOFTMMU) += mmu.o machine.o
-
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h
index 9dcfb0f..a1a732c 100644
--- a/target-microblaze/helper.h
+++ b/target-microblaze/helper.h
@@ -1,39 +1,39 @@
 #include def-helper.h
 
-DEF_HELPER_1(raise_exception, void, i32)
-DEF_HELPER_0(debug, void)
+DEF_HELPER_2(raise_exception, void, env, i32)
+DEF_HELPER_1(debug, void, env)
 DEF_HELPER_FLAGS_3(carry, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32, i32)
 DEF_HELPER_2(cmp, i32, i32, i32)
 DEF_HELPER_2(cmpu, i32, i32, i32)
 DEF_HELPER_FLAGS_1(clz, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32)
 
-DEF_HELPER_2(divs, i32, i32, i32)
-DEF_HELPER_2(divu, i32, i32, i32)
-
-DEF_HELPER_2(fadd, i32, i32, i32)
-DEF_HELPER_2(frsub, i32, i32, i32)
-DEF_HELPER_2(fmul, i32, i32, i32)
-DEF_HELPER_2(fdiv, i32, i32, i32)
-DEF_HELPER_1(flt, i32, i32)
-DEF_HELPER_1(fint, i32, i32)
-DEF_HELPER_1(fsqrt, i32, i32)
-
-DEF_HELPER_2(fcmp_un, i32, i32, i32)
-DEF_HELPER_2(fcmp_lt, i32, i32, i32)
-DEF_HELPER_2(fcmp_eq, i32, i32, i32)
-DEF_HELPER_2(fcmp_le, i32, i32, i32)
-DEF_HELPER_2(fcmp_gt, i32, i32, i32)
-DEF_HELPER_2(fcmp_ne, i32, i32, i32)
-DEF_HELPER_2(fcmp_ge, i32, i32, i32)
+DEF_HELPER_3(divs, i32, env, i32, i32)
+DEF_HELPER_3(divu, i32, env, i32, i32)
+
+DEF_HELPER_3(fadd, i32, env, i32, i32)
+DEF_HELPER_3(frsub, i32, env, i32, i32)
+DEF_HELPER_3(fmul, i32, env, i32, i32)
+DEF_HELPER_3(fdiv, i32, env, i32, i32)
+DEF_HELPER_2(flt, i32, env, i32)
+DEF_HELPER_2(fint, i32, env, i32)
+DEF_HELPER_2(fsqrt, i32, env, i32)
+
+DEF_HELPER_3(fcmp_un, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_lt, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_eq, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_le, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_gt, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_ne, i32, env, i32, i32)
+DEF_HELPER_3(fcmp_ge, i32, env, i32, i32)
 
 DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_PURE | TCG_CALL_CONST, i32, i32, i32)
 #if !defined(CONFIG_USER_ONLY)
-DEF_HELPER_1(mmu_read, i32, i32)
-DEF_HELPER_2(mmu_write, void, i32, i32)
+DEF_HELPER_2(mmu_read, i32, env, i32)
+DEF_HELPER_3(mmu_write, void, env, i32, i32)
 #endif
 
-DEF_HELPER_4(memalign, void, i32, i32, i32, i32)
-DEF_HELPER_1(stackprot, void, i32)
+DEF_HELPER_5(memalign, void, env, i32, i32, i32, i32)
+DEF_HELPER_2(stackprot, void, env, i32)
 
 DEF_HELPER_2(get, i32, i32, i32)
 DEF_HELPER_3(put, void, i32, i32, i32)
diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
index 3b1f072..c9789f4 100644
--- a/target-microblaze/op_helper.c
+++ b/target-microblaze/op_helper.c
@@ -20,7 +20,6 @@
 
 #include assert.h
 #include cpu.h
-#include dyngen-exec.h
 #include helper.h
 #include host-utils.h
 
@@ -42,17 +41,12 @@
 /* Try to fill the TLB and return an exception if error. If retaddr is
NULL, it means that the function was called in C code (i.e. not
from generated code or from helper.c) */
-/* XXX: fix it to restore all registers */
-void tlb_fill(CPUMBState *env1, target_ulong addr, int is_write, int mmu_idx,
+void tlb_fill(CPUMBState *env, target_ulong addr, int is_write, int mmu_idx,
   uintptr_t retaddr)
 {
 TranslationBlock *tb;
-CPUMBState *saved_env;
 int ret;
 
-saved_env = env;
-env = env1;
-
 ret = cpu_mb_handle_mmu_fault(env, addr, is_write, mmu_idx);
 if (unlikely(ret)) {
 if (retaddr) {
@@ -66,7 +60,6 @@ void tlb_fill(CPUMBState *env1, target_ulong addr, int 
is_write, int mmu_idx,
 }
 cpu_loop_exit(env);
 }
-env = saved_env;
 }
 #endif
 
@@ -105,13 +98,13 @@ uint32_t helper_get(uint32_t id, uint32_t ctrl)
 return 0xdead | id;
 }
 
-void helper_raise_exception(uint32_t index)
+void helper_raise_exception(CPUMBState *env,