mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 21:29:41 +00:00
Rename a class. These files are being migrated to the new isel and I want to
reuse the names git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eeff9b055c
commit
6b5d9cdfcf
@ -33,12 +33,12 @@ NodeType::ArgResultTypes NodeType::Translate(Record *R) {
|
|||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// TreePatternNode implementation
|
// TreePatternNodeX implementation
|
||||||
//
|
//
|
||||||
|
|
||||||
/// getValueRecord - Returns the value of this tree node as a record. For now
|
/// getValueRecord - Returns the value of this tree node as a record. For now
|
||||||
/// we only allow DefInit's as our leaf values, so this is used.
|
/// we only allow DefInit's as our leaf values, so this is used.
|
||||||
Record *TreePatternNode::getValueRecord() const {
|
Record *TreePatternNodeX::getValueRecord() const {
|
||||||
DefInit *DI = dynamic_cast<DefInit*>(getValue());
|
DefInit *DI = dynamic_cast<DefInit*>(getValue());
|
||||||
assert(DI && "Instruction Selector does not yet support non-def leaves!");
|
assert(DI && "Instruction Selector does not yet support non-def leaves!");
|
||||||
return DI->getDef();
|
return DI->getDef();
|
||||||
@ -48,7 +48,7 @@ Record *TreePatternNode::getValueRecord() const {
|
|||||||
// updateNodeType - Set the node type of N to VT if VT contains information. If
|
// updateNodeType - Set the node type of N to VT if VT contains information. If
|
||||||
// N already contains a conflicting type, then throw an exception
|
// N already contains a conflicting type, then throw an exception
|
||||||
//
|
//
|
||||||
bool TreePatternNode::updateNodeType(MVT::ValueType VT,
|
bool TreePatternNodeX::updateNodeType(MVT::ValueType VT,
|
||||||
const std::string &RecName) {
|
const std::string &RecName) {
|
||||||
if (VT == MVT::Other || getType() == VT) return false;
|
if (VT == MVT::Other || getType() == VT) return false;
|
||||||
if (getType() == MVT::Other) {
|
if (getType() == MVT::Other) {
|
||||||
@ -63,7 +63,7 @@ bool TreePatternNode::updateNodeType(MVT::ValueType VT,
|
|||||||
/// are not themselves completely resolved, clone the nonterminal and resolve it
|
/// are not themselves completely resolved, clone the nonterminal and resolve it
|
||||||
/// with the using context we provide.
|
/// with the using context we provide.
|
||||||
///
|
///
|
||||||
void TreePatternNode::InstantiateNonterminals(InstrSelectorEmitter &ISE) {
|
void TreePatternNodeX::InstantiateNonterminals(InstrSelectorEmitter &ISE) {
|
||||||
if (!isLeaf()) {
|
if (!isLeaf()) {
|
||||||
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
||||||
getChild(i)->InstantiateNonterminals(ISE);
|
getChild(i)->InstantiateNonterminals(ISE);
|
||||||
@ -87,22 +87,22 @@ void TreePatternNode::InstantiateNonterminals(InstrSelectorEmitter &ISE) {
|
|||||||
|
|
||||||
/// clone - Make a copy of this tree and all of its children.
|
/// clone - Make a copy of this tree and all of its children.
|
||||||
///
|
///
|
||||||
TreePatternNode *TreePatternNode::clone() const {
|
TreePatternNodeX *TreePatternNodeX::clone() const {
|
||||||
TreePatternNode *New;
|
TreePatternNodeX *New;
|
||||||
if (isLeaf()) {
|
if (isLeaf()) {
|
||||||
New = new TreePatternNode(Value);
|
New = new TreePatternNodeX(Value);
|
||||||
} else {
|
} else {
|
||||||
std::vector<std::pair<TreePatternNode*, std::string> > CChildren;
|
std::vector<std::pair<TreePatternNodeX*, std::string> > CChildren;
|
||||||
CChildren.reserve(Children.size());
|
CChildren.reserve(Children.size());
|
||||||
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
||||||
CChildren.push_back(std::make_pair(getChild(i)->clone(),getChildName(i)));
|
CChildren.push_back(std::make_pair(getChild(i)->clone(),getChildName(i)));
|
||||||
New = new TreePatternNode(Operator, CChildren);
|
New = new TreePatternNodeX(Operator, CChildren);
|
||||||
}
|
}
|
||||||
New->setType(Type);
|
New->setType(Type);
|
||||||
return New;
|
return New;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &llvm::operator<<(std::ostream &OS, const TreePatternNode &N) {
|
std::ostream &llvm::operator<<(std::ostream &OS, const TreePatternNodeX &N) {
|
||||||
if (N.isLeaf())
|
if (N.isLeaf())
|
||||||
return OS << N.getType() << ":" << *N.getValue();
|
return OS << N.getType() << ":" << *N.getValue();
|
||||||
OS << "(" << N.getType() << ":";
|
OS << "(" << N.getType() << ":";
|
||||||
@ -116,7 +116,7 @@ std::ostream &llvm::operator<<(std::ostream &OS, const TreePatternNode &N) {
|
|||||||
return OS << ")";
|
return OS << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreePatternNode::dump() const { std::cerr << *this; }
|
void TreePatternNodeX::dump() const { std::cerr << *this; }
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Pattern implementation
|
// Pattern implementation
|
||||||
@ -168,7 +168,7 @@ void Pattern::error(const std::string &Msg) const {
|
|||||||
/// calculateArgs - Compute the list of all of the arguments to this pattern,
|
/// calculateArgs - Compute the list of all of the arguments to this pattern,
|
||||||
/// which are the non-void leaf nodes in this pattern.
|
/// which are the non-void leaf nodes in this pattern.
|
||||||
///
|
///
|
||||||
void Pattern::calculateArgs(TreePatternNode *N, const std::string &Name) {
|
void Pattern::calculateArgs(TreePatternNodeX *N, const std::string &Name) {
|
||||||
if (N->isLeaf() || N->getNumChildren() == 0) {
|
if (N->isLeaf() || N->getNumChildren() == 0) {
|
||||||
if (N->getType() != MVT::isVoid)
|
if (N->getType() != MVT::isVoid)
|
||||||
Args.push_back(std::make_pair(N, Name));
|
Args.push_back(std::make_pair(N, Name));
|
||||||
@ -197,7 +197,7 @@ MVT::ValueType Pattern::getIntrinsicType(Record *R) const {
|
|||||||
return MVT::Other;
|
return MVT::Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
|
TreePatternNodeX *Pattern::ParseTreePattern(DagInit *Dag) {
|
||||||
Record *Operator = Dag->getNodeType();
|
Record *Operator = Dag->getNodeType();
|
||||||
|
|
||||||
if (Operator->isSubClassOf("ValueType")) {
|
if (Operator->isSubClassOf("ValueType")) {
|
||||||
@ -207,9 +207,9 @@ TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
|
|||||||
error("Type cast only valid for a leaf node!");
|
error("Type cast only valid for a leaf node!");
|
||||||
|
|
||||||
Init *Arg = Dag->getArg(0);
|
Init *Arg = Dag->getArg(0);
|
||||||
TreePatternNode *New;
|
TreePatternNodeX *New;
|
||||||
if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
|
if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
|
||||||
New = new TreePatternNode(DI);
|
New = new TreePatternNodeX(DI);
|
||||||
// If it's a regclass or something else known, set the type.
|
// If it's a regclass or something else known, set the type.
|
||||||
New->setType(getIntrinsicType(DI->getDef()));
|
New->setType(getIntrinsicType(DI->getDef()));
|
||||||
} else if (DagInit *DI = dynamic_cast<DagInit*>(Arg)) {
|
} else if (DagInit *DI = dynamic_cast<DagInit*>(Arg)) {
|
||||||
@ -228,7 +228,7 @@ TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
|
|||||||
if (!ISE.getNodeTypes().count(Operator))
|
if (!ISE.getNodeTypes().count(Operator))
|
||||||
error("Unrecognized node '" + Operator->getName() + "'!");
|
error("Unrecognized node '" + Operator->getName() + "'!");
|
||||||
|
|
||||||
std::vector<std::pair<TreePatternNode*, std::string> > Children;
|
std::vector<std::pair<TreePatternNodeX*, std::string> > Children;
|
||||||
|
|
||||||
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
|
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
|
||||||
Init *Arg = Dag->getArg(i);
|
Init *Arg = Dag->getArg(i);
|
||||||
@ -243,7 +243,7 @@ TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
|
|||||||
std::vector<std::pair<Init*, std::string> >()));
|
std::vector<std::pair<Init*, std::string> >()));
|
||||||
--i; // Revisit this node...
|
--i; // Revisit this node...
|
||||||
} else {
|
} else {
|
||||||
Children.push_back(std::make_pair(new TreePatternNode(DefI),
|
Children.push_back(std::make_pair(new TreePatternNodeX(DefI),
|
||||||
Dag->getArgName(i)));
|
Dag->getArgName(i)));
|
||||||
// If it's a regclass or something else known, set the type.
|
// If it's a regclass or something else known, set the type.
|
||||||
Children.back().first->setType(getIntrinsicType(R));
|
Children.back().first->setType(getIntrinsicType(R));
|
||||||
@ -254,7 +254,7 @@ TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TreePatternNode(Operator, Children);
|
return new TreePatternNodeX(Operator, Children);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pattern::InferAllTypes() {
|
void Pattern::InferAllTypes() {
|
||||||
@ -270,7 +270,7 @@ void Pattern::InferAllTypes() {
|
|||||||
// InferTypes - Perform type inference on the tree, returning true if there
|
// InferTypes - Perform type inference on the tree, returning true if there
|
||||||
// are any remaining untyped nodes and setting MadeChange if any changes were
|
// are any remaining untyped nodes and setting MadeChange if any changes were
|
||||||
// made.
|
// made.
|
||||||
bool Pattern::InferTypes(TreePatternNode *N, bool &MadeChange) {
|
bool Pattern::InferTypes(TreePatternNodeX *N, bool &MadeChange) {
|
||||||
if (N->isLeaf()) return N->getType() == MVT::Other;
|
if (N->isLeaf()) return N->getType() == MVT::Other;
|
||||||
|
|
||||||
bool AnyUnset = false;
|
bool AnyUnset = false;
|
||||||
@ -283,7 +283,7 @@ bool Pattern::InferTypes(TreePatternNode *N, bool &MadeChange) {
|
|||||||
error("Incorrect number of children for " + Operator->getName() + " node!");
|
error("Incorrect number of children for " + Operator->getName() + " node!");
|
||||||
|
|
||||||
for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) {
|
for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) {
|
||||||
TreePatternNode *Child = N->getChild(i);
|
TreePatternNodeX *Child = N->getChild(i);
|
||||||
AnyUnset |= InferTypes(Child, MadeChange);
|
AnyUnset |= InferTypes(Child, MadeChange);
|
||||||
|
|
||||||
switch (NT.ArgTypes[i]) {
|
switch (NT.ArgTypes[i]) {
|
||||||
@ -598,21 +598,21 @@ void InstrSelectorEmitter::CalculateComputableValues() {
|
|||||||
// MoveIdenticalPatterns - Given a tree pattern 'P', move all of the tree
|
// MoveIdenticalPatterns - Given a tree pattern 'P', move all of the tree
|
||||||
// patterns which have the same top-level structure as P from the 'From' list to
|
// patterns which have the same top-level structure as P from the 'From' list to
|
||||||
// the 'To' list.
|
// the 'To' list.
|
||||||
static void MoveIdenticalPatterns(TreePatternNode *P,
|
static void MoveIdenticalPatterns(TreePatternNodeX *P,
|
||||||
std::vector<std::pair<Pattern*, TreePatternNode*> > &From,
|
std::vector<std::pair<Pattern*, TreePatternNodeX*> > &From,
|
||||||
std::vector<std::pair<Pattern*, TreePatternNode*> > &To) {
|
std::vector<std::pair<Pattern*, TreePatternNodeX*> > &To) {
|
||||||
assert(!P->isLeaf() && "All leaves are identical!");
|
assert(!P->isLeaf() && "All leaves are identical!");
|
||||||
|
|
||||||
const std::vector<TreePatternNode*> &PChildren = P->getChildren();
|
const std::vector<TreePatternNodeX*> &PChildren = P->getChildren();
|
||||||
for (unsigned i = 0; i != From.size(); ++i) {
|
for (unsigned i = 0; i != From.size(); ++i) {
|
||||||
TreePatternNode *N = From[i].second;
|
TreePatternNodeX *N = From[i].second;
|
||||||
assert(P->getOperator() == N->getOperator() &&"Differing operators?");
|
assert(P->getOperator() == N->getOperator() &&"Differing operators?");
|
||||||
assert(PChildren.size() == N->getChildren().size() &&
|
assert(PChildren.size() == N->getChildren().size() &&
|
||||||
"Nodes with different arity??");
|
"Nodes with different arity??");
|
||||||
bool isDifferent = false;
|
bool isDifferent = false;
|
||||||
for (unsigned c = 0, e = PChildren.size(); c != e; ++c) {
|
for (unsigned c = 0, e = PChildren.size(); c != e; ++c) {
|
||||||
TreePatternNode *PC = PChildren[c];
|
TreePatternNodeX *PC = PChildren[c];
|
||||||
TreePatternNode *NC = N->getChild(c);
|
TreePatternNodeX *NC = N->getChild(c);
|
||||||
if (PC->isLeaf() != NC->isLeaf()) {
|
if (PC->isLeaf() != NC->isLeaf()) {
|
||||||
isDifferent = true;
|
isDifferent = true;
|
||||||
break;
|
break;
|
||||||
@ -650,7 +650,7 @@ static std::string getNodeName(Record *R) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void EmitPatternPredicates(TreePatternNode *Tree,
|
static void EmitPatternPredicates(TreePatternNodeX *Tree,
|
||||||
const std::string &VarName, std::ostream &OS){
|
const std::string &VarName, std::ostream &OS){
|
||||||
OS << " && " << VarName << "->getNodeType() == ISD::"
|
OS << " && " << VarName << "->getNodeType() == ISD::"
|
||||||
<< getNodeName(Tree->getOperator());
|
<< getNodeName(Tree->getOperator());
|
||||||
@ -661,7 +661,7 @@ static void EmitPatternPredicates(TreePatternNode *Tree,
|
|||||||
VarName + "->getUse(" + utostr(c)+")", OS);
|
VarName + "->getUse(" + utostr(c)+")", OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EmitPatternCosts(TreePatternNode *Tree, const std::string &VarName,
|
static void EmitPatternCosts(TreePatternNodeX *Tree, const std::string &VarName,
|
||||||
std::ostream &OS) {
|
std::ostream &OS) {
|
||||||
for (unsigned c = 0, e = Tree->getNumChildren(); c != e; ++c)
|
for (unsigned c = 0, e = Tree->getNumChildren(); c != e; ++c)
|
||||||
if (Tree->getChild(c)->isLeaf()) {
|
if (Tree->getChild(c)->isLeaf()) {
|
||||||
@ -680,7 +680,7 @@ static void EmitPatternCosts(TreePatternNode *Tree, const std::string &VarName,
|
|||||||
// pick. This is structured this way to avoid reevaluations of non-obvious
|
// pick. This is structured this way to avoid reevaluations of non-obvious
|
||||||
// subexpressions.
|
// subexpressions.
|
||||||
void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
||||||
const std::vector<std::pair<Pattern*, TreePatternNode*> > &Patterns,
|
const std::vector<std::pair<Pattern*, TreePatternNodeX*> > &Patterns,
|
||||||
const std::string &VarPrefix,
|
const std::string &VarPrefix,
|
||||||
unsigned IndentAmt) {
|
unsigned IndentAmt) {
|
||||||
assert(!Patterns.empty() && "No patterns to emit matchers for!");
|
assert(!Patterns.empty() && "No patterns to emit matchers for!");
|
||||||
@ -697,9 +697,9 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
|||||||
OS << "\n" << Indent << "// Operand matching costs...\n";
|
OS << "\n" << Indent << "// Operand matching costs...\n";
|
||||||
std::set<std::string> ComputedValues; // Avoid duplicate computations...
|
std::set<std::string> ComputedValues; // Avoid duplicate computations...
|
||||||
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
|
||||||
TreePatternNode *NParent = Patterns[i].second;
|
TreePatternNodeX *NParent = Patterns[i].second;
|
||||||
for (unsigned c = 0, e = NParent->getNumChildren(); c != e; ++c) {
|
for (unsigned c = 0, e = NParent->getNumChildren(); c != e; ++c) {
|
||||||
TreePatternNode *N = NParent->getChild(c);
|
TreePatternNodeX *N = NParent->getChild(c);
|
||||||
if (N->isLeaf()) {
|
if (N->isLeaf()) {
|
||||||
Record *VR = N->getValueRecord();
|
Record *VR = N->getValueRecord();
|
||||||
const std::string &LeafName = VR->getName();
|
const std::string &LeafName = VR->getName();
|
||||||
@ -723,11 +723,11 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
|||||||
#if 0
|
#if 0
|
||||||
// Separate out all of the patterns into groups based on what their top-level
|
// Separate out all of the patterns into groups based on what their top-level
|
||||||
// signature looks like...
|
// signature looks like...
|
||||||
std::vector<std::pair<Pattern*, TreePatternNode*> > PatternsLeft(Patterns);
|
std::vector<std::pair<Pattern*, TreePatternNodeX*> > PatternsLeft(Patterns);
|
||||||
while (!PatternsLeft.empty()) {
|
while (!PatternsLeft.empty()) {
|
||||||
// Process all of the patterns that have the same signature as the last
|
// Process all of the patterns that have the same signature as the last
|
||||||
// element...
|
// element...
|
||||||
std::vector<std::pair<Pattern*, TreePatternNode*> > Group;
|
std::vector<std::pair<Pattern*, TreePatternNodeX*> > Group;
|
||||||
MoveIdenticalPatterns(PatternsLeft.back().second, PatternsLeft, Group);
|
MoveIdenticalPatterns(PatternsLeft.back().second, PatternsLeft, Group);
|
||||||
assert(!Group.empty() && "Didn't at least pick the source pattern?");
|
assert(!Group.empty() && "Didn't at least pick the source pattern?");
|
||||||
|
|
||||||
@ -756,13 +756,13 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
|||||||
OS << "0;\n";
|
OS << "0;\n";
|
||||||
|
|
||||||
// Loop over all of the operands, adding in their costs...
|
// Loop over all of the operands, adding in their costs...
|
||||||
TreePatternNode *N = Group[0].second;
|
TreePatternNodeX *N = Group[0].second;
|
||||||
const std::vector<TreePatternNode*> &Children = N->getChildren();
|
const std::vector<TreePatternNodeX*> &Children = N->getChildren();
|
||||||
|
|
||||||
// If necessary, emit conditionals to check for the appropriate tree
|
// If necessary, emit conditionals to check for the appropriate tree
|
||||||
// structure here...
|
// structure here...
|
||||||
for (unsigned i = 0, e = Children.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Children.size(); i != e; ++i) {
|
||||||
TreePatternNode *C = Children[i];
|
TreePatternNodeX *C = Children[i];
|
||||||
if (C->isLeaf()) {
|
if (C->isLeaf()) {
|
||||||
// We already calculated the cost for this leaf, add it in now...
|
// We already calculated the cost for this leaf, add it in now...
|
||||||
OS << Indent << " " << LocCostName << " += "
|
OS << Indent << " " << LocCostName << " += "
|
||||||
@ -774,7 +774,7 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
|||||||
OS << Indent << " if (" << VarPrefix << "_Op" << i
|
OS << Indent << " if (" << VarPrefix << "_Op" << i
|
||||||
<< "->getNodeType() == ISD::" << getNodeName(C->getOperator())
|
<< "->getNodeType() == ISD::" << getNodeName(C->getOperator())
|
||||||
<< ") {\n";
|
<< ") {\n";
|
||||||
std::vector<std::pair<Pattern*, TreePatternNode*> > SubPatterns;
|
std::vector<std::pair<Pattern*, TreePatternNodeX*> > SubPatterns;
|
||||||
for (unsigned n = 0, e = Group.size(); n != e; ++n)
|
for (unsigned n = 0, e = Group.size(); n != e; ++n)
|
||||||
SubPatterns.push_back(std::make_pair(Group[n].first,
|
SubPatterns.push_back(std::make_pair(Group[n].first,
|
||||||
Group[n].second->getChild(i)));
|
Group[n].second->getChild(i)));
|
||||||
@ -796,7 +796,7 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
|||||||
|
|
||||||
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
|
||||||
Pattern *P = Patterns[i].first;
|
Pattern *P = Patterns[i].first;
|
||||||
TreePatternNode *PTree = P->getTree();
|
TreePatternNodeX *PTree = P->getTree();
|
||||||
unsigned PatternCost = 1;
|
unsigned PatternCost = 1;
|
||||||
|
|
||||||
// Check to see if there are any non-leaf elements in the pattern. If so,
|
// Check to see if there are any non-leaf elements in the pattern. If so,
|
||||||
@ -838,8 +838,8 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReduceAllOperands(TreePatternNode *N, const std::string &Name,
|
static void ReduceAllOperands(TreePatternNodeX *N, const std::string &Name,
|
||||||
std::vector<std::pair<TreePatternNode*, std::string> > &Operands,
|
std::vector<std::pair<TreePatternNodeX*, std::string> > &Operands,
|
||||||
std::ostream &OS) {
|
std::ostream &OS) {
|
||||||
if (N->isLeaf()) {
|
if (N->isLeaf()) {
|
||||||
// If this is a leaf, register or nonterminal reference...
|
// If this is a leaf, register or nonterminal reference...
|
||||||
@ -877,7 +877,7 @@ static void ReduceAllOperands(TreePatternNode *N, const std::string &Name,
|
|||||||
/// name.
|
/// name.
|
||||||
void InstrSelectorEmitter::PrintExpanderOperand(Init *Arg,
|
void InstrSelectorEmitter::PrintExpanderOperand(Init *Arg,
|
||||||
const std::string &NameVar,
|
const std::string &NameVar,
|
||||||
TreePatternNode *ArgDeclNode,
|
TreePatternNodeX *ArgDeclNode,
|
||||||
Pattern *P, bool PrintArg,
|
Pattern *P, bool PrintArg,
|
||||||
std::ostream &OS) {
|
std::ostream &OS) {
|
||||||
if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
|
if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
|
||||||
@ -939,7 +939,7 @@ void InstrSelectorEmitter::PrintExpanderOperand(Init *Arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::string getArgName(Pattern *P, const std::string &ArgName,
|
static std::string getArgName(Pattern *P, const std::string &ArgName,
|
||||||
const std::vector<std::pair<TreePatternNode*, std::string> > &Operands) {
|
const std::vector<std::pair<TreePatternNodeX*, std::string> > &Operands) {
|
||||||
assert(P->getNumArgs() == Operands.size() &&"Argument computation mismatch!");
|
assert(P->getNumArgs() == Operands.size() &&"Argument computation mismatch!");
|
||||||
if (ArgName.empty()) return "";
|
if (ArgName.empty()) return "";
|
||||||
|
|
||||||
@ -1128,7 +1128,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
|
|||||||
<< " unsigned Pattern = NoMatchPattern;\n"
|
<< " unsigned Pattern = NoMatchPattern;\n"
|
||||||
<< " unsigned MinCost = ~0U >> 1;\n";
|
<< " unsigned MinCost = ~0U >> 1;\n";
|
||||||
|
|
||||||
std::vector<std::pair<Pattern*, TreePatternNode*> > Patterns;
|
std::vector<std::pair<Pattern*, TreePatternNodeX*> > Patterns;
|
||||||
for (unsigned i = 0, e = J->second.size(); i != e; ++i)
|
for (unsigned i = 0, e = J->second.size(); i != e; ++i)
|
||||||
Patterns.push_back(std::make_pair(J->second[i],
|
Patterns.push_back(std::make_pair(J->second[i],
|
||||||
J->second[i]->getTree()));
|
J->second[i]->getTree()));
|
||||||
@ -1170,7 +1170,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
|
|||||||
OS << " case " << P->getRecord()->getName() << "_Pattern: {\n"
|
OS << " case " << P->getRecord()->getName() << "_Pattern: {\n"
|
||||||
<< " // " << *P << "\n";
|
<< " // " << *P << "\n";
|
||||||
// Loop over the operands, reducing them...
|
// Loop over the operands, reducing them...
|
||||||
std::vector<std::pair<TreePatternNode*, std::string> > Operands;
|
std::vector<std::pair<TreePatternNodeX*, std::string> > Operands;
|
||||||
ReduceAllOperands(P->getTree(), "N", Operands, OS);
|
ReduceAllOperands(P->getTree(), "N", Operands, OS);
|
||||||
|
|
||||||
// Now that we have reduced all of our operands, and have the values
|
// Now that we have reduced all of our operands, and have the values
|
||||||
@ -1218,7 +1218,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
|
|||||||
OS << ")";
|
OS << ")";
|
||||||
|
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
|
||||||
TreePatternNode *Op = Operands[i].first;
|
TreePatternNodeX *Op = Operands[i].first;
|
||||||
if (Op->isLeaf()) {
|
if (Op->isLeaf()) {
|
||||||
Record *RV = Op->getValueRecord();
|
Record *RV = Op->getValueRecord();
|
||||||
assert(RV->isSubClassOf("RegisterClass") &&
|
assert(RV->isSubClassOf("RegisterClass") &&
|
||||||
|
@ -55,9 +55,9 @@ struct NodeType {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// TreePatternNode - Represent a node of the tree patterns.
|
/// TreePatternNodeX - Represent a node of the tree patterns.
|
||||||
///
|
///
|
||||||
class TreePatternNode {
|
class TreePatternNodeX {
|
||||||
/// Operator - The operation that this node represents... this is null if this
|
/// Operator - The operation that this node represents... this is null if this
|
||||||
/// is a leaf.
|
/// is a leaf.
|
||||||
Record *Operator;
|
Record *Operator;
|
||||||
@ -68,16 +68,16 @@ class TreePatternNode {
|
|||||||
|
|
||||||
/// Children - If this is not a leaf (Operator != 0), this is the subtrees
|
/// Children - If this is not a leaf (Operator != 0), this is the subtrees
|
||||||
/// that we contain.
|
/// that we contain.
|
||||||
std::vector<std::pair<TreePatternNode*, std::string> > Children;
|
std::vector<std::pair<TreePatternNodeX*, std::string> > Children;
|
||||||
|
|
||||||
/// Value - If this node is a leaf, this indicates what the thing is.
|
/// Value - If this node is a leaf, this indicates what the thing is.
|
||||||
///
|
///
|
||||||
Init *Value;
|
Init *Value;
|
||||||
public:
|
public:
|
||||||
TreePatternNode(Record *o, const std::vector<std::pair<TreePatternNode*,
|
TreePatternNodeX(Record *o, const std::vector<std::pair<TreePatternNodeX*,
|
||||||
std::string> > &c)
|
std::string> > &c)
|
||||||
: Operator(o), Type(MVT::Other), Children(c), Value(0) {}
|
: Operator(o), Type(MVT::Other), Children(c), Value(0) {}
|
||||||
TreePatternNode(Init *V) : Operator(0), Type(MVT::Other), Value(V) {}
|
TreePatternNodeX(Init *V) : Operator(0), Type(MVT::Other), Value(V) {}
|
||||||
|
|
||||||
Record *getOperator() const {
|
Record *getOperator() const {
|
||||||
assert(Operator && "This is a leaf node!");
|
assert(Operator && "This is a leaf node!");
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
bool isLeaf() const { return Operator == 0; }
|
bool isLeaf() const { return Operator == 0; }
|
||||||
|
|
||||||
unsigned getNumChildren() const { return Children.size(); }
|
unsigned getNumChildren() const { return Children.size(); }
|
||||||
TreePatternNode *getChild(unsigned c) const {
|
TreePatternNodeX *getChild(unsigned c) const {
|
||||||
assert(Operator != 0 && "This is a leaf node!");
|
assert(Operator != 0 && "This is a leaf node!");
|
||||||
assert(c < Children.size() && "Child access out of range!");
|
assert(c < Children.size() && "Child access out of range!");
|
||||||
return Children[c].first;
|
return Children[c].first;
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
|
|
||||||
/// clone - Make a copy of this tree and all of its children.
|
/// clone - Make a copy of this tree and all of its children.
|
||||||
///
|
///
|
||||||
TreePatternNode *clone() const;
|
TreePatternNodeX *clone() const;
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public:
|
|||||||
bool updateNodeType(MVT::ValueType VT, const std::string &RecName);
|
bool updateNodeType(MVT::ValueType VT, const std::string &RecName);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &OS, const TreePatternNode &N);
|
std::ostream &operator<<(std::ostream &OS, const TreePatternNodeX &N);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -146,13 +146,13 @@ private:
|
|||||||
/// Tree - The tree pattern which corresponds to this pattern. Note that if
|
/// Tree - The tree pattern which corresponds to this pattern. Note that if
|
||||||
/// there was a (set) node on the outside level that it has been stripped off.
|
/// there was a (set) node on the outside level that it has been stripped off.
|
||||||
///
|
///
|
||||||
TreePatternNode *Tree;
|
TreePatternNodeX *Tree;
|
||||||
|
|
||||||
/// Result - If this is an instruction or expander pattern, this is the
|
/// Result - If this is an instruction or expander pattern, this is the
|
||||||
/// register result, specified with a (set) in the pattern.
|
/// register result, specified with a (set) in the pattern.
|
||||||
///
|
///
|
||||||
std::string ResultName; // The name of the result value...
|
std::string ResultName; // The name of the result value...
|
||||||
TreePatternNode *ResultNode; // The leaf node for the result register...
|
TreePatternNodeX *ResultNode; // The leaf node for the result register...
|
||||||
|
|
||||||
/// TheRecord - The actual TableGen record corresponding to this pattern.
|
/// TheRecord - The actual TableGen record corresponding to this pattern.
|
||||||
///
|
///
|
||||||
@ -168,7 +168,7 @@ private:
|
|||||||
|
|
||||||
/// Args - This is a list of all of the arguments to this pattern, which are
|
/// Args - This is a list of all of the arguments to this pattern, which are
|
||||||
/// the non-void leaf nodes in this pattern.
|
/// the non-void leaf nodes in this pattern.
|
||||||
std::vector<std::pair<TreePatternNode*, std::string> > Args;
|
std::vector<std::pair<TreePatternNodeX*, std::string> > Args;
|
||||||
|
|
||||||
/// ISE - the instruction selector emitter coordinating this madness.
|
/// ISE - the instruction selector emitter coordinating this madness.
|
||||||
///
|
///
|
||||||
@ -181,7 +181,7 @@ public:
|
|||||||
InstrSelectorEmitter &ise);
|
InstrSelectorEmitter &ise);
|
||||||
|
|
||||||
/// Pattern - Constructor used for cloning nonterminal patterns
|
/// Pattern - Constructor used for cloning nonterminal patterns
|
||||||
Pattern(TreePatternNode *tree, Record *rec, bool res,
|
Pattern(TreePatternNodeX *tree, Record *rec, bool res,
|
||||||
InstrSelectorEmitter &ise)
|
InstrSelectorEmitter &ise)
|
||||||
: PTy(Nonterminal), Tree(tree), ResultNode(0), TheRecord(rec),
|
: PTy(Nonterminal), Tree(tree), ResultNode(0), TheRecord(rec),
|
||||||
Resolved(res), ISE(ise) {
|
Resolved(res), ISE(ise) {
|
||||||
@ -194,13 +194,13 @@ public:
|
|||||||
|
|
||||||
/// getTree - Return the tree pattern which corresponds to this pattern.
|
/// getTree - Return the tree pattern which corresponds to this pattern.
|
||||||
///
|
///
|
||||||
TreePatternNode *getTree() const { return Tree; }
|
TreePatternNodeX *getTree() const { return Tree; }
|
||||||
|
|
||||||
Record *getResult() const {
|
Record *getResult() const {
|
||||||
return ResultNode ? ResultNode->getValueRecord() : 0;
|
return ResultNode ? ResultNode->getValueRecord() : 0;
|
||||||
}
|
}
|
||||||
const std::string &getResultName() const { return ResultName; }
|
const std::string &getResultName() const { return ResultName; }
|
||||||
TreePatternNode *getResultNode() const { return ResultNode; }
|
TreePatternNodeX *getResultNode() const { return ResultNode; }
|
||||||
|
|
||||||
/// getRecord - Return the actual TableGen record corresponding to this
|
/// getRecord - Return the actual TableGen record corresponding to this
|
||||||
/// pattern.
|
/// pattern.
|
||||||
@ -208,7 +208,7 @@ public:
|
|||||||
Record *getRecord() const { return TheRecord; }
|
Record *getRecord() const { return TheRecord; }
|
||||||
|
|
||||||
unsigned getNumArgs() const { return Args.size(); }
|
unsigned getNumArgs() const { return Args.size(); }
|
||||||
TreePatternNode *getArg(unsigned i) const {
|
TreePatternNodeX *getArg(unsigned i) const {
|
||||||
assert(i < Args.size() && "Argument reference out of range!");
|
assert(i < Args.size() && "Argument reference out of range!");
|
||||||
return Args[i].first;
|
return Args[i].first;
|
||||||
}
|
}
|
||||||
@ -253,10 +253,10 @@ public:
|
|||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void calculateArgs(TreePatternNode *N, const std::string &Name);
|
void calculateArgs(TreePatternNodeX *N, const std::string &Name);
|
||||||
MVT::ValueType getIntrinsicType(Record *R) const;
|
MVT::ValueType getIntrinsicType(Record *R) const;
|
||||||
TreePatternNode *ParseTreePattern(DagInit *DI);
|
TreePatternNodeX *ParseTreePattern(DagInit *DI);
|
||||||
bool InferTypes(TreePatternNode *N, bool &MadeChange);
|
bool InferTypes(TreePatternNodeX *N, bool &MadeChange);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &OS, const Pattern &P);
|
std::ostream &operator<<(std::ostream &OS, const Pattern &P);
|
||||||
@ -379,7 +379,7 @@ private:
|
|||||||
// pick. This is structured this way to avoid reevaluations of non-obvious
|
// pick. This is structured this way to avoid reevaluations of non-obvious
|
||||||
// subexpressions.
|
// subexpressions.
|
||||||
void EmitMatchCosters(std::ostream &OS,
|
void EmitMatchCosters(std::ostream &OS,
|
||||||
const std::vector<std::pair<Pattern*, TreePatternNode*> > &Patterns,
|
const std::vector<std::pair<Pattern*, TreePatternNodeX*> > &Patterns,
|
||||||
const std::string &VarPrefix, unsigned Indent);
|
const std::string &VarPrefix, unsigned Indent);
|
||||||
|
|
||||||
/// PrintExpanderOperand - Print out Arg as part of the instruction emission
|
/// PrintExpanderOperand - Print out Arg as part of the instruction emission
|
||||||
@ -389,7 +389,7 @@ private:
|
|||||||
/// to the BuildMI call. If it is false, we are printing the result register
|
/// to the BuildMI call. If it is false, we are printing the result register
|
||||||
/// name.
|
/// name.
|
||||||
void PrintExpanderOperand(Init *Arg, const std::string &NameVar,
|
void PrintExpanderOperand(Init *Arg, const std::string &NameVar,
|
||||||
TreePatternNode *ArgDecl, Pattern *P,
|
TreePatternNodeX *ArgDecl, Pattern *P,
|
||||||
bool PrintArg, std::ostream &OS);
|
bool PrintArg, std::ostream &OS);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user