Allow the commuted form of tied-operand constraints in tablegen ("$dst = $src",
authorLang Hames <lhames@gmail.com>
Sat, 20 Oct 2012 22:44:13 +0000 (22:44 +0000)
committerLang Hames <lhames@gmail.com>
Sat, 20 Oct 2012 22:44:13 +0000 (22:44 +0000)
rather than "$src = $dst").

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166382 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/CodeGenInstruction.cpp

index 99d2f173a87cbf74f94b1fef6d0f81c15487e430..fd38672bfcf5e28cb86311ce309ed3a54890b7ad 100644 (file)
@@ -233,11 +233,12 @@ static void ParseConstraint(const std::string &CStr, CGIOperandList &Ops) {
   if (wpos == std::string::npos)
     throw "Illegal format for tied-to constraint: '" + CStr + "'";
 
-  std::pair<unsigned,unsigned> SrcOp =
-  Ops.ParseOperandName(Name.substr(wpos), false);
-  if (SrcOp > DestOp)
-    throw "Illegal tied-to operand constraint '" + CStr + "'";
-
+  std::string SrcOpName = Name.substr(wpos);
+  std::pair<unsigned,unsigned> SrcOp = Ops.ParseOperandName(SrcOpName, false);
+  if (SrcOp > DestOp) {
+    std::swap(SrcOp, DestOp);
+    std::swap(SrcOpName, DestOpName);
+  }
 
   unsigned FlatOpNo = Ops.getFlattenedOperandNumber(SrcOp);