Fixed pr20314-2.c failure, added E, F, p constraint letters.
authorJohn Thompson <John.Thompson.JTSoftware@gmail.com>
Tue, 21 Sep 2010 22:04:54 +0000 (22:04 +0000)
committerJohn Thompson <John.Thompson.JTSoftware@gmail.com>
Tue, 21 Sep 2010 22:04:54 +0000 (22:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114490 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/TargetLowering.cpp

index 7fff8ada8c1c08fc2f2cd8ee2fe89e3365a83e3d..af48739c17acc64142b485d1d22b9891894ae41e 100644 (file)
@@ -2496,7 +2496,10 @@ TargetLowering::getConstraintType(const std::string &Constraint) const {
       return C_Memory;
     case 'i':    // Simple Integer or Relocatable Constant
     case 'n':    // Simple Integer
+    case 'E':    // Floating Point Constant
+    case 'F':    // Floating Point Constant
     case 's':    // Relocatable Constant
+    case 'p':    // Address.
     case 'X':    // Allow ANY value.
     case 'I':    // Target registers.
     case 'J':
@@ -2506,6 +2509,8 @@ TargetLowering::getConstraintType(const std::string &Constraint) const {
     case 'N':
     case 'O':
     case 'P':
+    case '<':
+    case '>':
       return C_Other;
     }
   }
@@ -2664,6 +2669,7 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
   /// ConstraintOperands - Information about all of the constraints.
   std::vector<AsmOperandInfo> ConstraintOperands;
   const InlineAsm *IA = cast<InlineAsm>(CS.getCalledValue());
+  unsigned maCount = 0; // Largest number of multiple alternative constraints.
 
   // Do a prepass over the constraints, canonicalizing them, and building up the
   // ConstraintOperands list.
@@ -2677,6 +2683,10 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
     ConstraintOperands.push_back(AsmOperandInfo(ConstraintInfos[i]));
     AsmOperandInfo &OpInfo = ConstraintOperands.back();
 
+    // Update multiple alternative constraint count.
+    if (OpInfo.multipleAlternatives.size() > maCount)
+      maCount = OpInfo.multipleAlternatives.size();
+
     EVT OpVT = MVT::Other;
 
     // Compute the value type for each operand.
@@ -2711,7 +2721,6 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
 
   // If we have multiple alternative constraints, select the best alternative.
   if (ConstraintInfos.size()) {
-    unsigned maCount = ConstraintInfos[0].multipleAlternatives.size();
     if (maCount) {
       unsigned bestMAIndex = 0;
       int bestWeight = -1;
@@ -2727,8 +2736,6 @@ std::vector<TargetLowering::AsmOperandInfo> TargetLowering::ParseConstraints(
           AsmOperandInfo& OpInfo = ConstraintOperands[cIndex];
           if (OpInfo.Type == InlineAsm::isClobber)
             continue;
-          assert((OpInfo.multipleAlternatives.size() == maCount)
-            && "Constraint has inconsistent multiple alternative count.");
 
           // If this is an output operand with a matching input operand, look up the
           // matching input. If their types mismatch, e.g. one is an integer, the
@@ -2827,12 +2834,16 @@ static unsigned getConstraintGenerality(TargetLowering::ConstraintType CT) {
 /// and the current alternative constraint selected.
 int TargetLowering::getMultipleConstraintMatchWeight(
     AsmOperandInfo &info, int maIndex) const {
-  std::vector<std::string> &rCodes = info.multipleAlternatives[maIndex].Codes;
+  std::vector<std::string> *rCodes;
+  if (maIndex >= (int)info.multipleAlternatives.size())
+    rCodes = &info.Codes;
+  else
+    rCodes = &info.multipleAlternatives[maIndex].Codes;
   int BestWeight = -1;
 
   // Loop over the options, keeping track of the most general one.
-  for (unsigned i = 0, e = rCodes.size(); i != e; ++i) {
-    int weight = getSingleConstraintMatchWeight(info, rCodes[i].c_str());
+  for (unsigned i = 0, e = rCodes->size(); i != e; ++i) {
+    int weight = getSingleConstraintMatchWeight(info, (*rCodes)[i].c_str());
     if (weight > BestWeight)
       BestWeight = weight;
   }