Vectors and function calls across modules

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Vectors and function calls across modules

Hey all, thanks for your prompt replies from before, now I have more

First, I've heard rumors about the ability to call functions across
modules. I'm interested in learning how, but I haven't been able to
figure it out yet. I tried just taking a Function* that I got from one
module and calling it from another one, but that didn't work. How do I
do that?

Second, I'm interested in using vectors of floats within llvm, but my
first stab at it proved unsuccessful. Here's what I tried: a simple
function which takes in 2 vectors, multiplies them, and returns the
result. Here's the relevant code for making the function ("mul"):

//Code snip start
VectorType *vType = VectorType::get(Type::FloatTy, 3);

std::vector<const Type*> Vectors(2, vType);
FunctionType *mul_type     = FunctionType::get(vType, Vectors, false);
Function* mul              = new Function(mul_type,
Function::ExternalLinkage, "mul", mod);

Function::arg_iterator args = mul->arg_begin();
Value* x = args++;
Value* y = args++;

BasicBlock* block = new BasicBlock("entry", mul);
Value* tmp  = BinaryOperator::create(Instruction::Mul, x, y, "result",
new ReturnInst(tmp, block);
//code snip end

When I try to get a pointer to this function through
llvm::JIT::getPointerToFunction(), I hit an abort trap which tells me
"Return operand #1 has unhandled type f32".

When I print out the IR, I get what I'd expect:
define <3 x float> @mul(<3 x float> %x, <3 x float> %y) {
        %result = mul <3 x float> %x, %y                ; <<3 x float>>
        ret <3 x float> %result

Any ideas on what I'm doing wrong here?

Thanks for all the help,
LLVM Developers mailing list
[hidden email]