[Top][All Lists]

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

Re: [Qemu-devel] [PATCH 05/10] tcg: add jr opcode

From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 05/10] tcg: add jr opcode
Date: Sat, 15 Apr 2017 04:40:35 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 04/11/2017 06:17 PM, Emilio G. Cota wrote:
This will be used by TCG targets to implement a fast path
for indirect branches.

I only have implemented and tested this on an i386 host, so
make this opcode optional and mark it as not implemented by
other TCG backends.

I don't think this is quite the right abstraction. In particular, if we can always return a valid address from the helper, we can eliminate a conditional branch.

I think this should work as follows:

(1) tb_ret_addr gets moved into TCGContext so that it's available for other code to see.

(2) Have a generic helper

void *HELPER(lookup_tb_ptr)(CPUArchState *env, target_ulong addr)
    TranslationBlock *tb = tb_from_jmp_cache(env, addr);
    return tb ? tb->tc_ptr : tcg_ctx.tb_ret_addr;

(3) Emit TCG opcodes like

        call t0,lookup_tb_ptr,env,addr
        jmp_tb t0

(4) Emit code for jmp_tb like

        mov     %rax,%rdx       // save target into new register
        xor     %eax,%eax       // set return value a-la exit_tb
        jmp     *%edx           // branch to tb or epilogue.

(5) There needs to be a convenience function in tcg/tcg-op.c. If the host does not support jmp_tb, we should just generate exit_tb like we do now. There should be no ifdefs inside target/*.


reply via email to

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