OSDN Git Service

Upgrade the llvm.isunordered intrinsics to "fcmp uno" instruction.
authorReid Spencer <rspencer@reidspencer.com>
Sun, 7 Jan 2007 08:07:10 +0000 (08:07 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 7 Jan 2007 08:07:10 +0000 (08:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32986 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-upgrade/UpgradeParser.y

index 0544d40..f6338e7 100644 (file)
@@ -1872,21 +1872,31 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
     delete $2.val;
   }
   | OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')'  {
-    if (!$2->empty())
-      *$1 += " " + *$2;
-    if (!$1->empty())
-      *$1 += " ";
-    *$1 += $3->getNewTy() + " " + *$4.val + "(";
-    for (unsigned i = 0; i < $6->size(); ++i) {
-      ValueInfo& VI = (*$6)[i];
-      *$1 += *VI.val;
-      if (i+1 < $6->size())
-        *$1 += ", ";
-      VI.destroy();
+    // map llvm.isunordered to "fcmp uno" 
+    if (*$4.val == "%llvm.isunordered.f32" ||
+        *$4.val == "%llvm.isunordered.f64") {
+      $$.val = new std::string( "fcmp uno " + *(*$6)[0].val + ", ");
+      size_t pos = (*$6)[1].val->find(' ');
+      assert(pos != std::string::npos && "no space?");
+      *$$.val += (*$6)[1].val->substr(pos+1);
+      $$.type = TypeInfo::get("bool", BoolTy);
+    } else {
+      if (!$2->empty())
+        *$1 += " " + *$2;
+      if (!$1->empty())
+        *$1 += " ";
+      *$1 += $3->getNewTy() + " " + *$4.val + "(";
+      for (unsigned i = 0; i < $6->size(); ++i) {
+        ValueInfo& VI = (*$6)[i];
+        *$1 += *VI.val;
+        if (i+1 < $6->size())
+          *$1 += ", ";
+        VI.destroy();
+      }
+      *$1 += ")";
+      $$.val = $1;
+      $$.type = getFunctionReturnType($3);
     }
-    *$1 += ")";
-    $$.val = $1;
-    $$.type = getFunctionReturnType($3);
     delete $2; $4.destroy(); delete $6;
   }
   | MemoryInst ;