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

Reid Spencer reid at x10sys.com
Sat Dec 30 21:56:07 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.449 -> 1.450
SelectionDAGISel.cpp updated: 1.334 -> 1.335
---
Log message:

For PR950: http://llvm.org/PR950 :
Three changes:
1. Convert signed integer types to signless versions.
2. Implement the @sext and @zext parameter attributes. Previously the
   type of an function parameter was used to determine whether it should
   be sign extended or zero extended before the call. This information is
   now communicated via the function type's parameter attributes. 
3. The interface to LowerCallTo had to be changed in order to accommodate
   the parameter attribute information. Although it would have been
   convenient to pass in the FunctionType itself, there isn't always one
   present in the caller. Consequently, a signedness indication for the
   result type and for each parameter was provided for in the interface
   to this method. All implementations were changed to make the adjustment
   necessary.


---
Diffs of the changes:  (+119 -97)

 LegalizeDAG.cpp      |  108 ++++++++++++++++++++++++++++++---------------------
 SelectionDAGISel.cpp |  108 +++++++++++++++++++++++++--------------------------
 2 files changed, 119 insertions(+), 97 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.449 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.450
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.449	Mon Dec 18 19:44:04 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Sat Dec 30 23:55:36 2006
@@ -186,7 +186,7 @@
     
   SDOperand CreateStackTemporary(MVT::ValueType VT);
 
-  SDOperand ExpandLibCall(const char *Name, SDNode *Node,
+  SDOperand ExpandLibCall(const char *Name, SDNode *Node, bool isSigned,
                           SDOperand &Hi);
   SDOperand ExpandIntToFP(bool isSigned, MVT::ValueType DestTy,
                           SDOperand Source);
@@ -2122,33 +2122,42 @@
       // operation to an explicit libcall as appropriate.
       MVT::ValueType IntPtr = TLI.getPointerTy();
       const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType();
-      std::vector<std::pair<SDOperand, const Type*> > Args;
+      TargetLowering::ArgListTy Args;
+      TargetLowering::ArgListEntry Entry;
 
       const char *FnName = 0;
       if (Node->getOpcode() == ISD::MEMSET) {
-        Args.push_back(std::make_pair(Tmp2, IntPtrTy));
+        Entry.Node = Tmp2;
+        Entry.Ty = IntPtrTy;
+        Entry.isSigned = false;
+        Args.push_back(Entry);
         // Extend the (previously legalized) ubyte argument to be an int value
         // for the call.
         if (Tmp3.getValueType() > MVT::i32)
           Tmp3 = DAG.getNode(ISD::TRUNCATE, MVT::i32, Tmp3);
         else
           Tmp3 = DAG.getNode(ISD::ZERO_EXTEND, MVT::i32, Tmp3);
-        Args.push_back(std::make_pair(Tmp3, Type::IntTy));
-        Args.push_back(std::make_pair(Tmp4, IntPtrTy));
+        Entry.Node = Tmp3; Entry.Ty = Type::Int32Ty; Entry.isSigned = true;
+        Args.push_back(Entry);
+        Entry.Node = Tmp4; Entry.Ty = IntPtrTy; Entry.isSigned = false;
+        Args.push_back(Entry);
 
         FnName = "memset";
       } else if (Node->getOpcode() == ISD::MEMCPY ||
                  Node->getOpcode() == ISD::MEMMOVE) {
-        Args.push_back(std::make_pair(Tmp2, IntPtrTy));
-        Args.push_back(std::make_pair(Tmp3, IntPtrTy));
-        Args.push_back(std::make_pair(Tmp4, IntPtrTy));
+        Entry.Node = Tmp2; Entry.Ty = IntPtrTy; Entry.isSigned = false;
+        Args.push_back(Entry);
+        Entry.Node = Tmp3; Entry.Ty = IntPtrTy; Entry.isSigned = false;
+        Args.push_back(Entry);
+        Entry.Node = Tmp4; Entry.Ty = IntPtrTy; Entry.isSigned = false;
+        Args.push_back(Entry);
         FnName = Node->getOpcode() == ISD::MEMMOVE ? "memmove" : "memcpy";
       } else {
         assert(0 && "Unknown op!");
       }
 
       std::pair<SDOperand,SDOperand> CallResult =
-        TLI.LowerCallTo(Tmp1, Type::VoidTy, false, CallingConv::C, false,
+        TLI.LowerCallTo(Tmp1, Type::VoidTy, false, false, CallingConv::C, false,
                         DAG.getExternalSymbol(FnName, IntPtr), Args, DAG);
       Result = CallResult.second;
       break;
@@ -2243,7 +2252,8 @@
           const char *FnName = Node->getOpcode() == ISD::UDIV
             ? "__udivsi3" : "__divsi3";
           SDOperand Dummy;
-          Result = ExpandLibCall(FnName, Node, Dummy);
+          bool isSigned = Node->getOpcode() == ISD::SDIV;
+          Result = ExpandLibCall(FnName, Node, isSigned, Dummy);
         };
         break;
       }
@@ -2346,7 +2356,7 @@
                                    DAG.getNode(ISD::FP_EXTEND, MVT::f64, Tmp2));
       }
       SDOperand Dummy;
-      Result = ExpandLibCall(FnName, Node, Dummy);
+      Result = ExpandLibCall(FnName, Node, false, Dummy);
       break;
     }
     break;
@@ -2419,6 +2429,7 @@
       break;
     case TargetLowering::Expand:
       unsigned DivOpc= (Node->getOpcode() == ISD::UREM) ? ISD::UDIV : ISD::SDIV;
+      bool isSigned = DivOpc == ISD::SDIV;
       if (MVT::isInteger(Node->getValueType(0))) {
         if (TLI.getOperationAction(DivOpc, Node->getValueType(0)) ==
             TargetLowering::Legal) {
@@ -2433,13 +2444,13 @@
           const char *FnName = Node->getOpcode() == ISD::UREM
             ? "__umodsi3" : "__modsi3";
           SDOperand Dummy;
-          Result = ExpandLibCall(FnName, Node, Dummy);
+          Result = ExpandLibCall(FnName, Node, isSigned, Dummy);
         }
       } else {
         // Floating point mod -> fmod libcall.
         const char *FnName = Node->getValueType(0) == MVT::f32 ? "fmodf":"fmod";
         SDOperand Dummy;
-        Result = ExpandLibCall(FnName, Node, Dummy);
+        Result = ExpandLibCall(FnName, Node, false, Dummy);
       }
       break;
     }
@@ -2688,7 +2699,7 @@
         default: assert(0 && "Unreachable!");
         }
         SDOperand Dummy;
-        Result = ExpandLibCall(FnName, Node, Dummy);
+        Result = ExpandLibCall(FnName, Node, false, Dummy);
         break;
       }
       }
@@ -2700,7 +2711,7 @@
     const char *FnName = Node->getValueType(0) == MVT::f32
                             ? "__powisf2" : "__powidf2";
     SDOperand Dummy;
-    Result = ExpandLibCall(FnName, Node, Dummy);
+    Result = ExpandLibCall(FnName, Node, false, Dummy);
     break;
   }
   case ISD::BIT_CONVERT:
@@ -2886,7 +2897,7 @@
       default: assert(0 && "Unreachable!");
       }
       SDOperand Dummy;
-      Result = ExpandLibCall(FnName, Node, Dummy);
+      Result = ExpandLibCall(FnName, Node, false, Dummy);
       break;
     }
     case Promote:
@@ -3609,13 +3620,15 @@
       
       SDOperand Dummy;
       Tmp1 = ExpandLibCall(FnName1,
-                       DAG.getNode(ISD::MERGE_VALUES, VT, LHS, RHS).Val, Dummy);
+                           DAG.getNode(ISD::MERGE_VALUES, VT, LHS, RHS).Val, 
+                           false, Dummy);
       Tmp2 = DAG.getConstant(0, MVT::i32);
       CC = DAG.getCondCode(CC1);
       if (FnName2) {
         Tmp1 = DAG.getNode(ISD::SETCC, TLI.getSetCCResultTy(), Tmp1, Tmp2, CC);
         LHS = ExpandLibCall(FnName2,
-                       DAG.getNode(ISD::MERGE_VALUES, VT, LHS, RHS).Val, Dummy);
+                            DAG.getNode(ISD::MERGE_VALUES, VT, LHS, RHS).Val, 
+                            false, Dummy);
         Tmp2 = DAG.getNode(ISD::SETCC, TLI.getSetCCResultTy(), LHS, Tmp2,
                            DAG.getCondCode(CC2));
         Tmp1 = DAG.getNode(ISD::OR, Tmp1.getValueType(), Tmp1, Tmp2);
@@ -4051,7 +4064,7 @@
 // by-reg argument.  If it does fit into a single register, return the result
 // and leave the Hi part unset.
 SDOperand SelectionDAGLegalize::ExpandLibCall(const char *Name, SDNode *Node,
-                                              SDOperand &Hi) {
+                                              bool isSigned, SDOperand &Hi) {
   assert(!IsLegalizingCall && "Cannot overlap legalization of calls!");
   // The input chain to this libcall is the entry node of the function. 
   // Legalizing the call will automatically add the previous call to the
@@ -4059,17 +4072,20 @@
   SDOperand InChain = DAG.getEntryNode();
   
   TargetLowering::ArgListTy Args;
+  TargetLowering::ArgListEntry Entry;
   for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
     MVT::ValueType ArgVT = Node->getOperand(i).getValueType();
     const Type *ArgTy = MVT::getTypeForValueType(ArgVT);
-    Args.push_back(std::make_pair(Node->getOperand(i), ArgTy));
+    Entry.Node = Node->getOperand(i); Entry.Ty = ArgTy; 
+    Entry.isSigned = isSigned;
+    Args.push_back(Entry);
   }
   SDOperand Callee = DAG.getExternalSymbol(Name, TLI.getPointerTy());
 
   // Splice the libcall in wherever FindInputOutputChains tells us to.
   const Type *RetTy = MVT::getTypeForValueType(Node->getValueType(0));
   std::pair<SDOperand,SDOperand> CallInfo =
-    TLI.LowerCallTo(InChain, RetTy, false, CallingConv::C, false,
+    TLI.LowerCallTo(InChain, RetTy, isSigned, false, CallingConv::C, false,
                     Callee, Args, DAG);
 
   // Legalize the call sequence, starting with the chain.  This will advance
@@ -4121,7 +4137,7 @@
                                       SignSet, Four, Zero);
     uint64_t FF = 0x5f800000ULL;
     if (TLI.isLittleEndian()) FF <<= 32;
-    static Constant *FudgeFactor = ConstantInt::get(Type::ULongTy, FF);
+    static Constant *FudgeFactor = ConstantInt::get(Type::Int64Ty, FF);
 
     SDOperand CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
     CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset);
@@ -4167,7 +4183,7 @@
   
   Source = DAG.getNode(ISD::SINT_TO_FP, DestTy, Source);
   SDOperand UnusedHiPart;
-  return ExpandLibCall(FnName, Source.Val, UnusedHiPart);
+  return ExpandLibCall(FnName, Source.Val, isSigned, UnusedHiPart);
 }
 
 /// ExpandLegalINT_TO_FP - This function is responsible for legalizing a
@@ -4252,7 +4268,7 @@
   case MVT::i64: FF = 0x5F800000ULL; break;  // 2^64 (as a float)
   }
   if (TLI.isLittleEndian()) FF <<= 32;
-  static Constant *FudgeFactor = ConstantInt::get(Type::ULongTy, FF);
+  static Constant *FudgeFactor = ConstantInt::get(Type::Int64Ty, FF);
 
   SDOperand CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
   CPIdx = DAG.getNode(ISD::ADD, TLI.getPointerTy(), CPIdx, CstOffset);
@@ -4820,9 +4836,9 @@
     }
 
     if (Node->getOperand(0).getValueType() == MVT::f32)
-      Lo = ExpandLibCall("__fixsfdi", Node, Hi);
+      Lo = ExpandLibCall("__fixsfdi", Node, false, Hi);
     else
-      Lo = ExpandLibCall("__fixdfdi", Node, Hi);
+      Lo = ExpandLibCall("__fixdfdi", Node, false, Hi);
     break;
 
   case ISD::FP_TO_UINT:
@@ -4844,9 +4860,9 @@
     }
 
     if (Node->getOperand(0).getValueType() == MVT::f32)
-      Lo = ExpandLibCall("__fixunssfdi", Node, Hi);
+      Lo = ExpandLibCall("__fixunssfdi", Node, false, Hi);
     else
-      Lo = ExpandLibCall("__fixunsdfdi", Node, Hi);
+      Lo = ExpandLibCall("__fixunsdfdi", Node, false, Hi);
     break;
 
   case ISD::SHL: {
@@ -4895,7 +4911,7 @@
     }
 
     // Otherwise, emit a libcall.
-    Lo = ExpandLibCall("__ashldi3", Node, Hi);
+    Lo = ExpandLibCall("__ashldi3", Node, false, Hi);
     break;
   }
 
@@ -4927,7 +4943,7 @@
     }
 
     // Otherwise, emit a libcall.
-    Lo = ExpandLibCall("__ashrdi3", Node, Hi);
+    Lo = ExpandLibCall("__ashrdi3", Node, true, Hi);
     break;
   }
 
@@ -4959,7 +4975,7 @@
     }
 
     // Otherwise, emit a libcall.
-    Lo = ExpandLibCall("__lshrdi3", Node, Hi);
+    Lo = ExpandLibCall("__lshrdi3", Node, false, Hi);
     break;
   }
 
@@ -5046,31 +5062,35 @@
       }
     }
 
-    Lo = ExpandLibCall("__muldi3" , Node, Hi);
+    Lo = ExpandLibCall("__muldi3" , Node, false, Hi);
     break;
   }
-  case ISD::SDIV: Lo = ExpandLibCall("__divdi3" , Node, Hi); break;
-  case ISD::UDIV: Lo = ExpandLibCall("__udivdi3", Node, Hi); break;
-  case ISD::SREM: Lo = ExpandLibCall("__moddi3" , Node, Hi); break;
-  case ISD::UREM: Lo = ExpandLibCall("__umoddi3", Node, Hi); break;
+  case ISD::SDIV: Lo = ExpandLibCall("__divdi3" , Node, true, Hi); break;
+  case ISD::UDIV: Lo = ExpandLibCall("__udivdi3", Node, false, Hi); break;
+  case ISD::SREM: Lo = ExpandLibCall("__moddi3" , Node, true, Hi); break;
+  case ISD::UREM: Lo = ExpandLibCall("__umoddi3", Node, false, Hi); break;
 
   case ISD::FADD:
-    Lo = ExpandLibCall(((VT == MVT::f32) ? "__addsf3" : "__adddf3"), Node, Hi);
+    Lo = ExpandLibCall(((VT == MVT::f32) ? "__addsf3" : "__adddf3"), Node, 
+                       false, Hi);
     break;
   case ISD::FSUB:
-    Lo = ExpandLibCall(((VT == MVT::f32) ? "__subsf3" : "__subdf3"), Node, Hi);
+    Lo = ExpandLibCall(((VT == MVT::f32) ? "__subsf3" : "__subdf3"), Node, 
+                       false, Hi);
     break;
   case ISD::FMUL:
-    Lo = ExpandLibCall(((VT == MVT::f32) ? "__mulsf3" : "__muldf3"), Node, Hi);
+    Lo = ExpandLibCall(((VT == MVT::f32) ? "__mulsf3" : "__muldf3"), Node, 
+                       false, Hi);
     break;
   case ISD::FDIV:
-    Lo = ExpandLibCall(((VT == MVT::f32) ? "__divsf3" : "__divdf3"), Node, Hi);
+    Lo = ExpandLibCall(((VT == MVT::f32) ? "__divsf3" : "__divdf3"), Node, 
+                       false, Hi);
     break;
   case ISD::FP_EXTEND:
-    Lo = ExpandLibCall("__extendsfdf2", Node, Hi);
+    Lo = ExpandLibCall("__extendsfdf2", Node, false, Hi);
     break;
   case ISD::FP_ROUND:
-    Lo = ExpandLibCall("__truncdfsf2", Node, Hi);
+    Lo = ExpandLibCall("__truncdfsf2", Node, false, Hi);
     break;
   case ISD::FSQRT:
   case ISD::FSIN:
@@ -5082,7 +5102,7 @@
     case ISD::FCOS:  FnName = (VT == MVT::f32) ? "cosf"  : "cos";  break;
     default: assert(0 && "Unreachable!");
     }
-    Lo = ExpandLibCall(FnName, Node, Hi);
+    Lo = ExpandLibCall(FnName, Node, false, Hi);
     break;
   }
   case ISD::FABS: {
@@ -5133,7 +5153,7 @@
         : DAG.getZeroExtendInReg(Tmp, SrcVT);
       Node = DAG.UpdateNodeOperands(Op, Tmp).Val;
     }
-    Lo = ExpandLibCall(FnName, Node, Hi);
+    Lo = ExpandLibCall(FnName, Node, isSigned, Hi);
     break;
   }
   }


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.334 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.335
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.334	Sat Dec 23 00:05:40 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Sat Dec 30 23:55:36 2006
@@ -396,13 +396,9 @@
   /// The comparison function for sorting Case values.
   struct CaseCmp {
     bool operator () (const Case& C1, const Case& C2) {
-      if (const ConstantInt* I1 = dyn_cast<const ConstantInt>(C1.first))
-        if (I1->getType()->isUnsigned())
-          return I1->getZExtValue() <
-            cast<const ConstantInt>(C2.first)->getZExtValue();
-      
-      return cast<const ConstantInt>(C1.first)->getSExtValue() <
-         cast<const ConstantInt>(C2.first)->getSExtValue();
+      assert(isa<ConstantInt>(C1.first) && isa<ConstantInt>(C2.first));
+      return cast<const ConstantInt>(C1.first)->getZExtValue() <
+        cast<const ConstantInt>(C2.first)->getZExtValue();
     }
   };
   
@@ -756,7 +752,6 @@
   NewValues.push_back(getRoot());
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
     SDOperand RetOp = getValue(I.getOperand(i));
-    bool isSigned = I.getOperand(i)->getType()->isSigned();
     
     // If this is an integer return value, we need to promote it ourselves to
     // the full width of a register, since LegalizeOp will use ANY_EXTEND rather
@@ -770,14 +765,14 @@
         TmpVT = TLI.getTypeToTransformTo(MVT::i32);
       else
         TmpVT = MVT::i32;
-
-      if (isSigned)
-        RetOp = DAG.getNode(ISD::SIGN_EXTEND, TmpVT, RetOp);
-      else
-        RetOp = DAG.getNode(ISD::ZERO_EXTEND, TmpVT, RetOp);
+      const FunctionType *FTy = I.getParent()->getParent()->getFunctionType();
+      ISD::NodeType ExtendKind = ISD::SIGN_EXTEND;
+      if (FTy->paramHasAttr(0, FunctionType::ZExtAttribute))
+        ExtendKind = ISD::ZERO_EXTEND;
+      RetOp = DAG.getNode(ExtendKind, TmpVT, RetOp);
     }
     NewValues.push_back(RetOp);
-    NewValues.push_back(DAG.getConstant(isSigned, MVT::i32));
+    NewValues.push_back(DAG.getConstant(false, MVT::i32));
   }
   DAG.setRoot(DAG.getNode(ISD::RET, MVT::Other,
                           &NewValues[0], NewValues.size()));
@@ -1383,7 +1378,7 @@
       // Create a CaseBlock record representing a conditional branch to
       // the LHS node if the value being switched on SV is less than C. 
       // Otherwise, branch to LHS.
-      ISD::CondCode CC = C->getType()->isSigned() ? ISD::SETLT : ISD::SETULT;
+      ISD::CondCode CC =  ISD::SETULT;
       SelectionDAGISel::CaseBlock CB(CC, SV, C, TrueBB, FalseBB, CR.CaseBB);
 
       if (CR.CaseBB == CurMBB)
@@ -1705,12 +1700,7 @@
       // If this is a constant subscript, handle it quickly.
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx)) {
         if (CI->getZExtValue() == 0) continue;
-        uint64_t Offs;
-        if (CI->getType()->isSigned()) 
-          Offs = (int64_t)
-            TD->getTypeSize(Ty)*cast<ConstantInt>(CI)->getSExtValue();
-        else
-          Offs = 
+        uint64_t Offs = 
             TD->getTypeSize(Ty)*cast<ConstantInt>(CI)->getZExtValue();
         N = DAG.getNode(ISD::ADD, N.getValueType(), N, getIntPtrConstant(Offs));
         continue;
@@ -1723,10 +1713,7 @@
       // If the index is smaller or larger than intptr_t, truncate or extend
       // it.
       if (IdxN.getValueType() < N.getValueType()) {
-        if (Idx->getType()->isSigned())
-          IdxN = DAG.getNode(ISD::SIGN_EXTEND, N.getValueType(), IdxN);
-        else
-          IdxN = DAG.getNode(ISD::ZERO_EXTEND, N.getValueType(), IdxN);
+        IdxN = DAG.getNode(ISD::SIGN_EXTEND, N.getValueType(), IdxN);
       } else if (IdxN.getValueType() > N.getValueType())
         IdxN = DAG.getNode(ISD::TRUNCATE, N.getValueType(), IdxN);
 
@@ -2185,25 +2172,30 @@
     return;
   }
 
+  const PointerType *PT = cast<PointerType>(I.getCalledValue()->getType());
+  const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
+
   SDOperand Callee;
   if (!RenameFn)
     Callee = getValue(I.getOperand(0));
   else
     Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy());
-  std::vector<std::pair<SDOperand, const Type*> > Args;
+  TargetLowering::ArgListTy Args;
+  TargetLowering::ArgListEntry Entry;
   Args.reserve(I.getNumOperands());
   for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i) {
     Value *Arg = I.getOperand(i);
     SDOperand ArgNode = getValue(Arg);
-    Args.push_back(std::make_pair(ArgNode, Arg->getType()));
+    Entry.Node = ArgNode; Entry.Ty = Arg->getType();
+    Entry.isSigned = FTy->paramHasAttr(i, FunctionType::SExtAttribute);
+    Args.push_back(Entry);
   }
 
-  const PointerType *PT = cast<PointerType>(I.getCalledValue()->getType());
-  const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
-
   std::pair<SDOperand,SDOperand> Result =
-    TLI.LowerCallTo(getRoot(), I.getType(), FTy->isVarArg(), I.getCallingConv(),
-                    I.isTailCall(), Callee, Args, DAG);
+    TLI.LowerCallTo(getRoot(), I.getType(), 
+                    FTy->paramHasAttr(0,FunctionType::SExtAttribute),
+                    FTy->isVarArg(), I.getCallingConv(), I.isTailCall(), 
+                    Callee, Args, DAG);
   if (I.getType() != Type::VoidTy)
     setValue(&I, Result.first);
   DAG.setRoot(Result.second);
@@ -2785,11 +2777,15 @@
   Src = DAG.getNode(ISD::MUL, Src.getValueType(),
                     Src, getIntPtrConstant(ElementSize));
 
-  std::vector<std::pair<SDOperand, const Type*> > Args;
-  Args.push_back(std::make_pair(Src, TLI.getTargetData()->getIntPtrType()));
+  TargetLowering::ArgListTy Args;
+  TargetLowering::ArgListEntry Entry;
+  Entry.Node = Src;
+  Entry.Ty = TLI.getTargetData()->getIntPtrType();
+  Entry.isSigned = false;
+  Args.push_back(Entry);
 
   std::pair<SDOperand,SDOperand> Result =
-    TLI.LowerCallTo(getRoot(), I.getType(), false, CallingConv::C, true,
+    TLI.LowerCallTo(getRoot(), I.getType(), false, false, CallingConv::C, true,
                     DAG.getExternalSymbol("malloc", IntPtr),
                     Args, DAG);
   setValue(&I, Result.first);  // Pointers always fit in registers
@@ -2797,12 +2793,15 @@
 }
 
 void SelectionDAGLowering::visitFree(FreeInst &I) {
-  std::vector<std::pair<SDOperand, const Type*> > Args;
-  Args.push_back(std::make_pair(getValue(I.getOperand(0)),
-                                TLI.getTargetData()->getIntPtrType()));
+  TargetLowering::ArgListTy Args;
+  TargetLowering::ArgListEntry Entry;
+  Entry.Node = getValue(I.getOperand(0));
+  Entry.Ty = TLI.getTargetData()->getIntPtrType();
+  Entry.isSigned = false;
+  Args.push_back(Entry);
   MVT::ValueType IntPtr = TLI.getPointerTy();
   std::pair<SDOperand,SDOperand> Result =
-    TLI.LowerCallTo(getRoot(), Type::VoidTy, false, CallingConv::C, true,
+    TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, CallingConv::C, true,
                     DAG.getExternalSymbol("free", IntPtr), Args, DAG);
   DAG.setRoot(Result.second);
 }
@@ -2939,8 +2938,11 @@
 
   // Set up the return result vector.
   Ops.clear();
+  const FunctionType *FTy = F.getFunctionType();
   unsigned i = 0;
-  for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) {
+  unsigned Idx = 1;
+  for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; 
+      ++I, ++Idx) {
     MVT::ValueType VT = getValueType(I->getType());
     
     switch (getTypeAction(VT)) {
@@ -2951,8 +2953,9 @@
     case Promote: {
       SDOperand Op(Result, i++);
       if (MVT::isInteger(VT)) {
-        unsigned AssertOp = I->getType()->isSigned() ? ISD::AssertSext 
-                                                     : ISD::AssertZext;
+        unsigned AssertOp = ISD::AssertSext;
+        if (FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute))
+          AssertOp = ISD::AssertZext;
         Op = DAG.getNode(AssertOp, Op.getValueType(), Op, DAG.getValueType(VT));
         Op = DAG.getNode(ISD::TRUNCATE, VT, Op);
       } else {
@@ -3035,7 +3038,8 @@
 /// lowered by the target to something concrete.  FIXME: When all targets are
 /// migrated to using ISD::CALL, this hook should be integrated into SDISel.
 std::pair<SDOperand, SDOperand>
-TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, bool isVarArg,
+TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, 
+                            bool RetTyIsSigned, bool isVarArg,
                             unsigned CallingConv, bool isTailCall, 
                             SDOperand Callee,
                             ArgListTy &Args, SelectionDAG &DAG) {
@@ -3048,9 +3052,9 @@
   
   // Handle all of the outgoing arguments.
   for (unsigned i = 0, e = Args.size(); i != e; ++i) {
-    MVT::ValueType VT = getValueType(Args[i].second);
-    SDOperand Op = Args[i].first;
-    bool isSigned = Args[i].second->isSigned();
+    MVT::ValueType VT = getValueType(Args[i].Ty);
+    SDOperand Op = Args[i].Node;
+    bool isSigned = Args[i].isSigned;
     switch (getTypeAction(VT)) {
     default: assert(0 && "Unknown type action!");
     case Legal: 
@@ -3077,7 +3081,7 @@
       } else {
         // Otherwise, this is a vector type.  We only support legal vectors
         // right now.
-        const PackedType *PTy = cast<PackedType>(Args[i].second);
+        const PackedType *PTy = cast<PackedType>(Args[i].Ty);
         unsigned NumElems = PTy->getNumElements();
         const Type *EltTy = PTy->getElementType();
         
@@ -3177,8 +3181,9 @@
             abort();
           }
         } else if (MVT::isInteger(VT)) {
-          unsigned AssertOp = RetTy->isSigned() ?
-                                  ISD::AssertSext : ISD::AssertZext;
+          unsigned AssertOp = ISD::AssertSext;
+          if (!RetTyIsSigned)
+            AssertOp = ISD::AssertZext;
           ResVal = DAG.getNode(AssertOp, ResVal.getValueType(), ResVal, 
                                DAG.getValueType(VT));
           ResVal = DAG.getNode(ISD::TRUNCATE, VT, ResVal);
@@ -3673,10 +3678,7 @@
       // Handle constant subscripts.
       if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx)) {
         if (CI->getZExtValue() == 0) continue;
-        if (CI->getType()->isSigned())
-          ConstantOffset += (int64_t)TD->getTypeSize(Ty)*CI->getSExtValue();
-        else
-          ConstantOffset += TD->getTypeSize(Ty)*CI->getZExtValue();
+        ConstantOffset += (int64_t)TD->getTypeSize(Ty)*CI->getSExtValue();
         continue;
       }
       






More information about the llvm-commits mailing list