<div class="gmail_quote">On 26 April 2011 10:18, Dan Gohman <span dir="ltr"><<a href="mailto:gohman@apple.com">gohman@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Author: djg<br>
Date: Tue Apr 26 12:18:34 2011<br>
New Revision: 130205<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=130205&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=130205&view=rev</a><br>
Log:<br>
Fast-isel support for simple inline asms.<br>
<br>
Modified:<br>
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp<br>
llvm/trunk/test/CodeGen/X86/fast-isel.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130205&r1=130204&r2=130205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130205&r1=130204&r2=130205&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Apr 26 12:18:34 2011<br>
@@ -482,14 +482,35 @@<br>
}<br>
<br>
bool FastISel::SelectCall(const User *I) {<br>
- const Function *F = cast<CallInst>(I)->getCalledFunction();<br>
+ const CallInst *Call = cast<CallInst>(I);<br>
+<br>
+ // Handle simple inline asms.<br>
+ if (const InlineAsm *IA = dyn_cast<InlineAsm>(Call->getArgOperand(0))) {<br></blockquote><div><br></div><div>Are you sure this is what you mean? This is checking that the first argument to a call is the result of an inline asm run earlier. Did you mean "if (const InlineAsm *IA = dyn_cast<InlineAsm>(Call->getCalledValue())) {" ?</div>
<div><br></div><div>If so, make sure to hoist the "const Function *F = Call->getCalledFunction();" stuff below above this and reuse it.</div><div><br></div><div>Nick</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
+ // Don't attempt to handle constraints.<br>
+ if (!IA->getConstraintString().empty())<br>
+ return false;<br>
+<br>
+ unsigned ExtraInfo = 0;<br>
+ if (IA->hasSideEffects())<br>
+ ExtraInfo |= InlineAsm::Extra_HasSideEffects;<br>
+ if (IA->isAlignStack())<br>
+ ExtraInfo |= InlineAsm::Extra_IsAlignStack;<br>
+<br>
+ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,<br>
+ TII.get(TargetOpcode::INLINEASM))<br>
+ .addExternalSymbol(IA->getAsmString().c_str())<br>
+ .addImm(ExtraInfo);<br>
+ return true;<br>
+ }<br>
+<br>
+ const Function *F = Call->getCalledFunction();<br>
if (!F) return false;<br>
<br>
// Handle selected intrinsic function calls.<br>
switch (F->getIntrinsicID()) {<br>
default: break;<br>
case Intrinsic::dbg_declare: {<br>
- const DbgDeclareInst *DI = cast<DbgDeclareInst>(I);<br>
+ const DbgDeclareInst *DI = cast<DbgDeclareInst>(Call);<br>
if (!DIVariable(DI->getVariable()).Verify() ||<br>
!FuncInfo.MF->getMMI().hasDebugInfo())<br>
return true;<br>
@@ -521,7 +542,7 @@<br>
}<br>
case Intrinsic::dbg_value: {<br>
// This form of DBG_VALUE is target-independent.<br>
- const DbgValueInst *DI = cast<DbgValueInst>(I);<br>
+ const DbgValueInst *DI = cast<DbgValueInst>(Call);<br>
const TargetInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);<br>
const Value *V = DI->getValue();<br>
if (!V) {<br>
@@ -550,7 +571,7 @@<br>
return true;<br>
}<br>
case Intrinsic::eh_exception: {<br>
- EVT VT = TLI.getValueType(I->getType());<br>
+ EVT VT = TLI.getValueType(Call->getType());<br>
if (TLI.getOperationAction(ISD::EXCEPTIONADDR, VT)!=TargetLowering::Expand)<br>
break;<br>
<br>
@@ -561,18 +582,18 @@<br>
unsigned ResultReg = createResultReg(RC);<br>
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),<br>
ResultReg).addReg(Reg);<br>
- UpdateValueMap(I, ResultReg);<br>
+ UpdateValueMap(Call, ResultReg);<br>
return true;<br>
}<br>
case Intrinsic::eh_selector: {<br>
- EVT VT = TLI.getValueType(I->getType());<br>
+ EVT VT = TLI.getValueType(Call->getType());<br>
if (TLI.getOperationAction(ISD::EHSELECTION, VT) != TargetLowering::Expand)<br>
break;<br>
if (FuncInfo.MBB->isLandingPad())<br>
- AddCatchInfo(*cast<CallInst>(I), &FuncInfo.MF->getMMI(), FuncInfo.MBB);<br>
+ AddCatchInfo(*Call, &FuncInfo.MF->getMMI(), FuncInfo.MBB);<br>
else {<br>
#ifndef NDEBUG<br>
- FuncInfo.CatchInfoLost.insert(cast<CallInst>(I));<br>
+ FuncInfo.CatchInfoLost.insert(Call);<br>
#endif<br>
// FIXME: Mark exception selector register as live in. Hack for PR1508.<br>
unsigned Reg = TLI.getExceptionSelectorRegister();<br>
@@ -586,7 +607,7 @@<br>
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY),<br>
ResultReg).addReg(Reg);<br>
<br>
- bool ResultRegIsKill = hasTrivialKill(I);<br>
+ bool ResultRegIsKill = hasTrivialKill(Call);<br>
<br>
// Cast the register to the type of the selector.<br>
if (SrcVT.bitsGT(MVT::i32))<br>
@@ -599,7 +620,7 @@<br>
// Unhandled operand. Halt "fast" selection and bail.<br>
return false;<br>
<br>
- UpdateValueMap(I, ResultReg);<br>
+ UpdateValueMap(Call, ResultReg);<br>
<br>
return true;<br>
}<br>
<br>
Modified: llvm/trunk/test/CodeGen/X86/fast-isel.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=130205&r1=130204&r2=130205&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=130205&r1=130204&r2=130205&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/X86/fast-isel.ll (original)<br>
+++ llvm/trunk/test/CodeGen/X86/fast-isel.ll Tue Apr 26 12:18:34 2011<br>
@@ -20,6 +20,7 @@<br>
%t6 = add i32 %t5, 2<br>
%t7 = getelementptr i32* %y, i32 1<br>
%t8 = getelementptr i32* %t7, i32 %t6<br>
+ call void asm sideeffect "hello world", ""()<br>
br label %exit<br>
<br>
exit:<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br>