Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 1 | //===- SubtargetEmitter.cpp - Generate subtarget enumerations -------------===// |
| 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 | // |
Chris Lattner | 3d87811 | 2006-03-03 02:04:07 +0000 | [diff] [blame] | 10 | // This tablegen backend emits subtarget enumerations. |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 14 | #include "CodeGenTarget.h" |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 15 | #include "CodeGenSchedule.h" |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/StringExtras.h" |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/STLExtras.h" |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCInstrItineraries.h" |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 19 | #include "llvm/TableGen/Error.h" |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 20 | #include "llvm/TableGen/Record.h" |
| 21 | #include "llvm/TableGen/TableGenBackend.h" |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 22 | #include "llvm/Support/Debug.h" |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 23 | #include "llvm/Support/Format.h" |
Jeff Cohen | 9489c04 | 2005-10-28 01:43:09 +0000 | [diff] [blame] | 24 | #include <algorithm> |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 25 | #include <map> |
| 26 | #include <string> |
| 27 | #include <vector> |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 28 | using namespace llvm; |
| 29 | |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 30 | namespace { |
| 31 | class SubtargetEmitter { |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 32 | // Each processor has a SchedClassDesc table with an entry for each SchedClass. |
| 33 | // The SchedClassDesc table indexes into a global write resource table, write |
| 34 | // latency table, and read advance table. |
| 35 | struct SchedClassTables { |
| 36 | std::vector<std::vector<MCSchedClassDesc> > ProcSchedClasses; |
| 37 | std::vector<MCWriteProcResEntry> WriteProcResources; |
| 38 | std::vector<MCWriteLatencyEntry> WriteLatencies; |
| 39 | std::vector<MCReadAdvanceEntry> ReadAdvanceEntries; |
| 40 | |
| 41 | // Reserve an invalid entry at index 0 |
| 42 | SchedClassTables() { |
| 43 | ProcSchedClasses.resize(1); |
| 44 | WriteProcResources.resize(1); |
| 45 | WriteLatencies.resize(1); |
| 46 | ReadAdvanceEntries.resize(1); |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | struct LessWriteProcResources { |
| 51 | bool operator()(const MCWriteProcResEntry &LHS, |
| 52 | const MCWriteProcResEntry &RHS) { |
| 53 | return LHS.ProcResourceIdx < RHS.ProcResourceIdx; |
| 54 | } |
| 55 | }; |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 56 | |
| 57 | RecordKeeper &Records; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 58 | CodeGenSchedModels &SchedModels; |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 59 | std::string Target; |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 60 | |
| 61 | void Enumeration(raw_ostream &OS, const char *ClassName, bool isBits); |
| 62 | unsigned FeatureKeyValues(raw_ostream &OS); |
| 63 | unsigned CPUKeyValues(raw_ostream &OS); |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 64 | void FormItineraryStageString(const std::string &Names, |
| 65 | Record *ItinData, std::string &ItinString, |
| 66 | unsigned &NStages); |
| 67 | void FormItineraryOperandCycleString(Record *ItinData, std::string &ItinString, |
| 68 | unsigned &NOperandCycles); |
| 69 | void FormItineraryBypassString(const std::string &Names, |
| 70 | Record *ItinData, |
| 71 | std::string &ItinString, unsigned NOperandCycles); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 72 | void EmitStageAndOperandCycleData(raw_ostream &OS, |
| 73 | std::vector<std::vector<InstrItinerary> > |
| 74 | &ProcItinLists); |
| 75 | void EmitItineraries(raw_ostream &OS, |
| 76 | std::vector<std::vector<InstrItinerary> > |
| 77 | &ProcItinLists); |
| 78 | void EmitProcessorProp(raw_ostream &OS, const Record *R, const char *Name, |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 79 | char Separator); |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 80 | void EmitProcessorResources(const CodeGenProcModel &ProcModel, |
| 81 | raw_ostream &OS); |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 82 | Record *FindWriteResources(Record *WriteDef, |
| 83 | const CodeGenProcModel &ProcModel); |
| 84 | Record *FindReadAdvance(Record *ReadDef, const CodeGenProcModel &ProcModel); |
| 85 | void GenSchedClassTables(const CodeGenProcModel &ProcModel, |
| 86 | SchedClassTables &SchedTables); |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 87 | void EmitSchedClassTables(SchedClassTables &SchedTables, raw_ostream &OS); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 88 | void EmitProcessorModels(raw_ostream &OS); |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 89 | void EmitProcessorLookup(raw_ostream &OS); |
Andrew Trick | 4d2d1c4 | 2012-09-18 03:41:43 +0000 | [diff] [blame] | 90 | void EmitSchedModelHelpers(std::string ClassName, raw_ostream &OS); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 91 | void EmitSchedModel(raw_ostream &OS); |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 92 | void ParseFeaturesFunction(raw_ostream &OS, unsigned NumFeatures, |
| 93 | unsigned NumProcs); |
| 94 | |
| 95 | public: |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 96 | SubtargetEmitter(RecordKeeper &R, CodeGenTarget &TGT): |
| 97 | Records(R), SchedModels(TGT.getSchedModels()), Target(TGT.getName()) {} |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 98 | |
| 99 | void run(raw_ostream &o); |
| 100 | |
| 101 | }; |
| 102 | } // End anonymous namespace |
| 103 | |
Jim Laskey | 7dc0204 | 2005-10-22 07:59:56 +0000 | [diff] [blame] | 104 | // |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 105 | // Enumeration - Emit the specified class as an enumeration. |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 106 | // |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 107 | void SubtargetEmitter::Enumeration(raw_ostream &OS, |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 108 | const char *ClassName, |
| 109 | bool isBits) { |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 110 | // Get all records of class and sort |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 111 | std::vector<Record*> DefList = Records.getAllDerivedDefinitions(ClassName); |
Duraid Madina | 42d24c7 | 2005-12-30 14:56:37 +0000 | [diff] [blame] | 112 | std::sort(DefList.begin(), DefList.end(), LessRecord()); |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 113 | |
Evan Cheng | b6a6388 | 2011-04-15 19:35:46 +0000 | [diff] [blame] | 114 | unsigned N = DefList.size(); |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 115 | if (N == 0) |
| 116 | return; |
Evan Cheng | b6a6388 | 2011-04-15 19:35:46 +0000 | [diff] [blame] | 117 | if (N > 64) { |
| 118 | errs() << "Too many (> 64) subtarget features!\n"; |
| 119 | exit(1); |
| 120 | } |
| 121 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 122 | OS << "namespace " << Target << " {\n"; |
| 123 | |
Jakob Stoklund Olesen | ac1ed44 | 2012-01-03 23:04:28 +0000 | [diff] [blame] | 124 | // For bit flag enumerations with more than 32 items, emit constants. |
| 125 | // Emit an enum for everything else. |
| 126 | if (isBits && N > 32) { |
| 127 | // For each record |
| 128 | for (unsigned i = 0; i < N; i++) { |
| 129 | // Next record |
| 130 | Record *Def = DefList[i]; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 131 | |
Jakob Stoklund Olesen | ac1ed44 | 2012-01-03 23:04:28 +0000 | [diff] [blame] | 132 | // Get and emit name and expression (1 << i) |
| 133 | OS << " const uint64_t " << Def->getName() << " = 1ULL << " << i << ";\n"; |
| 134 | } |
| 135 | } else { |
| 136 | // Open enumeration |
| 137 | OS << "enum {\n"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 138 | |
Jakob Stoklund Olesen | ac1ed44 | 2012-01-03 23:04:28 +0000 | [diff] [blame] | 139 | // For each record |
| 140 | for (unsigned i = 0; i < N;) { |
| 141 | // Next record |
| 142 | Record *Def = DefList[i]; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 143 | |
Jakob Stoklund Olesen | ac1ed44 | 2012-01-03 23:04:28 +0000 | [diff] [blame] | 144 | // Get and emit name |
| 145 | OS << " " << Def->getName(); |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 146 | |
Jakob Stoklund Olesen | ac1ed44 | 2012-01-03 23:04:28 +0000 | [diff] [blame] | 147 | // If bit flags then emit expression (1 << i) |
| 148 | if (isBits) OS << " = " << " 1ULL << " << i; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 149 | |
Jakob Stoklund Olesen | ac1ed44 | 2012-01-03 23:04:28 +0000 | [diff] [blame] | 150 | // Depending on 'if more in the list' emit comma |
| 151 | if (++i < N) OS << ","; |
| 152 | |
| 153 | OS << "\n"; |
| 154 | } |
| 155 | |
| 156 | // Close enumeration |
| 157 | OS << "};\n"; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 158 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 159 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 160 | OS << "}\n"; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 164 | // FeatureKeyValues - Emit data of all the subtarget features. Used by the |
| 165 | // command line. |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 166 | // |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 167 | unsigned SubtargetEmitter::FeatureKeyValues(raw_ostream &OS) { |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 168 | // Gather and sort all the features |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 169 | std::vector<Record*> FeatureList = |
| 170 | Records.getAllDerivedDefinitions("SubtargetFeature"); |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 171 | |
| 172 | if (FeatureList.empty()) |
| 173 | return 0; |
| 174 | |
Jim Grosbach | 7c9a772 | 2008-09-11 17:05:32 +0000 | [diff] [blame] | 175 | std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName()); |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 176 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 177 | // Begin feature table |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 178 | OS << "// Sorted (by key) array of values for CPU features.\n" |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 179 | << "extern const llvm::SubtargetFeatureKV " << Target |
| 180 | << "FeatureKV[] = {\n"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 181 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 182 | // For each feature |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 183 | unsigned NumFeatures = 0; |
Jim Laskey | dbe4006 | 2006-12-12 20:55:58 +0000 | [diff] [blame] | 184 | for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) { |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 185 | // Next feature |
| 186 | Record *Feature = FeatureList[i]; |
| 187 | |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 188 | const std::string &Name = Feature->getName(); |
| 189 | const std::string &CommandLineName = Feature->getValueAsString("Name"); |
| 190 | const std::string &Desc = Feature->getValueAsString("Desc"); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 191 | |
Jim Laskey | dbe4006 | 2006-12-12 20:55:58 +0000 | [diff] [blame] | 192 | if (CommandLineName.empty()) continue; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 193 | |
Jim Grosbach | da4231f | 2009-03-26 16:17:51 +0000 | [diff] [blame] | 194 | // Emit as { "feature", "description", featureEnum, i1 | i2 | ... | in } |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 195 | OS << " { " |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 196 | << "\"" << CommandLineName << "\", " |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 197 | << "\"" << Desc << "\", " |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 198 | << Target << "::" << Name << ", "; |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 199 | |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 200 | const std::vector<Record*> &ImpliesList = |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 201 | Feature->getValueAsListOfDefs("Implies"); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 202 | |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 203 | if (ImpliesList.empty()) { |
Evan Cheng | b6a6388 | 2011-04-15 19:35:46 +0000 | [diff] [blame] | 204 | OS << "0ULL"; |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 205 | } else { |
| 206 | for (unsigned j = 0, M = ImpliesList.size(); j < M;) { |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 207 | OS << Target << "::" << ImpliesList[j]->getName(); |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 208 | if (++j < M) OS << " | "; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | OS << " }"; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 213 | ++NumFeatures; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 214 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 215 | // Depending on 'if more in the list' emit comma |
Jim Laskey | dbe4006 | 2006-12-12 20:55:58 +0000 | [diff] [blame] | 216 | if ((i + 1) < N) OS << ","; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 217 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 218 | OS << "\n"; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 219 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 220 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 221 | // End feature table |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 222 | OS << "};\n"; |
| 223 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 224 | return NumFeatures; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | // |
| 228 | // CPUKeyValues - Emit data of all the subtarget processors. Used by command |
| 229 | // line. |
| 230 | // |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 231 | unsigned SubtargetEmitter::CPUKeyValues(raw_ostream &OS) { |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 232 | // Gather and sort processor information |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 233 | std::vector<Record*> ProcessorList = |
| 234 | Records.getAllDerivedDefinitions("Processor"); |
Duraid Madina | 42d24c7 | 2005-12-30 14:56:37 +0000 | [diff] [blame] | 235 | std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 236 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 237 | // Begin processor table |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 238 | OS << "// Sorted (by key) array of values for CPU subtype.\n" |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 239 | << "extern const llvm::SubtargetFeatureKV " << Target |
| 240 | << "SubTypeKV[] = {\n"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 241 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 242 | // For each processor |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 243 | for (unsigned i = 0, N = ProcessorList.size(); i < N;) { |
| 244 | // Next processor |
| 245 | Record *Processor = ProcessorList[i]; |
| 246 | |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 247 | const std::string &Name = Processor->getValueAsString("Name"); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 248 | const std::vector<Record*> &FeatureList = |
Chris Lattner | b0e103d | 2005-10-28 22:49:02 +0000 | [diff] [blame] | 249 | Processor->getValueAsListOfDefs("Features"); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 250 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 251 | // Emit as { "cpu", "description", f1 | f2 | ... fn }, |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 252 | OS << " { " |
| 253 | << "\"" << Name << "\", " |
| 254 | << "\"Select the " << Name << " processor\", "; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 255 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 256 | if (FeatureList.empty()) { |
Evan Cheng | b6a6388 | 2011-04-15 19:35:46 +0000 | [diff] [blame] | 257 | OS << "0ULL"; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 258 | } else { |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 259 | for (unsigned j = 0, M = FeatureList.size(); j < M;) { |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 260 | OS << Target << "::" << FeatureList[j]->getName(); |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 261 | if (++j < M) OS << " | "; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 262 | } |
| 263 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 264 | |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 265 | // The "0" is for the "implies" section of this data structure. |
Evan Cheng | b6a6388 | 2011-04-15 19:35:46 +0000 | [diff] [blame] | 266 | OS << ", 0ULL }"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 267 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 268 | // Depending on 'if more in the list' emit comma |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 269 | if (++i < N) OS << ","; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 270 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 271 | OS << "\n"; |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 272 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 273 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 274 | // End processor table |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 275 | OS << "};\n"; |
| 276 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 277 | return ProcessorList.size(); |
Jim Laskey | b3b1d5f | 2005-10-25 15:16:36 +0000 | [diff] [blame] | 278 | } |
Jim Laskey | 7dc0204 | 2005-10-22 07:59:56 +0000 | [diff] [blame] | 279 | |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 280 | // |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 281 | // FormItineraryStageString - Compose a string containing the stage |
| 282 | // data initialization for the specified itinerary. N is the number |
| 283 | // of stages. |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 284 | // |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 285 | void SubtargetEmitter::FormItineraryStageString(const std::string &Name, |
| 286 | Record *ItinData, |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 287 | std::string &ItinString, |
| 288 | unsigned &NStages) { |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 289 | // Get states list |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 290 | const std::vector<Record*> &StageList = |
| 291 | ItinData->getValueAsListOfDefs("Stages"); |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 292 | |
| 293 | // For each stage |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 294 | unsigned N = NStages = StageList.size(); |
Christopher Lamb | 8dadf6b | 2007-04-22 09:04:24 +0000 | [diff] [blame] | 295 | for (unsigned i = 0; i < N;) { |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 296 | // Next stage |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 297 | const Record *Stage = StageList[i]; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 298 | |
Anton Korobeynikov | 96085a3 | 2010-04-07 18:19:32 +0000 | [diff] [blame] | 299 | // Form string as ,{ cycles, u1 | u2 | ... | un, timeinc, kind } |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 300 | int Cycles = Stage->getValueAsInt("Cycles"); |
Jim Laskey | 7f39c14 | 2005-11-03 22:47:41 +0000 | [diff] [blame] | 301 | ItinString += " { " + itostr(Cycles) + ", "; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 302 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 303 | // Get unit list |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 304 | const std::vector<Record*> &UnitList = Stage->getValueAsListOfDefs("Units"); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 305 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 306 | // For each unit |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 307 | for (unsigned j = 0, M = UnitList.size(); j < M;) { |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 308 | // Add name and bitwise or |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 309 | ItinString += Name + "FU::" + UnitList[j]->getName(); |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 310 | if (++j < M) ItinString += " | "; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 311 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 312 | |
David Goodwin | 1a8f36e | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 313 | int TimeInc = Stage->getValueAsInt("TimeInc"); |
| 314 | ItinString += ", " + itostr(TimeInc); |
| 315 | |
Anton Korobeynikov | 96085a3 | 2010-04-07 18:19:32 +0000 | [diff] [blame] | 316 | int Kind = Stage->getValueAsInt("Kind"); |
| 317 | ItinString += ", (llvm::InstrStage::ReservationKinds)" + itostr(Kind); |
| 318 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 319 | // Close off stage |
| 320 | ItinString += " }"; |
Christopher Lamb | 8dadf6b | 2007-04-22 09:04:24 +0000 | [diff] [blame] | 321 | if (++i < N) ItinString += ", "; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 322 | } |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | // |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 326 | // FormItineraryOperandCycleString - Compose a string containing the |
| 327 | // operand cycle initialization for the specified itinerary. N is the |
| 328 | // number of operands that has cycles specified. |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 329 | // |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 330 | void SubtargetEmitter::FormItineraryOperandCycleString(Record *ItinData, |
| 331 | std::string &ItinString, unsigned &NOperandCycles) { |
| 332 | // Get operand cycle list |
| 333 | const std::vector<int64_t> &OperandCycleList = |
| 334 | ItinData->getValueAsListOfInts("OperandCycles"); |
| 335 | |
| 336 | // For each operand cycle |
| 337 | unsigned N = NOperandCycles = OperandCycleList.size(); |
| 338 | for (unsigned i = 0; i < N;) { |
| 339 | // Next operand cycle |
| 340 | const int OCycle = OperandCycleList[i]; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 341 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 342 | ItinString += " " + itostr(OCycle); |
| 343 | if (++i < N) ItinString += ", "; |
| 344 | } |
| 345 | } |
| 346 | |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 347 | void SubtargetEmitter::FormItineraryBypassString(const std::string &Name, |
| 348 | Record *ItinData, |
| 349 | std::string &ItinString, |
| 350 | unsigned NOperandCycles) { |
| 351 | const std::vector<Record*> &BypassList = |
| 352 | ItinData->getValueAsListOfDefs("Bypasses"); |
| 353 | unsigned N = BypassList.size(); |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 354 | unsigned i = 0; |
| 355 | for (; i < N;) { |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 356 | ItinString += Name + "Bypass::" + BypassList[i]->getName(); |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 357 | if (++i < NOperandCycles) ItinString += ", "; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 358 | } |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 359 | for (; i < NOperandCycles;) { |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 360 | ItinString += " 0"; |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 361 | if (++i < NOperandCycles) ItinString += ", "; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 365 | // |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 366 | // EmitStageAndOperandCycleData - Generate unique itinerary stages and operand |
| 367 | // cycle tables. Create a list of InstrItinerary objects (ProcItinLists) indexed |
| 368 | // by CodeGenSchedClass::Index. |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 369 | // |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 370 | void SubtargetEmitter:: |
| 371 | EmitStageAndOperandCycleData(raw_ostream &OS, |
| 372 | std::vector<std::vector<InstrItinerary> > |
| 373 | &ProcItinLists) { |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 374 | |
Andrew Trick | cb94192 | 2012-07-09 20:43:03 +0000 | [diff] [blame] | 375 | // Multiple processor models may share an itinerary record. Emit it once. |
| 376 | SmallPtrSet<Record*, 8> ItinsDefSet; |
| 377 | |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 378 | // Emit functional units for all the itineraries. |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 379 | for (CodeGenSchedModels::ProcIter PI = SchedModels.procModelBegin(), |
| 380 | PE = SchedModels.procModelEnd(); PI != PE; ++PI) { |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 381 | |
Andrew Trick | cb94192 | 2012-07-09 20:43:03 +0000 | [diff] [blame] | 382 | if (!ItinsDefSet.insert(PI->ItinsDef)) |
| 383 | continue; |
| 384 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 385 | std::vector<Record*> FUs = PI->ItinsDef->getValueAsListOfDefs("FU"); |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 386 | if (FUs.empty()) |
| 387 | continue; |
| 388 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 389 | const std::string &Name = PI->ItinsDef->getName(); |
| 390 | OS << "\n// Functional units for \"" << Name << "\"\n" |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 391 | << "namespace " << Name << "FU {\n"; |
| 392 | |
| 393 | for (unsigned j = 0, FUN = FUs.size(); j < FUN; ++j) |
Hal Finkel | b460a33 | 2012-06-22 20:27:13 +0000 | [diff] [blame] | 394 | OS << " const unsigned " << FUs[j]->getName() |
| 395 | << " = 1 << " << j << ";\n"; |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 396 | |
| 397 | OS << "}\n"; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 398 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 399 | std::vector<Record*> BPs = PI->ItinsDef->getValueAsListOfDefs("BP"); |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 400 | if (BPs.size()) { |
| 401 | OS << "\n// Pipeline forwarding pathes for itineraries \"" << Name |
| 402 | << "\"\n" << "namespace " << Name << "Bypass {\n"; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 403 | |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 404 | OS << " const unsigned NoBypass = 0;\n"; |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 405 | for (unsigned j = 0, BPN = BPs.size(); j < BPN; ++j) |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 406 | OS << " const unsigned " << BPs[j]->getName() |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 407 | << " = 1 << " << j << ";\n"; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 408 | |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 409 | OS << "}\n"; |
| 410 | } |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 411 | } |
| 412 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 413 | // Begin stages table |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 414 | std::string StageTable = "\nextern const llvm::InstrStage " + Target + |
| 415 | "Stages[] = {\n"; |
Anton Korobeynikov | 96085a3 | 2010-04-07 18:19:32 +0000 | [diff] [blame] | 416 | StageTable += " { 0, 0, 0, llvm::InstrStage::Required }, // No itinerary\n"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 417 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 418 | // Begin operand cycle table |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 419 | std::string OperandCycleTable = "extern const unsigned " + Target + |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 420 | "OperandCycles[] = {\n"; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 421 | OperandCycleTable += " 0, // No itinerary\n"; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 422 | |
| 423 | // Begin pipeline bypass table |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 424 | std::string BypassTable = "extern const unsigned " + Target + |
Andrew Trick | a11a628 | 2012-07-07 03:59:48 +0000 | [diff] [blame] | 425 | "ForwardingPaths[] = {\n"; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 426 | BypassTable += " 0, // No itinerary\n"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 427 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 428 | // For each Itinerary across all processors, add a unique entry to the stages, |
| 429 | // operand cycles, and pipepine bypess tables. Then add the new Itinerary |
| 430 | // object with computed offsets to the ProcItinLists result. |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 431 | unsigned StageCount = 1, OperandCycleCount = 1; |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 432 | std::map<std::string, unsigned> ItinStageMap, ItinOperandMap; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 433 | for (CodeGenSchedModels::ProcIter PI = SchedModels.procModelBegin(), |
| 434 | PE = SchedModels.procModelEnd(); PI != PE; ++PI) { |
| 435 | const CodeGenProcModel &ProcModel = *PI; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 436 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 437 | // Add process itinerary to the list. |
| 438 | ProcItinLists.resize(ProcItinLists.size()+1); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 439 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 440 | // If this processor defines no itineraries, then leave the itinerary list |
| 441 | // empty. |
| 442 | std::vector<InstrItinerary> &ItinList = ProcItinLists.back(); |
| 443 | if (ProcModel.ItinDefList.empty()) |
Andrew Trick | d85934b | 2012-06-22 03:58:51 +0000 | [diff] [blame] | 444 | continue; |
Andrew Trick | d85934b | 2012-06-22 03:58:51 +0000 | [diff] [blame] | 445 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 446 | // Reserve index==0 for NoItinerary. |
| 447 | ItinList.resize(SchedModels.numItineraryClasses()+1); |
| 448 | |
| 449 | const std::string &Name = ProcModel.ItinsDef->getName(); |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 450 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 451 | // For each itinerary data |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 452 | for (unsigned SchedClassIdx = 0, |
| 453 | SchedClassEnd = ProcModel.ItinDefList.size(); |
| 454 | SchedClassIdx < SchedClassEnd; ++SchedClassIdx) { |
| 455 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 456 | // Next itinerary data |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 457 | Record *ItinData = ProcModel.ItinDefList[SchedClassIdx]; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 458 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 459 | // Get string and stage count |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 460 | std::string ItinStageString; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 461 | unsigned NStages = 0; |
| 462 | if (ItinData) |
| 463 | FormItineraryStageString(Name, ItinData, ItinStageString, NStages); |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 464 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 465 | // Get string and operand cycle count |
| 466 | std::string ItinOperandCycleString; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 467 | unsigned NOperandCycles = 0; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 468 | std::string ItinBypassString; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 469 | if (ItinData) { |
| 470 | FormItineraryOperandCycleString(ItinData, ItinOperandCycleString, |
| 471 | NOperandCycles); |
| 472 | |
| 473 | FormItineraryBypassString(Name, ItinData, ItinBypassString, |
| 474 | NOperandCycles); |
| 475 | } |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 476 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 477 | // Check to see if stage already exists and create if it doesn't |
| 478 | unsigned FindStage = 0; |
| 479 | if (NStages > 0) { |
| 480 | FindStage = ItinStageMap[ItinStageString]; |
| 481 | if (FindStage == 0) { |
Andrew Trick | 2348232 | 2011-04-01 02:22:47 +0000 | [diff] [blame] | 482 | // Emit as { cycles, u1 | u2 | ... | un, timeinc }, // indices |
| 483 | StageTable += ItinStageString + ", // " + itostr(StageCount); |
| 484 | if (NStages > 1) |
| 485 | StageTable += "-" + itostr(StageCount + NStages - 1); |
| 486 | StageTable += "\n"; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 487 | // Record Itin class number. |
| 488 | ItinStageMap[ItinStageString] = FindStage = StageCount; |
| 489 | StageCount += NStages; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 490 | } |
| 491 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 492 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 493 | // Check to see if operand cycle already exists and create if it doesn't |
| 494 | unsigned FindOperandCycle = 0; |
| 495 | if (NOperandCycles > 0) { |
Evan Cheng | 3881cb7 | 2010-09-29 22:42:35 +0000 | [diff] [blame] | 496 | std::string ItinOperandString = ItinOperandCycleString+ItinBypassString; |
| 497 | FindOperandCycle = ItinOperandMap[ItinOperandString]; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 498 | if (FindOperandCycle == 0) { |
| 499 | // Emit as cycle, // index |
Andrew Trick | 2348232 | 2011-04-01 02:22:47 +0000 | [diff] [blame] | 500 | OperandCycleTable += ItinOperandCycleString + ", // "; |
| 501 | std::string OperandIdxComment = itostr(OperandCycleCount); |
| 502 | if (NOperandCycles > 1) |
| 503 | OperandIdxComment += "-" |
| 504 | + itostr(OperandCycleCount + NOperandCycles - 1); |
| 505 | OperandCycleTable += OperandIdxComment + "\n"; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 506 | // Record Itin class number. |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 507 | ItinOperandMap[ItinOperandCycleString] = |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 508 | FindOperandCycle = OperandCycleCount; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 509 | // Emit as bypass, // index |
Andrew Trick | 2348232 | 2011-04-01 02:22:47 +0000 | [diff] [blame] | 510 | BypassTable += ItinBypassString + ", // " + OperandIdxComment + "\n"; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 511 | OperandCycleCount += NOperandCycles; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 512 | } |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 513 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 514 | |
Evan Cheng | 5f54ce3 | 2010-09-09 18:18:55 +0000 | [diff] [blame] | 515 | // Set up itinerary as location and location + stage count |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 516 | int NumUOps = ItinData ? ItinData->getValueAsInt("NumMicroOps") : 0; |
Evan Cheng | 5f54ce3 | 2010-09-09 18:18:55 +0000 | [diff] [blame] | 517 | InstrItinerary Intinerary = { NumUOps, FindStage, FindStage + NStages, |
| 518 | FindOperandCycle, |
| 519 | FindOperandCycle + NOperandCycles}; |
| 520 | |
Jim Laskey | 908ae27 | 2005-10-28 15:20:43 +0000 | [diff] [blame] | 521 | // Inject - empty slots will be 0, 0 |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 522 | ItinList[SchedClassIdx] = Intinerary; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 523 | } |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 524 | } |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 525 | |
Jim Laskey | 7f39c14 | 2005-11-03 22:47:41 +0000 | [diff] [blame] | 526 | // Closing stage |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 527 | StageTable += " { 0, 0, 0, llvm::InstrStage::Required } // End stages\n"; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 528 | StageTable += "};\n"; |
| 529 | |
| 530 | // Closing operand cycles |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 531 | OperandCycleTable += " 0 // End operand cycles\n"; |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 532 | OperandCycleTable += "};\n"; |
| 533 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 534 | BypassTable += " 0 // End bypass tables\n"; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 535 | BypassTable += "};\n"; |
| 536 | |
David Goodwin | fac8541 | 2009-08-17 16:02:57 +0000 | [diff] [blame] | 537 | // Emit tables. |
| 538 | OS << StageTable; |
| 539 | OS << OperandCycleTable; |
Evan Cheng | 63d66ee | 2010-09-28 23:50:49 +0000 | [diff] [blame] | 540 | OS << BypassTable; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 541 | } |
| 542 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 543 | // |
| 544 | // EmitProcessorData - Generate data for processor itineraries that were |
| 545 | // computed during EmitStageAndOperandCycleData(). ProcItinLists lists all |
| 546 | // Itineraries for each processor. The Itinerary lists are indexed on |
| 547 | // CodeGenSchedClass::Index. |
| 548 | // |
| 549 | void SubtargetEmitter:: |
| 550 | EmitItineraries(raw_ostream &OS, |
| 551 | std::vector<std::vector<InstrItinerary> > &ProcItinLists) { |
| 552 | |
Andrew Trick | cb94192 | 2012-07-09 20:43:03 +0000 | [diff] [blame] | 553 | // Multiple processor models may share an itinerary record. Emit it once. |
| 554 | SmallPtrSet<Record*, 8> ItinsDefSet; |
| 555 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 556 | // For each processor's machine model |
| 557 | std::vector<std::vector<InstrItinerary> >::iterator |
| 558 | ProcItinListsIter = ProcItinLists.begin(); |
| 559 | for (CodeGenSchedModels::ProcIter PI = SchedModels.procModelBegin(), |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 560 | PE = SchedModels.procModelEnd(); PI != PE; ++PI, ++ProcItinListsIter) { |
Andrew Trick | cb94192 | 2012-07-09 20:43:03 +0000 | [diff] [blame] | 561 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 562 | Record *ItinsDef = PI->ItinsDef; |
Andrew Trick | cb94192 | 2012-07-09 20:43:03 +0000 | [diff] [blame] | 563 | if (!ItinsDefSet.insert(ItinsDef)) |
| 564 | continue; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 565 | |
| 566 | // Get processor itinerary name |
| 567 | const std::string &Name = ItinsDef->getName(); |
| 568 | |
| 569 | // Get the itinerary list for the processor. |
| 570 | assert(ProcItinListsIter != ProcItinLists.end() && "bad iterator"); |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 571 | std::vector<InstrItinerary> &ItinList = *ProcItinListsIter; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 572 | |
| 573 | OS << "\n"; |
| 574 | OS << "static const llvm::InstrItinerary "; |
| 575 | if (ItinList.empty()) { |
| 576 | OS << '*' << Name << " = 0;\n"; |
| 577 | continue; |
| 578 | } |
| 579 | |
| 580 | // Begin processor itinerary table |
| 581 | OS << Name << "[] = {\n"; |
| 582 | |
| 583 | // For each itinerary class in CodeGenSchedClass::Index order. |
| 584 | for (unsigned j = 0, M = ItinList.size(); j < M; ++j) { |
| 585 | InstrItinerary &Intinerary = ItinList[j]; |
| 586 | |
| 587 | // Emit Itinerary in the form of |
| 588 | // { firstStage, lastStage, firstCycle, lastCycle } // index |
| 589 | OS << " { " << |
| 590 | Intinerary.NumMicroOps << ", " << |
| 591 | Intinerary.FirstStage << ", " << |
| 592 | Intinerary.LastStage << ", " << |
| 593 | Intinerary.FirstOperandCycle << ", " << |
| 594 | Intinerary.LastOperandCycle << " }" << |
| 595 | ", // " << j << " " << SchedModels.getSchedClass(j).Name << "\n"; |
| 596 | } |
| 597 | // End processor itinerary table |
| 598 | OS << " { 0, ~0U, ~0U, ~0U, ~0U } // end marker\n"; |
| 599 | OS << "};\n"; |
| 600 | } |
| 601 | } |
| 602 | |
Sylvestre Ledru | c8e41c5 | 2012-07-23 08:51:15 +0000 | [diff] [blame] | 603 | // Emit either the value defined in the TableGen Record, or the default |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 604 | // value defined in the C++ header. The Record is null if the processor does not |
| 605 | // define a model. |
| 606 | void SubtargetEmitter::EmitProcessorProp(raw_ostream &OS, const Record *R, |
Andrew Trick | fc99299 | 2012-06-05 03:44:40 +0000 | [diff] [blame] | 607 | const char *Name, char Separator) { |
| 608 | OS << " "; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 609 | int V = R ? R->getValueAsInt(Name) : -1; |
Andrew Trick | fc99299 | 2012-06-05 03:44:40 +0000 | [diff] [blame] | 610 | if (V >= 0) |
| 611 | OS << V << Separator << " // " << Name; |
| 612 | else |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 613 | OS << "MCSchedModel::Default" << Name << Separator; |
Andrew Trick | fc99299 | 2012-06-05 03:44:40 +0000 | [diff] [blame] | 614 | OS << '\n'; |
| 615 | } |
| 616 | |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 617 | void SubtargetEmitter::EmitProcessorResources(const CodeGenProcModel &ProcModel, |
| 618 | raw_ostream &OS) { |
| 619 | char Sep = ProcModel.ProcResourceDefs.empty() ? ' ' : ','; |
| 620 | |
| 621 | OS << "\n// {Name, NumUnits, SuperIdx}\n"; |
| 622 | OS << "static const llvm::MCProcResourceDesc " |
| 623 | << ProcModel.ModelName << "ProcResources" << "[] = {\n" |
| 624 | << " {DBGFIELD(\"InvalidUnit\") 0, 0}" << Sep << "\n"; |
| 625 | |
| 626 | for (unsigned i = 0, e = ProcModel.ProcResourceDefs.size(); i < e; ++i) { |
| 627 | Record *PRDef = ProcModel.ProcResourceDefs[i]; |
| 628 | |
| 629 | // Find the SuperIdx |
| 630 | unsigned SuperIdx = 0; |
| 631 | Record *SuperDef = 0; |
| 632 | if (PRDef->getValueInit("Super")->isComplete()) { |
| 633 | SuperDef = |
| 634 | SchedModels.findProcResUnits(PRDef->getValueAsDef("Super"), ProcModel); |
| 635 | SuperIdx = ProcModel.getProcResourceIdx(SuperDef); |
| 636 | } |
| 637 | // Emit the ProcResourceDesc |
| 638 | if (i+1 == e) |
| 639 | Sep = ' '; |
| 640 | OS << " {DBGFIELD(\"" << PRDef->getName() << "\") "; |
| 641 | if (PRDef->getName().size() < 15) |
| 642 | OS.indent(15 - PRDef->getName().size()); |
| 643 | OS << PRDef->getValueAsInt("NumUnits") << ", " << SuperIdx |
| 644 | << "}" << Sep << " // #" << i+1; |
| 645 | if (SuperDef) |
| 646 | OS << ", Super=" << SuperDef->getName(); |
| 647 | OS << "\n"; |
| 648 | } |
| 649 | OS << "};\n"; |
| 650 | } |
| 651 | |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 652 | // Find the WriteRes Record that defines processor resources for this |
| 653 | // SchedWrite. |
| 654 | Record *SubtargetEmitter::FindWriteResources( |
| 655 | Record *WriteDef, const CodeGenProcModel &ProcModel) { |
| 656 | |
| 657 | // Check if the SchedWrite is already subtarget-specific and directly |
| 658 | // specifies a set of processor resources. |
| 659 | if (WriteDef->isSubClassOf("SchedWriteRes")) |
| 660 | return WriteDef; |
| 661 | |
| 662 | // Check this processor's list of write resources. |
| 663 | for (RecIter WRI = ProcModel.WriteResDefs.begin(), |
| 664 | WRE = ProcModel.WriteResDefs.end(); WRI != WRE; ++WRI) { |
| 665 | if (!(*WRI)->isSubClassOf("WriteRes")) |
| 666 | continue; |
| 667 | if (WriteDef == (*WRI)->getValueAsDef("WriteType")) |
| 668 | return *WRI; |
| 669 | } |
| 670 | throw TGError(ProcModel.ModelDef->getLoc(), |
| 671 | std::string("Processor does not define resources for ") |
| 672 | + WriteDef->getName()); |
| 673 | } |
| 674 | |
| 675 | /// Find the ReadAdvance record for the given SchedRead on this processor or |
| 676 | /// return NULL. |
| 677 | Record *SubtargetEmitter::FindReadAdvance(Record *ReadDef, |
| 678 | const CodeGenProcModel &ProcModel) { |
| 679 | // Check for SchedReads that directly specify a ReadAdvance. |
| 680 | if (ReadDef->isSubClassOf("SchedReadAdvance")) |
| 681 | return ReadDef; |
| 682 | |
| 683 | // Check this processor's ReadAdvanceList. |
| 684 | for (RecIter RAI = ProcModel.ReadAdvanceDefs.begin(), |
| 685 | RAE = ProcModel.ReadAdvanceDefs.end(); RAI != RAE; ++RAI) { |
| 686 | if (!(*RAI)->isSubClassOf("ReadAdvance")) |
| 687 | continue; |
| 688 | if (ReadDef == (*RAI)->getValueAsDef("ReadType")) |
| 689 | return *RAI; |
| 690 | } |
| 691 | if (ReadDef->getName() != "ReadDefault") { |
| 692 | throw TGError(ProcModel.ModelDef->getLoc(), |
| 693 | std::string("Processor does not define resources for ") |
| 694 | + ReadDef->getName()); |
| 695 | } |
| 696 | return NULL; |
| 697 | } |
| 698 | |
| 699 | // Generate the SchedClass table for this processor and update global |
| 700 | // tables. Must be called for each processor in order. |
| 701 | void SubtargetEmitter::GenSchedClassTables(const CodeGenProcModel &ProcModel, |
| 702 | SchedClassTables &SchedTables) { |
| 703 | SchedTables.ProcSchedClasses.resize(SchedTables.ProcSchedClasses.size() + 1); |
| 704 | if (!ProcModel.hasInstrSchedModel()) |
| 705 | return; |
| 706 | |
| 707 | std::vector<MCSchedClassDesc> &SCTab = SchedTables.ProcSchedClasses.back(); |
| 708 | for (CodeGenSchedModels::SchedClassIter SCI = SchedModels.schedClassBegin(), |
| 709 | SCE = SchedModels.schedClassEnd(); SCI != SCE; ++SCI) { |
| 710 | SCTab.resize(SCTab.size() + 1); |
| 711 | MCSchedClassDesc &SCDesc = SCTab.back(); |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 712 | // SCDesc.Name is guarded by NDEBUG |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 713 | SCDesc.NumMicroOps = 0; |
| 714 | SCDesc.BeginGroup = false; |
| 715 | SCDesc.EndGroup = false; |
| 716 | SCDesc.WriteProcResIdx = 0; |
| 717 | SCDesc.WriteLatencyIdx = 0; |
| 718 | SCDesc.ReadAdvanceIdx = 0; |
| 719 | |
| 720 | // A Variant SchedClass has no resources of its own. |
| 721 | if (!SCI->Transitions.empty()) { |
| 722 | SCDesc.NumMicroOps = MCSchedClassDesc::VariantNumMicroOps; |
| 723 | continue; |
| 724 | } |
| 725 | |
| 726 | // Determine if the SchedClass is actually reachable on this processor. If |
| 727 | // not don't try to locate the processor resources, it will fail. |
| 728 | // If ProcIndices contains 0, this class applies to all processors. |
| 729 | assert(!SCI->ProcIndices.empty() && "expect at least one procidx"); |
| 730 | if (SCI->ProcIndices[0] != 0) { |
| 731 | IdxIter PIPos = std::find(SCI->ProcIndices.begin(), |
| 732 | SCI->ProcIndices.end(), ProcModel.Index); |
| 733 | if (PIPos == SCI->ProcIndices.end()) |
| 734 | continue; |
| 735 | } |
| 736 | IdxVec Writes = SCI->Writes; |
| 737 | IdxVec Reads = SCI->Reads; |
| 738 | if (SCI->ItinClassDef) { |
| 739 | assert(SCI->InstRWs.empty() && "ItinClass should not have InstRWs"); |
| 740 | // Check this processor's itinerary class resources. |
| 741 | for (RecIter II = ProcModel.ItinRWDefs.begin(), |
| 742 | IE = ProcModel.ItinRWDefs.end(); II != IE; ++II) { |
| 743 | RecVec Matched = (*II)->getValueAsListOfDefs("MatchedItinClasses"); |
| 744 | if (std::find(Matched.begin(), Matched.end(), SCI->ItinClassDef) |
| 745 | != Matched.end()) { |
| 746 | SchedModels.findRWs((*II)->getValueAsListOfDefs("OperandReadWrites"), |
| 747 | Writes, Reads); |
| 748 | break; |
| 749 | } |
| 750 | } |
| 751 | if (Writes.empty()) { |
| 752 | DEBUG(dbgs() << ProcModel.ItinsDef->getName() |
| 753 | << " does not have resources for itinerary class " |
| 754 | << SCI->ItinClassDef->getName() << '\n'); |
| 755 | } |
| 756 | } |
| 757 | else if (!SCI->InstRWs.empty()) { |
| 758 | assert(SCI->Writes.empty() && SCI->Reads.empty() && |
| 759 | "InstRW class should not have its own ReadWrites"); |
| 760 | Record *RWDef = 0; |
| 761 | for (RecIter RWI = SCI->InstRWs.begin(), RWE = SCI->InstRWs.end(); |
| 762 | RWI != RWE; ++RWI) { |
| 763 | Record *RWModelDef = (*RWI)->getValueAsDef("SchedModel"); |
| 764 | if (&ProcModel == &SchedModels.getProcModel(RWModelDef)) { |
| 765 | RWDef = *RWI; |
| 766 | break; |
| 767 | } |
| 768 | } |
| 769 | if (RWDef) { |
| 770 | SchedModels.findRWs(RWDef->getValueAsListOfDefs("OperandReadWrites"), |
| 771 | Writes, Reads); |
| 772 | } |
| 773 | } |
| 774 | // Sum resources across all operand writes. |
| 775 | std::vector<MCWriteProcResEntry> WriteProcResources; |
| 776 | std::vector<MCWriteLatencyEntry> WriteLatencies; |
| 777 | std::vector<MCReadAdvanceEntry> ReadAdvanceEntries; |
| 778 | for (IdxIter WI = Writes.begin(), WE = Writes.end(); WI != WE; ++WI) { |
| 779 | IdxVec WriteSeq; |
| 780 | SchedModels.expandRWSequence(*WI, WriteSeq, /*IsRead=*/false); |
| 781 | |
| 782 | // For each operand, create a latency entry. |
| 783 | MCWriteLatencyEntry WLEntry; |
| 784 | WLEntry.Cycles = 0; |
| 785 | WLEntry.WriteResourceID = WriteSeq.back(); |
| 786 | |
| 787 | for (IdxIter WSI = WriteSeq.begin(), WSE = WriteSeq.end(); |
| 788 | WSI != WSE; ++WSI) { |
| 789 | |
| 790 | Record *WriteDef = SchedModels.getSchedWrite(*WSI).TheDef; |
| 791 | Record *WriteRes = FindWriteResources(WriteDef, ProcModel); |
| 792 | |
| 793 | // Mark the parent class as invalid for unsupported write types. |
| 794 | if (WriteRes->getValueAsBit("Unsupported")) { |
| 795 | SCDesc.NumMicroOps = MCSchedClassDesc::InvalidNumMicroOps; |
| 796 | break; |
| 797 | } |
| 798 | WLEntry.Cycles += WriteRes->getValueAsInt("Latency"); |
| 799 | SCDesc.NumMicroOps += WriteRes->getValueAsInt("NumMicroOps"); |
| 800 | SCDesc.BeginGroup |= WriteRes->getValueAsBit("BeginGroup"); |
| 801 | SCDesc.EndGroup |= WriteRes->getValueAsBit("EndGroup"); |
| 802 | |
| 803 | // Create an entry for each ProcResource listed in WriteRes. |
| 804 | RecVec PRVec = WriteRes->getValueAsListOfDefs("ProcResources"); |
| 805 | std::vector<int64_t> Cycles = |
| 806 | WriteRes->getValueAsListOfInts("ResourceCycles"); |
| 807 | for (unsigned PRIdx = 0, PREnd = PRVec.size(); |
| 808 | PRIdx != PREnd; ++PRIdx) { |
| 809 | MCWriteProcResEntry WPREntry; |
| 810 | WPREntry.ProcResourceIdx = ProcModel.getProcResourceIdx(PRVec[PRIdx]); |
| 811 | assert(WPREntry.ProcResourceIdx && "Bad ProcResourceIdx"); |
| 812 | if (Cycles.size() > PRIdx) |
| 813 | WPREntry.Cycles = Cycles[PRIdx]; |
| 814 | else |
| 815 | WPREntry.Cycles = 1; |
| 816 | WriteProcResources.push_back(WPREntry); |
| 817 | } |
| 818 | } |
| 819 | WriteLatencies.push_back(WLEntry); |
| 820 | } |
| 821 | // Create an entry for each operand Read in this SchedClass. |
| 822 | // Entries must be sorted first by UseIdx then by WriteResourceID. |
| 823 | for (unsigned UseIdx = 0, EndIdx = Reads.size(); |
| 824 | UseIdx != EndIdx; ++UseIdx) { |
| 825 | Record *ReadDef = SchedModels.getSchedRead(Reads[UseIdx]).TheDef; |
| 826 | Record *ReadAdvance = FindReadAdvance(ReadDef, ProcModel); |
| 827 | if (!ReadAdvance) |
| 828 | continue; |
| 829 | |
| 830 | // Mark the parent class as invalid for unsupported write types. |
| 831 | if (ReadAdvance->getValueAsBit("Unsupported")) { |
| 832 | SCDesc.NumMicroOps = MCSchedClassDesc::InvalidNumMicroOps; |
| 833 | break; |
| 834 | } |
| 835 | RecVec ValidWrites = ReadAdvance->getValueAsListOfDefs("ValidWrites"); |
| 836 | IdxVec WriteIDs; |
| 837 | if (ValidWrites.empty()) |
| 838 | WriteIDs.push_back(0); |
| 839 | else { |
| 840 | for (RecIter VWI = ValidWrites.begin(), VWE = ValidWrites.end(); |
| 841 | VWI != VWE; ++VWI) { |
| 842 | WriteIDs.push_back(SchedModels.getSchedRWIdx(*VWI, /*IsRead=*/false)); |
| 843 | } |
| 844 | } |
| 845 | std::sort(WriteIDs.begin(), WriteIDs.end()); |
| 846 | for(IdxIter WI = WriteIDs.begin(), WE = WriteIDs.end(); WI != WE; ++WI) { |
| 847 | MCReadAdvanceEntry RAEntry; |
| 848 | RAEntry.UseIdx = UseIdx; |
| 849 | RAEntry.WriteResourceID = *WI; |
| 850 | RAEntry.Cycles = ReadAdvance->getValueAsInt("Cycles"); |
| 851 | ReadAdvanceEntries.push_back(RAEntry); |
| 852 | } |
| 853 | } |
| 854 | if (SCDesc.NumMicroOps == MCSchedClassDesc::InvalidNumMicroOps) { |
| 855 | WriteProcResources.clear(); |
| 856 | WriteLatencies.clear(); |
| 857 | ReadAdvanceEntries.clear(); |
| 858 | } |
| 859 | // Add the information for this SchedClass to the global tables using basic |
| 860 | // compression. |
| 861 | // |
| 862 | // WritePrecRes entries are sorted by ProcResIdx. |
| 863 | std::sort(WriteProcResources.begin(), WriteProcResources.end(), |
| 864 | LessWriteProcResources()); |
| 865 | |
| 866 | SCDesc.NumWriteProcResEntries = WriteProcResources.size(); |
| 867 | std::vector<MCWriteProcResEntry>::iterator WPRPos = |
| 868 | std::search(SchedTables.WriteProcResources.begin(), |
| 869 | SchedTables.WriteProcResources.end(), |
| 870 | WriteProcResources.begin(), WriteProcResources.end()); |
| 871 | if (WPRPos != SchedTables.WriteProcResources.end()) |
| 872 | SCDesc.WriteProcResIdx = WPRPos - SchedTables.WriteProcResources.begin(); |
| 873 | else { |
| 874 | SCDesc.WriteProcResIdx = SchedTables.WriteProcResources.size(); |
| 875 | SchedTables.WriteProcResources.insert(WPRPos, WriteProcResources.begin(), |
| 876 | WriteProcResources.end()); |
| 877 | } |
| 878 | // Latency entries must remain in operand order. |
| 879 | SCDesc.NumWriteLatencyEntries = WriteLatencies.size(); |
| 880 | std::vector<MCWriteLatencyEntry>::iterator WLPos = |
| 881 | std::search(SchedTables.WriteLatencies.begin(), |
| 882 | SchedTables.WriteLatencies.end(), |
| 883 | WriteLatencies.begin(), WriteLatencies.end()); |
| 884 | if (WLPos != SchedTables.WriteLatencies.end()) |
| 885 | SCDesc.WriteLatencyIdx = WLPos - SchedTables.WriteLatencies.begin(); |
| 886 | else { |
| 887 | SCDesc.WriteLatencyIdx = SchedTables.WriteLatencies.size(); |
| 888 | SchedTables.WriteLatencies.insert(WLPos, WriteLatencies.begin(), |
| 889 | WriteLatencies.end()); |
| 890 | } |
| 891 | // ReadAdvanceEntries must remain in operand order. |
| 892 | SCDesc.NumReadAdvanceEntries = ReadAdvanceEntries.size(); |
| 893 | std::vector<MCReadAdvanceEntry>::iterator RAPos = |
| 894 | std::search(SchedTables.ReadAdvanceEntries.begin(), |
| 895 | SchedTables.ReadAdvanceEntries.end(), |
| 896 | ReadAdvanceEntries.begin(), ReadAdvanceEntries.end()); |
| 897 | if (RAPos != SchedTables.ReadAdvanceEntries.end()) |
| 898 | SCDesc.ReadAdvanceIdx = RAPos - SchedTables.ReadAdvanceEntries.begin(); |
| 899 | else { |
| 900 | SCDesc.ReadAdvanceIdx = SchedTables.ReadAdvanceEntries.size(); |
| 901 | SchedTables.ReadAdvanceEntries.insert(RAPos, ReadAdvanceEntries.begin(), |
| 902 | ReadAdvanceEntries.end()); |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 907 | // Emit SchedClass tables for all processors and associated global tables. |
| 908 | void SubtargetEmitter::EmitSchedClassTables(SchedClassTables &SchedTables, |
| 909 | raw_ostream &OS) { |
| 910 | // Emit global WriteProcResTable. |
| 911 | OS << "\n// {ProcResourceIdx, Cycles}\n" |
| 912 | << "extern const llvm::MCWriteProcResEntry " |
| 913 | << Target << "WriteProcResTable[] = {\n" |
| 914 | << " { 0, 0}, // Invalid\n"; |
| 915 | for (unsigned WPRIdx = 1, WPREnd = SchedTables.WriteProcResources.size(); |
| 916 | WPRIdx != WPREnd; ++WPRIdx) { |
| 917 | MCWriteProcResEntry &WPREntry = SchedTables.WriteProcResources[WPRIdx]; |
| 918 | OS << " {" << format("%2d", WPREntry.ProcResourceIdx) << ", " |
| 919 | << format("%2d", WPREntry.Cycles) << "}"; |
| 920 | if (WPRIdx + 1 < WPREnd) |
| 921 | OS << ','; |
| 922 | OS << " // #" << WPRIdx << '\n'; |
| 923 | } |
| 924 | OS << "}; // " << Target << "WriteProcResTable\n"; |
| 925 | |
| 926 | // Emit global WriteLatencyTable. |
| 927 | OS << "\n// {Cycles, WriteResourceID}\n" |
| 928 | << "extern const llvm::MCWriteLatencyEntry " |
| 929 | << Target << "WriteLatencyTable[] = {\n" |
| 930 | << " { 0, 0}, // Invalid\n"; |
| 931 | for (unsigned WLIdx = 1, WLEnd = SchedTables.WriteLatencies.size(); |
| 932 | WLIdx != WLEnd; ++WLIdx) { |
| 933 | MCWriteLatencyEntry &WLEntry = SchedTables.WriteLatencies[WLIdx]; |
| 934 | OS << " {" << format("%2d", WLEntry.Cycles) << ", " |
| 935 | << format("%2d", WLEntry.WriteResourceID) << "}"; |
| 936 | if (WLIdx + 1 < WLEnd) |
| 937 | OS << ','; |
| 938 | OS << " // #" << WLIdx << " " |
| 939 | << SchedModels.getSchedWrite(WLEntry.WriteResourceID).Name << '\n'; |
| 940 | } |
| 941 | OS << "}; // " << Target << "WriteLatencyTable\n"; |
| 942 | |
| 943 | // Emit global ReadAdvanceTable. |
| 944 | OS << "\n// {UseIdx, WriteResourceID, Cycles}\n" |
| 945 | << "extern const llvm::MCReadAdvanceEntry " |
| 946 | << Target << "ReadAdvanceTable[] = {\n" |
| 947 | << " {0, 0, 0}, // Invalid\n"; |
| 948 | for (unsigned RAIdx = 1, RAEnd = SchedTables.ReadAdvanceEntries.size(); |
| 949 | RAIdx != RAEnd; ++RAIdx) { |
| 950 | MCReadAdvanceEntry &RAEntry = SchedTables.ReadAdvanceEntries[RAIdx]; |
| 951 | OS << " {" << RAEntry.UseIdx << ", " |
| 952 | << format("%2d", RAEntry.WriteResourceID) << ", " |
| 953 | << format("%2d", RAEntry.Cycles) << "}"; |
| 954 | if (RAIdx + 1 < RAEnd) |
| 955 | OS << ','; |
| 956 | OS << " // #" << RAIdx << '\n'; |
| 957 | } |
| 958 | OS << "}; // " << Target << "ReadAdvanceTable\n"; |
| 959 | |
| 960 | // Emit a SchedClass table for each processor. |
| 961 | for (CodeGenSchedModels::ProcIter PI = SchedModels.procModelBegin(), |
| 962 | PE = SchedModels.procModelEnd(); PI != PE; ++PI) { |
| 963 | if (!PI->hasInstrSchedModel()) |
| 964 | continue; |
| 965 | |
| 966 | std::vector<MCSchedClassDesc> &SCTab = |
| 967 | SchedTables.ProcSchedClasses[1 + PI - SchedModels.procModelBegin()]; |
| 968 | |
| 969 | OS << "\n// {Name, NumMicroOps, BeginGroup, EndGroup," |
| 970 | << " WriteProcResIdx,#, WriteLatencyIdx,#, ReadAdvanceIdx,#}\n"; |
| 971 | OS << "static const llvm::MCSchedClassDesc " |
| 972 | << PI->ModelName << "SchedClasses[] = {\n"; |
| 973 | |
| 974 | // The first class is always invalid. We no way to distinguish it except by |
| 975 | // name and position. |
Andrew Trick | e4095f9 | 2012-09-17 23:14:15 +0000 | [diff] [blame] | 976 | assert(SchedModels.getSchedClass(0).Name == "NoItinerary" |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 977 | && "invalid class not first"); |
| 978 | OS << " {DBGFIELD(\"InvalidSchedClass\") " |
| 979 | << MCSchedClassDesc::InvalidNumMicroOps |
| 980 | << ", 0, 0, 0, 0, 0, 0, 0, 0},\n"; |
| 981 | |
| 982 | for (unsigned SCIdx = 1, SCEnd = SCTab.size(); SCIdx != SCEnd; ++SCIdx) { |
| 983 | MCSchedClassDesc &MCDesc = SCTab[SCIdx]; |
| 984 | const CodeGenSchedClass &SchedClass = SchedModels.getSchedClass(SCIdx); |
| 985 | OS << " {DBGFIELD(\"" << SchedClass.Name << "\") "; |
| 986 | if (SchedClass.Name.size() < 18) |
| 987 | OS.indent(18 - SchedClass.Name.size()); |
| 988 | OS << MCDesc.NumMicroOps |
| 989 | << ", " << MCDesc.BeginGroup << ", " << MCDesc.EndGroup |
| 990 | << ", " << format("%2d", MCDesc.WriteProcResIdx) |
| 991 | << ", " << MCDesc.NumWriteProcResEntries |
| 992 | << ", " << format("%2d", MCDesc.WriteLatencyIdx) |
| 993 | << ", " << MCDesc.NumWriteLatencyEntries |
| 994 | << ", " << format("%2d", MCDesc.ReadAdvanceIdx) |
| 995 | << ", " << MCDesc.NumReadAdvanceEntries << "}"; |
| 996 | if (SCIdx + 1 < SCEnd) |
| 997 | OS << ','; |
| 998 | OS << " // #" << SCIdx << '\n'; |
| 999 | } |
| 1000 | OS << "}; // " << PI->ModelName << "SchedClasses\n"; |
| 1001 | } |
| 1002 | } |
| 1003 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1004 | void SubtargetEmitter::EmitProcessorModels(raw_ostream &OS) { |
| 1005 | // For each processor model. |
| 1006 | for (CodeGenSchedModels::ProcIter PI = SchedModels.procModelBegin(), |
| 1007 | PE = SchedModels.procModelEnd(); PI != PE; ++PI) { |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1008 | // Emit processor resource table. |
| 1009 | if (PI->hasInstrSchedModel()) |
| 1010 | EmitProcessorResources(*PI, OS); |
| 1011 | else if(!PI->ProcResourceDefs.empty()) |
| 1012 | throw TGError(PI->ModelDef->getLoc(), "SchedMachineModel defines " |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 1013 | "ProcResources without defining WriteRes SchedWriteRes"); |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1014 | |
Andrew Trick | fc99299 | 2012-06-05 03:44:40 +0000 | [diff] [blame] | 1015 | // Begin processor itinerary properties |
| 1016 | OS << "\n"; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1017 | OS << "static const llvm::MCSchedModel " << PI->ModelName << "(\n"; |
| 1018 | EmitProcessorProp(OS, PI->ModelDef, "IssueWidth", ','); |
| 1019 | EmitProcessorProp(OS, PI->ModelDef, "MinLatency", ','); |
| 1020 | EmitProcessorProp(OS, PI->ModelDef, "LoadLatency", ','); |
| 1021 | EmitProcessorProp(OS, PI->ModelDef, "HighLatency", ','); |
Andrew Trick | d43b5c9 | 2012-08-08 02:44:16 +0000 | [diff] [blame] | 1022 | EmitProcessorProp(OS, PI->ModelDef, "MispredictPenalty", ','); |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1023 | OS << " " << PI->Index << ", // Processor ID\n"; |
| 1024 | if (PI->hasInstrSchedModel()) |
| 1025 | OS << " " << PI->ModelName << "ProcResources" << ",\n" |
| 1026 | << " " << PI->ModelName << "SchedClasses" << ",\n" |
| 1027 | << " " << PI->ProcResourceDefs.size()+1 << ",\n" |
| 1028 | << " " << (SchedModels.schedClassEnd() |
| 1029 | - SchedModels.schedClassBegin()) << ",\n"; |
| 1030 | else |
| 1031 | OS << " 0, 0, 0, 0, // No instruction-level machine model.\n"; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1032 | if (SchedModels.hasItineraryClasses()) |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1033 | OS << " " << PI->ItinsDef->getName() << ");\n"; |
Andrew Trick | d85934b | 2012-06-22 03:58:51 +0000 | [diff] [blame] | 1034 | else |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1035 | OS << " 0); // No Itinerary\n"; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 1036 | } |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | // |
| 1040 | // EmitProcessorLookup - generate cpu name to itinerary lookup table. |
| 1041 | // |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 1042 | void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) { |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1043 | // Gather and sort processor information |
| 1044 | std::vector<Record*> ProcessorList = |
| 1045 | Records.getAllDerivedDefinitions("Processor"); |
Duraid Madina | 42d24c7 | 2005-12-30 14:56:37 +0000 | [diff] [blame] | 1046 | std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1047 | |
| 1048 | // Begin processor table |
| 1049 | OS << "\n"; |
| 1050 | OS << "// Sorted (by key) array of itineraries for CPU subtype.\n" |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 1051 | << "extern const llvm::SubtargetInfoKV " |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1052 | << Target << "ProcSchedKV[] = {\n"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 1053 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1054 | // For each processor |
| 1055 | for (unsigned i = 0, N = ProcessorList.size(); i < N;) { |
| 1056 | // Next processor |
| 1057 | Record *Processor = ProcessorList[i]; |
| 1058 | |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 1059 | const std::string &Name = Processor->getValueAsString("Name"); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1060 | const std::string &ProcModelName = |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 1061 | SchedModels.getModelForProc(Processor).ModelName; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 1062 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1063 | // Emit as { "cpu", procinit }, |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1064 | OS << " { \"" << Name << "\", (const void *)&" << ProcModelName << " }"; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 1065 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1066 | // Depending on ''if more in the list'' emit comma |
| 1067 | if (++i < N) OS << ","; |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 1068 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1069 | OS << "\n"; |
| 1070 | } |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 1071 | |
Jim Laskey | 10b1dd9 | 2005-10-31 17:16:01 +0000 | [diff] [blame] | 1072 | // End processor table |
| 1073 | OS << "};\n"; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | // |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1077 | // EmitSchedModel - Emits all scheduling model tables, folding common patterns. |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 1078 | // |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1079 | void SubtargetEmitter::EmitSchedModel(raw_ostream &OS) { |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1080 | OS << "#ifdef DBGFIELD\n" |
| 1081 | << "#error \"<target>GenSubtargetInfo.inc requires a DBGFIELD macro\"\n" |
| 1082 | << "#endif\n" |
| 1083 | << "#ifndef NDEBUG\n" |
| 1084 | << "#define DBGFIELD(x) x,\n" |
| 1085 | << "#else\n" |
| 1086 | << "#define DBGFIELD(x)\n" |
| 1087 | << "#endif\n"; |
| 1088 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1089 | if (SchedModels.hasItineraryClasses()) { |
| 1090 | std::vector<std::vector<InstrItinerary> > ProcItinLists; |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 1091 | // Emit the stage data |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1092 | EmitStageAndOperandCycleData(OS, ProcItinLists); |
| 1093 | EmitItineraries(OS, ProcItinLists); |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 1094 | } |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 1095 | OS << "\n// ===============================================================\n" |
| 1096 | << "// Data tables for the new per-operand machine model.\n"; |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1097 | |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 1098 | SchedClassTables SchedTables; |
| 1099 | for (CodeGenSchedModels::ProcIter PI = SchedModels.procModelBegin(), |
| 1100 | PE = SchedModels.procModelEnd(); PI != PE; ++PI) { |
| 1101 | GenSchedClassTables(*PI, SchedTables); |
| 1102 | } |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 1103 | EmitSchedClassTables(SchedTables, OS); |
| 1104 | |
| 1105 | // Emit the processor machine model |
| 1106 | EmitProcessorModels(OS); |
| 1107 | // Emit the processor lookup data |
| 1108 | EmitProcessorLookup(OS); |
Andrew Trick | 52c3a1d | 2012-09-17 22:18:48 +0000 | [diff] [blame] | 1109 | |
Andrew Trick | 40096d2 | 2012-09-17 22:18:45 +0000 | [diff] [blame] | 1110 | OS << "#undef DBGFIELD"; |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 1111 | } |
| 1112 | |
Andrew Trick | 4d2d1c4 | 2012-09-18 03:41:43 +0000 | [diff] [blame] | 1113 | void SubtargetEmitter::EmitSchedModelHelpers(std::string ClassName, |
| 1114 | raw_ostream &OS) { |
| 1115 | OS << "unsigned " << ClassName |
| 1116 | << "\n::resolveSchedClass(unsigned SchedClass, const MachineInstr *MI," |
| 1117 | << " const TargetSchedModel *SchedModel) const {\n"; |
| 1118 | |
| 1119 | std::vector<Record*> Prologs = Records.getAllDerivedDefinitions("PredicateProlog"); |
| 1120 | std::sort(Prologs.begin(), Prologs.end(), LessRecord()); |
| 1121 | for (std::vector<Record*>::const_iterator |
| 1122 | PI = Prologs.begin(), PE = Prologs.end(); PI != PE; ++PI) { |
| 1123 | OS << (*PI)->getValueAsString("Code") << '\n'; |
| 1124 | } |
| 1125 | IdxVec VariantClasses; |
| 1126 | for (CodeGenSchedModels::SchedClassIter SCI = SchedModels.schedClassBegin(), |
| 1127 | SCE = SchedModels.schedClassEnd(); SCI != SCE; ++SCI) { |
| 1128 | if (SCI->Transitions.empty()) |
| 1129 | continue; |
| 1130 | VariantClasses.push_back(SCI - SchedModels.schedClassBegin()); |
| 1131 | } |
| 1132 | if (!VariantClasses.empty()) { |
| 1133 | OS << " switch (SchedClass) {\n"; |
| 1134 | for (IdxIter VCI = VariantClasses.begin(), VCE = VariantClasses.end(); |
| 1135 | VCI != VCE; ++VCI) { |
| 1136 | const CodeGenSchedClass &SC = SchedModels.getSchedClass(*VCI); |
| 1137 | OS << " case " << *VCI << ": // " << SC.Name << '\n'; |
| 1138 | IdxVec ProcIndices; |
| 1139 | for (std::vector<CodeGenSchedTransition>::const_iterator |
| 1140 | TI = SC.Transitions.begin(), TE = SC.Transitions.end(); |
| 1141 | TI != TE; ++TI) { |
| 1142 | IdxVec PI; |
| 1143 | std::set_union(TI->ProcIndices.begin(), TI->ProcIndices.end(), |
| 1144 | ProcIndices.begin(), ProcIndices.end(), |
| 1145 | std::back_inserter(PI)); |
| 1146 | ProcIndices.swap(PI); |
| 1147 | } |
| 1148 | for (IdxIter PI = ProcIndices.begin(), PE = ProcIndices.end(); |
| 1149 | PI != PE; ++PI) { |
| 1150 | OS << " "; |
| 1151 | if (*PI != 0) |
| 1152 | OS << "if (SchedModel->getProcessorID() == " << *PI << ") "; |
| 1153 | OS << "{ // " << (SchedModels.procModelBegin() + *PI)->ModelName |
| 1154 | << '\n'; |
| 1155 | for (std::vector<CodeGenSchedTransition>::const_iterator |
| 1156 | TI = SC.Transitions.begin(), TE = SC.Transitions.end(); |
| 1157 | TI != TE; ++TI) { |
| 1158 | OS << " if ("; |
| 1159 | if (*PI != 0 && !std::count(TI->ProcIndices.begin(), |
| 1160 | TI->ProcIndices.end(), *PI)) { |
| 1161 | continue; |
| 1162 | } |
| 1163 | for (RecIter RI = TI->PredTerm.begin(), RE = TI->PredTerm.end(); |
| 1164 | RI != RE; ++RI) { |
| 1165 | if (RI != TI->PredTerm.begin()) |
| 1166 | OS << "\n && "; |
| 1167 | OS << "(" << (*RI)->getValueAsString("Predicate") << ")"; |
| 1168 | } |
| 1169 | OS << ")\n" |
| 1170 | << " return " << TI->ToClassIdx << "; // " |
| 1171 | << SchedModels.getSchedClass(TI->ToClassIdx).Name << '\n'; |
| 1172 | } |
| 1173 | OS << " }\n"; |
| 1174 | if (*PI == 0) |
| 1175 | break; |
| 1176 | } |
| 1177 | unsigned SCIdx = 0; |
| 1178 | if (SC.ItinClassDef) |
| 1179 | SCIdx = SchedModels.getSchedClassIdxForItin(SC.ItinClassDef); |
| 1180 | else |
| 1181 | SCIdx = SchedModels.findSchedClassIdx(SC.Writes, SC.Reads); |
| 1182 | if (SCIdx != *VCI) |
| 1183 | OS << " return " << SCIdx << ";\n"; |
| 1184 | OS << " break;\n"; |
| 1185 | } |
| 1186 | OS << " };\n"; |
| 1187 | } |
| 1188 | OS << " report_fatal_error(\"Expected a variant SchedClass\");\n" |
| 1189 | << "} // " << ClassName << "::resolveSchedClass\n"; |
| 1190 | } |
| 1191 | |
Jim Laskey | 0d841e0 | 2005-10-27 19:47:21 +0000 | [diff] [blame] | 1192 | // |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 1193 | // ParseFeaturesFunction - Produces a subtarget specific function for parsing |
| 1194 | // the subtarget features string. |
| 1195 | // |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1196 | void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS, |
| 1197 | unsigned NumFeatures, |
| 1198 | unsigned NumProcs) { |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 1199 | std::vector<Record*> Features = |
| 1200 | Records.getAllDerivedDefinitions("SubtargetFeature"); |
Duraid Madina | 42d24c7 | 2005-12-30 14:56:37 +0000 | [diff] [blame] | 1201 | std::sort(Features.begin(), Features.end(), LessRecord()); |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 1202 | |
Andrew Trick | da96cf2 | 2011-04-01 01:56:55 +0000 | [diff] [blame] | 1203 | OS << "// ParseSubtargetFeatures - Parses features string setting specified\n" |
| 1204 | << "// subtarget options.\n" |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 1205 | << "void llvm::"; |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 1206 | OS << Target; |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 1207 | OS << "Subtarget::ParseSubtargetFeatures(StringRef CPU, StringRef FS) {\n" |
David Greene | f0fd3af | 2010-01-05 17:47:41 +0000 | [diff] [blame] | 1208 | << " DEBUG(dbgs() << \"\\nFeatures:\" << FS);\n" |
Hal Finkel | 3f696e5 | 2012-06-12 04:21:36 +0000 | [diff] [blame] | 1209 | << " DEBUG(dbgs() << \"\\nCPU:\" << CPU << \"\\n\\n\");\n"; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1210 | |
| 1211 | if (Features.empty()) { |
| 1212 | OS << "}\n"; |
| 1213 | return; |
| 1214 | } |
| 1215 | |
Andrew Trick | 34aadd6 | 2012-09-18 05:33:15 +0000 | [diff] [blame] | 1216 | OS << " InitMCProcessorInfo(CPU, FS);\n" |
| 1217 | << " uint64_t Bits = getFeatureBits();\n"; |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 1218 | |
Jim Laskey | f7bcde0 | 2005-10-28 21:47:29 +0000 | [diff] [blame] | 1219 | for (unsigned i = 0; i < Features.size(); i++) { |
| 1220 | // Next record |
| 1221 | Record *R = Features[i]; |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 1222 | const std::string &Instance = R->getName(); |
| 1223 | const std::string &Value = R->getValueAsString("Value"); |
| 1224 | const std::string &Attribute = R->getValueAsString("Attribute"); |
Evan Cheng | 19c9550 | 2006-01-27 08:09:42 +0000 | [diff] [blame] | 1225 | |
Dale Johannesen | db01c8b | 2008-02-14 23:35:16 +0000 | [diff] [blame] | 1226 | if (Value=="true" || Value=="false") |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 1227 | OS << " if ((Bits & " << Target << "::" |
| 1228 | << Instance << ") != 0) " |
Dale Johannesen | db01c8b | 2008-02-14 23:35:16 +0000 | [diff] [blame] | 1229 | << Attribute << " = " << Value << ";\n"; |
| 1230 | else |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 1231 | OS << " if ((Bits & " << Target << "::" |
| 1232 | << Instance << ") != 0 && " |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1233 | << Attribute << " < " << Value << ") " |
| 1234 | << Attribute << " = " << Value << ";\n"; |
Jim Laskey | 6cee630 | 2005-11-01 20:06:59 +0000 | [diff] [blame] | 1235 | } |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame] | 1236 | |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 1237 | OS << "}\n"; |
Jim Laskey | 581a8f7 | 2005-10-26 17:30:34 +0000 | [diff] [blame] | 1238 | } |
| 1239 | |
Anton Korobeynikov | 41a0243 | 2009-05-23 19:50:50 +0000 | [diff] [blame] | 1240 | // |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 1241 | // SubtargetEmitter::run - Main subtarget enumeration emitter. |
| 1242 | // |
Daniel Dunbar | 1a55180 | 2009-07-03 00:10:29 +0000 | [diff] [blame] | 1243 | void SubtargetEmitter::run(raw_ostream &OS) { |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 1244 | emitSourceFileHeader("Subtarget Enumeration Source Fragment", OS); |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 1245 | |
Evan Cheng | ebdeeab | 2011-07-08 01:53:10 +0000 | [diff] [blame] | 1246 | OS << "\n#ifdef GET_SUBTARGETINFO_ENUM\n"; |
| 1247 | OS << "#undef GET_SUBTARGETINFO_ENUM\n"; |
| 1248 | |
| 1249 | OS << "namespace llvm {\n"; |
| 1250 | Enumeration(OS, "SubtargetFeature", true); |
| 1251 | OS << "} // End llvm namespace \n"; |
| 1252 | OS << "#endif // GET_SUBTARGETINFO_ENUM\n\n"; |
| 1253 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1254 | OS << "\n#ifdef GET_SUBTARGETINFO_MC_DESC\n"; |
| 1255 | OS << "#undef GET_SUBTARGETINFO_MC_DESC\n"; |
Anton Korobeynikov | 928eb49 | 2010-04-18 20:31:01 +0000 | [diff] [blame] | 1256 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1257 | OS << "namespace llvm {\n"; |
Evan Cheng | c60f9b7 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 1258 | #if 0 |
| 1259 | OS << "namespace {\n"; |
| 1260 | #endif |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1261 | unsigned NumFeatures = FeatureKeyValues(OS); |
Evan Cheng | c60f9b7 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 1262 | OS << "\n"; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1263 | unsigned NumProcs = CPUKeyValues(OS); |
Evan Cheng | c60f9b7 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 1264 | OS << "\n"; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1265 | EmitSchedModel(OS); |
Evan Cheng | c60f9b7 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 1266 | OS << "\n"; |
| 1267 | #if 0 |
| 1268 | OS << "}\n"; |
| 1269 | #endif |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1270 | |
| 1271 | // MCInstrInfo initialization routine. |
| 1272 | OS << "static inline void Init" << Target |
Evan Cheng | 59ee62d | 2011-07-11 03:57:24 +0000 | [diff] [blame] | 1273 | << "MCSubtargetInfo(MCSubtargetInfo *II, " |
| 1274 | << "StringRef TT, StringRef CPU, StringRef FS) {\n"; |
| 1275 | OS << " II->InitMCSubtargetInfo(TT, CPU, FS, "; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1276 | if (NumFeatures) |
| 1277 | OS << Target << "FeatureKV, "; |
| 1278 | else |
| 1279 | OS << "0, "; |
| 1280 | if (NumProcs) |
| 1281 | OS << Target << "SubTypeKV, "; |
| 1282 | else |
| 1283 | OS << "0, "; |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 1284 | OS << '\n'; OS.indent(22); |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1285 | OS << Target << "ProcSchedKV, " |
| 1286 | << Target << "WriteProcResTable, " |
| 1287 | << Target << "WriteLatencyTable, " |
| 1288 | << Target << "ReadAdvanceTable, "; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1289 | if (SchedModels.hasItineraryClasses()) { |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1290 | OS << '\n'; OS.indent(22); |
| 1291 | OS << Target << "Stages, " |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1292 | << Target << "OperandCycles, " |
Andrew Trick | a11a628 | 2012-07-07 03:59:48 +0000 | [diff] [blame] | 1293 | << Target << "ForwardingPaths, "; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1294 | } else |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1295 | OS << "0, 0, 0, "; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1296 | OS << NumFeatures << ", " << NumProcs << ");\n}\n\n"; |
| 1297 | |
| 1298 | OS << "} // End llvm namespace \n"; |
| 1299 | |
| 1300 | OS << "#endif // GET_SUBTARGETINFO_MC_DESC\n\n"; |
| 1301 | |
| 1302 | OS << "\n#ifdef GET_SUBTARGETINFO_TARGET_DESC\n"; |
| 1303 | OS << "#undef GET_SUBTARGETINFO_TARGET_DESC\n"; |
| 1304 | |
| 1305 | OS << "#include \"llvm/Support/Debug.h\"\n"; |
| 1306 | OS << "#include \"llvm/Support/raw_ostream.h\"\n"; |
| 1307 | ParseFeaturesFunction(OS, NumFeatures, NumProcs); |
| 1308 | |
| 1309 | OS << "#endif // GET_SUBTARGETINFO_TARGET_DESC\n\n"; |
| 1310 | |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 1311 | // Create a TargetSubtargetInfo subclass to hide the MC layer initialization. |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1312 | OS << "\n#ifdef GET_SUBTARGETINFO_HEADER\n"; |
| 1313 | OS << "#undef GET_SUBTARGETINFO_HEADER\n"; |
| 1314 | |
| 1315 | std::string ClassName = Target + "GenSubtargetInfo"; |
| 1316 | OS << "namespace llvm {\n"; |
Anshuman Dasgupta | dc81e5d | 2011-12-01 21:10:21 +0000 | [diff] [blame] | 1317 | OS << "class DFAPacketizer;\n"; |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 1318 | OS << "struct " << ClassName << " : public TargetSubtargetInfo {\n" |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 1319 | << " explicit " << ClassName << "(StringRef TT, StringRef CPU, " |
| 1320 | << "StringRef FS);\n" |
Anshuman Dasgupta | dc81e5d | 2011-12-01 21:10:21 +0000 | [diff] [blame] | 1321 | << "public:\n" |
Andrew Trick | 4d2d1c4 | 2012-09-18 03:41:43 +0000 | [diff] [blame] | 1322 | << " unsigned resolveSchedClass(unsigned SchedClass, const MachineInstr *DefMI," |
| 1323 | << " const TargetSchedModel *SchedModel) const;\n" |
Sebastian Pop | 464f3a3 | 2011-12-06 17:34:16 +0000 | [diff] [blame] | 1324 | << " DFAPacketizer *createDFAPacketizer(const InstrItineraryData *IID)" |
Anshuman Dasgupta | dc81e5d | 2011-12-01 21:10:21 +0000 | [diff] [blame] | 1325 | << " const;\n" |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1326 | << "};\n"; |
| 1327 | OS << "} // End llvm namespace \n"; |
| 1328 | |
| 1329 | OS << "#endif // GET_SUBTARGETINFO_HEADER\n\n"; |
| 1330 | |
| 1331 | OS << "\n#ifdef GET_SUBTARGETINFO_CTOR\n"; |
| 1332 | OS << "#undef GET_SUBTARGETINFO_CTOR\n"; |
| 1333 | |
Andrew Trick | ee290ba | 2012-09-18 03:32:57 +0000 | [diff] [blame] | 1334 | OS << "#include \"llvm/CodeGen/TargetSchedule.h\"\n"; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1335 | OS << "namespace llvm {\n"; |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 1336 | OS << "extern const llvm::SubtargetFeatureKV " << Target << "FeatureKV[];\n"; |
| 1337 | OS << "extern const llvm::SubtargetFeatureKV " << Target << "SubTypeKV[];\n"; |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 1338 | OS << "extern const llvm::SubtargetInfoKV " << Target << "ProcSchedKV[];\n"; |
| 1339 | OS << "extern const llvm::MCWriteProcResEntry " |
| 1340 | << Target << "WriteProcResTable[];\n"; |
| 1341 | OS << "extern const llvm::MCWriteLatencyEntry " |
| 1342 | << Target << "WriteLatencyTable[];\n"; |
| 1343 | OS << "extern const llvm::MCReadAdvanceEntry " |
| 1344 | << Target << "ReadAdvanceTable[];\n"; |
| 1345 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1346 | if (SchedModels.hasItineraryClasses()) { |
Benjamin Kramer | 1a2f988 | 2011-10-22 16:50:00 +0000 | [diff] [blame] | 1347 | OS << "extern const llvm::InstrStage " << Target << "Stages[];\n"; |
| 1348 | OS << "extern const unsigned " << Target << "OperandCycles[];\n"; |
Andrew Trick | a11a628 | 2012-07-07 03:59:48 +0000 | [diff] [blame] | 1349 | OS << "extern const unsigned " << Target << "ForwardingPaths[];\n"; |
Evan Cheng | c60f9b7 | 2011-07-14 20:59:42 +0000 | [diff] [blame] | 1350 | } |
| 1351 | |
Evan Cheng | 0ddff1b | 2011-07-07 07:07:08 +0000 | [diff] [blame] | 1352 | OS << ClassName << "::" << ClassName << "(StringRef TT, StringRef CPU, " |
| 1353 | << "StringRef FS)\n" |
Evan Cheng | 5b1b4489 | 2011-07-01 21:01:15 +0000 | [diff] [blame] | 1354 | << " : TargetSubtargetInfo() {\n" |
Evan Cheng | 59ee62d | 2011-07-11 03:57:24 +0000 | [diff] [blame] | 1355 | << " InitMCSubtargetInfo(TT, CPU, FS, "; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1356 | if (NumFeatures) |
| 1357 | OS << Target << "FeatureKV, "; |
| 1358 | else |
| 1359 | OS << "0, "; |
| 1360 | if (NumProcs) |
| 1361 | OS << Target << "SubTypeKV, "; |
| 1362 | else |
| 1363 | OS << "0, "; |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1364 | OS << '\n'; OS.indent(22); |
| 1365 | OS << Target << "ProcSchedKV, " |
| 1366 | << Target << "WriteProcResTable, " |
| 1367 | << Target << "WriteLatencyTable, " |
| 1368 | << Target << "ReadAdvanceTable, "; |
| 1369 | OS << '\n'; OS.indent(22); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1370 | if (SchedModels.hasItineraryClasses()) { |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1371 | OS << Target << "Stages, " |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1372 | << Target << "OperandCycles, " |
Andrew Trick | a11a628 | 2012-07-07 03:59:48 +0000 | [diff] [blame] | 1373 | << Target << "ForwardingPaths, "; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1374 | } else |
Andrew Trick | e127dfd | 2012-09-18 03:18:56 +0000 | [diff] [blame] | 1375 | OS << "0, 0, 0, "; |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1376 | OS << NumFeatures << ", " << NumProcs << ");\n}\n\n"; |
Andrew Trick | 544c880 | 2012-09-17 22:18:50 +0000 | [diff] [blame] | 1377 | |
Andrew Trick | 4d2d1c4 | 2012-09-18 03:41:43 +0000 | [diff] [blame] | 1378 | EmitSchedModelHelpers(ClassName, OS); |
| 1379 | |
Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame] | 1380 | OS << "} // End llvm namespace \n"; |
| 1381 | |
| 1382 | OS << "#endif // GET_SUBTARGETINFO_CTOR\n\n"; |
Jim Laskey | 4bb9cbb | 2005-10-21 19:00:04 +0000 | [diff] [blame] | 1383 | } |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 1384 | |
| 1385 | namespace llvm { |
| 1386 | |
| 1387 | void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS) { |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1388 | CodeGenTarget CGTarget(RK); |
| 1389 | SubtargetEmitter(RK, CGTarget).run(OS); |
Jakob Stoklund Olesen | 6f36fa9 | 2012-06-11 15:37:55 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | } // End llvm namespace |