2005-10-27 18:18:05 +00:00
|
|
|
//===-- llvm/Target/TargetInstrItineraries.h - Scheduling -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-10-27 18:18:05 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file describes the structures used for instruction itineraries and
|
|
|
|
// states. This is used by schedulers to determine instruction states and
|
|
|
|
// latencies.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_TARGETINSTRITINERARIES_H
|
|
|
|
#define LLVM_TARGET_TARGETINSTRITINERARIES_H
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-11-20 22:09:52 +00:00
|
|
|
/// Instruction stage - These values represent a step in the execution of an
|
|
|
|
/// instruction. The latency represents the number of discrete time slots used
|
|
|
|
/// need to complete the stage. Units represent the choice of functional units
|
|
|
|
/// that can be used to complete the stage. Eg. IntUnit1, IntUnit2.
|
|
|
|
///
|
2005-10-27 18:18:05 +00:00
|
|
|
struct InstrStage {
|
2008-11-20 22:09:52 +00:00
|
|
|
unsigned Cycles; ///< Length of stage in machine cycles
|
|
|
|
unsigned Units; ///< Choice of functional units
|
2005-10-27 18:18:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-11-20 22:09:52 +00:00
|
|
|
/// Instruction itinerary - An itinerary represents a sequential series of steps
|
|
|
|
/// required to complete an instruction. Itineraries are represented as
|
|
|
|
/// sequences of instruction stages.
|
|
|
|
///
|
2005-10-27 18:18:05 +00:00
|
|
|
struct InstrItinerary {
|
2008-11-20 22:09:52 +00:00
|
|
|
unsigned First; ///< Index of first stage in itinerary
|
|
|
|
unsigned Last; ///< Index of last + 1 stage in itinerary
|
2005-10-27 18:18:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-01 20:06:59 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-11-20 22:09:52 +00:00
|
|
|
/// Instruction itinerary Data - Itinerary data supplied by a subtarget to be
|
|
|
|
/// used by a target.
|
|
|
|
///
|
2005-11-03 22:47:41 +00:00
|
|
|
struct InstrItineraryData {
|
2008-11-20 22:09:52 +00:00
|
|
|
const InstrStage *Stages; ///< Array of stages selected
|
|
|
|
const InstrItinerary *Itineratries; ///< Array of itineraries selected
|
2005-11-01 20:06:59 +00:00
|
|
|
|
2008-11-20 22:09:52 +00:00
|
|
|
/// Ctors.
|
|
|
|
///
|
2005-11-04 01:45:04 +00:00
|
|
|
InstrItineraryData() : Stages(0), Itineratries(0) {}
|
2008-03-25 21:45:14 +00:00
|
|
|
InstrItineraryData(const InstrStage *S, const InstrItinerary *I)
|
|
|
|
: Stages(S), Itineratries(I) {}
|
2005-11-01 20:06:59 +00:00
|
|
|
|
2008-11-20 22:09:52 +00:00
|
|
|
/// isEmpty - Returns true if there are no itineraries.
|
|
|
|
///
|
2008-11-20 22:10:21 +00:00
|
|
|
bool isEmpty() const { return Itineratries == 0; }
|
2005-11-01 20:06:59 +00:00
|
|
|
|
2008-11-20 22:09:52 +00:00
|
|
|
/// begin - Return the first stage of the itinerary.
|
|
|
|
///
|
2008-11-20 22:10:21 +00:00
|
|
|
const InstrStage *begin(unsigned ItinClassIndx) const {
|
2005-11-01 20:06:59 +00:00
|
|
|
unsigned StageIdx = Itineratries[ItinClassIndx].First;
|
|
|
|
return Stages + StageIdx;
|
|
|
|
}
|
|
|
|
|
2008-11-20 22:09:52 +00:00
|
|
|
/// end - Return the last+1 stage of the itinerary.
|
|
|
|
///
|
2008-11-20 22:10:21 +00:00
|
|
|
const InstrStage *end(unsigned ItinClassIndx) const {
|
2005-11-01 20:06:59 +00:00
|
|
|
unsigned StageIdx = Itineratries[ItinClassIndx].Last;
|
|
|
|
return Stages + StageIdx;
|
|
|
|
}
|
2008-11-21 00:12:10 +00:00
|
|
|
|
|
|
|
/// getLatency - Return the scheduling latency of the given class. A
|
|
|
|
/// simple latency value for an instruction is an over-simplification
|
|
|
|
/// for some architectures, but it's a reasonable first approximation.
|
|
|
|
///
|
|
|
|
unsigned getLatency(unsigned ItinClassIndx) const {
|
|
|
|
// If the target doesn't provide latency information, use a simple
|
|
|
|
// non-zero default value for all instructions.
|
|
|
|
if (isEmpty())
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
// Just sum the cycle count for each stage.
|
|
|
|
unsigned Latency = 0;
|
|
|
|
for (const InstrStage *IS = begin(ItinClassIndx), *E = end(ItinClassIndx);
|
|
|
|
IS != E; ++IS)
|
|
|
|
Latency += IS->Cycles;
|
|
|
|
return Latency;
|
|
|
|
}
|
2005-11-01 20:06:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-10-27 18:18:05 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|