blob: f882f1d53cfc53050f6d9b6fae217caaa71d57dc [file] [log] [blame]
Jim Laskey4bb9cbb2005-10-21 19:00:04 +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"
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 Laskeyb3b1d5f2005-10-25 15:16:36 +000030
Jim Laskey581a8f72005-10-26 17:30:34 +000031 void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000032 void FeatureKeyValues(std::ostream &OS);
33 void CPUKeyValues(std::ostream &OS);
Jim Laskeyf7bcde02005-10-28 21:47:29 +000034 unsigned CollectAllItinClasses(std::map<std::string, unsigned>
35 &ItinClassesMap);
Jim Laskey0d841e02005-10-27 19:47:21 +000036 void FormItineraryString(Record *ItinData, std::string &ItinString,
Jim Laskeyf7bcde02005-10-28 21:47:29 +000037 unsigned &NStages);
38 void EmitStageData(std::ostream &OS, unsigned NItinClasses,
39 std::map<std::string, unsigned> &ItinClassesMap,
40 std::vector<std::vector<InstrItinerary> > &ProcList);
Jim Laskey10b1dd92005-10-31 17:16:01 +000041 void EmitProcessorData(std::ostream &OS,
Jim Laskeyf7bcde02005-10-28 21:47:29 +000042 std::vector<std::vector<InstrItinerary> > &ProcList);
Jim Laskey10b1dd92005-10-31 17:16:01 +000043 void EmitProcessorLookup(std::ostream &OS);
Jim Laskey0d841e02005-10-27 19:47:21 +000044 void EmitData(std::ostream &OS);
45 void ParseFeaturesFunction(std::ostream &OS);
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000046
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000047public:
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