qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 6/8] tcg: Add bytecode generator for tcg interpr


From: Stefan Weil
Subject: Re: [Qemu-devel] [PATCH 6/8] tcg: Add bytecode generator for tcg interpreter
Date: Sat, 01 Oct 2011 23:25:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15

Am 01.10.2011 18:54, schrieb Andreas Färber:
Am 17.09.2011 22:00, schrieb Stefan Weil:
Unlike other tcg target code generators, this one does not generate
machine code for some cpu. It generates machine independent bytecode
which is interpreted later.

This allows running QEMU on any host.

Interpreted bytecode is slower than direct execution of generated
machine code.

Signed-off-by: Stefan Weil <address@hidden>
[...]
diff --git a/tcg/bytecode/README b/tcg/bytecode/README
new file mode 100644
index 0000000..6fe9755
--- /dev/null
+++ b/tcg/bytecode/README
@@ -0,0 +1,129 @@
+TCG Interpreter (TCI) - Copyright (c) 2011 Stefan Weil.
+
+This file is released under GPL 2 or later.
+
+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/bytecode.
+
+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.

While reusing TCG opcode values certainly makes things easy to
implement, have you evaluated using LLVM bitcode as alternative to a
fully custom intermediate code format?

Andreas

I had a look on several bytecode representations - initially I thought
of using Java. LLVM was on my list, too, but I cannot say that I really
evaluated any of these alternatives. My primary goal was to learn more
about TCG and to get something working, and as you said, reusing the
TCG opcodes made things easier.

LLVM might also be used as a replacement for TCG.
It would be really interesting to see how both compare.

Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]