<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 31, 2009, at 10:24 AM, Michael Graumann wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div lang="DE" link="blue" vlink="purple"><div class="Section1"><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Hi,<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">I’ am trying to insert an InlineAsm Instruction in my pass, which FunctionType do I need for Inlineasm?<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">If I understand it right, I need a call instruction to insert the new produced InlineAsm?<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Thanks for help</span></div></div></div></span></blockquote><div><br></div><div>Inline asm works like a "callee". So for:</div><div><br></div><div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div lang="DE" link="blue" vlink="purple"><div class="Section1"><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; ">call void asm sideeffect "isync", "~{dirflag},~{fpsr},~{flags}"() nounwind<o:p></o:p></div></div></div></span><div><font class="Apple-style-span" face="Calibri, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 15px;"><br></span></font></div><div><font class="Apple-style-span" face="Calibri, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 15px;">The thing your calling has type "void()*". You just pass "void()" into the InlineAsm ctor.</span></font></div><div><font class="Apple-style-span" face="Calibri, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 15px;"><br></span></font></div><div><font class="Apple-style-span" face="Calibri, sans-serif" size="4"><span class="Apple-style-span" style="font-size: 15px;">-Chris</span></font></div></div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div lang="DE" link="blue" vlink="purple"><div class="Section1"><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">,<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Michael<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: blue; ">for</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "><span class="Apple-converted-space"> </span>(BasicBlock::iterator bi = i->begin(), be = i->end(); bi != be; ++bi){<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 70.8pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 35.4pt; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; ">std::vector<<span style="color: blue; ">const</span><span class="Apple-converted-space"> </span>Type*> asm_arguments;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> FunctionType *asm_type = FunctionType::get(Type::VoidTy, asm_arguments,<span class="Apple-converted-space"> </span><span style="color: blue; ">false</span>);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> InlineAsm* au =<span class="Apple-converted-space"> </span><span style="color: blue; ">new</span><span class="Apple-converted-space"> </span>InlineAsm(asm_type ???,<span class="Apple-converted-space"> </span><span style="color: rgb(163, 21, 21); ">"isync"</span>,<span style="color: rgb(163, 21, 21); ">"~{dirflag},~{fpsr},~{flags}"</span>,<span style="color: blue; ">true</span>);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: green; ">//CallInst* ae = new CallInst(au ??);</span><o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; ">//Works fine<span style="color: green; "><o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> AllocaInst* ai =<span class="Apple-converted-space"> </span><span style="color: blue; ">new</span><span class="Apple-converted-space"> </span>AllocaInst(Type::Int16Ty);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> Instruction *pi = bi;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span></span><span style="font-size: 10pt; font-family: 'Courier New'; ">pi->getParent()->getInstList().insert(pi, ai);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: 'Courier New'; "> }<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: 'Courier New'; "><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: 'Courier New'; "><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: 'Courier New'; ">Test.ll<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; ">call void asm sideeffect "isync", "~{dirflag},~{fpsr},~{flags}"() nounwind<o:p></o:p></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><o:p> </o:p></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">llvm::FunctionType<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; color: blue; ">public</span><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; ">:<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: green; ">/// FunctionType::get - This static method is the primary way of constructing<o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: green; ">/// a FunctionType.<o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: green; ">///<o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: blue; ">static</span><span class="Apple-converted-space"> </span>FunctionType *get(<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: blue; ">const</span><span class="Apple-converted-space"> </span>Type *Result,<span class="Apple-converted-space"> </span><span style="color: green; ">///< The result type, isync is Void<o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: blue; ">const</span><span class="Apple-converted-space"> </span>std::vector<<span style="color: blue; ">const</span><span class="Apple-converted-space"> </span>Type*> &Params,<span class="Apple-converted-space"> </span><span style="color: green; ">///< The types of the parameters ???<o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span><span style="color: blue; ">bool</span><span class="Apple-converted-space"> </span>isVarArg <span class="Apple-converted-space"> </span><span style="color: green; ">///< Whether this is a variable argument length function, isync false?<o:p></o:p></span></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US" style="font-size: 10pt; font-family: 'Courier New'; "> <span class="Apple-converted-space"> </span></span><span style="font-size: 10pt; font-family: 'Courier New'; ">);</span><span lang="EN-US"><o:p></o:p></span></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" style="color: blue; text-decoration: underline; ">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" style="color: blue; text-decoration: underline; ">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></span></blockquote></div><br></body></html>