Factor the addressing mode and the load/store VT out of LoadSDNode
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SelectionDAGISel.cpp
index e1b5ed175c76da882c8d6a3fe0631f015f3ea41c..406011ac9165d51be5f021b3a6cd0d039938016c 100644 (file)
@@ -57,7 +57,7 @@ ViewSchedDAGs("view-sched-dags", cl::Hidden,
           cl::desc("Pop up a window to show sched dags as they are processed"));
 static cl::opt<bool>
 ViewSUnitDAGs("view-sunit-dags", cl::Hidden,
-          cl::desc("Pop up a window to show SUnit dags after they are processed"));
+      cl::desc("Pop up a window to show SUnit dags after they are processed"));
 #else
 static const bool ViewISelDAGs = 0, ViewSchedDAGs = 0, ViewSUnitDAGs = 0;
 #endif
@@ -79,7 +79,8 @@ namespace {
           RegisterPassParser<RegisterScheduler> >
   ISHeuristic("pre-RA-sched",
               cl::init(&createDefaultScheduler),
-              cl::desc("Instruction schedulers available (before register allocation):"));
+              cl::desc("Instruction schedulers available (before register"
+                       " allocation):"));
 
   static RegisterScheduler
   defaultListDAGScheduler("default", "  Best scheduler for the target",
@@ -3249,27 +3250,41 @@ void AsmOperandInfo::ComputeConstraintToUse(const TargetLowering &TLI) {
   if (Codes.size() == 1) {   // Single-letter constraints ('r') are very common.
     ConstraintCode = *Current;
     ConstraintType = CurType;
-    return;
+  } else {
+    unsigned CurGenerality = getConstraintGenerality(CurType);
+
+    // If we have multiple constraints, try to pick the most general one ahead
+    // of time.  This isn't a wonderful solution, but handles common cases.
+    for (unsigned j = 1, e = Codes.size(); j != e; ++j) {
+      TargetLowering::ConstraintType ThisType = TLI.getConstraintType(Codes[j]);
+      unsigned ThisGenerality = getConstraintGenerality(ThisType);
+      if (ThisGenerality > CurGenerality) {
+        // This constraint letter is more general than the previous one,
+        // use it.
+        CurType = ThisType;
+        Current = &Codes[j];
+        CurGenerality = ThisGenerality;
+      }
+    }
+
+    ConstraintCode = *Current;
+    ConstraintType = CurType;
   }
-  
-  unsigned CurGenerality = getConstraintGenerality(CurType);
-  
-  // If we have multiple constraints, try to pick the most general one ahead
-  // of time.  This isn't a wonderful solution, but handles common cases.
-  for (unsigned j = 1, e = Codes.size(); j != e; ++j) {
-    TargetLowering::ConstraintType ThisType = TLI.getConstraintType(Codes[j]);
-    unsigned ThisGenerality = getConstraintGenerality(ThisType);
-    if (ThisGenerality > CurGenerality) {
-      // This constraint letter is more general than the previous one,
-      // use it.
-      CurType = ThisType;
-      Current = &Codes[j];
-      CurGenerality = ThisGenerality;
+
+  if (ConstraintCode == "X") {
+    if (isa<BasicBlock>(CallOperandVal) || isa<ConstantInt>(CallOperandVal))
+      return;
+    // This matches anything.  Labels and constants we handle elsewhere 
+    // ('X' is the only thing that matches labels).  Otherwise, try to 
+    // resolve it to something we know about by looking at the actual 
+    // operand type.
+    std::string s = "";
+    TLI.lowerXConstraint(ConstraintVT, s);
+    if (s!="") {
+      ConstraintCode = s;
+      ConstraintType = TLI.getConstraintType(ConstraintCode);
     }
   }
-  
-  ConstraintCode = *Current;
-  ConstraintType = CurType;
 }
 
 
@@ -3491,7 +3506,8 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
     if (OpInfo.CallOperandVal) {
       if (isa<BasicBlock>(OpInfo.CallOperandVal))
         OpInfo.CallOperand = 
-          DAG.getBasicBlock(FuncInfo.MBBMap[cast<BasicBlock>(OpInfo.CallOperandVal)]);
+          DAG.getBasicBlock(FuncInfo.MBBMap[cast<BasicBlock>(
+                                                 OpInfo.CallOperandVal)]);
       else {
         OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
         const Type *OpTy = OpInfo.CallOperandVal->getType();
@@ -3917,8 +3933,7 @@ TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) {
       Flags |= ISD::ParamFlags::ByVal;
       const PointerType *Ty = cast<PointerType>(I->getType());
       const Type *ElementTy = Ty->getElementType();
-      unsigned FrameAlign =
-          Log2_32(getTargetData()->getCallFrameTypeAlignment(ElementTy));
+      unsigned FrameAlign = Log2_32(getByValTypeAlignment(ElementTy));
       unsigned FrameSize  = getTargetData()->getABITypeSize(ElementTy);
       Flags |= (FrameAlign << ISD::ParamFlags::ByValAlignOffs);
       Flags |= (FrameSize  << ISD::ParamFlags::ByValSizeOffs);
@@ -4047,8 +4062,7 @@ TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy,
       Flags |= ISD::ParamFlags::ByVal;
       const PointerType *Ty = cast<PointerType>(Args[i].Ty);
       const Type *ElementTy = Ty->getElementType();
-      unsigned FrameAlign =
-          Log2_32(getTargetData()->getCallFrameTypeAlignment(ElementTy));
+      unsigned FrameAlign = Log2_32(getByValTypeAlignment(ElementTy));
       unsigned FrameSize  = getTargetData()->getABITypeSize(ElementTy);
       Flags |= (FrameAlign << ISD::ParamFlags::ByValAlignOffs);
       Flags |= (FrameSize  << ISD::ParamFlags::ByValSizeOffs);