Now generating instruction itineraries for scheduling. Not my best work, but...
[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 //
27 // Convenience types.
28 //
29 typedef std::map<std::string, unsigned> IntMap;
30 typedef std::vector<InstrItinerary> IntineraryList;
31 typedef std::vector<IntineraryList> ProcessorList;
32
33 class SubtargetEmitter : public TableGenBackend {
34   
35   RecordKeeper &Records;
36   std::string Target;
37   
38   void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
39   void FeatureKeyValues(std::ostream &OS);
40   void CPUKeyValues(std::ostream &OS);
41   unsigned CollectAllItinClasses(IntMap &ItinClassesMap);
42   void FormItineraryString(Record *ItinData, std::string &ItinString,
43                            unsigned &N);
44   void EmitStageData(std::ostream &OS, unsigned N,
45                      IntMap &ItinClassesMap, ProcessorList &ProcList);
46   void EmitProcessData(std::ostream &OS, ProcessorList &ProcList);
47   void EmitData(std::ostream &OS);
48   void ParseFeaturesFunction(std::ostream &OS);
49   
50 public:
51   SubtargetEmitter(RecordKeeper &R) : Records(R) {}
52
53   // run - Output the subtarget enumerations, returning true on failure.
54   void run(std::ostream &o);
55
56 };
57
58
59 } // End llvm namespace
60
61 #endif
62
63
64