Richard Henderson <r...@twiddle.net> writes:

> And use tcg pointer differencing functions as appropriate.
>
> Signed-off-by: Richard Henderson <r...@twiddle.net>
> ---
>  tcg/ppc64/tcg-target.c | 164 
> ++++++++++++++++++++++++-------------------------
>  tcg/ppc64/tcg-target.h |   1 +
>  2 files changed, 81 insertions(+), 84 deletions(-)
>
> diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
> index 45b1c06..4a0b7db 100644
> --- a/tcg/ppc64/tcg-target.c
> +++ b/tcg/ppc64/tcg-target.c
> @@ -31,7 +31,7 @@
>  #define TCG_CT_CONST_ZERO 0x1000
>  #define TCG_CT_CONST_MONE 0x2000
>  
> -static uint8_t *tb_ret_addr;
> +static tcg_insn_unit *tb_ret_addr;
>  
>  #if TARGET_LONG_BITS == 32
>  #define LD_ADDR LWZ
> @@ -168,61 +168,54 @@ static inline bool in_range_b(tcg_target_long target)
>      return target == sextract64(target, 0, 26);
>  }
>  
> -static uint32_t reloc_pc24_val(void *pc, tcg_target_long target)
> +static uint32_t reloc_pc24_val(tcg_insn_unit *pc, tcg_insn_unit *target)
>  {
> -    tcg_target_long disp;
> -
> -    disp = target - (tcg_target_long)pc;
> +    ptrdiff_t disp = tcg_ptr_byte_diff(target, pc);
>      assert(in_range_b(disp));
> -
>      return disp & 0x3fffffc;
>  }
>  
> -static void reloc_pc24(void *pc, tcg_target_long target)
> +static void reloc_pc24(tcg_insn_unit *pc, tcg_insn_unit *target)
>  {
> -    *(uint32_t *)pc = (*(uint32_t *)pc & ~0x3fffffc)
> -        | reloc_pc24_val(pc, target);
> +    *pc = (*pc & ~0x3fffffc) | reloc_pc24_val(pc, target);
>  }

Should 0x3fffffc be a #define'd mask? Can the PC ever actually be
non-word aligned?

Otherwise:

Reviewed-by: Alex Bennée <alex.ben...@linaro.org>

-- 
Alex Bennée


Reply via email to