I have been working on something along similar lines:
translating Alpha machine code into LLVM. It is probably
much more simple to handle Alpha instructions than x86
instructions. Translating individual instructions is easy,
more analysis is needed to eliminate things like register allocated variables,
function call setup/prolog/epilogue etc.
Machine specific operations can be encoded using intrinsic
functions. As for how suitable the LLVM IR is for doing
any optimizations, I think it should be able do most of the
basic optimizations provided that we do a good job of
translation.
Rahul
---- Original message ---->Date: Sat, 29 Nov 2003 11:39:35 -0800
>From: Reid Spencer <reid at x10sys.com>
>Subject: [LLVMdev] Reverse Optimization?
>To: LLVMdev List <llvmdev at cs.uiuc.edu>
>
> I was sitting around thinking about making web
> applications, especially PHP based ones, perform
> better. While PHP has come a long way since its
> initial releases, it could still benefit from LLVM
> style "whole program" optimization. So, I had this
> radical idea. What if we built a PHP front end for
> LLVM so PHP programs could be LLVMized. What if we
> also built a i386 ELF front end so that we could
> factor in Apache and its various modules? That is,
> we build an LLVM front end that reads an executable
> or shared object in ELF format for an i386 processor
> (or whatever) and produces LLVM bytecode for it?
> Then, all of Apache and PHP and the PHP programs
> could be optimized into single running application.
>
> While I think this is cool, I don't think the
> translation would work. While it might be
> technically possible to find an LLVM expression for
> each i386 instruction, the result might not be
> semantically meaningful and therefore not easily
> subject to optimization.
>
> My question is: am I right about reverse engineering
> for optimization like this, or could it work?
>
> (The practical thing to do would be to compile
> Apache/PHP/modules from their C/C++ sources using
> llvmgcc, but that's just not radical enough to
> mention :)
>
> Reid.
>________________
>signature.asc (1k bytes)