Skip to content

Commit

Permalink
Add support for naming the destination of a "set" in a pattern
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7748 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Aug 11, 2003
1 parent 88118bf commit 57fb6ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions support/tools/TableGen/InstrSelectorEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Pattern::Pattern(PatternType pty, DagInit *RawPat, Record *TheRec,
if (!Tree->getChild(0)->isLeaf())
error("Arg #0 of set should be a register or register class!");
Result = Tree->getChild(0)->getValueRecord();
ResultName = Tree->getChildName(0);
Tree = Tree->getChild(1);
}
}
Expand Down Expand Up @@ -895,6 +896,9 @@ static std::string getArgName(Pattern *P, const std::string &ArgName,
for (unsigned i = 0, e = P->getNumArgs(); i != e; ++i)
if (P->getArgName(i) == ArgName)
return Operands[i].second + "->Val";

if (ArgName == P->getResultName())
return "NewReg";
P->error("Pattern does not define a value named $" + ArgName + "!");
return "";
}
Expand Down
2 changes: 2 additions & 0 deletions support/tools/TableGen/InstrSelectorEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct Pattern {
/// register result, specified with a (set) in the pattern.
///
Record *Result;
std::string ResultName; // The name of the result value...

/// TheRecord - The actual TableGen record corresponding to this pattern.
///
Expand Down Expand Up @@ -185,6 +186,7 @@ struct Pattern {
TreePatternNode *getTree() const { return Tree; }

Record *getResult() const { return Result; }
const std::string &getResultName() const { return ResultName; }

/// getRecord - Return the actual TableGen record corresponding to this
/// pattern.
Expand Down
4 changes: 4 additions & 0 deletions utils/TableGen/InstrSelectorEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Pattern::Pattern(PatternType pty, DagInit *RawPat, Record *TheRec,
if (!Tree->getChild(0)->isLeaf())
error("Arg #0 of set should be a register or register class!");
Result = Tree->getChild(0)->getValueRecord();
ResultName = Tree->getChildName(0);
Tree = Tree->getChild(1);
}
}
Expand Down Expand Up @@ -895,6 +896,9 @@ static std::string getArgName(Pattern *P, const std::string &ArgName,
for (unsigned i = 0, e = P->getNumArgs(); i != e; ++i)
if (P->getArgName(i) == ArgName)
return Operands[i].second + "->Val";

if (ArgName == P->getResultName())
return "NewReg";
P->error("Pattern does not define a value named $" + ArgName + "!");
return "";
}
Expand Down
2 changes: 2 additions & 0 deletions utils/TableGen/InstrSelectorEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct Pattern {
/// register result, specified with a (set) in the pattern.
///
Record *Result;
std::string ResultName; // The name of the result value...

/// TheRecord - The actual TableGen record corresponding to this pattern.
///
Expand Down Expand Up @@ -185,6 +186,7 @@ struct Pattern {
TreePatternNode *getTree() const { return Tree; }

Record *getResult() const { return Result; }
const std::string &getResultName() const { return ResultName; }

/// getRecord - Return the actual TableGen record corresponding to this
/// pattern.
Expand Down

0 comments on commit 57fb6ab

Please sign in to comment.