[LLVMdev] Inserting Instructions (pass)
Chris Lattner
clattner at apple.com
Fri Jul 31 12:49:45 PDT 2009
On Jul 31, 2009, at 10:24 AM, Michael Graumann wrote:
> Hi,
> I’ am trying to insert an InlineAsm Instruction in my pass, which
> FunctionType do I need for Inlineasm?
> If I understand it right, I need a call instruction to insert the
> new produced InlineAsm?
>
> Thanks for help
Inline asm works like a "callee". So for:
call void asm sideeffect "isync", "~{dirflag},~{fpsr},~{flags}"()
nounwind
The thing your calling has type "void()*". You just pass "void()"
into the InlineAsm ctor.
-Chris
> ,
>
> Michael
>
> for (BasicBlock::iterator bi = i->begin(), be = i->end(); bi != be; +
> +bi){
> std::vector<const Type*> asm_arguments;
> FunctionType *asm_type =
> FunctionType::get(Type::VoidTy, asm_arguments, false);
> InlineAsm* au = new InlineAsm(asm_type ???,
> "isync","~{dirflag},~{fpsr},~{flags}",true);
> //CallInst* ae = new CallInst(au ??);
> //Works fine
> AllocaInst* ai = new AllocaInst(Type::Int16Ty);
> Instruction *pi = bi;
> pi->getParent()->getInstList().insert(pi, ai);
> }
>
>
> Test.ll
> call void asm sideeffect "isync", "~{dirflag},~{fpsr},~{flags}"()
> nounwind
>
> llvm::FunctionType
> public:
> /// FunctionType::get - This static method is the primary way of
> constructing
> /// a FunctionType.
> ///
> static FunctionType *get(
> const Type *Result, ///< The result type, isync is Void
> const std::vector<const Type*> &Params, ///< The types of the
> parameters ???
> bool isVarArg ///< Whether this is a variable argument length
> function, isync false?
> );
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090731/c944baf6/attachment.html>
More information about the llvm-dev
mailing list