aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2009-12-16 19:43:02 +0000
committerJim Grosbach <grosbach@apple.com>2009-12-16 19:43:02 +0000
commit06801722a43c697eff0acee905de6b50257ce19b (patch)
treeee384449fb3ccccfca6aab7122c0aaf1355921be /utils
parent0a0124e4f60da9ee8d76ccaab3116862a20be2b0 (diff)
Add @earlyclobber TableGen constraint
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/CodeGenInstruction.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp
index e6ed709d6e..c69ce962ff 100644
--- a/utils/TableGen/CodeGenInstruction.cpp
+++ b/utils/TableGen/CodeGenInstruction.cpp
@@ -18,14 +18,35 @@
using namespace llvm;
static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) {
- // FIXME: Only supports TIED_TO for now.
+ // EARLY_CLOBBER: @early $reg
+ std::string::size_type wpos = CStr.find_first_of(" \t");
+ std::string::size_type start = CStr.find_first_not_of(" \t");
+ std::string Tok = CStr.substr(start, wpos - start);
+ if (Tok == "@earlyclobber") {
+ std::string Name = CStr.substr(wpos+1);
+ wpos = Name.find_first_not_of(" \t");
+ if (wpos == std::string::npos)
+ throw "Illegal format for @earlyclobber constraint: '" + CStr + "'";
+ Name = Name.substr(wpos);
+ std::pair<unsigned,unsigned> Op =
+ I->ParseOperandName(Name, false);
+
+ // Build the string for the operand
+ std::string OpConstraint = "(1 << TOI::EARLY_CLOBBER)";
+ if (!I->OperandList[Op.first].Constraints[Op.second].empty())
+ throw "Operand '" + Name + "' cannot have multiple constraints!";
+ I->OperandList[Op.first].Constraints[Op.second] = OpConstraint;
+ return;
+ }
+
+ // Only other constraint is "TIED_TO" for now.
std::string::size_type pos = CStr.find_first_of('=');
assert(pos != std::string::npos && "Unrecognized constraint");
- std::string::size_type start = CStr.find_first_not_of(" \t");
+ start = CStr.find_first_not_of(" \t");
std::string Name = CStr.substr(start, pos - start);
// TIED_TO: $src1 = $dst
- std::string::size_type wpos = Name.find_first_of(" \t");
+ wpos = Name.find_first_of(" \t");
if (wpos == std::string::npos)
throw "Illegal format for tied-to constraint: '" + CStr + "'";
std::string DestOpName = Name.substr(0, wpos);
@@ -47,7 +68,6 @@ static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) {
std::string OpConstraint =
"((" + utostr(FlatOpNo) + " << 16) | (1 << TOI::TIED_TO))";
-
if (!I->OperandList[DestOp.first].Constraints[DestOp.second].empty())
throw "Operand '" + DestOpName + "' cannot have multiple constraints!";
I->OperandList[DestOp.first].Constraints[DestOp.second] = OpConstraint;