qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Laurent Desnogues" <laurent.desnogues@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH][TCG] Move gen_opc_ptr and gen_opparam_ptr into tcg context
Date: Wed, 30 Jul 2008 13:04:56 +0200	[thread overview]
Message-ID: <761ea48b0807300404j5fe7a8e2pf03bedba8b3b8b45@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 242 bytes --]

Hello,

this patch moves gen_opc_ptr and gen_opparam_ptr into tcg context.
This modification was "asked for" in tcg.c.  It seems not to alter speed
(I took care putting the 2 new structure elements at the beginning of the
context).


Laurent

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tcg-gen_op.patch --]
[-- Type: text/x-patch; name=tcg-gen_op.patch, Size: 22543 bytes --]

Index: target-alpha/translate.c
===================================================================
--- target-alpha/translate.c	(revision 4975)
+++ target-alpha/translate.c	(working copy)
@@ -2012,7 +2012,7 @@
             }
         }
         if (search_pc) {
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -2066,9 +2066,9 @@
     /* Generate the return instruction */
     tcg_gen_exit_tb(0);
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
     if (search_pc) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: target-arm/translate.c
===================================================================
--- target-arm/translate.c	(revision 4975)
+++ target-arm/translate.c	(working copy)
@@ -8646,7 +8646,7 @@
             }
         }
         if (search_pc) {
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -8693,7 +8693,7 @@
          * Also stop translation when a page boundary is reached.  This
          * ensures prefetch aborts occur at the right place.  */
         num_insns ++;
-    } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
+    } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
              !env->singlestep_enabled &&
              dc->pc < next_page_start &&
              num_insns < max_insns);
@@ -8773,7 +8773,7 @@
 
 done_generating:
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
 
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_IN_ASM) {
@@ -8784,7 +8784,7 @@
     }
 #endif
     if (search_pc) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: target-cris/translate.c
===================================================================
--- target-cris/translate.c	(revision 4975)
+++ target-cris/translate.c	(working copy)
@@ -3108,7 +3108,7 @@
 		check_breakpoint(env, dc);
 
 		if (search_pc) {
-			j = gen_opc_ptr - gen_opc_buf;
+			j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
 			if (lj < j) {
 				lj++;
 				while (lj < j)
@@ -3165,7 +3165,7 @@
 		   delay slots dont break.  */
 		if (!(tb->pc & 1) && env->singlestep_enabled)
 			break;
-	} while (!dc->is_jmp && gen_opc_ptr < gen_opc_end
+	} while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end
 		 && (dc->pc < next_page_start)
                  && num_insns < max_insns);
 
@@ -3214,9 +3214,9 @@
 		}
 	}
         gen_icount_end(tb, num_insns);
-	*gen_opc_ptr = INDEX_op_end;
+	*tcg_ctx.gen_opc_ptr = INDEX_op_end;
 	if (search_pc) {
-		j = gen_opc_ptr - gen_opc_buf;
+		j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
 		lj++;
 		while (lj <= j)
 			gen_opc_instr_start[lj++] = 0;
@@ -3231,7 +3231,7 @@
 		fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
 		target_disas(logfile, pc_start, dc->pc - pc_start, 0);
 		fprintf(logfile, "\nisize=%d osize=%zd\n",
-			dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
+			dc->pc - pc_start, tcg_ctx.gen_opc_ptr - gen_opc_buf);
 	}
 #endif
 }
Index: target-i386/translate.c
===================================================================
--- target-i386/translate.c	(revision 4975)
+++ target-i386/translate.c	(working copy)
@@ -7247,7 +7247,7 @@
             }
         }
         if (search_pc) {
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -7278,7 +7278,7 @@
             break;
         }
         /* if too long translation, stop generation too */
-        if (gen_opc_ptr >= gen_opc_end ||
+        if (tcg_ctx.gen_opc_ptr >= gen_opc_end ||
             (pc_ptr - pc_start) >= (TARGET_PAGE_SIZE - 32) ||
             num_insns >= max_insns) {
             gen_jmp_im(pc_ptr - dc->cs_base);
@@ -7289,10 +7289,10 @@
     if (tb->cflags & CF_LAST_IO)
         gen_io_end();
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
     /* we don't forget to fill the last values */
     if (search_pc) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: target-m68k/translate.c
===================================================================
--- target-m68k/translate.c	(revision 4975)
+++ target-m68k/translate.c	(working copy)
@@ -2962,7 +2962,7 @@
                 break;
         }
         if (search_pc) {
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -2984,7 +2984,7 @@
          * IRQ raising bits.  */
         if (dc->is_mem && env->nb_watchpoints)
             break;
-    } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
+    } while (!dc->is_jmp && tcg_ctx.gen_opc_ptr < gen_opc_end &&
              !env->singlestep_enabled &&
              (pc_offset) < (TARGET_PAGE_SIZE - 32) &&
              num_insns < max_insns);
@@ -3017,7 +3017,7 @@
         }
     }
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
 
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_IN_ASM) {
@@ -3028,7 +3028,7 @@
     }
 #endif
     if (search_pc) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: target-mips/translate.c
===================================================================
--- target-mips/translate.c	(revision 4975)
+++ target-mips/translate.c	(working copy)
@@ -8514,7 +8514,7 @@
         }
 
         if (search_pc) {
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -8538,7 +8538,7 @@
         if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
             break;
 
-        if (gen_opc_ptr >= gen_opc_end)
+        if (tcg_ctx.gen_opc_ptr >= gen_opc_end)
             break;
 
         if (num_insns >= max_insns)
@@ -8573,9 +8573,9 @@
     }
 done_generating:
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
     if (search_pc) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: target-ppc/translate.c
===================================================================
--- target-ppc/translate.c	(revision 4975)
+++ target-ppc/translate.c	(working copy)
@@ -209,7 +209,7 @@
     if (set_fprf != 0) {
         /* This case might be optimized later */
 #if defined(OPTIMIZE_FPRF_UPDATE)
-        *gen_fprf_ptr++ = gen_opc_ptr;
+        *gen_fprf_ptr++ = tcg_ctx.gen_opc_ptr;
 #endif
         gen_op_compute_fprf(1);
         if (unlikely(set_rc))
@@ -6233,7 +6233,7 @@
 
     gen_icount_start();
     /* Set env in case of segfault during code fetch */
-    while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
+    while (ctx.exception == POWERPC_EXCP_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) {
         if (unlikely(env->nb_breakpoints > 0)) {
             for (j = 0; j < env->nb_breakpoints; j++) {
                 if (env->breakpoints[j] == ctx.nip) {
@@ -6244,7 +6244,7 @@
             }
         }
         if (unlikely(search_pc)) {
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -6355,9 +6355,9 @@
         tcg_gen_exit_tb(0);
     }
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
     if (unlikely(search_pc)) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: target-sh4/translate.c
===================================================================
--- target-sh4/translate.c	(revision 4975)
+++ target-sh4/translate.c	(working copy)
@@ -1234,7 +1234,7 @@
     if (max_insns == 0)
         max_insns = CF_COUNT_MASK;
     gen_icount_start();
-    while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) {
+    while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end) {
 	if (env->nb_breakpoints > 0) {
 	    for (i = 0; i < env->nb_breakpoints; i++) {
 		if (ctx.pc == env->breakpoints[i]) {
@@ -1247,7 +1247,7 @@
 	    }
 	}
         if (search_pc) {
-            i = gen_opc_ptr - gen_opc_buf;
+            i = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (ii < i) {
                 ii++;
                 while (ii < i)
@@ -1304,9 +1304,9 @@
     }
 
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
     if (search_pc) {
-        i = gen_opc_ptr - gen_opc_buf;
+        i = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         ii++;
         while (ii <= i)
             gen_opc_instr_start[ii++] = 0;
Index: target-sparc/translate.c
===================================================================
--- target-sparc/translate.c	(revision 4975)
+++ target-sparc/translate.c	(working copy)
@@ -4787,7 +4787,7 @@
         if (spc) {
             if (loglevel > 0)
                 fprintf(logfile, "Search PC...\n");
-            j = gen_opc_ptr - gen_opc_buf;
+            j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
                 while (lj < j)
@@ -4820,7 +4820,7 @@
             tcg_gen_exit_tb(0);
             break;
         }
-    } while ((gen_opc_ptr < gen_opc_end) &&
+    } while ((tcg_ctx.gen_opc_ptr < gen_opc_end) &&
              (dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32) &&
              num_insns < max_insns);
 
@@ -4846,9 +4846,9 @@
         }
     }
     gen_icount_end(tb, num_insns);
-    *gen_opc_ptr = INDEX_op_end;
+    *tcg_ctx.gen_opc_ptr = INDEX_op_end;
     if (spc) {
-        j = gen_opc_ptr - gen_opc_buf;
+        j = tcg_ctx.gen_opc_ptr - gen_opc_buf;
         lj++;
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
Index: gen-icount.h
===================================================================
--- gen-icount.h	(revision 4975)
+++ gen-icount.h	(working copy)
@@ -21,7 +21,7 @@
 #endif
     tcg_gen_ld_i32(count, cpu_env, offsetof(CPUState, icount_decr.u32));
     /* This is a horrid hack to allow fixing up the value later.  */
-    icount_arg = gen_opparam_ptr + 1;
+    icount_arg = tcg_ctx.gen_opparam_ptr + 1;
     tcg_gen_subi_i32(count, count, 0xdeadbeef);
 
     tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
Index: tcg/tcg-op.h
===================================================================
--- tcg/tcg-op.h	(revision 4975)
+++ tcg/tcg-op.h	(working copy)
@@ -32,131 +32,131 @@
 
 static inline void tcg_gen_op1(int opc, TCGv arg1)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
 }
 
 static inline void tcg_gen_op1i(int opc, TCGArg arg1)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = arg1;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = arg1;
 }
 
 static inline void tcg_gen_op2(int opc, TCGv arg1, TCGv arg2)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
 }
 
 static inline void tcg_gen_op2i(int opc, TCGv arg1, TCGArg arg2)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = arg2;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = arg2;
 }
 
 static inline void tcg_gen_op2ii(int opc, TCGArg arg1, TCGArg arg2)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = arg1;
-    *gen_opparam_ptr++ = arg2;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = arg1;
+    *tcg_ctx.gen_opparam_ptr++ = arg2;
 }
 
 static inline void tcg_gen_op3(int opc, TCGv arg1, TCGv arg2, TCGv arg3)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
 }
 
 static inline void tcg_gen_op3i(int opc, TCGv arg1, TCGv arg2, TCGArg arg3)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = arg3;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = arg3;
 }
 
 static inline void tcg_gen_op4(int opc, TCGv arg1, TCGv arg2, TCGv arg3, 
                                TCGv arg4)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
-    *gen_opparam_ptr++ = GET_TCGV(arg4);
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg4);
 }
 
 static inline void tcg_gen_op4i(int opc, TCGv arg1, TCGv arg2, TCGv arg3, 
                                 TCGArg arg4)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
-    *gen_opparam_ptr++ = arg4;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opparam_ptr++ = arg4;
 }
 
 static inline void tcg_gen_op4ii(int opc, TCGv arg1, TCGv arg2, TCGArg arg3, 
                                  TCGArg arg4)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = arg3;
-    *gen_opparam_ptr++ = arg4;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = arg3;
+    *tcg_ctx.gen_opparam_ptr++ = arg4;
 }
 
 static inline void tcg_gen_op5(int opc, TCGv arg1, TCGv arg2, 
                                TCGv arg3, TCGv arg4,
                                TCGv arg5)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
-    *gen_opparam_ptr++ = GET_TCGV(arg4);
-    *gen_opparam_ptr++ = GET_TCGV(arg5);
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg4);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg5);
 }
 
 static inline void tcg_gen_op5i(int opc, TCGv arg1, TCGv arg2, 
                                 TCGv arg3, TCGv arg4,
                                 TCGArg arg5)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
-    *gen_opparam_ptr++ = GET_TCGV(arg4);
-    *gen_opparam_ptr++ = arg5;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg4);
+    *tcg_ctx.gen_opparam_ptr++ = arg5;
 }
 
 static inline void tcg_gen_op6(int opc, TCGv arg1, TCGv arg2, 
                                TCGv arg3, TCGv arg4,
                                TCGv arg5, TCGv arg6)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
-    *gen_opparam_ptr++ = GET_TCGV(arg4);
-    *gen_opparam_ptr++ = GET_TCGV(arg5);
-    *gen_opparam_ptr++ = GET_TCGV(arg6);
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg4);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg5);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg6);
 }
 
 static inline void tcg_gen_op6ii(int opc, TCGv arg1, TCGv arg2, 
                                  TCGv arg3, TCGv arg4,
                                  TCGArg arg5, TCGArg arg6)
 {
-    *gen_opc_ptr++ = opc;
-    *gen_opparam_ptr++ = GET_TCGV(arg1);
-    *gen_opparam_ptr++ = GET_TCGV(arg2);
-    *gen_opparam_ptr++ = GET_TCGV(arg3);
-    *gen_opparam_ptr++ = GET_TCGV(arg4);
-    *gen_opparam_ptr++ = arg5;
-    *gen_opparam_ptr++ = arg6;
+    *tcg_ctx.gen_opc_ptr++ = opc;
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg1);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg2);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg3);
+    *tcg_ctx.gen_opparam_ptr++ = GET_TCGV(arg4);
+    *tcg_ctx.gen_opparam_ptr++ = arg5;
+    *tcg_ctx.gen_opparam_ptr++ = arg6;
 }
 
 static inline void gen_set_label(int n)
Index: tcg/tcg.c
===================================================================
--- tcg/tcg.c	(revision 4975)
+++ tcg/tcg.c	(working copy)
@@ -66,10 +66,6 @@
 TCGRegSet tcg_target_available_regs[2];
 TCGRegSet tcg_target_call_clobber_regs;
 
-/* XXX: move that inside the context */
-uint16_t *gen_opc_ptr;
-TCGArg *gen_opparam_ptr;
-
 static inline void tcg_out8(TCGContext *s, uint8_t v)
 {
     *s->code_ptr++ = v;
@@ -270,8 +266,8 @@
     s->nb_labels = 0;
     s->current_frame_offset = s->frame_start;
 
-    gen_opc_ptr = gen_opc_buf;
-    gen_opparam_ptr = gen_opparam_buf;
+    s->gen_opc_ptr = gen_opc_buf;
+    s->gen_opparam_ptr = gen_opparam_buf;
 }
 
 static inline void tcg_temp_alloc(TCGContext *s, int n)
@@ -518,19 +514,19 @@
                                   unsigned int nb_params, const TCGv *params)
 {
     int i;
-    *gen_opc_ptr++ = INDEX_op_call;
-    *gen_opparam_ptr++ = (nb_rets << 16) | (nb_params + 1);
+    *s->gen_opc_ptr++ = INDEX_op_call;
+    *s->gen_opparam_ptr++ = (nb_rets << 16) | (nb_params + 1);
     for(i = 0; i < nb_rets; i++) {
-        *gen_opparam_ptr++ = GET_TCGV(rets[i]);
+        *s->gen_opparam_ptr++ = GET_TCGV(rets[i]);
     }
     for(i = 0; i < nb_params; i++) {
-        *gen_opparam_ptr++ = GET_TCGV(params[i]);
+        *s->gen_opparam_ptr++ = GET_TCGV(params[i]);
     }
-    *gen_opparam_ptr++ = GET_TCGV(func);
+    *s->gen_opparam_ptr++ = GET_TCGV(func);
 
-    *gen_opparam_ptr++ = flags;
+    *s->gen_opparam_ptr++ = flags;
     /* total parameters, needed to go backward in the instruction stream */
-    *gen_opparam_ptr++ = 1 + nb_rets + nb_params + 3;
+    *s->gen_opparam_ptr++ = 1 + nb_rets + nb_params + 3;
 }
 
 
@@ -755,7 +751,7 @@
     first_insn = 1;
     opc_ptr = gen_opc_buf;
     args = gen_opparam_buf;
-    while (opc_ptr < gen_opc_ptr) {
+    while (opc_ptr < s->gen_opc_ptr) {
         c = *opc_ptr++;
         def = &tcg_op_defs[c];
         if (c == INDEX_op_debug_insn_start) {
@@ -1033,9 +1029,9 @@
     uint8_t *dead_temps;
     unsigned int dead_iargs;
     
-    gen_opc_ptr++; /* skip end */
+    s->gen_opc_ptr++; /* skip end */
 
-    nb_ops = gen_opc_ptr - gen_opc_buf;
+    nb_ops = s->gen_opc_ptr - gen_opc_buf;
 
     /* XXX: make it really dynamic */
     s->op_dead_iargs = tcg_malloc(OPC_BUF_SIZE * sizeof(uint16_t));
@@ -1043,7 +1039,7 @@
     dead_temps = tcg_malloc(s->nb_temps);
     memset(dead_temps, 1, s->nb_temps);
 
-    args = gen_opparam_ptr;
+    args = s->gen_opparam_ptr;
     op_index = nb_ops - 1;
     while (op_index >= 0) {
         op = gen_opc_buf[op_index];
@@ -1184,7 +1180,7 @@
 void tcg_liveness_analysis(TCGContext *s)
 {
     int nb_ops;
-    nb_ops = gen_opc_ptr - gen_opc_buf;
+    nb_ops = s->gen_opc_ptr - gen_opc_buf;
 
     s->op_dead_iargs = tcg_malloc(nb_ops * sizeof(uint16_t));
     memset(s->op_dead_iargs, 0, nb_ops * sizeof(uint16_t));
@@ -1979,7 +1975,7 @@
 #ifdef CONFIG_PROFILER
     {
         int n;
-        n = (gen_opc_ptr - gen_opc_buf);
+        n = (s->gen_opc_ptr - gen_opc_buf);
         s->op_count += n;
         if (n > s->op_count_max)
             s->op_count_max = n;
Index: tcg/tcg.h
===================================================================
--- tcg/tcg.h	(revision 4975)
+++ tcg/tcg.h	(working copy)
@@ -209,6 +209,9 @@
 typedef struct TCGContext TCGContext;
 
 struct TCGContext {
+    uint16_t *gen_opc_ptr;
+    TCGArg *gen_opparam_ptr;
+
     uint8_t *pool_cur, *pool_end;
     TCGPool *pool_first, *pool_current;
     TCGLabel *labels;
@@ -267,8 +270,6 @@
 };
 
 extern TCGContext tcg_ctx;
-extern uint16_t *gen_opc_ptr;
-extern TCGArg *gen_opparam_ptr;
 extern uint16_t gen_opc_buf[];
 extern TCGArg gen_opparam_buf[];
 
Index: dyngen.c
===================================================================
--- dyngen.c	(revision 4975)
+++ dyngen.c	(working copy)
@@ -2623,9 +2623,9 @@
         fprintf(outfile, ")\n");
         fprintf(outfile, "{\n");
         for(i = 0; i < nb_args; i++) {
-            fprintf(outfile, "    *gen_opparam_ptr++ = param%d;\n", i + 1);
+            fprintf(outfile, "    *tcg_ctx.gen_opparam_ptr++ = param%d;\n", i + 1);
         }
-        fprintf(outfile, "    *gen_opc_ptr++ = INDEX_%s;\n", name);
+        fprintf(outfile, "    *tcg_ctx.gen_opc_ptr++ = INDEX_%s;\n", name);
         fprintf(outfile, "}\n\n");
     }
 }

                 reply	other threads:[~2008-07-30 11:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=761ea48b0807300404j5fe7a8e2pf03bedba8b3b8b45@mail.gmail.com \
    --to=laurent.desnogues@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).