#ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H
#define LLVM_TARGET_TARGETINSTRITINERARIES_H
-#include "llvm/Support/Debug.h"
#include <cassert>
namespace llvm {
// Instruction itinerary Data - Itinerary data supplied by a subtarget to be
// used by a target.
//
-class InstrItineraryData {
+struct InstrItineraryData {
InstrStage *Stages; // Array of stages selected
- unsigned NStages; // Number of stages
InstrItinerary *Itineratries; // Array of itineraries selected
- unsigned NItineraries; // Number of itineraries (actually classes)
-public:
-
- //
- // Ctors.
- //
- 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)
- {}
+//
+// Ctors.
+//
+ InstrItineraryData() : Stages(NULL), Itineratries(NULL) {}
+ InstrItineraryData(InstrStage *S, InstrItinerary *I) : Stages(S), Itineratries(I) {}
//
// 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.
//
inline InstrStage *begin(unsigned ItinClassIndx) const {
- assert(ItinClassIndx < NItineraries && "Itinerary index out of range");
unsigned StageIdx = Itineratries[ItinClassIndx].First;
- assert(StageIdx < NStages && "Stage index out of range");
return Stages + StageIdx;
}
// end - Return the last+1 stage of the itinerary.
//
inline InstrStage *end(unsigned ItinClassIndx) const {
- assert(ItinClassIndx < NItineraries && "Itinerary index out of range");
unsigned StageIdx = Itineratries[ItinClassIndx].Last;
- assert(StageIdx < NStages && "Stage index out of range");
return Stages + StageIdx;
}
};
// Form string as ,{ cycles, u1 | u2 | ... | un }
int Cycles = Stage->getValueAsInt("Cycles");
- ItinString += " ,{ " + itostr(Cycles) + ", ";
+ ItinString += " { " + itostr(Cycles) + ", ";
// Get unit list
std::vector<Record*> UnitList = Stage->getValueAsListOfDefs("Units");
// Begin stages table
OS << "static llvm::InstrStage Stages[] = {\n"
- " { 0, 0 } // No itinerary\n";
+ " { 0, 0 }, // No itinerary\n";
unsigned ItinEnum = 1;
std::map<std::string, unsigned> ItinMap;
// If new itinerary
if (Find == 0) {
- // Emit as ,{ cycles, u1 | u2 | ... | un } // index
- OS << ItinString << " // " << ItinEnum << "\n";
+ // Emit as { cycles, u1 | u2 | ... | un }, // index
+ OS << ItinString << ", // " << ItinEnum << "\n";
+ // Record Itin class number
ItinMap[ItinString] = Find = ItinEnum++;
}
ProcList.push_back(ItinList);
}
+ // Closing stage
+ OS << " { 0, 0 } // End itinerary\n";
// End stages table
OS << "};\n";
// Begin processor table
OS << "\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 (unsigned i = 0, N = ProcessorList.size(); i < N;) {
// Emit size of table
OS<<"\nenum {\n";
- OS<<" SubTypeInfoKVSize = sizeof(SubTypeInfoKV)/"
+ OS<<" ProcItinKVSize = sizeof(ProcItinKV)/"
"sizeof(llvm::SubtargetInfoKV)\n";
OS<<"};\n";
}
if (HasItineraries) {
OS << "\n"
<< " InstrItinerary *Itinerary = (InstrItinerary *)"
- "Features.getInfo(SubTypeInfoKV, SubTypeInfoKVSize);\n"
- " InstrItins = InstrItineraryData(Stages, StagesSize, "
- "Itinerary, ItinClassesSize);\n";
+ "Features.getInfo(ProcItinKV, ProcItinKVSize);\n"
+ " InstrItins = InstrItineraryData(Stages, Itinerary);\n";
}
OS << "}\n";