example of language with vector as first class type

Hi All

Does anyone know any example compiler where it has vector/matrix as first class type like matlab using llvm? If not, does anyone have idea how that should be done on llvm?

Thanks

Leon

Any GCC-compatible frontend — i.e. llvm-gcc, clang, or dragonegg — has vectors as a first-class type. I wouldn't exactly laud any of GCC's various vector extensions as a sterling example of good language design, but if you're just looking for demonstrations of how to generate vector IR, that's where I'd start.

John.

When you say vector in GCC, do you mean vector in the mathematical sense or the low level array sense?

Leon

In the approximately mathematical sense of "the sort of object manipulated by a processor with vector extensions", i.e. a generally small, fixed-size tuple of integer or floating-point element type. I don't mean the C++ resizable-array type.

John.

Hi Leon,

Does anyone know any example compiler where it has vector/matrix as first class
type like matlab using llvm? If not, does anyone have idea how that should be
done on llvm?

llvm-gcc and dragonegg support Ada which has first class vector and matrix
types. They can have variable size.

Ciao, Duncan.

Hi,

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?

Thanks.

Leon Sit <wing1127aishi@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." :slight_smile:

                            -Dave