From 7f39c14f52262a154285df9180f5edcdabe2d7df Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Thu, 3 Nov 2005 22:47:41 +0000 Subject: [PATCH] 1. Remove ranges from itinerary data. 2. Tidy up the subtarget emittined code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24172 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetInstrItineraries.h | 27 +++++--------------- utils/TableGen/SubtargetEmitter.cpp | 20 ++++++++------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/include/llvm/Target/TargetInstrItineraries.h b/include/llvm/Target/TargetInstrItineraries.h index 9b2bb666c61..cccd4bcf1e7 100644 --- a/include/llvm/Target/TargetInstrItineraries.h +++ b/include/llvm/Target/TargetInstrItineraries.h @@ -16,7 +16,6 @@ #ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H #define LLVM_TARGET_TARGETINSTRITINERARIES_H -#include "llvm/Support/Debug.h" #include namespace llvm { @@ -49,36 +48,26 @@ struct InstrItinerary { // 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; } @@ -86,9 +75,7 @@ public: // 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; } }; diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp index 0ec780390cf..04701fda062 100644 --- a/utils/TableGen/SubtargetEmitter.cpp +++ b/utils/TableGen/SubtargetEmitter.cpp @@ -223,7 +223,7 @@ void SubtargetEmitter::FormItineraryString(Record *ItinData, // Form string as ,{ cycles, u1 | u2 | ... | un } int Cycles = Stage->getValueAsInt("Cycles"); - ItinString += " ,{ " + itostr(Cycles) + ", "; + ItinString += " { " + itostr(Cycles) + ", "; // Get unit list std::vector UnitList = Stage->getValueAsListOfDefs("Units"); @@ -260,7 +260,7 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS, // Begin stages table OS << "static llvm::InstrStage Stages[] = {\n" - " { 0, 0 } // No itinerary\n"; + " { 0, 0 }, // No itinerary\n"; unsigned ItinEnum = 1; std::map ItinMap; @@ -296,8 +296,9 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS, // 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++; } @@ -316,6 +317,8 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS, ProcList.push_back(ItinList); } + // Closing stage + OS << " { 0, 0 } // End itinerary\n"; // End stages table OS << "};\n"; @@ -390,7 +393,7 @@ void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) { // 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;) { @@ -418,7 +421,7 @@ void SubtargetEmitter::EmitProcessorLookup(std::ostream &OS) { // Emit size of table OS<<"\nenum {\n"; - OS<<" SubTypeInfoKVSize = sizeof(SubTypeInfoKV)/" + OS<<" ProcItinKVSize = sizeof(ProcItinKV)/" "sizeof(llvm::SubtargetInfoKV)\n"; OS<<"};\n"; } @@ -479,9 +482,8 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) { 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"; -- 2.34.1