Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 1 | //===- SubtargetEmitter.h - Generate subtarget enumerations -----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 3060910 | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 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 Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetInstrItineraries.h" |
| 19 | #include <vector> |
| 20 | #include <map> |
| 21 | #include <string> |
| 22 | |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 23 | |
| 24 | namespace llvm { |
| 25 | |
| 26 | class SubtargetEmitter : public TableGenBackend { |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 27 | |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 28 | RecordKeeper &Records; |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 29 | std::string Target; |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 30 | bool HasItineraries; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 31 | |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 32 | void Enumeration(raw_ostream &OS, const char *ClassName, bool isBits); |
| 33 | void FeatureKeyValues(raw_ostream &OS); |
| 34 | void CPUKeyValues(raw_ostream &OS); |
| 35 | unsigned CollectAllItinClasses(raw_ostream &OS, |
Evan Cheng | 5f54ce3 | 2010-09-09 18:18:55 +0000 | [diff] [blame] | 36 | std::map<std::string,unsigned> &ItinClassesMap, |
| 37 | std::vector<Record*> &ItinClassList); |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 38 | void FormItineraryStageString(const std::string &Names, |
| 39 | Record *ItinData, std::string &ItinString, |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 40 | unsigned &NStages); |
| 41 | void FormItineraryOperandCycleString(Record *ItinData, std::string &ItinString, |
| 42 | unsigned &NOperandCycles); |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 43 | void FormItineraryBypassString(const std::string &Names, |
| 44 | Record *ItinData, |
| 45 | std::string &ItinString, unsigned NOperandCycles); |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 46 | void EmitStageAndOperandCycleData(raw_ostream &OS, unsigned NItinClasses, |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 47 | std::map<std::string, unsigned> &ItinClassesMap, |
Evan Cheng | 5f54ce3 | 2010-09-09 18:18:55 +0000 | [diff] [blame] | 48 | std::vector<Record*> &ItinClassList, |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 49 | std::vector<std::vector<InstrItinerary> > &ProcList); |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 50 | void EmitProcessorData(raw_ostream &OS, |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 51 | std::vector<std::vector<InstrItinerary> > &ProcList); |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 52 | void EmitProcessorLookup(raw_ostream &OS); |
| 53 | void EmitData(raw_ostream &OS); |
| 54 | void ParseFeaturesFunction(raw_ostream &OS); |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 55 | |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 56 | public: |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 57 | SubtargetEmitter(RecordKeeper &R) : Records(R), HasItineraries(false) {} |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 58 | |
| 59 | // run - Output the subtarget enumerations, returning true on failure. |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 60 | void run(raw_ostream &o); |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 61 | |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | } // End llvm namespace |
| 66 | |
| 67 | #endif |
| 68 | |
| 69 | |
| 70 | |