[LLVMdev] Inserting Instructions (pass)

Michael Graumann MichaelGraumann at gmx.net
Fri Jul 31 17:04:19 PDT 2009


Thank you Chris,

for your hint, but I am still too stupid. I tried two versions

 

asm_arguments.push_back(Type::VoidTy);

FunctionType *asm_type = FunctionType::get(Type::VoidTy, asm_arguments,
false);

 

Alternatively

 

FunctionType *asm_type = FunctionType::get(Type::VoidTy, std::vector<const
Type*>(), false);

 

. Can you give me a snippet of example code, or somebody else? 

Thanks for help

 

Michael

 

for (BasicBlock::iterator bi = i->begin(), be = i->end(); bi != be; ++bi){

std::vector<const Type*> asm_arguments;

 

asm_arguments.push_back(Type::VoidTy);

 

                  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);

            }

 

 

Von: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] Im
Auftrag von Chris Lattner
Gesendet: Freitag, 31. Juli 2009 21:50
An: LLVM Developers Mailing List
Betreff: Re: [LLVMdev] Inserting Instructions (pass)

 

 

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/20090801/0623187a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090801/0623187a/attachment.bin>


More information about the llvm-dev mailing list