From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NuWww-0002as-1E for qemu-devel@nongnu.org; Wed, 24 Mar 2010 16:13:10 -0400 Received: from [140.186.70.92] (port=36600 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuWwf-0002aB-Dn for qemu-devel@nongnu.org; Wed, 24 Mar 2010 16:13:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuWvw-0004nL-9u for qemu-devel@nongnu.org; Wed, 24 Mar 2010 16:12:13 -0400 Received: from are.twiddle.net ([75.149.56.221]:49745) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuWvw-0004nB-30 for qemu-devel@nongnu.org; Wed, 24 Mar 2010 16:12:08 -0400 Message-ID: <4BAA7216.3020105@twiddle.net> Date: Wed, 24 Mar 2010 13:12:06 -0700 From: Richard Henderson MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: Compile files only once: some planning References: <4BA9DFAA.3070107@redhat.com> <4BA9F52C.6070309@twiddle.net> <4BAA25A7.7000201@redhat.com> <4BAA46D8.1080505@twiddle.net> In-Reply-To: <4BAA46D8.1080505@twiddle.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Blue Swirl , qemu-devel On 03/24/2010 10:07 AM, Richard Henderson wrote: > struct CPUSmallCommonState > { > // most of the stuff from CPU_COMMON. > // sorted for some thought of padding elimination. ;-) > }; > > struct CPULargeCommonState > { > CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; > target_phys_addr_t iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; > struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; > jmp_buf jmp_env; > }; ... > Now. If you're compiling a file for which cpu-specific code is ok: > > register CPUXYZLargeState *env __asm__(AREG0); > #define ENV_SMALL_COMMON_STATE (&env->s.common_s) > #define ENV_LARGE_COMMON_STATE (&env->common_l) > > If you're compiling a file which is supposed to be independant of cpu: > > register CPUSmallCommonState *env __asm__(AREG0); > #define ENV_SMALL_COMMON_STATE (env) > #define ENV_LARGE_COMMON_STATE ((CPULargeCommonState *)((char *)env + cpu_large_state_offset)) On 03/24/2010 11:00 AM, Blue Swirl wrote: > One trick is to define a fixed offset (about half CPUState size) and > make env point to CPUState + offset. Then the negative part of the > offset space can be used efficiently. But this just doubles the space > that can be accessed fast, so it's not a big win. A good idea. We can eliminate the cpu_large_state_offset from above via: struct CPUSmallCommonState { // most of the stuff from CPU_COMMON. } __attribute__((aligned)); struct CPUXYZPrivateState { // all the cpu-specific stuff }; struct CPUXYZSmallState { CPUXYZPrivateState p; CPUSmallCommonState s; }; struct CPUXYZAllState { CPUXYZSmallState s; CPULargeCommonState l; // ARG0 register points here. }; register void *biased_env __asm__(AREG0); static inline CPUXYZPrivateState *get_env_cpu_private(void) { return &((CPUXYZSmallState *)biased_env - 1)->p; } static inline CPUSmallCommonState *get_env_common_small(void) { return (CPUSmallCommonState *)biased_env - 1; } static inline CPULargeCommonState *get_env_common_large(void) { return (CPULargeCommonState *)biased_env; } r~