Generate cpu to itinerary map.
[oota-llvm.git] / utils / TableGen / SubtargetEmitter.h
1 //===- SubtargetEmitter.h - Generate subtarget enumerations -----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by James M. Laskey and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This tablegen backend emits subtarget enumerations.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SUBTARGET_EMITTER_H
15 #define SUBTARGET_EMITTER_H
16
17 #include "TableGenBackend.h"
18 #include "llvm/Target/TargetInstrItineraries.h"
19 #include <vector>
20 #include <map>
21 #include <string>
22
23
24 namespace llvm {
25
26 class SubtargetEmitter : public TableGenBackend {
27   
28   RecordKeeper &Records;
29   std::string Target;
30   
31   void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
32   void FeatureKeyValues(std::ostream &OS);
33   void CPUKeyValues(std::ostream &OS);
34   unsigned CollectAllItinClasses(std::map<std::string, unsigned>
35                                                                &ItinClassesMap);
36   void FormItineraryString(Record *ItinData, std::string &ItinString,
37                            unsigned &NStages);
38   void EmitStageData(std::ostream &OS, unsigned NItinClasses,
39                      std::map<std::string, unsigned> &ItinClassesMap,
40                      std::vector<std::vector<InstrItinerary> > &ProcList);
41   void EmitProcessorData(std::ostream &OS,
42                        std::vector<std::vector<InstrItinerary> > &ProcList);
43   void EmitProcessorLookup(std::ostream &OS);
44   void EmitData(std::ostream &OS);
45   void ParseFeaturesFunction(std::ostream &OS);
46   
47 public:
48   SubtargetEmitter(RecordKeeper &R) : Records(R) {}
49
50   // run - Output the subtarget enumerations, returning true on failure.
51   void run(std::ostream &o);
52
53 };
54
55
56 } // End llvm namespace
57
58 #endif
59
60
61