[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Jul 10 18:40:21 PDT 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.380 -> 1.381
---
Log message:

Fix CodeGen/Alpha/2006-07-03-ASMFormalLowering.ll and PR818: http://llvm.org/PR818 .


---
Diffs of the changes:  (+29 -12)

 LegalizeDAG.cpp |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.380 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.381
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.380	Wed Jun 28 16:58:30 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Mon Jul 10 20:40:09 2006
@@ -1163,25 +1163,42 @@
     AddLegalizedOperand(SDOperand(Node, 1), Tmp2);
     return Op.ResNo ? Tmp2 : Tmp1;
   }
-  case ISD::INLINEASM:
-    Tmp1 = LegalizeOp(Node->getOperand(0));   // Legalize Chain.
-    Tmp2 = Node->getOperand(Node->getNumOperands()-1);
-    if (Tmp2.getValueType() == MVT::Flag)     // Legalize Flag if it exists.
-      Tmp2 = Tmp3 = SDOperand(0, 0);
-    else
-      Tmp3 = LegalizeOp(Tmp2);
+  case ISD::INLINEASM: {
+    std::vector<SDOperand> Ops(Node->op_begin(), Node->op_end());
+    bool Changed = false;
+    // Legalize all of the operands of the inline asm, in case they are nodes
+    // that need to be expanded or something.  Note we skip the asm string and
+    // all of the TargetConstant flags.
+    SDOperand Op = LegalizeOp(Ops[0]);
+    Changed = Op != Ops[0];
+    Ops[0] = Op;
+
+    bool HasInFlag = Ops.back().getValueType() == MVT::Flag;
+    for (unsigned i = 2, e = Ops.size()-HasInFlag; i < e; ) {
+      unsigned NumVals = cast<ConstantSDNode>(Ops[i])->getValue() >> 3;
+      for (++i; NumVals; ++i, --NumVals) {
+        SDOperand Op = LegalizeOp(Ops[i]);
+        if (Op != Ops[i]) {
+          Changed = true;
+          Ops[i] = Op;
+        }
+      }
+    }
+
+    if (HasInFlag) {
+      Op = LegalizeOp(Ops.back());
+      Changed |= Op != Ops.back();
+      Ops.back() = Op;
+    }
     
-    if (Tmp1 != Node->getOperand(0) || Tmp2 != Tmp3) {
-      std::vector<SDOperand> Ops(Node->op_begin(), Node->op_end());
-      Ops[0] = Tmp1;
-      if (Tmp3.Val) Ops.back() = Tmp3;
+    if (Changed)
       Result = DAG.UpdateNodeOperands(Result, Ops);
-    }
       
     // INLINE asm returns a chain and flag, make sure to add both to the map.
     AddLegalizedOperand(SDOperand(Node, 0), Result.getValue(0));
     AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
     return Result.getValue(Op.ResNo);
+  }
   case ISD::BR:
     Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
     // Ensure that libcalls are emitted before a branch.






More information about the llvm-commits mailing list