[LLVMdev] Calling functions

Álvaro Castro alvcastro at yahoo.es
Fri Feb 22 08:43:46 PST 2008


Hello!


I'm trying LLVM for generating code and I found something I cannot figure out or find in the documentation:

I'm doing something like this to call "sin" from std:

  std::vector<const Type*> params;
  params.push_back( Type::FloatTy );
  FunctionType *FT = FunctionType::get( Type::FloatTy, params, false);
  Function *F = new Function( FT, Function::ExternalLinkage, "sin", M );
  CallInst *CallExternal = new CallInst( F, SomeValue, "external_call", BB  );


I can make some calls to functions like glclear() as I'm using opengl:
...
  Function *F = new Function( FT, Function::ExternalLinkage, "glclear", M );
...

But if I want to call any function inside a C++ namespace I don't find the way to do it. Imagine you want to call

othernamespace::globalFunction()

How should I do it?
I've tried all the linkage types, but it's clear that's not the solution.

And another question:
is it possible to call a function of an instance of a C++ class? Which are the limits of interaction between generated code and "precompiled" code (I mean any library for example)?
I want to generate code able to use functionality from c/c++ libraries...

like:
classinstance.memberFunction()



Thank you very much,

.alvaro.castro.




       
______________________________________________ 
¿Con Mascota por primera vez? Sé un mejor Amigo. Entra en Yahoo! Respuestas http://es.answers.yahoo.com/info/welcome




More information about the llvm-dev mailing list