[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 05/16] tcg: Define tcg_insn_unit for codepoin
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH v3 05/16] tcg: Define tcg_insn_unit for codepointerss |
Date: |
Tue, 29 Apr 2014 07:20:21 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
On 04/29/2014 03:38 AM, Alex Bennée wrote:
>> @@ -2653,7 +2683,8 @@ static inline int tcg_gen_code_common(TCGContext *s,
>> uint8_t *gen_code_buf,
>> }
>> args += def->nb_args;
>> next:
>> - if (search_pc >= 0 && search_pc < s->code_ptr - gen_code_buf) {
>> + if (search_pc >= 0
>> + && search_pc < (intptr_t)s->code_ptr - (intptr_t)gen_code_buf) {
>> return op_index;
>> }
>
> I thought we were trying to avoid excessive casting with pointer
> arithmetic? Can this be made neater?
Yes, incomplete conversion to the helpers. Will fix.
>> +#ifndef TCG_TARGET_INSN_UNIT_SIZE
>> +#define TCG_TARGET_INSN_UNIT_SIZE 1
>> +#endif
>> +#if TCG_TARGET_INSN_UNIT_SIZE == 1
>> +typedef uint8_t tcg_insn_unit;
>> +#elif TCG_TARGET_INSN_UNIT_SIZE == 2
>> +typedef uint16_t tcg_insn_unit;
>> +#elif TCG_TARGET_INSN_UNIT_SIZE == 4
>> +typedef uint32_t tcg_insn_unit;
>> +#elif TCG_TARGET_INSN_UNIT_SIZE == 8
>> +typedef uint64_t tcg_insn_unit;
>> +#else
>> +/* The port better have done this. */
>
> Shouldn't we #error if the port hasn't done this then?
The compiler will error very shortly if this hasn't been done,
since we'll use the type in a declaration below. But, no,
there is no way to #error here.
r~
- [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
- [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
- [Qemu-devel] [PATCH v3 07/16] tcg-ppc64: Define TCG_TARGET_INSN_UNIT_SIZE, Richard Henderson, 2014/04/28