J. Mayer wrote: > On Wed, 2007-10-10 at 07:06 +0200, J. Mayer wrote: > > On Wed, 2007-10-10 at 01:12 +0100, Thiemo Seufer wrote: > > > J. Mayer wrote: > > > > Here's a proposal to add a int cpu_mem_index (CPUState *env) function in > > > > targets cpu.h header. > > > > The idea of this patch is: > > > > - avoid many #ifdef TARGET_xxx in exec-all.h and softmmu_header.h then > > > > make the code more readable > > > > - avoid multiple implementation of the same code (3, in that particular > > > > case) this to avoid potential conflicts if the definition has to be > > > > updated for any reason (ie support for new memory access modes, > > > > emulation optimisation...) > > > > > > > > Please comment. > > > > > > > > -- > > > > J. Mayer <[EMAIL PROTECTED]> > > > > Never organized > > > > > [...] > > Here's an updated version of the patch. My comments about it stay valid, > with two additions: > 1/ when is user is needed to maintain compatibility with existing code, > I now define it as: > int is_user = mmu_idx == MMU_USER_IDX; > instead of just is_user = mmu_idx. > This definition will then remain correct even if the definition of the > MMU modes are later changed for a specific target > 2/ I now precompute the mmu_idx on PowerPC platform as it can never > change inside a single TB. This may save a few instructions for every > memory access. I guess the same optimisation can be made for the other > targets, but not knowing exactly when it would have to be recomputed, > for most targets, I prefer not to do this optimisation myself.
I like this version. Tested with x86 and mips, on Linux/ppc host. Thiemo