2009-06-02 17:52:33 +00:00
|
|
|
//===- SubtargetEmitter.cpp - Generate subtarget enumerations -------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This tablegen backend emits subtarget enumerations.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SubtargetEmitter.h"
|
|
|
|
#include "CodeGenTarget.h"
|
2011-10-20 21:10:27 +00:00
|
|
|
#include "llvm/TableGen/Record.h"
|
2009-06-02 17:52:33 +00:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include <algorithm>
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Enumeration - Emit the specified class as an enumeration.
|
|
|
|
//
|
2009-07-04 13:58:26 +00:00
|
|
|
void SubtargetEmitter::Enumeration(raw_ostream &OS,
|
2009-06-02 17:52:33 +00:00
|
|
|
const char *ClassName,
|
|
|
|
bool isBits) {
|
|
|
|
// Get all records of class and sort
|
|
|
|
std::vector<Record*> DefList = Records.getAllDerivedDefinitions(ClassName);
|
|
|
|
std::sort(DefList.begin(), DefList.end(), LessRecord());
|
|
|
|
|
2011-05-02 19:34:44 +00:00
|
|
|
unsigned N = DefList.size();
|
2011-07-17 15:36:56 +00:00
|
|
|
if (N == 0)
|
|
|
|
return;
|
2011-05-02 19:34:44 +00:00
|
|
|
if (N > 64) {
|
|
|
|
errs() << "Too many (> 64) subtarget features!\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "namespace " << Target << " {\n";
|
|
|
|
|
|
|
|
// Open enumeration
|
|
|
|
OS << "enum {\n";
|
|
|
|
|
|
|
|
// For each record
|
2011-05-02 19:34:44 +00:00
|
|
|
for (unsigned i = 0; i < N;) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// Next record
|
|
|
|
Record *Def = DefList[i];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get and emit name
|
|
|
|
OS << " " << Def->getName();
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// If bit flags then emit expression (1 << i)
|
2011-05-02 19:34:44 +00:00
|
|
|
if (isBits) OS << " = " << " 1ULL << " << i;
|
2009-06-02 17:52:33 +00:00
|
|
|
|
|
|
|
// Depending on 'if more in the list' emit comma
|
|
|
|
if (++i < N) OS << ",";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << "\n";
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Close enumeration
|
|
|
|
OS << "};\n";
|
2011-07-17 15:36:56 +00:00
|
|
|
|
|
|
|
OS << "}\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// FeatureKeyValues - Emit data of all the subtarget features. Used by the
|
|
|
|
// command line.
|
|
|
|
//
|
2011-07-17 15:36:56 +00:00
|
|
|
unsigned SubtargetEmitter::FeatureKeyValues(raw_ostream &OS) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// Gather and sort all the features
|
|
|
|
std::vector<Record*> FeatureList =
|
|
|
|
Records.getAllDerivedDefinitions("SubtargetFeature");
|
2011-07-17 15:36:56 +00:00
|
|
|
|
|
|
|
if (FeatureList.empty())
|
|
|
|
return 0;
|
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName());
|
|
|
|
|
|
|
|
// Begin feature table
|
|
|
|
OS << "// Sorted (by key) array of values for CPU features.\n"
|
2011-07-17 15:36:56 +00:00
|
|
|
<< "llvm::SubtargetFeatureKV " << Target << "FeatureKV[] = {\n";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each feature
|
2011-07-17 15:36:56 +00:00
|
|
|
unsigned NumFeatures = 0;
|
2009-06-02 17:52:33 +00:00
|
|
|
for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) {
|
|
|
|
// Next feature
|
|
|
|
Record *Feature = FeatureList[i];
|
|
|
|
|
|
|
|
const std::string &Name = Feature->getName();
|
|
|
|
const std::string &CommandLineName = Feature->getValueAsString("Name");
|
|
|
|
const std::string &Desc = Feature->getValueAsString("Desc");
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
if (CommandLineName.empty()) continue;
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Emit as { "feature", "description", featureEnum, i1 | i2 | ... | in }
|
|
|
|
OS << " { "
|
|
|
|
<< "\"" << CommandLineName << "\", "
|
|
|
|
<< "\"" << Desc << "\", "
|
2011-07-17 15:36:56 +00:00
|
|
|
<< Target << "::" << Name << ", ";
|
2009-06-02 17:52:33 +00:00
|
|
|
|
2011-05-02 19:34:44 +00:00
|
|
|
const std::vector<Record*> &ImpliesList =
|
2009-06-02 17:52:33 +00:00
|
|
|
Feature->getValueAsListOfDefs("Implies");
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
if (ImpliesList.empty()) {
|
2011-05-02 19:34:44 +00:00
|
|
|
OS << "0ULL";
|
2009-06-02 17:52:33 +00:00
|
|
|
} else {
|
|
|
|
for (unsigned j = 0, M = ImpliesList.size(); j < M;) {
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << Target << "::" << ImpliesList[j]->getName();
|
2009-06-02 17:52:33 +00:00
|
|
|
if (++j < M) OS << " | ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << " }";
|
2011-07-17 15:36:56 +00:00
|
|
|
++NumFeatures;
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Depending on 'if more in the list' emit comma
|
|
|
|
if ((i + 1) < N) OS << ",";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << "\n";
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// End feature table
|
|
|
|
OS << "};\n";
|
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
return NumFeatures;
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// CPUKeyValues - Emit data of all the subtarget processors. Used by command
|
|
|
|
// line.
|
|
|
|
//
|
2011-07-17 15:36:56 +00:00
|
|
|
unsigned SubtargetEmitter::CPUKeyValues(raw_ostream &OS) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// Gather and sort processor information
|
|
|
|
std::vector<Record*> ProcessorList =
|
|
|
|
Records.getAllDerivedDefinitions("Processor");
|
|
|
|
std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName());
|
|
|
|
|
|
|
|
// Begin processor table
|
|
|
|
OS << "// Sorted (by key) array of values for CPU subtype.\n"
|
2011-07-17 15:36:56 +00:00
|
|
|
<< "llvm::SubtargetFeatureKV " << Target << "SubTypeKV[] = {\n";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each processor
|
|
|
|
for (unsigned i = 0, N = ProcessorList.size(); i < N;) {
|
|
|
|
// Next processor
|
|
|
|
Record *Processor = ProcessorList[i];
|
|
|
|
|
|
|
|
const std::string &Name = Processor->getValueAsString("Name");
|
2011-05-02 19:34:44 +00:00
|
|
|
const std::vector<Record*> &FeatureList =
|
2009-06-02 17:52:33 +00:00
|
|
|
Processor->getValueAsListOfDefs("Features");
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Emit as { "cpu", "description", f1 | f2 | ... fn },
|
|
|
|
OS << " { "
|
|
|
|
<< "\"" << Name << "\", "
|
|
|
|
<< "\"Select the " << Name << " processor\", ";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
if (FeatureList.empty()) {
|
2011-05-02 19:34:44 +00:00
|
|
|
OS << "0ULL";
|
2009-06-02 17:52:33 +00:00
|
|
|
} else {
|
|
|
|
for (unsigned j = 0, M = FeatureList.size(); j < M;) {
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << Target << "::" << FeatureList[j]->getName();
|
2009-06-02 17:52:33 +00:00
|
|
|
if (++j < M) OS << " | ";
|
|
|
|
}
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// The "0" is for the "implies" section of this data structure.
|
2011-05-02 19:34:44 +00:00
|
|
|
OS << ", 0ULL }";
|
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Depending on 'if more in the list' emit comma
|
|
|
|
if (++i < N) OS << ",";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << "\n";
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// End processor table
|
|
|
|
OS << "};\n";
|
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
return ProcessorList.size();
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// CollectAllItinClasses - Gathers and enumerates all the itinerary classes.
|
|
|
|
// Returns itinerary class count.
|
|
|
|
//
|
2011-02-20 12:57:14 +00:00
|
|
|
unsigned SubtargetEmitter::
|
|
|
|
CollectAllItinClasses(raw_ostream &OS,
|
|
|
|
std::map<std::string, unsigned> &ItinClassesMap,
|
|
|
|
std::vector<Record*> &ItinClassList) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each itinerary class
|
|
|
|
unsigned N = ItinClassList.size();
|
|
|
|
for (unsigned i = 0; i < N; i++) {
|
|
|
|
// Next itinerary class
|
|
|
|
const Record *ItinClass = ItinClassList[i];
|
|
|
|
// Get name of itinerary class
|
|
|
|
// Assign itinerary class a unique number
|
|
|
|
ItinClassesMap[ItinClass->getName()] = i;
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Return itinerary class count
|
|
|
|
return N;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-10-14 17:57:32 +00:00
|
|
|
// FormItineraryStageString - Compose a string containing the stage
|
|
|
|
// data initialization for the specified itinerary. N is the number
|
|
|
|
// of stages.
|
2009-06-02 17:52:33 +00:00
|
|
|
//
|
2010-05-04 16:11:02 +00:00
|
|
|
void SubtargetEmitter::FormItineraryStageString(const std::string &Name,
|
|
|
|
Record *ItinData,
|
2009-10-14 17:57:32 +00:00
|
|
|
std::string &ItinString,
|
|
|
|
unsigned &NStages) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get states list
|
|
|
|
const std::vector<Record*> &StageList =
|
|
|
|
ItinData->getValueAsListOfDefs("Stages");
|
|
|
|
|
|
|
|
// For each stage
|
|
|
|
unsigned N = NStages = StageList.size();
|
|
|
|
for (unsigned i = 0; i < N;) {
|
|
|
|
// Next stage
|
|
|
|
const Record *Stage = StageList[i];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2010-05-04 16:11:02 +00:00
|
|
|
// Form string as ,{ cycles, u1 | u2 | ... | un, timeinc, kind }
|
2009-06-02 17:52:33 +00:00
|
|
|
int Cycles = Stage->getValueAsInt("Cycles");
|
|
|
|
ItinString += " { " + itostr(Cycles) + ", ";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get unit list
|
|
|
|
const std::vector<Record*> &UnitList = Stage->getValueAsListOfDefs("Units");
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each unit
|
|
|
|
for (unsigned j = 0, M = UnitList.size(); j < M;) {
|
|
|
|
// Add name and bitwise or
|
2010-05-04 16:11:02 +00:00
|
|
|
ItinString += Name + "FU::" + UnitList[j]->getName();
|
2009-06-02 17:52:33 +00:00
|
|
|
if (++j < M) ItinString += " | ";
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
int TimeInc = Stage->getValueAsInt("TimeInc");
|
|
|
|
ItinString += ", " + itostr(TimeInc);
|
|
|
|
|
2010-05-04 16:11:02 +00:00
|
|
|
int Kind = Stage->getValueAsInt("Kind");
|
|
|
|
ItinString += ", (llvm::InstrStage::ReservationKinds)" + itostr(Kind);
|
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Close off stage
|
|
|
|
ItinString += " }";
|
|
|
|
if (++i < N) ItinString += ", ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-10-14 17:57:32 +00:00
|
|
|
// FormItineraryOperandCycleString - Compose a string containing the
|
|
|
|
// operand cycle initialization for the specified itinerary. N is the
|
|
|
|
// number of operands that has cycles specified.
|
|
|
|
//
|
|
|
|
void SubtargetEmitter::FormItineraryOperandCycleString(Record *ItinData,
|
|
|
|
std::string &ItinString, unsigned &NOperandCycles) {
|
|
|
|
// Get operand cycle list
|
|
|
|
const std::vector<int64_t> &OperandCycleList =
|
|
|
|
ItinData->getValueAsListOfInts("OperandCycles");
|
|
|
|
|
|
|
|
// For each operand cycle
|
|
|
|
unsigned N = NOperandCycles = OperandCycleList.size();
|
|
|
|
for (unsigned i = 0; i < N;) {
|
|
|
|
// Next operand cycle
|
|
|
|
const int OCycle = OperandCycleList[i];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
ItinString += " " + itostr(OCycle);
|
|
|
|
if (++i < N) ItinString += ", ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-20 12:57:14 +00:00
|
|
|
void SubtargetEmitter::FormItineraryBypassString(const std::string &Name,
|
|
|
|
Record *ItinData,
|
|
|
|
std::string &ItinString,
|
|
|
|
unsigned NOperandCycles) {
|
|
|
|
const std::vector<Record*> &BypassList =
|
|
|
|
ItinData->getValueAsListOfDefs("Bypasses");
|
|
|
|
unsigned N = BypassList.size();
|
|
|
|
unsigned i = 0;
|
|
|
|
for (; i < N;) {
|
|
|
|
ItinString += Name + "Bypass::" + BypassList[i]->getName();
|
|
|
|
if (++i < NOperandCycles) ItinString += ", ";
|
|
|
|
}
|
|
|
|
for (; i < NOperandCycles;) {
|
|
|
|
ItinString += " 0";
|
|
|
|
if (++i < NOperandCycles) ItinString += ", ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
//
|
|
|
|
// EmitStageAndOperandCycleData - Generate unique itinerary stages and
|
|
|
|
// operand cycle tables. Record itineraries for processors.
|
2009-06-02 17:52:33 +00:00
|
|
|
//
|
2009-10-14 17:57:32 +00:00
|
|
|
void SubtargetEmitter::EmitStageAndOperandCycleData(raw_ostream &OS,
|
2009-06-02 17:52:33 +00:00
|
|
|
unsigned NItinClasses,
|
2011-02-20 12:57:14 +00:00
|
|
|
std::map<std::string, unsigned> &ItinClassesMap,
|
|
|
|
std::vector<Record*> &ItinClassList,
|
2009-06-02 17:52:33 +00:00
|
|
|
std::vector<std::vector<InstrItinerary> > &ProcList) {
|
|
|
|
// Gather processor iteraries
|
|
|
|
std::vector<Record*> ProcItinList =
|
|
|
|
Records.getAllDerivedDefinitions("ProcessorItineraries");
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// If just no itinerary then don't bother
|
|
|
|
if (ProcItinList.size() < 2) return;
|
|
|
|
|
2010-05-04 16:11:02 +00:00
|
|
|
// Emit functional units for all the itineraries.
|
|
|
|
for (unsigned i = 0, N = ProcItinList.size(); i < N; ++i) {
|
|
|
|
// Next record
|
|
|
|
Record *Proc = ProcItinList[i];
|
|
|
|
|
|
|
|
std::vector<Record*> FUs = Proc->getValueAsListOfDefs("FU");
|
|
|
|
if (FUs.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const std::string &Name = Proc->getName();
|
|
|
|
OS << "\n// Functional units for itineraries \"" << Name << "\"\n"
|
|
|
|
<< "namespace " << Name << "FU {\n";
|
|
|
|
|
|
|
|
for (unsigned j = 0, FUN = FUs.size(); j < FUN; ++j)
|
|
|
|
OS << " const unsigned " << FUs[j]->getName()
|
|
|
|
<< " = 1 << " << j << ";\n";
|
|
|
|
|
|
|
|
OS << "}\n";
|
2011-02-20 12:57:14 +00:00
|
|
|
|
|
|
|
std::vector<Record*> BPs = Proc->getValueAsListOfDefs("BP");
|
|
|
|
if (BPs.size()) {
|
|
|
|
OS << "\n// Pipeline forwarding pathes for itineraries \"" << Name
|
|
|
|
<< "\"\n" << "namespace " << Name << "Bypass {\n";
|
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << " unsigned NoBypass = 0;\n";
|
2011-02-20 12:57:14 +00:00
|
|
|
for (unsigned j = 0, BPN = BPs.size(); j < BPN; ++j)
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << " unsigned " << BPs[j]->getName()
|
2011-02-20 12:57:14 +00:00
|
|
|
<< " = 1 << " << j << ";\n";
|
|
|
|
|
|
|
|
OS << "}\n";
|
|
|
|
}
|
2010-05-04 16:11:02 +00:00
|
|
|
}
|
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Begin stages table
|
2011-07-17 15:36:56 +00:00
|
|
|
std::string StageTable = "\nllvm::InstrStage " + Target + "Stages[] = {\n";
|
2010-05-04 16:11:02 +00:00
|
|
|
StageTable += " { 0, 0, 0, llvm::InstrStage::Required }, // No itinerary\n";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
// Begin operand cycle table
|
2011-07-17 15:36:56 +00:00
|
|
|
std::string OperandCycleTable = "unsigned " + Target +
|
|
|
|
"OperandCycles[] = {\n";
|
2009-10-14 17:57:32 +00:00
|
|
|
OperandCycleTable += " 0, // No itinerary\n";
|
2011-02-20 12:57:14 +00:00
|
|
|
|
|
|
|
// Begin pipeline bypass table
|
2011-07-17 15:36:56 +00:00
|
|
|
std::string BypassTable = "unsigned " + Target +
|
|
|
|
"ForwardingPathes[] = {\n";
|
2011-02-20 12:57:14 +00:00
|
|
|
BypassTable += " 0, // No itinerary\n";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
unsigned StageCount = 1, OperandCycleCount = 1;
|
2011-02-20 12:57:14 +00:00
|
|
|
std::map<std::string, unsigned> ItinStageMap, ItinOperandMap;
|
2009-06-02 17:52:33 +00:00
|
|
|
for (unsigned i = 0, N = ProcItinList.size(); i < N; i++) {
|
|
|
|
// Next record
|
|
|
|
Record *Proc = ProcItinList[i];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get processor itinerary name
|
|
|
|
const std::string &Name = Proc->getName();
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Skip default
|
|
|
|
if (Name == "NoItineraries") continue;
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Create and expand processor itinerary to cover all itinerary classes
|
|
|
|
std::vector<InstrItinerary> ItinList;
|
|
|
|
ItinList.resize(NItinClasses);
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get itinerary data list
|
|
|
|
std::vector<Record*> ItinDataList = Proc->getValueAsListOfDefs("IID");
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each itinerary data
|
|
|
|
for (unsigned j = 0, M = ItinDataList.size(); j < M; j++) {
|
|
|
|
// Next itinerary data
|
|
|
|
Record *ItinData = ItinDataList[j];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get string and stage count
|
2009-10-14 17:57:32 +00:00
|
|
|
std::string ItinStageString;
|
2009-06-02 17:52:33 +00:00
|
|
|
unsigned NStages;
|
2010-05-04 16:11:02 +00:00
|
|
|
FormItineraryStageString(Name, ItinData, ItinStageString, NStages);
|
2009-10-14 17:57:32 +00:00
|
|
|
|
|
|
|
// Get string and operand cycle count
|
|
|
|
std::string ItinOperandCycleString;
|
|
|
|
unsigned NOperandCycles;
|
|
|
|
FormItineraryOperandCycleString(ItinData, ItinOperandCycleString,
|
|
|
|
NOperandCycles);
|
|
|
|
|
2011-02-20 12:57:14 +00:00
|
|
|
std::string ItinBypassString;
|
|
|
|
FormItineraryBypassString(Name, ItinData, ItinBypassString,
|
|
|
|
NOperandCycles);
|
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
// Check to see if stage already exists and create if it doesn't
|
|
|
|
unsigned FindStage = 0;
|
|
|
|
if (NStages > 0) {
|
|
|
|
FindStage = ItinStageMap[ItinStageString];
|
|
|
|
if (FindStage == 0) {
|
2011-05-02 19:34:44 +00:00
|
|
|
// Emit as { cycles, u1 | u2 | ... | un, timeinc }, // indices
|
|
|
|
StageTable += ItinStageString + ", // " + itostr(StageCount);
|
|
|
|
if (NStages > 1)
|
|
|
|
StageTable += "-" + itostr(StageCount + NStages - 1);
|
|
|
|
StageTable += "\n";
|
2009-10-14 17:57:32 +00:00
|
|
|
// Record Itin class number.
|
|
|
|
ItinStageMap[ItinStageString] = FindStage = StageCount;
|
|
|
|
StageCount += NStages;
|
|
|
|
}
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
// Check to see if operand cycle already exists and create if it doesn't
|
|
|
|
unsigned FindOperandCycle = 0;
|
|
|
|
if (NOperandCycles > 0) {
|
2011-02-20 12:57:14 +00:00
|
|
|
std::string ItinOperandString = ItinOperandCycleString+ItinBypassString;
|
|
|
|
FindOperandCycle = ItinOperandMap[ItinOperandString];
|
2009-10-14 17:57:32 +00:00
|
|
|
if (FindOperandCycle == 0) {
|
|
|
|
// Emit as cycle, // index
|
2011-05-02 19:34:44 +00:00
|
|
|
OperandCycleTable += ItinOperandCycleString + ", // ";
|
|
|
|
std::string OperandIdxComment = itostr(OperandCycleCount);
|
|
|
|
if (NOperandCycles > 1)
|
|
|
|
OperandIdxComment += "-"
|
|
|
|
+ itostr(OperandCycleCount + NOperandCycles - 1);
|
|
|
|
OperandCycleTable += OperandIdxComment + "\n";
|
2009-10-14 17:57:32 +00:00
|
|
|
// Record Itin class number.
|
2011-05-02 19:34:44 +00:00
|
|
|
ItinOperandMap[ItinOperandCycleString] =
|
2009-10-14 17:57:32 +00:00
|
|
|
FindOperandCycle = OperandCycleCount;
|
2011-02-20 12:57:14 +00:00
|
|
|
// Emit as bypass, // index
|
2011-05-02 19:34:44 +00:00
|
|
|
BypassTable += ItinBypassString + ", // " + OperandIdxComment + "\n";
|
2009-10-14 17:57:32 +00:00
|
|
|
OperandCycleCount += NOperandCycles;
|
|
|
|
}
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Locate where to inject into processor itinerary table
|
|
|
|
const std::string &Name = ItinData->getValueAsDef("TheClass")->getName();
|
2009-10-14 17:57:32 +00:00
|
|
|
unsigned Find = ItinClassesMap[Name];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2011-02-20 12:57:14 +00:00
|
|
|
// Set up itinerary as location and location + stage count
|
|
|
|
unsigned NumUOps = ItinClassList[Find]->getValueAsInt("NumMicroOps");
|
|
|
|
InstrItinerary Intinerary = { NumUOps, FindStage, FindStage + NStages,
|
|
|
|
FindOperandCycle,
|
|
|
|
FindOperandCycle + NOperandCycles};
|
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Inject - empty slots will be 0, 0
|
|
|
|
ItinList[Find] = Intinerary;
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Add process itinerary to list
|
|
|
|
ProcList.push_back(ItinList);
|
|
|
|
}
|
2011-02-20 12:57:14 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Closing stage
|
2010-05-04 16:11:02 +00:00
|
|
|
StageTable += " { 0, 0, 0, llvm::InstrStage::Required } // End itinerary\n";
|
2009-10-14 17:57:32 +00:00
|
|
|
StageTable += "};\n";
|
|
|
|
|
|
|
|
// Closing operand cycles
|
|
|
|
OperandCycleTable += " 0 // End itinerary\n";
|
|
|
|
OperandCycleTable += "};\n";
|
|
|
|
|
2011-02-20 12:57:14 +00:00
|
|
|
BypassTable += " 0 // End itinerary\n";
|
|
|
|
BypassTable += "};\n";
|
|
|
|
|
2009-10-14 17:57:32 +00:00
|
|
|
// Emit tables.
|
|
|
|
OS << StageTable;
|
|
|
|
OS << OperandCycleTable;
|
2011-02-20 12:57:14 +00:00
|
|
|
OS << BypassTable;
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EmitProcessorData - Generate data for processor itineraries.
|
|
|
|
//
|
2011-05-02 19:34:44 +00:00
|
|
|
void SubtargetEmitter::
|
|
|
|
EmitProcessorData(raw_ostream &OS,
|
|
|
|
std::vector<Record*> &ItinClassList,
|
|
|
|
std::vector<std::vector<InstrItinerary> > &ProcList) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// Get an iterator for processor itinerary stages
|
|
|
|
std::vector<std::vector<InstrItinerary> >::iterator
|
|
|
|
ProcListIter = ProcList.begin();
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each processor itinerary
|
|
|
|
std::vector<Record*> Itins =
|
|
|
|
Records.getAllDerivedDefinitions("ProcessorItineraries");
|
|
|
|
for (unsigned i = 0, N = Itins.size(); i < N; i++) {
|
|
|
|
// Next record
|
|
|
|
Record *Itin = Itins[i];
|
|
|
|
|
|
|
|
// Get processor itinerary name
|
|
|
|
const std::string &Name = Itin->getName();
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Skip default
|
|
|
|
if (Name == "NoItineraries") continue;
|
|
|
|
|
|
|
|
// Begin processor itinerary table
|
|
|
|
OS << "\n";
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "llvm::InstrItinerary " << Name << "[] = {\n";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each itinerary class
|
|
|
|
std::vector<InstrItinerary> &ItinList = *ProcListIter++;
|
2011-05-02 19:34:44 +00:00
|
|
|
assert(ItinList.size() == ItinClassList.size() && "bad itinerary");
|
2009-10-14 17:57:32 +00:00
|
|
|
for (unsigned j = 0, M = ItinList.size(); j < M; ++j) {
|
2009-06-02 17:52:33 +00:00
|
|
|
InstrItinerary &Intinerary = ItinList[j];
|
2011-05-02 19:34:44 +00:00
|
|
|
|
|
|
|
// Emit in the form of
|
2009-10-14 17:57:32 +00:00
|
|
|
// { firstStage, lastStage, firstCycle, lastCycle } // index
|
|
|
|
if (Intinerary.FirstStage == 0) {
|
2011-02-20 12:57:14 +00:00
|
|
|
OS << " { 1, 0, 0, 0, 0 }";
|
2009-06-02 17:52:33 +00:00
|
|
|
} else {
|
2011-02-20 12:57:14 +00:00
|
|
|
OS << " { " <<
|
|
|
|
Intinerary.NumMicroOps << ", " <<
|
2011-05-02 19:34:44 +00:00
|
|
|
Intinerary.FirstStage << ", " <<
|
|
|
|
Intinerary.LastStage << ", " <<
|
|
|
|
Intinerary.FirstOperandCycle << ", " <<
|
2009-10-14 17:57:32 +00:00
|
|
|
Intinerary.LastOperandCycle << " }";
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
|
|
|
OS << ", // " << j << " " << ItinClassList[j]->getName() << "\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// End processor itinerary table
|
2011-02-20 12:57:14 +00:00
|
|
|
OS << " { 1, ~0U, ~0U, ~0U, ~0U } // end marker\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << "};\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EmitProcessorLookup - generate cpu name to itinerary lookup table.
|
|
|
|
//
|
2009-07-04 13:58:26 +00:00
|
|
|
void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) {
|
2009-06-02 17:52:33 +00:00
|
|
|
// Gather and sort processor information
|
|
|
|
std::vector<Record*> ProcessorList =
|
|
|
|
Records.getAllDerivedDefinitions("Processor");
|
|
|
|
std::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName());
|
|
|
|
|
|
|
|
// Begin processor table
|
|
|
|
OS << "\n";
|
|
|
|
OS << "// Sorted (by key) array of itineraries for CPU subtype.\n"
|
2011-07-17 15:36:56 +00:00
|
|
|
<< "llvm::SubtargetInfoKV "
|
|
|
|
<< Target << "ProcItinKV[] = {\n";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// For each processor
|
|
|
|
for (unsigned i = 0, N = ProcessorList.size(); i < N;) {
|
|
|
|
// Next processor
|
|
|
|
Record *Processor = ProcessorList[i];
|
|
|
|
|
|
|
|
const std::string &Name = Processor->getValueAsString("Name");
|
|
|
|
const std::string &ProcItin =
|
|
|
|
Processor->getValueAsDef("ProcItin")->getName();
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Emit as { "cpu", procinit },
|
|
|
|
OS << " { "
|
|
|
|
<< "\"" << Name << "\", "
|
|
|
|
<< "(void *)&" << ProcItin;
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << " }";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Depending on ''if more in the list'' emit comma
|
|
|
|
if (++i < N) OS << ",";
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << "\n";
|
|
|
|
}
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// End processor table
|
|
|
|
OS << "};\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// EmitData - Emits all stages and itineries, folding common patterns.
|
|
|
|
//
|
2009-07-04 13:58:26 +00:00
|
|
|
void SubtargetEmitter::EmitData(raw_ostream &OS) {
|
2009-06-02 17:52:33 +00:00
|
|
|
std::map<std::string, unsigned> ItinClassesMap;
|
2011-02-20 12:57:14 +00:00
|
|
|
// Gather and sort all itinerary classes
|
|
|
|
std::vector<Record*> ItinClassList =
|
|
|
|
Records.getAllDerivedDefinitions("InstrItinClass");
|
|
|
|
std::sort(ItinClassList.begin(), ItinClassList.end(), LessRecord());
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
// Enumerate all the itinerary classes
|
2011-02-20 12:57:14 +00:00
|
|
|
unsigned NItinClasses = CollectAllItinClasses(OS, ItinClassesMap,
|
|
|
|
ItinClassList);
|
2009-06-02 17:52:33 +00:00
|
|
|
// Make sure the rest is worth the effort
|
|
|
|
HasItineraries = NItinClasses != 1; // Ignore NoItinerary.
|
2011-05-02 19:34:44 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
if (HasItineraries) {
|
2011-02-20 12:57:14 +00:00
|
|
|
std::vector<std::vector<InstrItinerary> > ProcList;
|
2009-06-02 17:52:33 +00:00
|
|
|
// Emit the stage data
|
2011-02-20 12:57:14 +00:00
|
|
|
EmitStageAndOperandCycleData(OS, NItinClasses, ItinClassesMap,
|
|
|
|
ItinClassList, ProcList);
|
2009-06-02 17:52:33 +00:00
|
|
|
// Emit the processor itinerary data
|
2011-05-02 19:34:44 +00:00
|
|
|
EmitProcessorData(OS, ItinClassList, ProcList);
|
2009-06-02 17:52:33 +00:00
|
|
|
// Emit the processor lookup data
|
|
|
|
EmitProcessorLookup(OS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ParseFeaturesFunction - Produces a subtarget specific function for parsing
|
|
|
|
// the subtarget features string.
|
|
|
|
//
|
2011-07-17 15:36:56 +00:00
|
|
|
void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS,
|
|
|
|
unsigned NumFeatures,
|
|
|
|
unsigned NumProcs) {
|
2009-06-02 17:52:33 +00:00
|
|
|
std::vector<Record*> Features =
|
|
|
|
Records.getAllDerivedDefinitions("SubtargetFeature");
|
|
|
|
std::sort(Features.begin(), Features.end(), LessRecord());
|
|
|
|
|
2011-05-02 19:34:44 +00:00
|
|
|
OS << "// ParseSubtargetFeatures - Parses features string setting specified\n"
|
|
|
|
<< "// subtarget options.\n"
|
2011-07-17 15:36:56 +00:00
|
|
|
<< "void llvm::";
|
2009-06-02 17:52:33 +00:00
|
|
|
OS << Target;
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "Subtarget::ParseSubtargetFeatures(StringRef CPU, StringRef FS) {\n"
|
2010-01-15 15:37:28 +00:00
|
|
|
<< " DEBUG(dbgs() << \"\\nFeatures:\" << FS);\n"
|
2011-07-17 15:36:56 +00:00
|
|
|
<< " DEBUG(dbgs() << \"\\nCPU:\" << CPU);\n";
|
|
|
|
|
|
|
|
if (Features.empty()) {
|
|
|
|
OS << "}\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << " uint64_t Bits = ReInitMCSubtargetInfo(CPU, FS);\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
|
|
|
|
for (unsigned i = 0; i < Features.size(); i++) {
|
|
|
|
// Next record
|
|
|
|
Record *R = Features[i];
|
|
|
|
const std::string &Instance = R->getName();
|
|
|
|
const std::string &Value = R->getValueAsString("Value");
|
|
|
|
const std::string &Attribute = R->getValueAsString("Attribute");
|
|
|
|
|
|
|
|
if (Value=="true" || Value=="false")
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << " if ((Bits & " << Target << "::"
|
|
|
|
<< Instance << ") != 0) "
|
2009-06-02 17:52:33 +00:00
|
|
|
<< Attribute << " = " << Value << ";\n";
|
|
|
|
else
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << " if ((Bits & " << Target << "::"
|
|
|
|
<< Instance << ") != 0 && "
|
|
|
|
<< Attribute << " < " << Value << ") "
|
|
|
|
<< Attribute << " = " << Value << ";\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "}\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// SubtargetEmitter::run - Main subtarget enumeration emitter.
|
|
|
|
//
|
2009-07-04 13:58:26 +00:00
|
|
|
void SubtargetEmitter::run(raw_ostream &OS) {
|
2011-02-20 12:57:14 +00:00
|
|
|
Target = CodeGenTarget(Records).getName();
|
2009-06-02 17:52:33 +00:00
|
|
|
|
|
|
|
EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
|
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "\n#ifdef GET_SUBTARGETINFO_ENUM\n";
|
|
|
|
OS << "#undef GET_SUBTARGETINFO_ENUM\n";
|
2010-05-04 16:11:02 +00:00
|
|
|
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "namespace llvm {\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
Enumeration(OS, "SubtargetFeature", true);
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "} // End llvm namespace \n";
|
|
|
|
OS << "#endif // GET_SUBTARGETINFO_ENUM\n\n";
|
|
|
|
|
|
|
|
OS << "\n#ifdef GET_SUBTARGETINFO_MC_DESC\n";
|
|
|
|
OS << "#undef GET_SUBTARGETINFO_MC_DESC\n";
|
|
|
|
|
|
|
|
OS << "namespace llvm {\n";
|
|
|
|
#if 0
|
|
|
|
OS << "namespace {\n";
|
|
|
|
#endif
|
|
|
|
unsigned NumFeatures = FeatureKeyValues(OS);
|
|
|
|
OS << "\n";
|
|
|
|
unsigned NumProcs = CPUKeyValues(OS);
|
|
|
|
OS << "\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
EmitData(OS);
|
2011-07-17 15:36:56 +00:00
|
|
|
OS << "\n";
|
|
|
|
#if 0
|
|
|
|
OS << "}\n";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// MCInstrInfo initialization routine.
|
|
|
|
OS << "static inline void Init" << Target
|
|
|
|
<< "MCSubtargetInfo(MCSubtargetInfo *II, "
|
|
|
|
<< "StringRef TT, StringRef CPU, StringRef FS) {\n";
|
|
|
|
OS << " II->InitMCSubtargetInfo(TT, CPU, FS, ";
|
|
|
|
if (NumFeatures)
|
|
|
|
OS << Target << "FeatureKV, ";
|
|
|
|
else
|
|
|
|
OS << "0, ";
|
|
|
|
if (NumProcs)
|
|
|
|
OS << Target << "SubTypeKV, ";
|
|
|
|
else
|
|
|
|
OS << "0, ";
|
|
|
|
if (HasItineraries) {
|
|
|
|
OS << Target << "ProcItinKV, "
|
|
|
|
<< Target << "Stages, "
|
|
|
|
<< Target << "OperandCycles, "
|
|
|
|
<< Target << "ForwardingPathes, ";
|
|
|
|
} else
|
|
|
|
OS << "0, 0, 0, 0, ";
|
|
|
|
OS << NumFeatures << ", " << NumProcs << ");\n}\n\n";
|
|
|
|
|
|
|
|
OS << "} // End llvm namespace \n";
|
|
|
|
|
|
|
|
OS << "#endif // GET_SUBTARGETINFO_MC_DESC\n\n";
|
|
|
|
|
|
|
|
OS << "\n#ifdef GET_SUBTARGETINFO_TARGET_DESC\n";
|
|
|
|
OS << "#undef GET_SUBTARGETINFO_TARGET_DESC\n";
|
|
|
|
|
|
|
|
OS << "#include \"llvm/Support/Debug.h\"\n";
|
|
|
|
OS << "#include \"llvm/Support/raw_ostream.h\"\n";
|
|
|
|
ParseFeaturesFunction(OS, NumFeatures, NumProcs);
|
|
|
|
|
|
|
|
OS << "#endif // GET_SUBTARGETINFO_TARGET_DESC\n\n";
|
|
|
|
|
|
|
|
// Create a TargetSubtargetInfo subclass to hide the MC layer initialization.
|
|
|
|
OS << "\n#ifdef GET_SUBTARGETINFO_HEADER\n";
|
|
|
|
OS << "#undef GET_SUBTARGETINFO_HEADER\n";
|
|
|
|
|
|
|
|
std::string ClassName = Target + "GenSubtargetInfo";
|
|
|
|
OS << "namespace llvm {\n";
|
|
|
|
OS << "struct " << ClassName << " : public TargetSubtargetInfo {\n"
|
|
|
|
<< " explicit " << ClassName << "(StringRef TT, StringRef CPU, "
|
|
|
|
<< "StringRef FS);\n"
|
|
|
|
<< "};\n";
|
|
|
|
OS << "} // End llvm namespace \n";
|
|
|
|
|
|
|
|
OS << "#endif // GET_SUBTARGETINFO_HEADER\n\n";
|
|
|
|
|
|
|
|
OS << "\n#ifdef GET_SUBTARGETINFO_CTOR\n";
|
|
|
|
OS << "#undef GET_SUBTARGETINFO_CTOR\n";
|
|
|
|
|
|
|
|
OS << "namespace llvm {\n";
|
|
|
|
OS << "extern llvm::SubtargetFeatureKV " << Target << "FeatureKV[];\n";
|
|
|
|
OS << "extern llvm::SubtargetFeatureKV " << Target << "SubTypeKV[];\n";
|
|
|
|
if (HasItineraries) {
|
|
|
|
OS << "extern llvm::SubtargetInfoKV " << Target << "ProcItinKV[];\n";
|
|
|
|
OS << "extern llvm::InstrStage " << Target << "Stages[];\n";
|
|
|
|
OS << "extern unsigned " << Target << "OperandCycles[];\n";
|
|
|
|
OS << "extern unsigned " << Target << "ForwardingPathes[];\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << ClassName << "::" << ClassName << "(StringRef TT, StringRef CPU, "
|
|
|
|
<< "StringRef FS)\n"
|
|
|
|
<< " : TargetSubtargetInfo() {\n"
|
|
|
|
<< " InitMCSubtargetInfo(TT, CPU, FS, ";
|
|
|
|
if (NumFeatures)
|
|
|
|
OS << Target << "FeatureKV, ";
|
|
|
|
else
|
|
|
|
OS << "0, ";
|
|
|
|
if (NumProcs)
|
|
|
|
OS << Target << "SubTypeKV, ";
|
|
|
|
else
|
|
|
|
OS << "0, ";
|
|
|
|
if (HasItineraries) {
|
|
|
|
OS << Target << "ProcItinKV, "
|
|
|
|
<< Target << "Stages, "
|
|
|
|
<< Target << "OperandCycles, "
|
|
|
|
<< Target << "ForwardingPathes, ";
|
|
|
|
} else
|
|
|
|
OS << "0, 0, 0, 0, ";
|
|
|
|
OS << NumFeatures << ", " << NumProcs << ");\n}\n\n";
|
|
|
|
OS << "} // End llvm namespace \n";
|
|
|
|
|
|
|
|
OS << "#endif // GET_SUBTARGETINFO_CTOR\n\n";
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|