1. Remove ranges from itinerary data.

2. Tidy up the subtarget emittined code.

llvm-svn: 24172
This commit is contained in:
Jim Laskey 2005-11-03 22:47:41 +00:00
parent 5f48179c85
commit d6d3afb05e
2 changed files with 18 additions and 29 deletions

View File

@ -16,7 +16,6 @@
#ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H #ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H
#define LLVM_TARGET_TARGETINSTRITINERARIES_H #define LLVM_TARGET_TARGETINSTRITINERARIES_H
#include "llvm/Support/Debug.h"
#include <cassert> #include <cassert>
namespace llvm { namespace llvm {
@ -49,36 +48,26 @@ struct InstrItinerary {
// Instruction itinerary Data - Itinerary data supplied by a subtarget to be // Instruction itinerary Data - Itinerary data supplied by a subtarget to be
// used by a target. // used by a target.
// //
class InstrItineraryData { struct InstrItineraryData {
InstrStage *Stages; // Array of stages selected InstrStage *Stages; // Array of stages selected
unsigned NStages; // Number of stages
InstrItinerary *Itineratries; // Array of itineraries selected InstrItinerary *Itineratries; // Array of itineraries selected
unsigned NItineraries; // Number of itineraries (actually classes)
public: //
// Ctors.
// //
// Ctors. InstrItineraryData() : Stages(NULL), Itineratries(NULL) {}
// InstrItineraryData(InstrStage *S, InstrItinerary *I) : Stages(S), Itineratries(I) {}
InstrItineraryData()
: Stages(NULL), NStages(0), Itineratries(NULL), NItineraries(0)
{}
InstrItineraryData(InstrStage *S, unsigned NS, InstrItinerary *I, unsigned NI)
: Stages(S), NStages(NS), Itineratries(I), NItineraries(NI)
{}
// //
// isEmpty - Returns true if there are no itineraries. // isEmpty - Returns true if there are no itineraries.
// //
inline bool isEmpty() const { return NItineraries == 0; } inline bool isEmpty() const { return Itineratries == NULL; }
// //
// begin - Return the first stage of the itinerary. // begin - Return the first stage of the itinerary.
// //
inline InstrStage *begin(unsigned ItinClassIndx) const { inline InstrStage *begin(unsigned ItinClassIndx) const {
assert(ItinClassIndx < NItineraries && "Itinerary index out of range");
unsigned StageIdx = Itineratries[ItinClassIndx].First; unsigned StageIdx = Itineratries[ItinClassIndx].First;
assert(StageIdx < NStages && "Stage index out of range");
return Stages + StageIdx; return Stages + StageIdx;
} }
@ -86,9 +75,7 @@ public:
// end - Return the last+1 stage of the itinerary. // end - Return the last+1 stage of the itinerary.
// //
inline InstrStage *end(unsigned ItinClassIndx) const { inline InstrStage *end(unsigned ItinClassIndx) const {
assert(ItinClassIndx < NItineraries && "Itinerary index out of range");
unsigned StageIdx = Itineratries[ItinClassIndx].Last; unsigned StageIdx = Itineratries[ItinClassIndx].Last;
assert(StageIdx < NStages && "Stage index out of range");
return Stages + StageIdx; return Stages + StageIdx;
} }
}; };

View File

@ -223,7 +223,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData,
// Form string as ,{ cycles, u1 | u2 | ... | un } // Form string as ,{ cycles, u1 | u2 | ... | un }
int Cycles = Stage->getValueAsInt("Cycles"); int Cycles = Stage->getValueAsInt("Cycles");
ItinString += " ,{ " + itostr(Cycles) + ", "; ItinString += " { " + itostr(Cycles) + ", ";
// Get unit list // Get unit list
std::vector<Record*> UnitList = Stage->getValueAsListOfDefs("Units"); std::vector<Record*> UnitList = Stage->getValueAsListOfDefs("Units");
@ -260,7 +260,7 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
// Begin stages table // Begin stages table
OS << "static llvm::InstrStage Stages[] = {\n" OS << "static llvm::InstrStage Stages[] = {\n"
" { 0, 0 } // No itinerary\n"; " { 0, 0 }, // No itinerary\n";
unsigned ItinEnum = 1; unsigned ItinEnum = 1;
std::map<std::string, unsigned> ItinMap; std::map<std::string, unsigned> ItinMap;
@ -296,8 +296,9 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
// If new itinerary // If new itinerary
if (Find == 0) { if (Find == 0) {
// Emit as ,{ cycles, u1 | u2 | ... | un } // index // Emit as { cycles, u1 | u2 | ... | un }, // index
OS << ItinString << " // " << ItinEnum << "\n"; OS << ItinString << ", // " << ItinEnum << "\n";
// Record Itin class number
ItinMap[ItinString] = Find = ItinEnum++; ItinMap[ItinString] = Find = ItinEnum++;
} }
@ -316,6 +317,8 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS,
ProcList.push_back(ItinList); ProcList.push_back(ItinList);
} }
// Closing stage
OS << " { 0, 0 } // End itinerary\n";
// End stages table // End stages table
OS << "};\n"; OS << "};\n";
@ -390,7 +393,7 @@ void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) {
// Begin processor table // Begin processor table
OS << "\n"; OS << "\n";
OS << "// Sorted (by key) array of itineraries for CPU subtype.\n" OS << "// Sorted (by key) array of itineraries for CPU subtype.\n"
<< "static const llvm::SubtargetInfoKV SubTypeInfoKV[] = {\n"; << "static const llvm::SubtargetInfoKV ProcItinKV[] = {\n";
// For each processor // For each processor
for (unsigned i = 0, N = ProcessorList.size(); i < N;) { for (unsigned i = 0, N = ProcessorList.size(); i < N;) {
@ -418,7 +421,7 @@ void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) {
// Emit size of table // Emit size of table
OS<<"\nenum {\n"; OS<<"\nenum {\n";
OS<<" SubTypeInfoKVSize = sizeof(SubTypeInfoKV)/" OS<<" ProcItinKVSize = sizeof(ProcItinKV)/"
"sizeof(llvm::SubtargetInfoKV)\n"; "sizeof(llvm::SubtargetInfoKV)\n";
OS<<"};\n"; OS<<"};\n";
} }
@ -479,9 +482,8 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) {
if (HasItineraries) { if (HasItineraries) {
OS << "\n" OS << "\n"
<< " InstrItinerary *Itinerary = (InstrItinerary *)" << " InstrItinerary *Itinerary = (InstrItinerary *)"
"Features.getInfo(SubTypeInfoKV, SubTypeInfoKVSize);\n" "Features.getInfo(ProcItinKV, ProcItinKVSize);\n"
" InstrItins = InstrItineraryData(Stages, StagesSize, " " InstrItins = InstrItineraryData(Stages, Itinerary);\n";
"Itinerary, ItinClassesSize);\n";
} }
OS << "}\n"; OS << "}\n";