1 //===-- llvm/Target/TargetInstrItineraries.h - Scheduling -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file describes the structures used for instruction itineraries and
11 // states. This is used by schedulers to determine instruction states and
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H
17 #define LLVM_TARGET_TARGETINSTRITINERARIES_H
19 #include "llvm/Support/Debug.h"
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.
31 unsigned Cycles; // Length of stage in machine cycles
32 unsigned Units; // Choice of functional units
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.
41 struct InstrItinerary {
42 unsigned First; // Index of first stage in itinerary
43 unsigned Last; // Index of last + 1 stage in itinerary
48 //===----------------------------------------------------------------------===//
49 // Instruction itinerary Data - Itinerary data supplied by a subtarget to be
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)
64 : Stages(NULL), NStages(0), Itineratries(NULL), NItineraries(0)
66 InstrItineraryData(InstrStage *S, unsigned NS, InstrItinerary *I, unsigned NI)
67 : Stages(S), NStages(NS), Itineratries(I), NItineraries(NI)
71 // isEmpty - Returns true if there are no itineraries.
73 inline bool isEmpty() const { return NItineraries == 0; }
76 // begin - Return the first stage of the itinerary.
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;
86 // end - Return the last+1 stage of the itinerary.
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;
97 } // End llvm namespace