From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RA2rc-0002aP-1U for qemu-devel@nongnu.org; Sat, 01 Oct 2011 12:56:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RA2ra-0003Zu-RV for qemu-devel@nongnu.org; Sat, 01 Oct 2011 12:56:35 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:44444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RA2ra-0003Zo-Fd for qemu-devel@nongnu.org; Sat, 01 Oct 2011 12:56:34 -0400 Message-ID: <4E8745DE.5030007@web.de> Date: Sat, 01 Oct 2011 18:54:54 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <4E74FC29.1050003@mail.berlios.de> <1316289634-18786-6-git-send-email-weil@mail.berlios.de> In-Reply-To: <1316289634-18786-6-git-send-email-weil@mail.berlios.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sender: andreas.faerber@web.de Subject: Re: [Qemu-devel] [PATCH 6/8] tcg: Add bytecode generator for tcg interpreter List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: QEMU Developers 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 [...] > 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