C-sparse
view release on metacpan or search on metacpan
src/sparse-0.4.4/perl/t/tcg/tci/README view on Meta::CPAN
TCG Interpreter (TCI) - Copyright (c) 2011 Stefan Weil.
This file is released under the BSD license.
1) Introduction
TCG (Tiny Code Generator) is a code generator which translates
code fragments ("basic blocks") from target code (any of the
targets supported by QEMU) to a code representation which
can be run on a host.
QEMU can create native code for some hosts (arm, hppa, i386, ia64, ppc, ppc64,
s390, sparc, x86_64). For others, unofficial host support was written.
By adding a code generator for a virtual machine and using an
interpreter for the generated bytecode, it is possible to
support (almost) any host.
This is what TCI (Tiny Code Interpreter) does.
2) Implementation
Like each TCG host frontend, TCI implements the code generator in
tcg-target.c, tcg-target.h. Both files are in directory tcg/tci.
The additional file tcg/tci.c adds the interpreter.
The bytecode consists of opcodes (same numeric values as those used by
TCG), command length and arguments of variable size and number.
3) Usage
For hosts without native TCG, the interpreter TCI must be enabled by
configure --enable-tcg-interpreter
If configure is called without --enable-tcg-interpreter, it will
suggest using this option. Setting it automatically would need
additional code in configure which must be fixed when new native TCG
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
configure --enable-tcg-interpreter
The only difference from running QEMU with TCI to running without TCI
should be speed. Especially during development of TCI, it was very
useful to compare runs with and without TCI. Create /tmp/qemu.log by
qemu-system-i386 -d in_asm,op_opt,cpu -D /tmp/qemu.log -singlestep
once with interpreter and once without interpreter and compare the resulting
qemu.log files. This is also useful to see the effects of additional
registers or additional opcodes (it is easy to modify the virtual machine).
It can also be used to verify native TCGs.
Hosts with native TCG can also enable TCI by claiming to be unsupported:
configure --cpu=unknown --enable-tcg-interpreter
configure then no longer uses the native linker script (*.ld) for
user mode emulation.
( run in 1.057 second using v1.01-cache-2.11-cpan-364913b4093 )