From ee858d2a8357e6773553fa11f3502f72a0372f06 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 7 Aug 2003 20:42:23 +0000 Subject: [PATCH] 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 --- .../tools/TableGen/InstrSelectorEmitter.cpp | 66 ++++++++++--------- support/tools/TableGen/InstrSelectorEmitter.h | 25 +++---- utils/TableGen/InstrSelectorEmitter.cpp | 66 ++++++++++--------- utils/TableGen/InstrSelectorEmitter.h | 25 +++---- 4 files changed, 98 insertions(+), 84 deletions(-) diff --git a/support/tools/TableGen/InstrSelectorEmitter.cpp b/support/tools/TableGen/InstrSelectorEmitter.cpp index b33888acda3..d7d91f03b95 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 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 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 Insts = Records.getAllDerivedDefinitions("Instruction"); for (unsigned i = 0, e = Insts.size(); i != e; ++i) { Record *Inst = Insts[i]; if (DagInit *DI = dynamic_cast(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 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::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 a9d7028eb02..8a8734b9349 100644 --- a/support/tools/TableGen/InstrSelectorEmitter.h +++ b/support/tools/TableGen/InstrSelectorEmitter.h @@ -194,21 +194,24 @@ public: std::map &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 diff --git a/utils/TableGen/InstrSelectorEmitter.cpp b/utils/TableGen/InstrSelectorEmitter.cpp index b33888acda3..d7d91f03b95 100644 --- a/utils/TableGen/InstrSelectorEmitter.cpp +++ b/utils/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 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 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 Insts = Records.getAllDerivedDefinitions("Instruction"); for (unsigned i = 0, e = Insts.size(); i != e; ++i) { Record *Inst = Insts[i]; if (DagInit *DI = dynamic_cast(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 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::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/utils/TableGen/InstrSelectorEmitter.h b/utils/TableGen/InstrSelectorEmitter.h index a9d7028eb02..8a8734b9349 100644 --- a/utils/TableGen/InstrSelectorEmitter.h +++ b/utils/TableGen/InstrSelectorEmitter.h @@ -194,21 +194,24 @@ public: std::map &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 -- 2.34.1