blob: 2a7b70be25de25d3257d975418fabebc34872f17 [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
Jim Laskey0d841e02005-10-27 19:47:21 +000026//
27// Convenience types.
28//
29typedef std::map<std::string, unsigned> IntMap;
30typedef std::vector<InstrItinerary> IntineraryList;
31typedef std::vector<IntineraryList> ProcessorList;
32
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000033class SubtargetEmitter : public TableGenBackend {
Jim Laskey0d841e02005-10-27 19:47:21 +000034
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000035 RecordKeeper &Records;
Jim Laskey581a8f72005-10-26 17:30:34 +000036 std::string Target;
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000037
Jim Laskey581a8f72005-10-26 17:30:34 +000038 void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000039 void FeatureKeyValues(std::ostream &OS);
40 void CPUKeyValues(std::ostream &OS);
Jim Laskey0d841e02005-10-27 19:47:21 +000041 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);
Jim Laskeyb3b1d5f2005-10-25 15:16:36 +000049
Jim Laskey4bb9cbb2005-10-21 19:00:04 +000050public:
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