blob: 4fcd8f8b0b24be5a539b0a48820a4bb5cf2902fb [file] [log] [blame]
Jim Laskey4bb9cbb2005-10-21 19:00:04 +00001//===- SubtargetEmitter.h - Generate subtarget enumerations -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner30609102007-12-29 20:37:13 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey4bb9cbb2005-10-21 19:00:04 +00007//
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"
Jim Laskey0d841e02005-10-27 19:47:21 +000018#include "llvm/Target/TargetInstrItineraries.h"
19#include <vector>
20#include <map>
21#include <string>
22
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000023
24namespace llvm {
25
26class SubtargetEmitter : public TableGenBackend {
Jim Laskey0d841e02005-10-27 19:47:21 +000027
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000028 RecordKeeper &Records;
Jim Laskey581a8f72005-10-26 17:30:34 +000029 std::string Target;
Jim Laskey6cee6302005-11-01 20:06:59 +000030 bool HasItineraries;
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000031
Jim Laskey581a8f72005-10-26 17:30:34 +000032 void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000033 void FeatureKeyValues(std::ostream &OS);
34 void CPUKeyValues(std::ostream &OS);
Jim Laskey6cee6302005-11-01 20:06:59 +000035 unsigned CollectAllItinClasses(std::ostream &OS,
36 std::map<std::string, unsigned> &ItinClassesMap);
Jim Laskey0d841e02005-10-27 19:47:21 +000037 void FormItineraryString(Record *ItinData, std::string &ItinString,
Jim Laskeyf7bcde02005-10-28 21:47:29 +000038 unsigned &NStages);
39 void EmitStageData(std::ostream &OS, unsigned NItinClasses,
40 std::map<std::string, unsigned> &ItinClassesMap,
41 std::vector<std::vector<InstrItinerary> > &ProcList);
Jim Laskey10b1dd92005-10-31 17:16:01 +000042 void EmitProcessorData(std::ostream &OS,
Jim Laskeyf7bcde02005-10-28 21:47:29 +000043 std::vector<std::vector<InstrItinerary> > &ProcList);
Jim Laskey10b1dd92005-10-31 17:16:01 +000044 void EmitProcessorLookup(std::ostream &OS);
Jim Laskey0d841e02005-10-27 19:47:21 +000045 void EmitData(std::ostream &OS);
46 void ParseFeaturesFunction(std::ostream &OS);
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000047
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000048public:
Jim Laskey6cee6302005-11-01 20:06:59 +000049 SubtargetEmitter(RecordKeeper &R) : Records(R), HasItineraries(false) {}
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000050
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