qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Some cleanups after dyngen removal


From: Aurelien Jarno
Subject: Re: [Qemu-devel] [PATCH] Some cleanups after dyngen removal
Date: Sun, 7 Dec 2008 19:17:21 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

On Sun, Dec 07, 2008 at 06:12:50PM +0100, Laurent Desnogues wrote:
> Hello,
> 
>    this patch removes some now unused things after dyngen removal.
> 
> 1. dyngen-exec.h:  op_param, op _jmp and some associated macros
>    are now unused;
> 2. Makefile.target:  tcg-dyngen is not needed anymore
> 2. tcg/tcg-op.h, tcg/tcg-opc.h:  gen-op.h is dead
> 3. tcg.c:
>     - INDEX_op_end is now the first op
>     - CONFIG_DYNGEN_OP is never defined
> 4. tcg.h:  dyngen_op not needed anymore
> 5. exec-all.h:  remove some ASM macros.
> 
> Note tcg/tcg-dyngen.c can be removed.
> 
> I think dyngen-exec.h should be renamed (it's included by the various
> exec.h targets).
> 
> I tested all targets still compile on my x86_64 machine.
> 
> This patch is probably not complete for possible removals, but I hope
> it's a good start.
> 

Yes, it is a good start. A grep -r dyngen still gives some results, but
far less. This code can be removed in another commit.

Thanks a lot, applied.

> Laurent
> 
> Signed-off-by: Laurent Desnogues <address@hidden>

> Index: dyngen-exec.h
> ===================================================================
> --- dyngen-exec.h     (revision 5915)
> +++ dyngen-exec.h     (working copy)
> @@ -201,10 +201,6 @@
>  /* force GCC to generate only one epilog at the end of the function */
>  #define FORCE_RET() __asm__ __volatile__("" : : : "memory");
>  
> -#ifndef OPPROTO
> -#define OPPROTO
> -#endif
> -
>  #define xglue(x, y) x ## y
>  #define glue(x, y) xglue(x, y)
>  #define stringify(s) tostring(s)
> @@ -217,79 +213,6 @@
>  #define __hidden
>  #endif
>  
> -#if defined(__alpha__)
> -/* Suggested by Richard Henderson. This will result in code like
> -        ldah $0,__op_param1($29)        !gprelhigh
> -        lda $0,__op_param1($0)          !gprellow
> -   We can then conveniently change $29 to $31 and adapt the offsets to
> -   emit the appropriate constant.  */
> -extern int __op_param1 __hidden;
> -extern int __op_param2 __hidden;
> -extern int __op_param3 __hidden;
> -#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
> -#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
> -#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
> -#elif defined(__s390__)
> -extern int __op_param1 __hidden;
> -extern int __op_param2 __hidden;
> -extern int __op_param3 __hidden;
> -#define PARAM1 ({ int _r; asm("bras %0,8; .long " ASM_NAME(__op_param1) "; l 
> %0,0(%0)" : "=r"(_r) : ); _r; })
> -#define PARAM2 ({ int _r; asm("bras %0,8; .long " ASM_NAME(__op_param2) "; l 
> %0,0(%0)" : "=r"(_r) : ); _r; })
> -#define PARAM3 ({ int _r; asm("bras %0,8; .long " ASM_NAME(__op_param3) "; l 
> %0,0(%0)" : "=r"(_r) : ); _r; })
> -#else
> -#if defined(__APPLE__)
> -static int __op_param1, __op_param2, __op_param3;
> -#else
> -extern int __op_param1, __op_param2, __op_param3;
> -#endif
> -#define PARAM1 ((long)(&__op_param1))
> -#define PARAM2 ((long)(&__op_param2))
> -#define PARAM3 ((long)(&__op_param3))
> -#endif /* !defined(__alpha__) */
> -
> -extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
> -
> -#if defined(_WIN32) || defined(__APPLE__)
> -#define ASM_NAME(x) "_" #x
> -#else
> -#define ASM_NAME(x) #x
> -#endif
> -
> -#if defined(__i386__)
> -#define EXIT_TB() asm volatile ("ret")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
> -#elif defined(__x86_64__)
> -#define EXIT_TB() asm volatile ("ret")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n)
> -#elif defined(__powerpc__)
> -#define EXIT_TB() asm volatile ("blr")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
> -#elif defined(__s390__)
> -#define EXIT_TB() asm volatile ("br %r14")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("larl %r7,12; l %r7,0(%r7); br 
> %r7; .long " ASM_NAME(__op_gen_label) #n)
> -#elif defined(__alpha__)
> -#define EXIT_TB() asm volatile ("ret")
> -#elif defined(__ia64__)
> -#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("br.sptk.many " \
> -                                       ASM_NAME(__op_gen_label) #n)
> -#elif defined(__sparc__)
> -#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0; nop")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("ba " ASM_NAME(__op_gen_label) #n 
> ";nop")
> -#elif defined(__arm__)
> -#define EXIT_TB() asm volatile ("b exec_loop")
> -#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n)
> -#elif defined(__mc68000)
> -#define EXIT_TB() asm volatile ("rts")
> -#elif defined(__mips__)
> -#define EXIT_TB() asm volatile ("jr $ra")
> -#define GOTO_LABEL_PARAM(n) asm volatile (".set noat; la $1, " 
> ASM_NAME(__op_gen_label) #n "; jr $1; .set at")
> -#elif defined(__hppa__)
> -#define GOTO_LABEL_PARAM(n) asm volatile ("b,n " ASM_NAME(__op_gen_label) #n)
> -#else
> -#error unsupported CPU
> -#endif
> -
>  /* The return address may point to the start of the next instruction.
>     Subtracting one gets us the call instruction itself.  */
>  #if defined(__s390__)
> Index: Makefile.target
> ===================================================================
> --- Makefile.target   (revision 5915)
> +++ Makefile.target   (working copy)
> @@ -186,7 +186,7 @@
>  LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\
>          translate.o host-utils.o
>  # TCG code generator
> -LIBOBJS+= tcg/tcg.o tcg/tcg-dyngen.o tcg/tcg-runtime.o
> +LIBOBJS+= tcg/tcg.o tcg/tcg-runtime.o
>  CPPFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
>  ifeq ($(ARCH),sparc64)
>  CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
> Index: tcg/tcg-op.h
> ===================================================================
> --- tcg/tcg-op.h      (revision 5915)
> +++ tcg/tcg-op.h      (working copy)
> @@ -23,11 +23,6 @@
>   */
>  #include "tcg.h"
>  
> -#ifdef CONFIG_DYNGEN_OP
> -/* legacy dyngen operations */
> -#include "gen-op.h"
> -#endif
> -
>  int gen_new_label(void);
>  
>  static inline void tcg_gen_op1_i32(int opc, TCGv_i32 arg1)
> Index: tcg/tcg-opc.h
> ===================================================================
> --- tcg/tcg-opc.h     (revision 5915)
> +++ tcg/tcg-opc.h     (working copy)
> @@ -21,10 +21,6 @@
>   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
>   * THE SOFTWARE.
>   */
> -#ifdef CONFIG_DYNGEN_OP
> -#include "dyngen-opc.h"
> -#endif
> -
>  #ifndef DEF2
>  #define DEF2(name, oargs, iargs, cargs, flags) DEF(name, oargs + iargs + 
> cargs, 0)
>  #endif
> Index: tcg/tcg.c
> ===================================================================
> --- tcg/tcg.c (revision 5915)
> +++ tcg/tcg.c (working copy)
> @@ -1198,57 +1198,50 @@
>              break;
>              /* XXX: optimize by hardcoding common cases (e.g. triadic ops) */
>          default:
> -            if (op > INDEX_op_end) {
> -                args -= def->nb_args;
> -                nb_iargs = def->nb_iargs;
> -                nb_oargs = def->nb_oargs;
> +            args -= def->nb_args;
> +            nb_iargs = def->nb_iargs;
> +            nb_oargs = def->nb_oargs;
>  
> -                /* Test if the operation can be removed because all
> -                   its outputs are dead. We assume that nb_oargs == 0
> -                   implies side effects */
> -                if (!(def->flags & TCG_OPF_SIDE_EFFECTS) && nb_oargs != 0) {
> -                    for(i = 0; i < nb_oargs; i++) {
> -                        arg = args[i];
> -                        if (!dead_temps[arg])
> -                            goto do_not_remove;
> -                    }
> -                    tcg_set_nop(s, gen_opc_buf + op_index, args, 
> def->nb_args);
> +            /* Test if the operation can be removed because all
> +               its outputs are dead. We assume that nb_oargs == 0
> +               implies side effects */
> +            if (!(def->flags & TCG_OPF_SIDE_EFFECTS) && nb_oargs != 0) {
> +                for(i = 0; i < nb_oargs; i++) {
> +                    arg = args[i];
> +                    if (!dead_temps[arg])
> +                        goto do_not_remove;
> +                }
> +                tcg_set_nop(s, gen_opc_buf + op_index, args, def->nb_args);
>  #ifdef CONFIG_PROFILER
> -                    s->del_op_count++;
> +                s->del_op_count++;
>  #endif
> -                } else {
> -                do_not_remove:
> +            } else {
> +            do_not_remove:
>  
> -                    /* output args are dead */
> -                    for(i = 0; i < nb_oargs; i++) {
> -                        arg = args[i];
> -                        dead_temps[arg] = 1;
> +                /* output args are dead */
> +                for(i = 0; i < nb_oargs; i++) {
> +                    arg = args[i];
> +                    dead_temps[arg] = 1;
> +                }
> +                
> +                /* if end of basic block, update */
> +                if (def->flags & TCG_OPF_BB_END) {
> +                    tcg_la_bb_end(s, dead_temps);
> +                } else if (def->flags & TCG_OPF_CALL_CLOBBER) {
> +                    /* globals are live */
> +                    memset(dead_temps, 0, s->nb_globals);
> +                }
> +                
> +                /* input args are live */
> +                dead_iargs = 0;
> +                for(i = 0; i < nb_iargs; i++) {
> +                    arg = args[i + nb_oargs];
> +                    if (dead_temps[arg]) {
> +                        dead_iargs |= (1 << i);
>                      }
> -                    
> -                    /* if end of basic block, update */
> -                    if (def->flags & TCG_OPF_BB_END) {
> -                        tcg_la_bb_end(s, dead_temps);
> -                    } else if (def->flags & TCG_OPF_CALL_CLOBBER) {
> -                        /* globals are live */
> -                        memset(dead_temps, 0, s->nb_globals);
> -                    }
> -                    
> -                    /* input args are live */
> -                    dead_iargs = 0;
> -                    for(i = 0; i < nb_iargs; i++) {
> -                        arg = args[i + nb_oargs];
> -                        if (dead_temps[arg]) {
> -                            dead_iargs |= (1 << i);
> -                        }
> -                        dead_temps[arg] = 0;
> -                    }
> -                    s->op_dead_iargs[op_index] = dead_iargs;
> +                    dead_temps[arg] = 0;
>                  }
> -            } else {
> -                /* legacy dyngen operations */
> -                args -= def->nb_args;
> -                /* mark end of basic block */
> -                tcg_la_bb_end(s, dead_temps);
> +                s->op_dead_iargs[op_index] = dead_iargs;
>              }
>              break;
>          }
> @@ -2016,21 +2009,6 @@
>          case INDEX_op_end:
>              goto the_end;
>  
> -#ifdef CONFIG_DYNGEN_OP
> -        case 0 ... INDEX_op_end - 1:
> -            /* legacy dyngen ops */
> -#ifdef CONFIG_PROFILER
> -            s->old_op_count++;
> -#endif
> -            tcg_reg_alloc_bb_end(s, s->reserved_regs);
> -            if (search_pc >= 0) {
> -                s->code_ptr += def->copy_size;
> -                args += def->nb_args;
> -            } else {
> -                args = dyngen_op(s, opc, args);
> -            }
> -            goto next;
> -#endif
>          default:
>              /* Note: in order to speed up the code, it would be much
>                 faster to have specialized register allocator functions for
> Index: tcg/tcg.h
> ===================================================================
> --- tcg/tcg.h (revision 5915)
> +++ tcg/tcg.h (working copy)
> @@ -449,8 +449,6 @@
>  const TCGArg *tcg_gen_code_op(TCGContext *s, int opc, const TCGArg *args1,
>                                unsigned int dead_iargs);
>  
> -const TCGArg *dyngen_op(TCGContext *s, int opc, const TCGArg *opparam_ptr);
> -
>  /* tcg-runtime.c */
>  int64_t tcg_helper_shl_i64(int64_t arg1, int64_t arg2);
>  int64_t tcg_helper_shr_i64(int64_t arg1, int64_t arg2);
> Index: exec-all.h
> ===================================================================
> --- exec-all.h        (revision 5915)
> +++ exec-all.h        (working copy)
> @@ -267,20 +267,6 @@
>  
>  TranslationBlock *tb_find_pc(unsigned long pc_ptr);
>  
> -#if defined(_WIN32)
> -#define ASM_DATA_SECTION ".section \".data\"\n"
> -#define ASM_PREVIOUS_SECTION ".section .text\n"
> -#elif defined(__APPLE__)
> -#define ASM_DATA_SECTION ".data\n"
> -#define ASM_PREVIOUS_SECTION ".text\n"
> -#else
> -#define ASM_DATA_SECTION ".section \".data\"\n"
> -#define ASM_PREVIOUS_SECTION ".previous\n"
> -#endif
> -
> -#define ASM_OP_LABEL_NAME(n, opname) \
> -    ASM_NAME(__op_label) #n "." ASM_NAME(opname)
> -
>  extern CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
>  extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
>  extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];


-- 
  .''`.  Aurelien Jarno             | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   address@hidden         | address@hidden
   `-    people.debian.org/~aurel32 | www.aurel32.net




reply via email to

[Prev in Thread] Current Thread [Next in Thread]