blob: 1727150ae926880aff299d8df7ec92dd73ff6dea [file] [log] [blame]
Anshuman Dasguptadc81e5d2011-12-01 21:10:21 +00001//===- 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"
Anshuman Dasguptadc81e5d2011-12-01 21:10:21 +000019#include "llvm/TableGen/TableGenBackend.h"
20#include <map>
21#include <string>
22
23namespace llvm {
24//
25// class DFAGen: class that generates and prints out the DFA for resource
Sebastian Popf6f77e92011-12-06 17:34:11 +000026// tracking.
Anshuman Dasguptadc81e5d2011-12-01 21:10:21 +000027//
28class DFAGen : public TableGenBackend {
29private:
30 std::string TargetName;
31 //
32 // allInsnClasses is the set of all possible resources consumed by an
Sebastian Popf6f77e92011-12-06 17:34:11 +000033 // InstrStage.
Anshuman Dasguptadc81e5d2011-12-01 21:10:21 +000034 //
35 DenseSet<unsigned> allInsnClasses;
36 RecordKeeper &Records;
37
38public:
Sebastian Pop464f3a32011-12-06 17:34:16 +000039 DFAGen(RecordKeeper &R);
Anshuman Dasguptadc81e5d2011-12-01 21:10:21 +000040
41 //
42 // collectAllInsnClasses: Populate allInsnClasses which is a set of units
43 // used in each stage.
44 //
45 void collectAllInsnClasses(const std::string &Name,
46 Record *ItinData,
47 unsigned &NStages,
48 raw_ostream &OS);
49
50 void run(raw_ostream &OS);
51};
52}