Anshuman Dasgupta | dc81e5d | 2011-12-01 21:10:21 +0000 | [diff] [blame] | 1 | //===- DFAPacketizerEmitter.h - Packetization DFA for a VLIW machine-------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class parses the Schedule.td file and produces an API that can be used |
| 11 | // to reason about whether an instruction can be added to a packet on a VLIW |
| 12 | // architecture. The class internally generates a deterministic finite |
| 13 | // automaton (DFA) that models all possible mappings of machine instructions |
| 14 | // to functional units as instructions are added to a packet. |
| 15 | // |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | #include "llvm/ADT/DenseSet.h" |
| 19 | #include "llvm/ADT/SmallVector.h" |
| 20 | #include "llvm/CodeGen/Passes.h" |
| 21 | #include "llvm/TableGen/TableGenBackend.h" |
| 22 | #include <map> |
| 23 | #include <string> |
| 24 | |
| 25 | namespace llvm { |
| 26 | // |
| 27 | // class DFAGen: class that generates and prints out the DFA for resource |
Sebastian Pop | f6f77e9 | 2011-12-06 17:34:11 +0000 | [diff] [blame^] | 28 | // tracking. |
Anshuman Dasgupta | dc81e5d | 2011-12-01 21:10:21 +0000 | [diff] [blame] | 29 | // |
| 30 | class DFAGen : public TableGenBackend { |
| 31 | private: |
| 32 | std::string TargetName; |
| 33 | // |
| 34 | // allInsnClasses is the set of all possible resources consumed by an |
Sebastian Pop | f6f77e9 | 2011-12-06 17:34:11 +0000 | [diff] [blame^] | 35 | // InstrStage. |
Anshuman Dasgupta | dc81e5d | 2011-12-01 21:10:21 +0000 | [diff] [blame] | 36 | // |
| 37 | DenseSet<unsigned> allInsnClasses; |
| 38 | RecordKeeper &Records; |
| 39 | |
| 40 | public: |
| 41 | DFAGen(RecordKeeper& R); |
| 42 | |
| 43 | // |
| 44 | // collectAllInsnClasses: Populate allInsnClasses which is a set of units |
| 45 | // used in each stage. |
| 46 | // |
| 47 | void collectAllInsnClasses(const std::string &Name, |
| 48 | Record *ItinData, |
| 49 | unsigned &NStages, |
| 50 | raw_ostream &OS); |
| 51 | |
| 52 | void run(raw_ostream &OS); |
| 53 | }; |
| 54 | } |