qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 06/16] tcg-i386: DefineTCG_TARGET_INSN_UNIT_S


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v3 06/16] tcg-i386: DefineTCG_TARGET_INSN_UNIT_SIZEE
Date: Tue, 29 Apr 2014 07:28:08 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 04/29/2014 04:12 AM, Alex Bennée wrote:
> 
> Richard Henderson <address@hidden> writes:
> 
>> And use tcg pointer differencing functions as appropriate.
>>
>> Reviewed-by: Peter Maydell <address@hidden>
>> Signed-off-by: Richard Henderson <address@hidden>
> <snip>
>>  
>> -static void tcg_out_branch(TCGContext *s, int call, uintptr_t dest)
>> +static void tcg_out_branch(TCGContext *s, int call, tcg_insn_unit *dest)
>>  {
>> -    intptr_t disp = dest - (intptr_t)s->code_ptr - 5;
>> +    intptr_t disp = tcg_pcrel_diff(s, dest) - 5;
>>  
>>      if (disp == (int32_t)disp) {
>>          tcg_out_opc(s, call ? OPC_CALL_Jz : OPC_JMP_long, 0, 0, 0);
>>          tcg_out32(s, disp);
>>      } else {
>> -        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R10, dest);
>> +        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R10, (uintptr_t)dest);
>>          tcg_out_modrm(s, OPC_GRP5,
>>                        call ? EXT5_CALLN_Ev : EXT5_JMPN_Ev, TCG_REG_R10);
>>      }
>>  }
> 
> I'm a little unclear on where the -5 came from? Is this a relative
> address based on where we will be after we've emitted the code?

The branch is relative to the end of the branch insn, which itself
is 5 bytes long.  I suppose this could be written

        dest - (s->code_ptr + 5)

though I don't know if that's any more or less clear.


r~



reply via email to

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