mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
tcg/tci: Change encoding to uint32_t units
This removes all of the problems with unaligned accesses
to the bytecode stream.
With an 8-bit opcode at the bottom, we have 24 bits remaining,
which are generally split into 6 4-bit slots. This fits well
with the maximum length opcodes, e.g. INDEX_op_add2_i32, which
have 6 register operands.
We have, in previous patches, rearranged things such that there
are no operations with a label which have more than one other
operand. Which leaves us with a 20-bit field in which to encode
a label, giving us a maximum TB size of 512k -- easily large.
Change the INDEX_op_tci_movi_{i32,i64} opcodes to tci_mov[il].
The former puts the immediate in the upper 20 bits of the insn,
like we do for the label displacement. The later uses a label
to reference an entry in the constant pool. Thus, in the worst
case we still have a single memory reference for any constant,
but now the constants are out-of-line of the bytecode and can
be shared between different moves saving space.
Change INDEX_op_call to use a label to reference a pair of
pointers in the constant pool. This removes the only slightly
dodgy link with the layout of struct TCGHelperInfo.
The re-encode cannot be done in pieces.
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -277,8 +277,8 @@ DEF(last_generic, 0, 0, 0, TCG_OPF_NOT_PRESENT)
|
|||||||
|
|
||||||
#ifdef TCG_TARGET_INTERPRETER
|
#ifdef TCG_TARGET_INTERPRETER
|
||||||
/* These opcodes are only for use between the tci generator and interpreter. */
|
/* These opcodes are only for use between the tci generator and interpreter. */
|
||||||
DEF(tci_movi_i32, 1, 0, 1, TCG_OPF_NOT_PRESENT)
|
DEF(tci_movi, 1, 0, 1, TCG_OPF_NOT_PRESENT)
|
||||||
DEF(tci_movi_i64, 1, 0, 1, TCG_OPF_64BIT | TCG_OPF_NOT_PRESENT)
|
DEF(tci_movl, 1, 0, 1, TCG_OPF_NOT_PRESENT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef TLADDR_ARGS
|
#undef TLADDR_ARGS
|
||||||
|
|||||||
+5
-15
@@ -23,10 +23,12 @@ This is what TCI (Tiny Code Interpreter) does.
|
|||||||
Like each TCG host frontend, TCI implements the code generator in
|
Like each TCG host frontend, TCI implements the code generator in
|
||||||
tcg-target.c.inc, tcg-target.h. Both files are in directory tcg/tci.
|
tcg-target.c.inc, tcg-target.h. Both files are in directory tcg/tci.
|
||||||
|
|
||||||
The additional file tcg/tci.c adds the interpreter.
|
The additional file tcg/tci.c adds the interpreter and disassembler.
|
||||||
|
|
||||||
The bytecode consists of opcodes (same numeric values as those used by
|
The bytecode consists of opcodes (with only a few exceptions, with
|
||||||
TCG), command length and arguments of variable size and number.
|
the same same numeric values and semantics as used by TCG), and up
|
||||||
|
to six arguments packed into a 32-bit integer. See comments in tci.c
|
||||||
|
for details on the encoding.
|
||||||
|
|
||||||
3) Usage
|
3) Usage
|
||||||
|
|
||||||
@@ -39,11 +41,6 @@ suggest using this option. Setting it automatically would need
|
|||||||
additional code in configure which must be fixed when new native TCG
|
additional code in configure which must be fixed when new native TCG
|
||||||
implementations are added.
|
implementations are added.
|
||||||
|
|
||||||
System emulation should work on any 32 or 64 bit host.
|
|
||||||
User mode emulation might work. Maybe a new linker script (*.ld)
|
|
||||||
is needed. Byte order might be wrong (on big endian hosts)
|
|
||||||
and need fixes in configure.
|
|
||||||
|
|
||||||
For hosts with native TCG, the interpreter TCI can be enabled by
|
For hosts with native TCG, the interpreter TCI can be enabled by
|
||||||
|
|
||||||
configure --enable-tcg-interpreter
|
configure --enable-tcg-interpreter
|
||||||
@@ -118,13 +115,6 @@ u1 = linux-user-test works
|
|||||||
in the interpreter. These opcodes raise a runtime exception, so it is
|
in the interpreter. These opcodes raise a runtime exception, so it is
|
||||||
possible to see where code must be added.
|
possible to see where code must be added.
|
||||||
|
|
||||||
* The pseudo code is not optimized and still ugly. For hosts with special
|
|
||||||
alignment requirements, it needs some fixes (maybe aligned bytecode
|
|
||||||
would also improve speed for hosts which support byte alignment).
|
|
||||||
|
|
||||||
* A better disassembler for the pseudo code would be nice (a very primitive
|
|
||||||
disassembler is included in tcg-target.c.inc).
|
|
||||||
|
|
||||||
* It might be useful to have a runtime option which selects the native TCG
|
* It might be useful to have a runtime option which selects the native TCG
|
||||||
or TCI, so QEMU would have to include two TCGs. Today, selecting TCI
|
or TCI, so QEMU would have to include two TCGs. Today, selecting TCI
|
||||||
is a configure option, so you need two compilations of QEMU.
|
is a configure option, so you need two compilations of QEMU.
|
||||||
|
|||||||
+169
-208
File diff suppressed because it is too large
Load Diff
@@ -41,7 +41,7 @@
|
|||||||
#define TCG_TARGET_H
|
#define TCG_TARGET_H
|
||||||
|
|
||||||
#define TCG_TARGET_INTERPRETER 1
|
#define TCG_TARGET_INTERPRETER 1
|
||||||
#define TCG_TARGET_INSN_UNIT_SIZE 1
|
#define TCG_TARGET_INSN_UNIT_SIZE 4
|
||||||
#define TCG_TARGET_TLB_DISPLACEMENT_BITS 32
|
#define TCG_TARGET_TLB_DISPLACEMENT_BITS 32
|
||||||
#define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1)
|
#define MAX_CODE_GEN_BUFFER_SIZE ((size_t)-1)
|
||||||
|
|
||||||
@@ -166,6 +166,7 @@ typedef enum {
|
|||||||
#define TCG_TARGET_STACK_ALIGN 8
|
#define TCG_TARGET_STACK_ALIGN 8
|
||||||
|
|
||||||
#define HAVE_TCG_QEMU_TB_EXEC
|
#define HAVE_TCG_QEMU_TB_EXEC
|
||||||
|
#define TCG_TARGET_NEED_POOL_LABELS
|
||||||
|
|
||||||
/* We could notice __i386__ or __s390x__ and reduce the barriers depending
|
/* We could notice __i386__ or __s390x__ and reduce the barriers depending
|
||||||
on the host. But if you want performance, you use the normal backend.
|
on the host. But if you want performance, you use the normal backend.
|
||||||
|
|||||||
Reference in New Issue
Block a user