LLVM API Documentation

TargetInstrItineraries.h

Go to the documentation of this file.
00001 //===-- llvm/Target/TargetInstrItineraries.h - Scheduling -------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the James M. Laskey and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file describes the structures used for instruction itineraries and
00011 // states.  This is used by schedulers to determine instruction states and
00012 // latencies.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H
00017 #define LLVM_TARGET_TARGETINSTRITINERARIES_H
00018 
00019 namespace llvm {
00020 
00021 //===----------------------------------------------------------------------===//
00022 // Instruction stage - These values represent a step in the execution of an
00023 // instruction.  The latency represents the number of discrete time slots used
00024 // need to complete the stage.  Units represent the choice of functional units
00025 // that can be used to complete the stage.  Eg. IntUnit1, IntUnit2.
00026 //
00027 struct InstrStage {
00028   unsigned Cycles;  // Length of stage in machine cycles
00029   unsigned Units;   // Choice of functional units
00030 };
00031 
00032 
00033 //===----------------------------------------------------------------------===//
00034 // Instruction itinerary - An itinerary represents a sequential series of steps
00035 // required to complete an instruction.  Itineraries are represented as
00036 // sequences of instruction stages.
00037 //
00038 struct InstrItinerary {
00039   unsigned First;    // Index of first stage in itinerary
00040   unsigned Last;     // Index of last + 1 stage in itinerary
00041 };
00042 
00043 
00044 
00045 //===----------------------------------------------------------------------===//
00046 // Instruction itinerary Data - Itinerary data supplied by a subtarget to be
00047 // used by a target.
00048 //
00049 struct InstrItineraryData {
00050   InstrStage     *Stages;         // Array of stages selected
00051   InstrItinerary *Itineratries;   // Array of itineraries selected
00052 
00053 //
00054 // Ctors.
00055 //
00056   InstrItineraryData() : Stages(0), Itineratries(0) {}
00057   InstrItineraryData(InstrStage *S, InstrItinerary *I) : Stages(S), Itineratries(I) {}
00058   
00059   //
00060   // isEmpty - Returns true if there are no itineraries.
00061   //
00062   inline bool isEmpty() const { return Itineratries == 0; }
00063   
00064   //
00065   // begin - Return the first stage of the itinerary.
00066   // 
00067   inline InstrStage *begin(unsigned ItinClassIndx) const {
00068     unsigned StageIdx = Itineratries[ItinClassIndx].First;
00069     return Stages + StageIdx;
00070   }
00071 
00072   //
00073   // end - Return the last+1 stage of the itinerary.
00074   // 
00075   inline InstrStage *end(unsigned ItinClassIndx) const {
00076     unsigned StageIdx = Itineratries[ItinClassIndx].Last;
00077     return Stages + StageIdx;
00078   }
00079 };
00080 
00081 
00082 } // End llvm namespace
00083 
00084 #endif