From 64486737d59c835725c61c96511beeff7e31f403 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sat, 20 Oct 2012 22:44:13 +0000 Subject: [PATCH] Allow the commuted form of tied-operand constraints in tablegen ("$dst = $src", 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 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp index 99d2f173a87..fd38672bfcf 100644 --- a/utils/TableGen/CodeGenInstruction.cpp +++ b/utils/TableGen/CodeGenInstruction.cpp @@ -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 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 SrcOp = Ops.ParseOperandName(SrcOpName, false); + if (SrcOp > DestOp) { + std::swap(SrcOp, DestOp); + std::swap(SrcOpName, DestOpName); + } unsigned FlatOpNo = Ops.getFlattenedOperandNumber(SrcOp);