[LLVMdev] Resizing vector values

Anton Lokhmotov Anton.Lokhmotov at arm.com
Thu Mar 25 03:59:42 PDT 2010


Hello all,

I'm working on a prototype LLVM pass that would take a function operating on
'magic' vectors and produce a function operating on concrete vectors.  For
example, given vadd function operating on magic 17-element vectors:

typedef float vfloat __attribute__((ext_vector_type(17)));
vfloat vadd(vfloat a, vfloat b) { return a+b; }

it should produce vadd operating on 4-element vectors:

typedef float float4 __attribute__((ext_vector_type(4)));
float4 vadd(float4 a, float4 b) { return a+b; }

In other words, I only want to change the type from vfloat to float4 for
arguments, result, instructions and operands (aka 'values').  Unfortunately,
the type of an llvm::Value appears to be immutable?

It's very easy to clone a function by calling llvm::CloneFunction(&Function,
ValueMap), where ValueMap can be used to map from old values to new values.
But I'm not sure how to make the new values almost exact copies of the old
values (except for the number of elements per vector).  I can probably clone
individual instructions but then I need to mess with basic blocks, etc.  

I would greatly appreciate any hints.  Perhaps I am missing something
obvious?

Many thanks,
Anton L.





More information about the llvm-dev mailing list