mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-31 10:34:17 +00:00
Add support for immediates directly in the pattern, this allows itanium to
define: def : Pat<(i1 1), (CMPEQ r0, r0)>; git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
55d1728ec8
commit
0614b628cf
@ -621,6 +621,10 @@ TreePatternNode *TreePattern::ParseTreePattern(DagInit *Dag) {
|
||||
New = new TreePatternNode(DI);
|
||||
} else if (DagInit *DI = dynamic_cast<DagInit*>(Arg)) {
|
||||
New = ParseTreePattern(DI);
|
||||
} else if (IntInit *II = dynamic_cast<IntInit*>(Arg)) {
|
||||
New = new TreePatternNode(II);
|
||||
if (!Dag->getArgName(0).empty())
|
||||
error("Constant int argument should not have a name!");
|
||||
} else {
|
||||
Arg->dump();
|
||||
error("Unknown leaf value for tree pattern!");
|
||||
@ -1521,7 +1525,16 @@ void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N,
|
||||
const std::string &RootName,
|
||||
std::map<std::string,std::string> &VarMap,
|
||||
unsigned PatternNo, std::ostream &OS) {
|
||||
assert(!N->isLeaf() && "Cannot match against a leaf!");
|
||||
if (N->isLeaf()) {
|
||||
if (IntInit *II = dynamic_cast<IntInit*>(N->getLeafValue())) {
|
||||
OS << " if (cast<ConstantSDNode>(" << RootName
|
||||
<< ")->getSignExtended() != " << II->getValue() << ")\n"
|
||||
<< " goto P" << PatternNo << "Fail;\n";
|
||||
return;
|
||||
}
|
||||
assert(0 && "Cannot match this as a leaf value!");
|
||||
abort();
|
||||
}
|
||||
|
||||
// If this node has a name associated with it, capture it in VarMap. If
|
||||
// we already saw this in the pattern, emit code to verify dagness.
|
||||
@ -1762,6 +1775,12 @@ static bool InsertOneTypeCheck(TreePatternNode *Pat, TreePatternNode *Other,
|
||||
return false;
|
||||
}
|
||||
|
||||
Record *DAGISelEmitter::getSDNodeNamed(const std::string &Name) const {
|
||||
Record *N = Records.getDef(Name);
|
||||
assert(N && N->isSubClassOf("SDNode") && "Bad argument");
|
||||
return N;
|
||||
}
|
||||
|
||||
/// EmitCodeForPattern - Given a pattern to match, emit code to the specified
|
||||
/// stream to match the pattern, and generate the code for the match if it
|
||||
/// succeeds.
|
||||
@ -1897,8 +1916,17 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
|
||||
std::map<Record*, std::vector<PatternToMatch*>,
|
||||
CompareByRecordName> PatternsByOpcode;
|
||||
for (unsigned i = 0, e = PatternsToMatch.size(); i != e; ++i)
|
||||
PatternsByOpcode[PatternsToMatch[i].first->getOperator()]
|
||||
.push_back(&PatternsToMatch[i]);
|
||||
if (!PatternsToMatch[i].first->isLeaf()) {
|
||||
PatternsByOpcode[PatternsToMatch[i].first->getOperator()]
|
||||
.push_back(&PatternsToMatch[i]);
|
||||
} else {
|
||||
if (IntInit *II =
|
||||
dynamic_cast<IntInit*>(PatternsToMatch[i].first->getLeafValue())) {
|
||||
PatternsByOpcode[getSDNodeNamed("imm")].push_back(&PatternsToMatch[i]);
|
||||
} else {
|
||||
assert(0 && "Unknown leaf value");
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all of the case statements.
|
||||
for (std::map<Record*, std::vector<PatternToMatch*>,
|
||||
|
@ -382,6 +382,8 @@ public:
|
||||
|
||||
const CodeGenTarget &getTargetInfo() const { return Target; }
|
||||
|
||||
Record *getSDNodeNamed(const std::string &Name) const;
|
||||
|
||||
const SDNodeInfo &getSDNodeInfo(Record *R) const {
|
||||
assert(SDNodes.count(R) && "Unknown node!");
|
||||
return SDNodes.find(R)->second;
|
||||
|
Loading…
x
Reference in New Issue
Block a user