SubtargetEmitter.cpp (193323) | SubtargetEmitter.cpp (195340) |
---|---|
1//===- SubtargetEmitter.cpp - Generate subtarget enumerations -------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 8 unchanged lines hidden (view full) --- 17#include "llvm/ADT/StringExtras.h" 18#include "llvm/Support/Debug.h" 19#include <algorithm> 20using namespace llvm; 21 22// 23// Enumeration - Emit the specified class as an enumeration. 24// | 1//===- SubtargetEmitter.cpp - Generate subtarget enumerations -------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 8 unchanged lines hidden (view full) --- 17#include "llvm/ADT/StringExtras.h" 18#include "llvm/Support/Debug.h" 19#include <algorithm> 20using namespace llvm; 21 22// 23// Enumeration - Emit the specified class as an enumeration. 24// |
25void SubtargetEmitter::Enumeration(std::ostream &OS, | 25void SubtargetEmitter::Enumeration(raw_ostream &OS, |
26 const char *ClassName, 27 bool isBits) { 28 // Get all records of class and sort 29 std::vector<Record*> DefList = Records.getAllDerivedDefinitions(ClassName); 30 std::sort(DefList.begin(), DefList.end(), LessRecord()); 31 32 // Open enumeration 33 OS << "enum {\n"; --- 18 unchanged lines hidden (view full) --- 52 // Close enumeration 53 OS << "};\n"; 54} 55 56// 57// FeatureKeyValues - Emit data of all the subtarget features. Used by the 58// command line. 59// | 26 const char *ClassName, 27 bool isBits) { 28 // Get all records of class and sort 29 std::vector<Record*> DefList = Records.getAllDerivedDefinitions(ClassName); 30 std::sort(DefList.begin(), DefList.end(), LessRecord()); 31 32 // Open enumeration 33 OS << "enum {\n"; --- 18 unchanged lines hidden (view full) --- 52 // Close enumeration 53 OS << "};\n"; 54} 55 56// 57// FeatureKeyValues - Emit data of all the subtarget features. Used by the 58// command line. 59// |
60void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) { | 60void SubtargetEmitter::FeatureKeyValues(raw_ostream &OS) { |
61 // Gather and sort all the features 62 std::vector<Record*> FeatureList = 63 Records.getAllDerivedDefinitions("SubtargetFeature"); 64 std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName()); 65 66 // Begin feature table 67 OS << "// Sorted (by key) array of values for CPU features.\n" 68 << "static const llvm::SubtargetFeatureKV FeatureKV[] = {\n"; --- 43 unchanged lines hidden (view full) --- 112 OS<<" FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV)\n"; 113 OS<<"};\n"; 114} 115 116// 117// CPUKeyValues - Emit data of all the subtarget processors. Used by command 118// line. 119// | 61 // Gather and sort all the features 62 std::vector<Record*> FeatureList = 63 Records.getAllDerivedDefinitions("SubtargetFeature"); 64 std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName()); 65 66 // Begin feature table 67 OS << "// Sorted (by key) array of values for CPU features.\n" 68 << "static const llvm::SubtargetFeatureKV FeatureKV[] = {\n"; --- 43 unchanged lines hidden (view full) --- 112 OS<<" FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV)\n"; 113 OS<<"};\n"; 114} 115 116// 117// CPUKeyValues - Emit data of all the subtarget processors. Used by command 118// line. 119// |
120void SubtargetEmitter::CPUKeyValues(std::ostream &OS) { | 120void SubtargetEmitter::CPUKeyValues(raw_ostream &OS) { |
121 // Gather and sort processor information 122 std::vector<Record*> ProcessorList = 123 Records.getAllDerivedDefinitions("Processor"); 124 std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); 125 126 // Begin processor table 127 OS << "// Sorted (by key) array of values for CPU subtype.\n" 128 << "static const llvm::SubtargetFeatureKV SubTypeKV[] = {\n"; --- 38 unchanged lines hidden (view full) --- 167 OS<<" SubTypeKVSize = sizeof(SubTypeKV)/sizeof(llvm::SubtargetFeatureKV)\n"; 168 OS<<"};\n"; 169} 170 171// 172// CollectAllItinClasses - Gathers and enumerates all the itinerary classes. 173// Returns itinerary class count. 174// | 121 // Gather and sort processor information 122 std::vector<Record*> ProcessorList = 123 Records.getAllDerivedDefinitions("Processor"); 124 std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); 125 126 // Begin processor table 127 OS << "// Sorted (by key) array of values for CPU subtype.\n" 128 << "static const llvm::SubtargetFeatureKV SubTypeKV[] = {\n"; --- 38 unchanged lines hidden (view full) --- 167 OS<<" SubTypeKVSize = sizeof(SubTypeKV)/sizeof(llvm::SubtargetFeatureKV)\n"; 168 OS<<"};\n"; 169} 170 171// 172// CollectAllItinClasses - Gathers and enumerates all the itinerary classes. 173// Returns itinerary class count. 174// |
175unsigned SubtargetEmitter::CollectAllItinClasses(std::ostream &OS, | 175unsigned SubtargetEmitter::CollectAllItinClasses(raw_ostream &OS, |
176 std::map<std::string, unsigned> &ItinClassesMap) { 177 // Gather and sort all itinerary classes 178 std::vector<Record*> ItinClassList = 179 Records.getAllDerivedDefinitions("InstrItinClass"); 180 std::sort(ItinClassList.begin(), ItinClassList.end(), LessRecord()); 181 182 // For each itinerary class 183 unsigned N = ItinClassList.size(); --- 50 unchanged lines hidden (view full) --- 234 if (++i < N) ItinString += ", "; 235 } 236} 237 238// 239// EmitStageData - Generate unique itinerary stages. Record itineraries for 240// processors. 241// | 176 std::map<std::string, unsigned> &ItinClassesMap) { 177 // Gather and sort all itinerary classes 178 std::vector<Record*> ItinClassList = 179 Records.getAllDerivedDefinitions("InstrItinClass"); 180 std::sort(ItinClassList.begin(), ItinClassList.end(), LessRecord()); 181 182 // For each itinerary class 183 unsigned N = ItinClassList.size(); --- 50 unchanged lines hidden (view full) --- 234 if (++i < N) ItinString += ", "; 235 } 236} 237 238// 239// EmitStageData - Generate unique itinerary stages. Record itineraries for 240// processors. 241// |
242void SubtargetEmitter::EmitStageData(std::ostream &OS, | 242void SubtargetEmitter::EmitStageData(raw_ostream &OS, |
243 unsigned NItinClasses, 244 std::map<std::string, unsigned> &ItinClassesMap, 245 std::vector<std::vector<InstrItinerary> > &ProcList) { 246 // Gather processor iteraries 247 std::vector<Record*> ProcItinList = 248 Records.getAllDerivedDefinitions("ProcessorItineraries"); 249 250 // If just no itinerary then don't bother --- 70 unchanged lines hidden (view full) --- 321 OS<<"\nenum {\n"; 322 OS<<" StagesSize = sizeof(Stages)/sizeof(llvm::InstrStage)\n"; 323 OS<<"};\n"; 324} 325 326// 327// EmitProcessorData - Generate data for processor itineraries. 328// | 243 unsigned NItinClasses, 244 std::map<std::string, unsigned> &ItinClassesMap, 245 std::vector<std::vector<InstrItinerary> > &ProcList) { 246 // Gather processor iteraries 247 std::vector<Record*> ProcItinList = 248 Records.getAllDerivedDefinitions("ProcessorItineraries"); 249 250 // If just no itinerary then don't bother --- 70 unchanged lines hidden (view full) --- 321 OS<<"\nenum {\n"; 322 OS<<" StagesSize = sizeof(Stages)/sizeof(llvm::InstrStage)\n"; 323 OS<<"};\n"; 324} 325 326// 327// EmitProcessorData - Generate data for processor itineraries. 328// |
329void SubtargetEmitter::EmitProcessorData(std::ostream &OS, | 329void SubtargetEmitter::EmitProcessorData(raw_ostream &OS, |
330 std::vector<std::vector<InstrItinerary> > &ProcList) { 331 // Get an iterator for processor itinerary stages 332 std::vector<std::vector<InstrItinerary> >::iterator 333 ProcListIter = ProcList.begin(); 334 335 // For each processor itinerary 336 std::vector<Record*> Itins = 337 Records.getAllDerivedDefinitions("ProcessorItineraries"); --- 32 unchanged lines hidden (view full) --- 370 // End processor itinerary table 371 OS << "};\n"; 372 } 373} 374 375// 376// EmitProcessorLookup - generate cpu name to itinerary lookup table. 377// | 330 std::vector<std::vector<InstrItinerary> > &ProcList) { 331 // Get an iterator for processor itinerary stages 332 std::vector<std::vector<InstrItinerary> >::iterator 333 ProcListIter = ProcList.begin(); 334 335 // For each processor itinerary 336 std::vector<Record*> Itins = 337 Records.getAllDerivedDefinitions("ProcessorItineraries"); --- 32 unchanged lines hidden (view full) --- 370 // End processor itinerary table 371 OS << "};\n"; 372 } 373} 374 375// 376// EmitProcessorLookup - generate cpu name to itinerary lookup table. 377// |
378void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) { | 378void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) { |
379 // Gather and sort processor information 380 std::vector<Record*> ProcessorList = 381 Records.getAllDerivedDefinitions("Processor"); 382 std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); 383 384 // Begin processor table 385 OS << "\n"; 386 OS << "// Sorted (by key) array of itineraries for CPU subtype.\n" --- 29 unchanged lines hidden (view full) --- 416 OS<<" ProcItinKVSize = sizeof(ProcItinKV)/" 417 "sizeof(llvm::SubtargetInfoKV)\n"; 418 OS<<"};\n"; 419} 420 421// 422// EmitData - Emits all stages and itineries, folding common patterns. 423// | 379 // Gather and sort processor information 380 std::vector<Record*> ProcessorList = 381 Records.getAllDerivedDefinitions("Processor"); 382 std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName()); 383 384 // Begin processor table 385 OS << "\n"; 386 OS << "// Sorted (by key) array of itineraries for CPU subtype.\n" --- 29 unchanged lines hidden (view full) --- 416 OS<<" ProcItinKVSize = sizeof(ProcItinKV)/" 417 "sizeof(llvm::SubtargetInfoKV)\n"; 418 OS<<"};\n"; 419} 420 421// 422// EmitData - Emits all stages and itineries, folding common patterns. 423// |
424void SubtargetEmitter::EmitData(std::ostream &OS) { | 424void SubtargetEmitter::EmitData(raw_ostream &OS) { |
425 std::map<std::string, unsigned> ItinClassesMap; 426 std::vector<std::vector<InstrItinerary> > ProcList; 427 428 // Enumerate all the itinerary classes 429 unsigned NItinClasses = CollectAllItinClasses(OS, ItinClassesMap); 430 // Make sure the rest is worth the effort 431 HasItineraries = NItinClasses != 1; // Ignore NoItinerary. 432 --- 6 unchanged lines hidden (view full) --- 439 EmitProcessorLookup(OS); 440 } 441} 442 443// 444// ParseFeaturesFunction - Produces a subtarget specific function for parsing 445// the subtarget features string. 446// | 425 std::map<std::string, unsigned> ItinClassesMap; 426 std::vector<std::vector<InstrItinerary> > ProcList; 427 428 // Enumerate all the itinerary classes 429 unsigned NItinClasses = CollectAllItinClasses(OS, ItinClassesMap); 430 // Make sure the rest is worth the effort 431 HasItineraries = NItinClasses != 1; // Ignore NoItinerary. 432 --- 6 unchanged lines hidden (view full) --- 439 EmitProcessorLookup(OS); 440 } 441} 442 443// 444// ParseFeaturesFunction - Produces a subtarget specific function for parsing 445// the subtarget features string. 446// |
447void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) { | 447void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS) { |
448 std::vector<Record*> Features = 449 Records.getAllDerivedDefinitions("SubtargetFeature"); 450 std::sort(Features.begin(), Features.end(), LessRecord()); 451 452 OS << "// ParseSubtargetFeatures - Parses features string setting specified\n" 453 << "// subtarget options.\n" 454 << "std::string llvm::"; 455 OS << Target; --- 28 unchanged lines hidden (view full) --- 484 485 OS << " return Features.getCPU();\n" 486 << "}\n"; 487} 488 489// 490// SubtargetEmitter::run - Main subtarget enumeration emitter. 491// | 448 std::vector<Record*> Features = 449 Records.getAllDerivedDefinitions("SubtargetFeature"); 450 std::sort(Features.begin(), Features.end(), LessRecord()); 451 452 OS << "// ParseSubtargetFeatures - Parses features string setting specified\n" 453 << "// subtarget options.\n" 454 << "std::string llvm::"; 455 OS << Target; --- 28 unchanged lines hidden (view full) --- 484 485 OS << " return Features.getCPU();\n" 486 << "}\n"; 487} 488 489// 490// SubtargetEmitter::run - Main subtarget enumeration emitter. 491// |
492void SubtargetEmitter::run(std::ostream &OS) { | 492void SubtargetEmitter::run(raw_ostream &OS) { |
493 Target = CodeGenTarget().getName(); 494 495 EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS); 496 497 OS << "#include \"llvm/Target/SubtargetFeature.h\"\n"; 498 OS << "#include \"llvm/Target/TargetInstrItineraries.h\"\n\n"; 499 500 Enumeration(OS, "FuncUnit", true); --- 13 unchanged lines hidden --- | 493 Target = CodeGenTarget().getName(); 494 495 EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS); 496 497 OS << "#include \"llvm/Target/SubtargetFeature.h\"\n"; 498 OS << "#include \"llvm/Target/TargetInstrItineraries.h\"\n\n"; 499 500 Enumeration(OS, "FuncUnit", true); --- 13 unchanged lines hidden --- |