Keep VC++ happy.
[oota-llvm.git] / include / llvm / Target / TargetInstrItineraries.h
1 //===-- llvm/Target/TargetInstrItineraries.h - Scheduling -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the James M. Laskey and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the structures used for instruction itineraries and
11 // states.  This is used by schedulers to determine instruction states and
12 // latencies.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H
17 #define LLVM_TARGET_TARGETINSTRITINERARIES_H
18
19 #include "llvm/Support/Debug.h"
20 #include <cassert>
21
22 namespace llvm {
23
24 //===----------------------------------------------------------------------===//
25 // Instruction stage - These values represent a step in the execution of an
26 // instruction.  The latency represents the number of discrete time slots used
27 // need to complete the stage.  Units represent the choice of functional units
28 // that can be used to complete the stage.  Eg. IntUnit1, IntUnit2.
29 //
30 struct InstrStage {
31   unsigned Cycles;  // Length of stage in machine cycles
32   unsigned Units;   // Choice of functional units
33 };
34
35
36 //===----------------------------------------------------------------------===//
37 // Instruction itinerary - An itinerary represents a sequential series of steps
38 // required to complete an instruction.  Itineraries are represented as
39 // sequences of instruction stages.
40 //
41 struct InstrItinerary {
42   unsigned First;    // Index of first stage in itinerary
43   unsigned Last;     // Index of last + 1 stage in itinerary
44 };
45
46
47
48 //===----------------------------------------------------------------------===//
49 // Instruction itinerary Data - Itinerary data supplied by a subtarget to be
50 // used by a target.
51 //
52 class InstrItineraryData {
53   InstrStage     *Stages;         // Array of stages selected
54   unsigned        NStages;        // Number of stages
55   InstrItinerary *Itineratries;   // Array of itineraries selected
56   unsigned        NItineraries;   // Number of itineraries (actually classes)
57
58 public:
59
60   //
61   // Ctors.
62   //
63   InstrItineraryData()
64   : Stages(NULL), NStages(0), Itineratries(NULL), NItineraries(0)
65   {}
66   InstrItineraryData(InstrStage *S, unsigned NS, InstrItinerary *I, unsigned NI)
67   : Stages(S), NStages(NS), Itineratries(I), NItineraries(NI)
68   {}
69   
70   //
71   // isEmpty - Returns true if there are no itineraries.
72   //
73   inline bool isEmpty() const { return NItineraries == 0; }
74   
75   //
76   // begin - Return the first stage of the itinerary.
77   // 
78   inline InstrStage *begin(unsigned ItinClassIndx) const {
79     assert(ItinClassIndx < NItineraries && "Itinerary index out of range");
80     unsigned StageIdx = Itineratries[ItinClassIndx].First;
81     assert(StageIdx < NStages && "Stage index out of range");
82     return Stages + StageIdx;
83   }
84
85   //
86   // end - Return the last+1 stage of the itinerary.
87   // 
88   inline InstrStage *end(unsigned ItinClassIndx) const {
89     assert(ItinClassIndx < NItineraries && "Itinerary index out of range");
90     unsigned StageIdx = Itineratries[ItinClassIndx].Last;
91     assert(StageIdx < NStages && "Stage index out of range");
92     return Stages + StageIdx;
93   }
94 };
95
96
97 } // End llvm namespace
98
99 #endif