[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 04/16] tcg: Introduce byte pointerarithmetic
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [PATCH v3 04/16] tcg: Introduce byte pointerarithmetic helperss |
Date: |
Tue, 29 Apr 2014 11:28:33 +0100 |
User-agent: |
mu4e 0.9.9.6pre3; emacs 24.3.90.6 |
Richard Henderson <address@hidden> writes:
> Reviewed-by: Peter Maydell <address@hidden>
> Signed-off-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
> ---
> tcg/tcg.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/tcg/tcg.h b/tcg/tcg.h
> index a6a2d06..d38c92d 100644
> --- a/tcg/tcg.h
> +++ b/tcg/tcg.h
> @@ -724,6 +724,51 @@ TCGv_i32 tcg_const_local_i32(int32_t val);
> TCGv_i64 tcg_const_local_i64(int64_t val);
>
> /**
> + * tcg_ptr_byte_diff
> + * @a, @b: addresses to be differenced
> + *
> + * There are many places within the TCG backends where we need a byte
> + * difference between two pointers. While this can be accomplished
> + * with local casting, it's easy to get wrong -- especially if one is
> + * concerned with the signedness of the result.
> + *
> + * This version relies on GCC's void pointer arithmetic to get the
> + * correct result.
> + */
> +
> +static inline ptrdiff_t tcg_ptr_byte_diff(void *a, void *b)
> +{
> + return a - b;
> +}
> +
> +/**
> + * tcg_pcrel_diff
> + * @s: the tcg context
> + * @target: address of the target
> + *
> + * Produce a pc-relative difference, from the current code_ptr
> + * to the destination address.
> + */
> +
> +static inline ptrdiff_t tcg_pcrel_diff(TCGContext *s, void *target)
> +{
> + return tcg_ptr_byte_diff(target, s->code_ptr);
> +}
> +
> +/**
> + * tcg_current_code_size
> + * @s: the tcg context
> + *
> + * Compute the current code size within the translation block.
> + * This is used to fill in qemu's data structures for goto_tb.
> + */
> +
> +static inline size_t tcg_current_code_size(TCGContext *s)
> +{
> + return tcg_ptr_byte_diff(s->code_ptr, s->code_buf);
> +}
> +
> +/**
> * tcg_qemu_tb_exec:
> * @env: CPUArchState * for the CPU
> * @tb_ptr: address of generated code for the TB to execute
--
Alex Bennée
- [Qemu-devel] [PATCH v3 00/16] tcg: tidy the type of code_ptr, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 01/16] exec-all.h: Use stl_p to avoid undefined behaviour patching x86 jumps, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 02/16] tcg: Avoid stores to unaligned addresses, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 04/16] tcg: Introduce byte pointer arithmetic helpers, Richard Henderson, 2014/04/28
- Re: [Qemu-devel] [PATCH v3 04/16] tcg: Introduce byte pointerarithmetic helperss,
Alex Bennée <=
- [Qemu-devel] [PATCH v3 05/16] tcg: Define tcg_insn_unit for code pointers, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 03/16] tcg: Avoid undefined behaviour patching code at unaligned addresses, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 06/16] tcg-i386: Define TCG_TARGET_INSN_UNIT_SIZE, Richard Henderson, 2014/04/28
- [Qemu-devel] [PATCH v3 08/16] tcg-ppc: Define TCG_TARGET_INSN_UNIT_SIZE, Richard Henderson, 2014/04/28