[LLVMdev] example of language with vector as first class type

David A. Greene greened at obbligato.org
Wed Dec 15 12:55:24 PST 2010


Leon Sit <wing1127aishi at gmail.com> writes:

> To state my objective again because I was unclear about it. I want to write a interpretor/compiler that can handles mathematical vector/matrix with
> linear algebra operation on llvm. Something like matlab/R. I am thinking at a higher level like performing type, and shape inference on matrix/vector
> type, unrolling the inner loop of matrix operation of full algebraic expression instead of computing the terms eagerly. Do people think llvm is suitable
> for this context?

A higher-level optimizer would be better.  I think you've lost too much
information by the time it's reached the LLVM level.

Could you do it?  Sure.  In the worst case the metadata facility would
let you pass all sorts of information down to LLVM.  But it would be
ugly.

I'm not sure what you mean by "unrolling the inner loop of matrix
operation of full algebraic expression instead of computing the terms
eagerly," though I have an idea (something like Blitz-style
metaprogramming?).  The Cray compiler, for example, does shape inference
and the like on Fortran codes.  Fortran has first-class vector/matrix
types, at least for some definition of "first-class."  :)

                            -Dave




More information about the llvm-dev mailing list