1. Remove ranges from itinerary data.
[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 <cassert>
20
21 namespace llvm {
22
23 //===----------------------------------------------------------------------===//
24 // Instruction stage - These values represent a step in the execution of an
25 // instruction.  The latency represents the number of discrete time slots used
26 // need to complete the stage.  Units represent the choice of functional units
27 // that can be used to complete the stage.  Eg. IntUnit1, IntUnit2.
28 //
29 struct InstrStage {
30   unsigned Cycles;  // Length of stage in machine cycles
31   unsigned Units;   // Choice of functional units
32 };
33
34
35 //===----------------------------------------------------------------------===//
36 // Instruction itinerary - An itinerary represents a sequential series of steps
37 // required to complete an instruction.  Itineraries are represented as
38 // sequences of instruction stages.
39 //
40 struct InstrItinerary {
41   unsigned First;    // Index of first stage in itinerary
42   unsigned Last;     // Index of last + 1 stage in itinerary
43 };
44
45
46
47 //===----------------------------------------------------------------------===//
48 // Instruction itinerary Data - Itinerary data supplied by a subtarget to be
49 // used by a target.
50 //
51 struct InstrItineraryData {
52   InstrStage     *Stages;         // Array of stages selected
53   InstrItinerary *Itineratries;   // Array of itineraries selected
54
55 //
56 // Ctors.
57 //
58   InstrItineraryData() : Stages(NULL), Itineratries(NULL) {}
59   InstrItineraryData(InstrStage *S, InstrItinerary *I) : Stages(S), Itineratries(I) {}
60   
61   //
62   // isEmpty - Returns true if there are no itineraries.
63   //
64   inline bool isEmpty() const { return Itineratries == NULL; }
65   
66   //
67   // begin - Return the first stage of the itinerary.
68   // 
69   inline InstrStage *begin(unsigned ItinClassIndx) const {
70     unsigned StageIdx = Itineratries[ItinClassIndx].First;
71     return Stages + StageIdx;
72   }
73
74   //
75   // end - Return the last+1 stage of the itinerary.
76   // 
77   inline InstrStage *end(unsigned ItinClassIndx) const {
78     unsigned StageIdx = Itineratries[ItinClassIndx].Last;
79     return Stages + StageIdx;
80   }
81 };
82
83
84 } // End llvm namespace
85
86 #endif