diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-07 20:42:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-07 20:42:23 +0000 |
commit | ee858d2a8357e6773553fa11f3502f72a0372f06 (patch) | |
tree | 329c63457171488882242f9875841db86fb6d9dc /support | |
parent | 90825b4b4b6f98e6723423ac1a26f5174202782f (diff) | |
download | external_llvm-ee858d2a8357e6773553fa11f3502f72a0372f06.zip external_llvm-ee858d2a8357e6773553fa11f3502f72a0372f06.tar.gz external_llvm-ee858d2a8357e6773553fa11f3502f72a0372f06.tar.bz2 |
Rename all of the "Process" methods to be "read" methods, start the Instantiate method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support')
-rw-r--r-- | support/tools/TableGen/InstrSelectorEmitter.cpp | 66 | ||||
-rw-r--r-- | support/tools/TableGen/InstrSelectorEmitter.h | 25 |
2 files changed, 49 insertions, 42 deletions
diff --git a/support/tools/TableGen/InstrSelectorEmitter.cpp b/support/tools/TableGen/InstrSelectorEmitter.cpp index b33888a..d7d91f0 100644 --- a/support/tools/TableGen/InstrSelectorEmitter.cpp +++ b/support/tools/TableGen/InstrSelectorEmitter.cpp @@ -261,11 +261,10 @@ std::ostream &operator<<(std::ostream &OS, const Pattern &P) { // InstrSelectorEmitter implementation // -/// ProcessNodeTypes - Process all of the node types in the current -/// RecordKeeper, turning them into the more accessible NodeTypes data -/// structure. +/// ReadNodeTypes - Read in all of the node types in the current RecordKeeper, +/// turning them into the more accessible NodeTypes data structure. /// -void InstrSelectorEmitter::ProcessNodeTypes() { +void InstrSelectorEmitter::ReadNodeTypes() { std::vector<Record*> Nodes = Records.getAllDerivedDefinitions("DagNode"); DEBUG(std::cerr << "Getting node types: "); for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { @@ -301,61 +300,66 @@ void InstrSelectorEmitter::ProcessNodeTypes() { DEBUG(std::cerr << "DONE!\n"); } -// ProcessNonTerminals - Read in all nonterminals and incorporate them into -// our pattern database. -void InstrSelectorEmitter::ProcessNonterminals() { +// ReadNonTerminals - Read in all nonterminals and incorporate them into our +// pattern database. +void InstrSelectorEmitter::ReadNonterminals() { std::vector<Record*> NTs = Records.getAllDerivedDefinitions("Nonterminal"); for (unsigned i = 0, e = NTs.size(); i != e; ++i) { DagInit *DI = NTs[i]->getValueAsDag("Pattern"); - Pattern *P = new Pattern(Pattern::Nonterminal, DI, NTs[i], *this); - - - DEBUG(std::cerr << "Parsed " << *P << "\n"); + Patterns[NTs[i]] = new Pattern(Pattern::Nonterminal, DI, NTs[i], *this); + DEBUG(std::cerr << "Parsed " << *Patterns[NTs[i]] << "\n"); } } -/// ProcessInstructionPatterns - Read in all subclasses of Instruction, and -/// process those with a useful Pattern field. +/// ReadInstructionPatterns - Read in all subclasses of Instruction, and process +/// those with a useful Pattern field. /// -void InstrSelectorEmitter::ProcessInstructionPatterns() { +void InstrSelectorEmitter::ReadInstructionPatterns() { std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction"); for (unsigned i = 0, e = Insts.size(); i != e; ++i) { Record *Inst = Insts[i]; if (DagInit *DI = dynamic_cast<DagInit*>(Inst->getValueInit("Pattern"))) { - Pattern *P = new Pattern(Pattern::Instruction, DI, Inst, *this); - - DEBUG(std::cerr << "Parsed " << *P << "\n"); + Patterns[Inst] = new Pattern(Pattern::Instruction, DI, Inst, *this); + DEBUG(std::cerr << "Parsed " << *Patterns[Inst] << "\n"); } } } -/// ProcessExpanderPatterns - Read in all expander patterns... +/// ReadExpanderPatterns - Read in all expander patterns... /// -void InstrSelectorEmitter::ProcessExpanderPatterns() { +void InstrSelectorEmitter::ReadExpanderPatterns() { std::vector<Record*> Expanders = Records.getAllDerivedDefinitions("Expander"); for (unsigned i = 0, e = Expanders.size(); i != e; ++i) { Record *Expander = Expanders[i]; - DagInit *DI = Expanders[i]->getValueAsDag("Pattern"); + DagInit *DI = Expander->getValueAsDag("Pattern"); + Patterns[Expander] = new Pattern(Pattern::Expander, DI, Expander, *this); + DEBUG(std::cerr << "Parsed " << *Patterns[Expander] << "\n"); + } +} + - Pattern *P = new Pattern(Pattern::Expander, DI, Expanders[i], *this); +// InstantiateNonterminals - Instantiate any unresolved nonterminals with +// information from the context that they are used in. +void InstrSelectorEmitter::InstantiateNonterminals() { + for (std::map<Record*, Pattern*>::iterator I = Patterns.begin(), + E = Patterns.end(); I != E; ++I) { - DEBUG(std::cerr << "Parsed " << *P << "\n"); } } void InstrSelectorEmitter::run(std::ostream &OS) { // Type-check all of the node types to ensure we "understand" them. - ProcessNodeTypes(); + ReadNodeTypes(); - // Read in all of the nonterminals... - ProcessNonterminals(); - - // Read all of the instruction patterns in... - ProcessInstructionPatterns(); - - // Read all of the Expander patterns in... - ProcessExpanderPatterns(); + // Read in all of the nonterminals, instructions, and expanders... + ReadNonterminals(); + ReadInstructionPatterns(); + ReadExpanderPatterns(); + + // Instantiate any unresolved nonterminals with information from the context + // that they are used in. + InstantiateNonterminals(); } diff --git a/support/tools/TableGen/InstrSelectorEmitter.h b/support/tools/TableGen/InstrSelectorEmitter.h index a9d7028..8a8734b 100644 --- a/support/tools/TableGen/InstrSelectorEmitter.h +++ b/support/tools/TableGen/InstrSelectorEmitter.h @@ -194,21 +194,24 @@ public: std::map<Record*, NodeType> &getNodeTypes() { return NodeTypes; } private: - // ProcessNodeTypes - Process all of the node types in the current - // RecordKeeper, turning them into the more accessible NodeTypes data - // structure. - void ProcessNodeTypes(); + // ReadNodeTypes - Read in all of the node types in the current RecordKeeper, + // turning them into the more accessible NodeTypes data structure. + void ReadNodeTypes(); - // ProcessNonTerminals - Read in all nonterminals and incorporate them into - // our pattern database. - void ProcessNonterminals(); + // ReadNonTerminals - Read in all nonterminals and incorporate them into our + // pattern database. + void ReadNonterminals(); - // ProcessInstructionPatterns - Read in all subclasses of Instruction, and + // ReadInstructionPatterns - Read in all subclasses of Instruction, and // process those with a useful Pattern field. - void ProcessInstructionPatterns(); + void ReadInstructionPatterns(); - // ProcessExpanderPatterns - Read in all of the expanded patterns. - void ProcessExpanderPatterns(); + // ReadExpanderPatterns - Read in all of the expanded patterns. + void ReadExpanderPatterns(); + + // InstantiateNonterminals - Instantiate any unresolved nonterminals with + // information from the context that they are used in. + void InstantiateNonterminals(); }; #endif |