mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 18:24:34 +00:00
Switch to a slightly more structured representation for instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23345 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -700,18 +700,19 @@ void DAGISelEmitter::ParseAndResolveInstructions() {
|
|||||||
// Now that we have operands that are sets, inspect the operands list for
|
// Now that we have operands that are sets, inspect the operands list for
|
||||||
// the instruction. This determines the order that operands are added to
|
// the instruction. This determines the order that operands are added to
|
||||||
// the machine instruction the node corresponds to.
|
// the machine instruction the node corresponds to.
|
||||||
assert(SetDestinations.size() == 1 &&
|
unsigned NumResults = SetDestinations.size();
|
||||||
|
assert(NumResults == 1 &&
|
||||||
"This code only handles a single set right now!");
|
"This code only handles a single set right now!");
|
||||||
|
|
||||||
|
unsigned NumOperands = 0;
|
||||||
|
|
||||||
DEBUG(I->dump());
|
DEBUG(I->dump());
|
||||||
Instructions.push_back(I);
|
Instructions.push_back(DAGInstruction(I, NumResults, NumOperands));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we can, convert the instructions to be a patterns that are matched!
|
// If we can, convert the instructions to be a patterns that are matched!
|
||||||
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
|
||||||
TreePattern *I = Instructions[i];
|
TreePattern *I = Instructions[i].getPattern();
|
||||||
|
|
||||||
if (I->getNumTrees() != 1) {
|
if (I->getNumTrees() != 1) {
|
||||||
std::cerr << "CANNOT HANDLE: " << I->getRecord()->getName() << " yet!";
|
std::cerr << "CANNOT HANDLE: " << I->getRecord()->getName() << " yet!";
|
||||||
@@ -780,7 +781,5 @@ void DAGISelEmitter::run(std::ostream &OS) {
|
|||||||
delete I->second;
|
delete I->second;
|
||||||
PatternFragments.clear();
|
PatternFragments.clear();
|
||||||
|
|
||||||
for (unsigned i = 0, e = Instructions.size(); i != e; ++i)
|
|
||||||
delete Instructions[i];
|
|
||||||
Instructions.clear();
|
Instructions.clear();
|
||||||
}
|
}
|
||||||
|
@@ -272,7 +272,24 @@ namespace llvm {
|
|||||||
MVT::ValueType getIntrinsicType(Record *R) const;
|
MVT::ValueType getIntrinsicType(Record *R) const;
|
||||||
TreePatternNode *ParseTreePattern(DagInit *DI);
|
TreePatternNode *ParseTreePattern(DagInit *DI);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DAGInstruction {
|
||||||
|
TreePattern *Pattern;
|
||||||
|
unsigned NumResults;
|
||||||
|
unsigned NumOperands;
|
||||||
|
public:
|
||||||
|
DAGInstruction(TreePattern *TP, unsigned results, unsigned ops)
|
||||||
|
: Pattern(TP), NumResults(results), NumOperands(ops) {}
|
||||||
|
|
||||||
|
~DAGInstruction() {
|
||||||
|
delete Pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
TreePattern *getPattern() const { return Pattern; }
|
||||||
|
unsigned getNumResults() const { return NumResults; }
|
||||||
|
unsigned getNumOperands() const { return NumOperands; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// InstrSelectorEmitter - The top-level class which coordinates construction
|
/// InstrSelectorEmitter - The top-level class which coordinates construction
|
||||||
@@ -285,7 +302,7 @@ class DAGISelEmitter : public TableGenBackend {
|
|||||||
std::map<Record*, SDNodeInfo> SDNodes;
|
std::map<Record*, SDNodeInfo> SDNodes;
|
||||||
std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms;
|
std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms;
|
||||||
std::map<Record*, TreePattern*> PatternFragments;
|
std::map<Record*, TreePattern*> PatternFragments;
|
||||||
std::vector<TreePattern*> Instructions;
|
std::vector<DAGInstruction> Instructions;
|
||||||
|
|
||||||
/// PatternsToMatch - All of the things we are matching on the DAG. The first
|
/// PatternsToMatch - All of the things we are matching on the DAG. The first
|
||||||
/// value is the pattern to match, the second pattern is the result to
|
/// value is the pattern to match, the second pattern is the result to
|
||||||
|
Reference in New Issue
Block a user