[llvm-commits] [llvm] r158215 - in /llvm/trunk: include/llvm/MC/MCInstrItineraries.h utils/TableGen/SubtargetEmitter.cpp

Andrew Trick atrick at apple.com
Fri Jun 8 11:25:48 PDT 2012


Author: atrick
Date: Fri Jun  8 13:25:47 2012
New Revision: 158215

URL: http://llvm.org/viewvc/llvm-project?rev=158215&view=rev
Log:
Sched itinerary fix: Avoid static initializers.

This fixes an accidental dependence on static initialization order that I introduced yesterday.

Thank you Lang!!!

Modified:
    llvm/trunk/include/llvm/MC/MCInstrItineraries.h
    llvm/trunk/utils/TableGen/SubtargetEmitter.cpp

Modified: llvm/trunk/include/llvm/MC/MCInstrItineraries.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInstrItineraries.h?rev=158215&r1=158214&r2=158215&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCInstrItineraries.h (original)
+++ llvm/trunk/include/llvm/MC/MCInstrItineraries.h Fri Jun  8 13:25:47 2012
@@ -111,6 +111,7 @@
   // IssueWidth is the maximum number of instructions that may be scheduled in
   // the same per-cycle group.
   unsigned IssueWidth;
+  static const unsigned DefaultIssueWidth = 1;
 
   // MinLatency is the minimum latency between a register write
   // followed by a data dependent read. This determines which
@@ -133,12 +134,14 @@
   //      Optional InstrItinerary OperandCycles provides expected latency.
   //      TODO: can't yet specify both min and expected latency per operand.
   int MinLatency;
+  static const unsigned DefaultMinLatency = -1;
 
   // LoadLatency is the expected latency of load instructions.
   //
   // If MinLatency >= 0, this may be overriden for individual load opcodes by
   // InstrItinerary OperandCycles.
   unsigned LoadLatency;
+  static const unsigned DefaultLoadLatency = 4;
 
   // HighLatency is the expected latency of "very high latency" operations.
   // See TargetInstrInfo::isHighLatencyDef().
@@ -146,9 +149,16 @@
   // likely to have some impact on scheduling heuristics.
   // If MinLatency >= 0, this may be overriden by InstrItinData OperandCycles.
   unsigned HighLatency;
+  static const unsigned DefaultHighLatency = 10;
 
-  InstrItineraryProps(): IssueWidth(1), MinLatency(-1), LoadLatency(4),
-                         HighLatency(10) {}
+  // Default's must be specified as static const literals so that tablegenerated
+  // target code can use it in static initializers. The defaults need to be
+  // initialized in this default ctor because some clients directly instantiate
+  // InstrItineraryData instead of using a generated itinerary.
+  InstrItineraryProps(): IssueWidth(DefaultMinLatency),
+                         MinLatency(DefaultMinLatency),
+                         LoadLatency(DefaultLoadLatency),
+                         HighLatency(DefaultHighLatency) {}
 
   InstrItineraryProps(unsigned iw, int ml, unsigned ll, unsigned hl):
     IssueWidth(iw), MinLatency(ml), LoadLatency(ll), HighLatency(hl) {}

Modified: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetEmitter.cpp?rev=158215&r1=158214&r2=158215&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Fri Jun  8 13:25:47 2012
@@ -485,7 +485,7 @@
   if (V >= 0)
     OS << V << Separator << " // " << Name;
   else
-    OS << "DefaultItineraryProps." << Name << Separator;
+    OS << "InstrItineraryProps::Default" << Name << Separator;
   OS << '\n';
 }
 
@@ -496,7 +496,6 @@
 EmitProcessorData(raw_ostream &OS,
                   std::vector<Record*> &ItinClassList,
                   std::vector<std::vector<InstrItinerary> > &ProcList) {
-  OS << "static const llvm::InstrItineraryProps " << "DefaultItineraryProps;";
 
   // Get an iterator for processor itinerary stages
   std::vector<std::vector<InstrItinerary> >::iterator





More information about the llvm-commits mailing list