target-i386: Use TCGMemOp for 'ot' variables

The 'ot' variables (operand type?) hold the log2(byte size) of
the operand being manipulated.  This is the same as the MO_SIZE
subset of the TCGMemOp.  Indeed, we often pass 'ot' to the
tcg_gen_qemu_ld/st functions.

Changing the type from 'int' makes it easier to see what domain
the variable should be.

This does require adding some default cases to some switch statements,
to avoid the 'unhandled enumeration value' warning that would result
from the change of type.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Change gen_op_add_reg_* size parameter to TCGMemOp

These functions used the aflags/dflags domain, which is log2-1
of the byte size.  Confusingly, they used enumeration values
from the log2 domain.

Change the domain of the parameter and update all callers.

Since we're now in a common domain, defer the deposit/extend/mov
decision to gen_op_mov_reg_v.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Change gen_op_j*z_ecx size parameter to TCGMemOp

Change the domain of the parameter and update all callers.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Change aflag to TCGMemOp

Changing the domain to TCGMemOp makes it easier to interoperate
with other portions of the rest of the translator.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Change gen_op_mov_reg_A0 size parameter to TCGMemOp

Change the domain of the parameter and update all callers.
Which lets us defer completely to gen_op_mov_reg_v.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Change dflag to TCGMemOp

Changing the domain to TCGMemOp makes it easier to interoperate
with other portions of the rest of the translator.

We now only have one domain for size operands inside the translator,
which makes things less confusing all the way around.  There are
still a number of helpers that continue to use the log2-1 domain.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Fix addr32 prefix in gen_lea_modrm

Fix the following run-test-x86_64 testsuite failures:

-lea (%%eax) = 0000000000000001
-lea (%%ebx) = 0000000000000002
-lea (%%ecx) = 0000000000000004
-lea (%%edx) = 0000000000000008
-lea (%%esi) = 0000000000000010
-lea (%%edi) = 0000000000000020
+lea (%%eax) = 0000abcc00000001
+lea (%%ebx) = 0000abcf00000002
+lea (%%ecx) = 0000abc900000004
+lea (%%edx) = 0000abc500000008
+lea (%%esi) = 0000abdd00000010
+lea (%%edi) = 0000abed00000020

In addition, reduce ifdeffery and minimize the number of TCG ops
produced during address computation.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Tidy addr16 code in gen_lea_modrm

Unlike the addr32, there was no bug.  But we can use the same
technique to reduce the number of TCG ops.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Combine gen_push_T* into gen_push_v

Reduce ifdefs, share more code between paths, reduce the number of TCG
ops generated.

Add forgotten zero-extension in the TARGET_X86_64, !CODE64, ss32 case.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target_i386: Clean up gen_pop_T0

Reduce ifdefs, share more code between paths, reduce the number of TCG
ops generated.  Avoid re-computing the size of the operation across
gen_pop_T0 and gen_pop_update.

Add forgotten zero-extension in the TARGET_X86_64, !CODE64, ss32 case.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Create gen_lea_v_seg

Add forgotten zero-extension in the TARGET_X86_64, !CODE64, ss32 case;
use this new function to implement gen_string_movl_A0_EDI,
gen_string_movl_A0_ESI, gen_add_A0_ds_seg.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Use gen_lea_v_seg in gen_lea_modrm

Centralize handling of segment bases.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Use gen_lea_v_seg in stack subroutines

I.e. gen_push_v, gen_pop_T0, gen_stack_A0.
More centralization of handling of segment bases.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Tidy cpu_regs initialization

Signed-off-by: Richard Henderson <rth@twiddle.net>
exec: Delay CPU_LOG_TB_CPU until we actually execute a TB

The previous placement could result in duplicate logging while
still processing interrupts.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Access segs via TCG registers

Having segs[].base as a register significantly improves code
generation for real and protected modes, particularly for TBs
that have multiple memory references where the segment base
can be held in a hard register through the TB.

Signed-off-by: Richard Henderson <rth@twiddle.net>
target-i386: Use gen_lea_v_seg in pusha/popa

More centralization of handling of segment bases.
Also fixes the note about 16-bit wrap around not fully handled.

Signed-off-by: Richard Henderson <rth@twiddle.net>