blob: 69feeb2d0f53e707f8d204c189636654c504939a [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- 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
24namespace llvm {
25
26class SubtargetEmitter : public TableGenBackend {
27
28 RecordKeeper &Records;
29 std::string Target;
30 bool HasItineraries;
31
32 void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
33 void FeatureKeyValues(std::ostream &OS);
34 void CPUKeyValues(std::ostream &OS);
35 unsigned CollectAllItinClasses(std::ostream &OS,
36 std::map<std::string, unsigned> &ItinClassesMap);
37 void FormItineraryString(Record *ItinData, std::string &ItinString,
38 unsigned &NStages);
39 void EmitStageData(std::ostream &OS, unsigned NItinClasses,
40 std::map<std::string, unsigned> &ItinClassesMap,
41 std::vector<std::vector<InstrItinerary> > &ProcList);
42 void EmitProcessorData(std::ostream &OS,
43 std::vector<std::vector<InstrItinerary> > &ProcList);
44 void EmitProcessorLookup(std::ostream &OS);
45 void EmitData(std::ostream &OS);
46 void ParseFeaturesFunction(std::ostream &OS);
47
48public:
49 SubtargetEmitter(RecordKeeper &R) : Records(R), HasItineraries(false) {}
50
51 // run - Output the subtarget enumerations, returning true on failure.
52 void run(std::ostream &o);
53
54};
55
56
57} // End llvm namespace
58
59#endif
60
61
62