forked from OSchip/llvm-project
Refactored to make room for more stuff (scheduling info.)
llvm-svn: 23975
This commit is contained in:
parent
db4621a5f5
commit
1b7369b1ae
|
@ -44,22 +44,13 @@ struct LessRecordFieldName {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// SubtargetEmitter::run - Main subtarget enumeration emitter.
|
||||
// FeatureEnumeration - Emit an enumeration of all the subtarget features.
|
||||
//
|
||||
void SubtargetEmitter::run(std::ostream &OS) {
|
||||
EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
|
||||
|
||||
void SubtargetEmitter::FeatureEnumeration(std::ostream &OS) {
|
||||
RecordList Features = Records.getAllDerivedDefinitions("SubtargetFeature");
|
||||
sort(Features.begin(), Features.end(), LessRecord());
|
||||
|
||||
RecordList Processors = Records.getAllDerivedDefinitions("Processor");
|
||||
sort(Processors.begin(), Processors.end(), LessRecordFieldName());
|
||||
|
||||
OS << "#include \"llvm/Target/SubtargetFeature.h\"\n\n";
|
||||
|
||||
{ // Feature enumeration
|
||||
int i = 0;
|
||||
|
||||
OS << "enum {\n";
|
||||
|
@ -75,9 +66,16 @@ void SubtargetEmitter::run(std::ostream &OS) {
|
|||
}
|
||||
|
||||
OS << "};\n";
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// FeatureKeyValues - Emit data of all the subtarget features. Used by command
|
||||
// line.
|
||||
//
|
||||
void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) {
|
||||
RecordList Features = Records.getAllDerivedDefinitions("SubtargetFeature");
|
||||
sort(Features.begin(), Features.end(), LessRecord());
|
||||
|
||||
{ // Feature key values
|
||||
OS << "\n"
|
||||
<< "// Sorted (by key) array of values for CPU features.\n"
|
||||
<< "static llvm::SubtargetFeatureKV FeatureKV[] = {\n";
|
||||
|
@ -93,9 +91,20 @@ void SubtargetEmitter::run(std::ostream &OS) {
|
|||
<< ((RI != E) ? " },\n" : " }\n");
|
||||
}
|
||||
OS << "};\n";
|
||||
}
|
||||
|
||||
{ // CPU key values
|
||||
OS<<"\nenum {\n";
|
||||
OS<<" FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV)\n";
|
||||
OS<<"};\n";
|
||||
}
|
||||
|
||||
//
|
||||
// CPUKeyValues - Emit data of all the subtarget processors. Used by command
|
||||
// line.
|
||||
//
|
||||
void SubtargetEmitter::CPUKeyValues(std::ostream &OS) {
|
||||
RecordList Processors = Records.getAllDerivedDefinitions("Processor");
|
||||
sort(Processors.begin(), Processors.end(), LessRecordFieldName());
|
||||
|
||||
OS << "\n"
|
||||
<< "// Sorted (by key) array of values for CPU subtype.\n"
|
||||
<< "static const llvm::SubtargetFeatureKV SubTypeKV[] = {\n";
|
||||
|
@ -130,10 +139,21 @@ void SubtargetEmitter::run(std::ostream &OS) {
|
|||
OS << ((RI != E) ? " },\n" : " }\n");
|
||||
}
|
||||
OS << "};\n";
|
||||
}
|
||||
|
||||
OS<<"\nenum {\n";
|
||||
OS<<" FeatureKVSize = sizeof(FeatureKV)/sizeof(llvm::SubtargetFeatureKV),\n";
|
||||
OS<<" SubTypeKVSize = sizeof(SubTypeKV)/sizeof(llvm::SubtargetFeatureKV)\n";
|
||||
OS<<"};\n";
|
||||
}
|
||||
|
||||
//
|
||||
// SubtargetEmitter::run - Main subtarget enumeration emitter.
|
||||
//
|
||||
void SubtargetEmitter::run(std::ostream &OS) {
|
||||
EmitSourceFileHeader("Subtarget Enumeration Source Fragment", OS);
|
||||
|
||||
OS << "#include \"llvm/Target/SubtargetFeature.h\"\n\n";
|
||||
|
||||
FeatureEnumeration(OS);
|
||||
FeatureKeyValues(OS);
|
||||
CPUKeyValues(OS);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,11 @@ namespace llvm {
|
|||
|
||||
class SubtargetEmitter : public TableGenBackend {
|
||||
RecordKeeper &Records;
|
||||
|
||||
void FeatureEnumeration(std::ostream &OS);
|
||||
void FeatureKeyValues(std::ostream &OS);
|
||||
void CPUKeyValues(std::ostream &OS);
|
||||
|
||||
public:
|
||||
SubtargetEmitter(RecordKeeper &R) : Records(R) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue