[LLVMdev] PHP Zend LLVM extension (SoC)

Owen Anderson resistor at mac.com
Wed Apr 23 22:49:55 PDT 2008


On Apr 23, 2008, at 1:44 PM, Nuno Lopes wrote:

> Thank you both for your answers!
> That part of type inference was my second question. PHP uses a  
> structure
> with a union to represent a variable (because a variable can have  
> different
> types, like a long, a double, a stream, etc..), but often a single  
> variable
> will only have one type throughout the program (e.g. iterating  
> through $i in
> a loop). Will LLVM automagically see that we always use the same  
> type for a
> certain variable and discard the whole union and use a single scalar  
> (and
> also discard all the type checking done in the opcode handlers)? We  
> can do
> some type inference on our side if we do a pass on the bytecode, but  
> I would
> like to be sure if that's needed or if LLVM will do it on its own.
>

LLVM likely won't be able to do type inference for you.  That kind of  
high level language will be lost by the time you hit LLVM IR.  Take a  
look at how llvm-gcc or the online demo does codegen for C unions,  
especially for ones of any complexity.  If you want to see a real  
performance win from this, some degree of type inference at a stage  
where high level information has not yet been discarded will be very  
helpful.

--Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080424/bf61a4ab/attachment.bin>


More information about the llvm-dev mailing list