render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0084-tcg-sparc-Assume-v9-cpu-always-i.e.-force-v8plus-in-.patch

5544c1
From cf873edf4227be439a9ffa5abb3da61ff1fd6527 Mon Sep 17 00:00:00 2001
5544c1
From: Richard Henderson <rth@twiddle.net>
5544c1
Date: Fri, 21 Sep 2012 10:34:21 -0700
5544c1
Subject: [PATCH] tcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit
5544c1
 mode.
5544c1
5544c1
Current code doesn't actually work in 32-bit mode at all.  Since
5544c1
no one really noticed, drop the complication of v7 and v8 cpus.
5544c1
Eliminate the --sparc_cpu configure option and standardize macro
5544c1
testing on TCG_TARGET_REG_BITS / HOST_LONG_BITS
5544c1
5544c1
Signed-off-by: Richard Henderson <rth@twiddle.net>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 configure              | 40 ++++------------------------------------
5544c1
 disas.c                |  2 --
5544c1
 exec.c                 |  6 +++---
5544c1
 qemu-timer.h           |  8 +++++---
5544c1
 tcg/sparc/tcg-target.c | 20 +++++---------------
5544c1
 tcg/sparc/tcg-target.h |  7 ++++---
5544c1
 tcg/tcg.c              |  3 ++-
5544c1
 7 files changed, 23 insertions(+), 63 deletions(-)
5544c1
5544c1
diff --git a/configure b/configure
5544c1
index 816f0f9..0590f16 100755
5544c1
--- a/configure
5544c1
+++ b/configure
5544c1
@@ -111,7 +111,6 @@ source_path=`dirname "$0"`
5544c1
 cpu=""
5544c1
 interp_prefix="/usr/gnemul/qemu-%M"
5544c1
 static="no"
5544c1
-sparc_cpu=""
5544c1
 cross_prefix=""
5544c1
 audio_drv_list=""
5544c1
 audio_card_list="ac97 es1370 sb16 hda"
5544c1
@@ -249,21 +248,6 @@ for opt do
5544c1
   ;;
5544c1
   --disable-debug-info) debug_info="no"
5544c1
   ;;
5544c1
-  --sparc_cpu=*)
5544c1
-    sparc_cpu="$optarg"
5544c1
-    case $sparc_cpu in
5544c1
-    v7|v8|v8plus|v8plusa)
5544c1
-      cpu="sparc"
5544c1
-    ;;
5544c1
-    v9)
5544c1
-      cpu="sparc64"
5544c1
-    ;;
5544c1
-    *)
5544c1
-      echo "undefined SPARC architecture. Exiting";
5544c1
-      exit 1
5544c1
-    ;;
5544c1
-    esac
5544c1
-  ;;
5544c1
   esac
5544c1
 done
5544c1
 # OS specific
5544c1
@@ -351,8 +335,6 @@ elif check_define __i386__ ; then
5544c1
 elif check_define __x86_64__ ; then
5544c1
   cpu="x86_64"
5544c1
 elif check_define __sparc__ ; then
5544c1
-  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
5544c1
-  # They must be specified using --sparc_cpu
5544c1
   if check_define __arch64__ ; then
5544c1
     cpu="sparc64"
5544c1
   else
5544c1
@@ -798,8 +780,6 @@ for opt do
5544c1
   ;;
5544c1
   --enable-uname-release=*) uname_release="$optarg"
5544c1
   ;;
5544c1
-  --sparc_cpu=*)
5544c1
-  ;;
5544c1
   --enable-werror) werror="yes"
5544c1
   ;;
5544c1
   --disable-werror) werror="no"
5544c1
@@ -883,31 +863,19 @@ for opt do
5544c1
   esac
5544c1
 done
5544c1
 
5544c1
-#
5544c1
-# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
5544c1
-# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
5544c1
-#
5544c1
 host_guest_base="no"
5544c1
 case "$cpu" in
5544c1
-    sparc) case $sparc_cpu in
5544c1
-           v7|v8)
5544c1
-             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
5544c1
-           ;;
5544c1
-           v8plus|v8plusa)
5544c1
-             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
5544c1
-           ;;
5544c1
-           *) # sparc_cpu not defined in the command line
5544c1
-             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
5544c1
-           esac
5544c1
+    sparc)
5544c1
            LDFLAGS="-m32 $LDFLAGS"
5544c1
-           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
5544c1
+           QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
5544c1
+           QEMU_CFLAGS="-ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
5544c1
            if test "$solaris" = "no" ; then
5544c1
              QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
5544c1
            fi
5544c1
            ;;
5544c1
     sparc64)
5544c1
-           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
5544c1
            LDFLAGS="-m64 $LDFLAGS"
5544c1
+           QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
5544c1
            QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
5544c1
            if test "$solaris" != "no" ; then
5544c1
              QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
5544c1
diff --git a/disas.c b/disas.c
5544c1
index 7b2acc9..b801c8f 100644
5544c1
--- a/disas.c
5544c1
+++ b/disas.c
5544c1
@@ -316,9 +316,7 @@ void disas(FILE *out, void *code, unsigned long size)
5544c1
     print_insn = print_insn_alpha;
5544c1
 #elif defined(__sparc__)
5544c1
     print_insn = print_insn_sparc;
5544c1
-#if defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) || defined(__sparc_v9__)
5544c1
     disasm_info.mach = bfd_mach_sparc_v9b;
5544c1
-#endif
5544c1
 #elif defined(__arm__)
5544c1
     print_insn = print_insn_arm;
5544c1
 #elif defined(__MIPSEB__)
5544c1
diff --git a/exec.c b/exec.c
5544c1
index 871a68a..ad175db 100644
5544c1
--- a/exec.c
5544c1
+++ b/exec.c
5544c1
@@ -86,7 +86,7 @@ static int nb_tbs;
5544c1
 /* any access to the tbs or the page table must use this lock */
5544c1
 spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
5544c1
 
5544c1
-#if defined(__arm__) || defined(__sparc_v9__)
5544c1
+#if defined(__arm__) || defined(__sparc__)
5544c1
 /* The prologue must be reachable with a direct jump. ARM and Sparc64
5544c1
  have limited branch ranges (possibly also PPC) so place it in a
5544c1
  section close to code segment. */
5544c1
@@ -541,7 +541,7 @@ static void code_gen_alloc(unsigned long tb_size)
5544c1
         /* Cannot map more than that */
5544c1
         if (code_gen_buffer_size > (800 * 1024 * 1024))
5544c1
             code_gen_buffer_size = (800 * 1024 * 1024);
5544c1
-#elif defined(__sparc_v9__)
5544c1
+#elif defined(__sparc__) && HOST_LONG_BITS == 64
5544c1
         // Map the buffer below 2G, so we can use direct calls and branches
5544c1
         start = (void *) 0x40000000UL;
5544c1
         if (code_gen_buffer_size > (512 * 1024 * 1024))
5544c1
@@ -581,7 +581,7 @@ static void code_gen_alloc(unsigned long tb_size)
5544c1
         /* Cannot map more than that */
5544c1
         if (code_gen_buffer_size > (800 * 1024 * 1024))
5544c1
             code_gen_buffer_size = (800 * 1024 * 1024);
5544c1
-#elif defined(__sparc_v9__)
5544c1
+#elif defined(__sparc__) && HOST_LONG_BITS == 64
5544c1
         // Map the buffer below 2G, so we can use direct calls and branches
5544c1
         addr = (void *) 0x40000000UL;
5544c1
         if (code_gen_buffer_size > (512 * 1024 * 1024)) {
5544c1
diff --git a/qemu-timer.h b/qemu-timer.h
5544c1
index f8af595..da7e97c 100644
5544c1
--- a/qemu-timer.h
5544c1
+++ b/qemu-timer.h
5544c1
@@ -218,7 +218,7 @@ static inline int64_t cpu_get_real_ticks(void)
5544c1
     return val;
5544c1
 }
5544c1
 
5544c1
-#elif defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) || defined(__sparc_v9__)
5544c1
+#elif defined(__sparc__)
5544c1
 
5544c1
 static inline int64_t cpu_get_real_ticks (void)
5544c1
 {
5544c1
@@ -227,6 +227,8 @@ static inline int64_t cpu_get_real_ticks (void)
5544c1
     asm volatile("rd %%tick,%0" : "=r"(rval));
5544c1
     return rval;
5544c1
 #else
5544c1
+    /* We need an %o or %g register for this.  For recent enough gcc
5544c1
+       there is an "h" constraint for that.  Don't bother with that.  */
5544c1
     union {
5544c1
         uint64_t i64;
5544c1
         struct {
5544c1
@@ -234,8 +236,8 @@ static inline int64_t cpu_get_real_ticks (void)
5544c1
             uint32_t low;
5544c1
         }       i32;
5544c1
     } rval;
5544c1
-    asm volatile("rd %%tick,%1; srlx %1,32,%0"
5544c1
-                 : "=r"(rval.i32.high), "=r"(rval.i32.low));
5544c1
+    asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1"
5544c1
+                 : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1");
5544c1
     return rval.i64;
5544c1
 #endif
5544c1
 }
5544c1
diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c
5544c1
index 0a19313..23c2fda 100644
5544c1
--- a/tcg/sparc/tcg-target.c
5544c1
+++ b/tcg/sparc/tcg-target.c
5544c1
@@ -621,18 +621,10 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGArg ret,
5544c1
 
5544c1
     default:
5544c1
         tcg_out_cmp(s, c1, c2, c2const);
5544c1
-#if defined(__sparc_v9__) || defined(__sparc_v8plus__)
5544c1
         tcg_out_movi_imm13(s, ret, 0);
5544c1
-        tcg_out32 (s, ARITH_MOVCC | INSN_RD(ret)
5544c1
-                   | INSN_RS1(tcg_cond_to_bcond[cond])
5544c1
-                   | MOVCC_ICC | INSN_IMM11(1));
5544c1
-#else
5544c1
-        t = gen_new_label();
5544c1
-        tcg_out_branch_i32(s, INSN_COND(tcg_cond_to_bcond[cond], 1), t);
5544c1
-        tcg_out_movi_imm13(s, ret, 1);
5544c1
-        tcg_out_movi_imm13(s, ret, 0);
5544c1
-        tcg_out_label(s, t, s->code_ptr);
5544c1
-#endif
5544c1
+        tcg_out32(s, ARITH_MOVCC | INSN_RD(ret)
5544c1
+                  | INSN_RS1(tcg_cond_to_bcond[cond])
5544c1
+                  | MOVCC_ICC | INSN_IMM11(1));
5544c1
         return;
5544c1
     }
5544c1
 
5544c1
@@ -742,7 +734,7 @@ static const void * const qemu_st_helpers[4] = {
5544c1
 #endif
5544c1
 #endif
5544c1
 
5544c1
-#ifdef __arch64__
5544c1
+#if TCG_TARGET_REG_BITS == 64
5544c1
 #define HOST_LD_OP LDX
5544c1
 #define HOST_ST_OP STX
5544c1
 #define HOST_SLL_OP SHIFT_SLLX
5544c1
@@ -1600,11 +1592,9 @@ static void tcg_target_init(TCGContext *s)
5544c1
 
5544c1
 #if TCG_TARGET_REG_BITS == 64
5544c1
 # define ELF_HOST_MACHINE  EM_SPARCV9
5544c1
-#elif defined(__sparc_v8plus__)
5544c1
+#else
5544c1
 # define ELF_HOST_MACHINE  EM_SPARC32PLUS
5544c1
 # define ELF_HOST_FLAGS    EF_SPARC_32PLUS
5544c1
-#else
5544c1
-# define ELF_HOST_MACHINE  EM_SPARC
5544c1
 #endif
5544c1
 
5544c1
 typedef struct {
5544c1
diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h
5544c1
index d762574..adca1d2 100644
5544c1
--- a/tcg/sparc/tcg-target.h
5544c1
+++ b/tcg/sparc/tcg-target.h
5544c1
@@ -67,7 +67,8 @@ typedef enum {
5544c1
 
5544c1
 /* used for function call generation */
5544c1
 #define TCG_REG_CALL_STACK TCG_REG_I6
5544c1
-#ifdef __arch64__
5544c1
+
5544c1
+#if TCG_TARGET_REG_BITS == 64
5544c1
 // Reserve space for AREG0
5544c1
 #define TCG_TARGET_STACK_MINFRAME (176 + 4 * (int)sizeof(long) + \
5544c1
                                    TCG_STATIC_CALL_ARGS_SIZE)
5544c1
@@ -81,7 +82,7 @@ typedef enum {
5544c1
 #define TCG_TARGET_STACK_ALIGN 8
5544c1
 #endif
5544c1
 
5544c1
-#ifdef __arch64__
5544c1
+#if TCG_TARGET_REG_BITS == 64
5544c1
 #define TCG_TARGET_EXTEND_ARGS 1
5544c1
 #endif
5544c1
 
5544c1
@@ -129,7 +130,7 @@ typedef enum {
5544c1
 
5544c1
 #ifdef CONFIG_SOLARIS
5544c1
 #define TCG_AREG0 TCG_REG_G2
5544c1
-#elif defined(__sparc_v9__)
5544c1
+#elif HOST_LONG_BITS == 64
5544c1
 #define TCG_AREG0 TCG_REG_G5
5544c1
 #else
5544c1
 #define TCG_AREG0 TCG_REG_G6
5544c1
diff --git a/tcg/tcg.c b/tcg/tcg.c
5544c1
index 93421cd..16c4e1d 100644
5544c1
--- a/tcg/tcg.c
5544c1
+++ b/tcg/tcg.c
5544c1
@@ -1450,7 +1450,8 @@ static void temp_allocate_frame(TCGContext *s, int temp)
5544c1
 {
5544c1
     TCGTemp *ts;
5544c1
     ts = &s->temps[temp];
5544c1
-#ifndef __sparc_v9__ /* Sparc64 stack is accessed with offset of 2047 */
5544c1
+#if !(defined(__sparc__) && TCG_TARGET_REG_BITS == 64)
5544c1
+    /* Sparc64 stack is accessed with offset of 2047 */
5544c1
     s->current_frame_offset = (s->current_frame_offset +
5544c1
                                (tcg_target_long)sizeof(tcg_target_long) - 1) &
5544c1
         ~(sizeof(tcg_target_long) - 1);
5544c1
-- 
5544c1
1.7.12.1
5544c1