X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FSubtargetEmitter.cpp;h=b05b9968a2e83a149f09152e63f82c2a5a44d601;hb=f45a82890e34984ad1e1e259f8fb902caddfb0b1;hp=fc913e69e125e41eb66691c64d17f851720eb5c0;hpb=4222d806faae71ecc794cfdaa873817873c2f3d8;p=oota-llvm.git diff --git a/utils/TableGen/SubtargetEmitter.cpp b/utils/TableGen/SubtargetEmitter.cpp index fc913e69e12..b05b9968a2e 100644 --- a/utils/TableGen/SubtargetEmitter.cpp +++ b/utils/TableGen/SubtargetEmitter.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by James M. Laskey and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -19,24 +19,6 @@ #include using namespace llvm; -// -// Record sort by name function. -// -struct LessRecord { - bool operator()(const Record *Rec1, const Record *Rec2) const { - return Rec1->getName() < Rec2->getName(); - } -}; - -// -// Record sort by field "Name" function. -// -struct LessRecordFieldName { - bool operator()(const Record *Rec1, const Record *Rec2) const { - return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name"); - } -}; - // // Enumeration - Emit the specified class as an enumeration. // @@ -79,11 +61,11 @@ void SubtargetEmitter::FeatureKeyValues(std::ostream &OS) { // Gather and sort all the features std::vector FeatureList = Records.getAllDerivedDefinitions("SubtargetFeature"); - std::sort(FeatureList.begin(), FeatureList.end(), LessRecord()); + std::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName()); // Begin feature table OS << "// Sorted (by key) array of values for CPU features.\n" - << "static llvm::SubtargetFeatureKV FeatureKV[] = {\n"; + << "static const llvm::SubtargetFeatureKV FeatureKV[] = {\n"; // For each feature for (unsigned i = 0, N = FeatureList.size(); i < N; ++i) { @@ -269,9 +251,10 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS, if (ProcItinList.size() < 2) return; // Begin stages table - OS << "static llvm::InstrStage Stages[] = {\n" + OS << "static const llvm::InstrStage Stages[] = {\n" " { 0, 0 }, // No itinerary\n"; + unsigned StageCount = 1; unsigned ItinEnum = 1; std::map ItinMap; for (unsigned i = 0, N = ProcItinList.size(); i < N; i++) { @@ -308,8 +291,10 @@ void SubtargetEmitter::EmitStageData(std::ostream &OS, if (Find == 0) { // Emit as { cycles, u1 | u2 | ... | un }, // index OS << ItinString << ", // " << ItinEnum << "\n"; - // Record Itin class number - ItinMap[ItinString] = Find = ItinEnum++; + // Record Itin class number. + ItinMap[ItinString] = Find = StageCount; + StageCount += NStages; + ItinEnum++; } // Set up itinerary as location and location + stage count @@ -362,7 +347,7 @@ void SubtargetEmitter::EmitProcessorData(std::ostream &OS, // Begin processor itinerary table OS << "\n"; - OS << "static llvm::InstrItinerary " << Name << "[] = {\n"; + OS << "static const llvm::InstrItinerary " << Name << "[] = {\n"; // For each itinerary class std::vector &ItinList = *ProcListIter++; @@ -482,8 +467,12 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) { const std::string &Value = R->getValueAsString("Value"); const std::string &Attribute = R->getValueAsString("Attribute"); - OS << " if ((Bits & " << Instance << ") != 0) " - << Attribute << " = " << Value << ";\n"; + if (Value=="true" || Value=="false") + OS << " if ((Bits & " << Instance << ") != 0) " + << Attribute << " = " << Value << ";\n"; + else + OS << " if ((Bits & " << Instance << ") != 0 && " << Attribute << + " < " << Value << ") " << Attribute << " = " << Value << ";\n"; } if (HasItineraries) {