2012-07-26 18:38:11 +00:00
|
|
|
//===- lib/CodeGen/MachineTraceMetrics.h - Super-scalar metrics -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interface for the MachineTraceMetrics analysis pass
|
|
|
|
// that estimates CPU resource usage and critical data dependency paths through
|
|
|
|
// preferred traces. This is useful for super-scalar CPUs where execution speed
|
|
|
|
// can be limited both by data dependencies and by limited execution resources.
|
|
|
|
//
|
|
|
|
// Out-of-order CPUs will often be executing instructions from multiple basic
|
|
|
|
// blocks at the same time. This makes it difficult to estimate the resource
|
|
|
|
// usage accurately in a single basic block. Resources can be estimated better
|
|
|
|
// by looking at a trace through the current basic block.
|
|
|
|
//
|
|
|
|
// For every block, the MachineTraceMetrics pass will pick a preferred trace
|
|
|
|
// that passes through the block. The trace is chosen based on loop structure,
|
|
|
|
// branch probabilities, and resource usage. The intention is to pick likely
|
|
|
|
// traces that would be the most affected by code transformations.
|
|
|
|
//
|
|
|
|
// It is expensive to compute a full arbitrary trace for every block, so to
|
|
|
|
// save some computations, traces are chosen to be convergent. This means that
|
|
|
|
// if the traces through basic blocks A and B ever cross when moving away from
|
|
|
|
// A and B, they never diverge again. This applies in both directions - If the
|
|
|
|
// traces meet above A and B, they won't diverge when going further back.
|
|
|
|
//
|
|
|
|
// Traces tend to align with loops. The trace through a block in an inner loop
|
|
|
|
// will begin at the loop entry block and end at a back edge. If there are
|
|
|
|
// nested loops, the trace may begin and end at those instead.
|
|
|
|
//
|
|
|
|
// For each trace, we compute the critical path length, which is the number of
|
|
|
|
// cycles required to execute the trace when execution is limited by data
|
|
|
|
// dependencies only. We also compute the resource height, which is the number
|
|
|
|
// of cycles required to execute all instructions in the trace when ignoring
|
|
|
|
// data dependencies.
|
|
|
|
//
|
|
|
|
// Every instruction in the current block has a slack - the number of cycles
|
|
|
|
// execution of the instruction can be delayed without extending the critical
|
|
|
|
// path.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_CODEGEN_MACHINETRACEMETRICS_H
|
|
|
|
#define LLVM_CODEGEN_MACHINETRACEMETRICS_H
|
2012-07-26 18:38:11 +00:00
|
|
|
|
2012-08-01 22:36:00 +00:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2012-07-31 20:44:38 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2012-07-26 18:38:11 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2012-10-04 17:30:40 +00:00
|
|
|
#include "llvm/CodeGen/TargetSchedule.h"
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2012-07-31 20:44:38 +00:00
|
|
|
class InstrItineraryData;
|
2012-07-26 18:38:11 +00:00
|
|
|
class MachineBasicBlock;
|
2012-07-31 20:44:38 +00:00
|
|
|
class MachineInstr;
|
2012-07-26 18:38:11 +00:00
|
|
|
class MachineLoop;
|
2012-07-31 20:44:38 +00:00
|
|
|
class MachineLoopInfo;
|
|
|
|
class MachineRegisterInfo;
|
|
|
|
class TargetInstrInfo;
|
|
|
|
class TargetRegisterInfo;
|
2012-07-26 18:38:11 +00:00
|
|
|
class raw_ostream;
|
|
|
|
|
|
|
|
class MachineTraceMetrics : public MachineFunctionPass {
|
2012-07-30 18:34:11 +00:00
|
|
|
const MachineFunction *MF;
|
2012-07-26 18:38:11 +00:00
|
|
|
const TargetInstrInfo *TII;
|
|
|
|
const TargetRegisterInfo *TRI;
|
|
|
|
const MachineRegisterInfo *MRI;
|
|
|
|
const MachineLoopInfo *Loops;
|
2012-10-04 17:30:40 +00:00
|
|
|
TargetSchedModel SchedModel;
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
class Ensemble;
|
|
|
|
class Trace;
|
|
|
|
static char ID;
|
|
|
|
MachineTraceMetrics();
|
2014-03-07 09:26:03 +00:00
|
|
|
void getAnalysisUsage(AnalysisUsage&) const override;
|
|
|
|
bool runOnMachineFunction(MachineFunction&) override;
|
|
|
|
void releaseMemory() override;
|
|
|
|
void verifyAnalysis() const override;
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
friend class Ensemble;
|
|
|
|
friend class Trace;
|
|
|
|
|
|
|
|
/// Per-basic block information that doesn't depend on the trace through the
|
|
|
|
/// block.
|
|
|
|
struct FixedBlockInfo {
|
|
|
|
/// The number of non-trivial instructions in the block.
|
|
|
|
/// Doesn't count PHI and COPY instructions that are likely to be removed.
|
|
|
|
unsigned InstrCount;
|
|
|
|
|
|
|
|
/// True when the block contains calls.
|
|
|
|
bool HasCalls;
|
|
|
|
|
|
|
|
FixedBlockInfo() : InstrCount(~0u), HasCalls(false) {}
|
|
|
|
|
|
|
|
/// Returns true when resource information for this block has been computed.
|
|
|
|
bool hasResources() const { return InstrCount != ~0u; }
|
|
|
|
|
|
|
|
/// Invalidate resource information.
|
|
|
|
void invalidate() { InstrCount = ~0u; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Get the fixed resource information about MBB. Compute it on demand.
|
|
|
|
const FixedBlockInfo *getResources(const MachineBasicBlock*);
|
|
|
|
|
2013-04-02 17:49:51 +00:00
|
|
|
/// Get the scaled number of cycles used per processor resource in MBB.
|
|
|
|
/// This is an array with SchedModel.getNumProcResourceKinds() entries.
|
|
|
|
/// The getResources() function above must have been called first.
|
|
|
|
///
|
|
|
|
/// These numbers have already been scaled by SchedModel.getResourceFactor().
|
|
|
|
ArrayRef<unsigned> getProcResourceCycles(unsigned MBBNum) const;
|
|
|
|
|
2012-08-01 22:36:00 +00:00
|
|
|
/// A virtual register or regunit required by a basic block or its trace
|
|
|
|
/// successors.
|
|
|
|
struct LiveInReg {
|
|
|
|
/// The virtual register required, or a register unit.
|
|
|
|
unsigned Reg;
|
|
|
|
|
|
|
|
/// For virtual registers: Minimum height of the defining instruction.
|
|
|
|
/// For regunits: Height of the highest user in the trace.
|
|
|
|
unsigned Height;
|
|
|
|
|
|
|
|
LiveInReg(unsigned Reg, unsigned Height = 0) : Reg(Reg), Height(Height) {}
|
|
|
|
};
|
|
|
|
|
2012-07-26 18:38:11 +00:00
|
|
|
/// Per-basic block information that relates to a specific trace through the
|
|
|
|
/// block. Convergent traces means that only one of these is required per
|
|
|
|
/// block in a trace ensemble.
|
|
|
|
struct TraceBlockInfo {
|
|
|
|
/// Trace predecessor, or NULL for the first block in the trace.
|
2012-07-27 23:58:38 +00:00
|
|
|
/// Valid when hasValidDepth().
|
2012-07-26 18:38:11 +00:00
|
|
|
const MachineBasicBlock *Pred;
|
|
|
|
|
|
|
|
/// Trace successor, or NULL for the last block in the trace.
|
2012-07-27 23:58:38 +00:00
|
|
|
/// Valid when hasValidHeight().
|
2012-07-26 18:38:11 +00:00
|
|
|
const MachineBasicBlock *Succ;
|
|
|
|
|
2012-07-27 23:58:36 +00:00
|
|
|
/// The block number of the head of the trace. (When hasValidDepth()).
|
|
|
|
unsigned Head;
|
|
|
|
|
|
|
|
/// The block number of the tail of the trace. (When hasValidHeight()).
|
|
|
|
unsigned Tail;
|
|
|
|
|
2012-07-26 18:38:11 +00:00
|
|
|
/// Accumulated number of instructions in the trace above this block.
|
|
|
|
/// Does not include instructions in this block.
|
|
|
|
unsigned InstrDepth;
|
|
|
|
|
|
|
|
/// Accumulated number of instructions in the trace below this block.
|
|
|
|
/// Includes instructions in this block.
|
|
|
|
unsigned InstrHeight;
|
|
|
|
|
2012-07-31 20:44:38 +00:00
|
|
|
TraceBlockInfo() :
|
2014-04-14 00:51:57 +00:00
|
|
|
Pred(nullptr), Succ(nullptr),
|
2012-07-31 20:44:38 +00:00
|
|
|
InstrDepth(~0u), InstrHeight(~0u),
|
|
|
|
HasValidInstrDepths(false), HasValidInstrHeights(false) {}
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
/// Returns true if the depth resources have been computed from the trace
|
|
|
|
/// above this block.
|
|
|
|
bool hasValidDepth() const { return InstrDepth != ~0u; }
|
|
|
|
|
|
|
|
/// Returns true if the height resources have been computed from the trace
|
|
|
|
/// below this block.
|
|
|
|
bool hasValidHeight() const { return InstrHeight != ~0u; }
|
|
|
|
|
|
|
|
/// Invalidate depth resources when some block above this one has changed.
|
2012-07-31 20:44:38 +00:00
|
|
|
void invalidateDepth() { InstrDepth = ~0u; HasValidInstrDepths = false; }
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
/// Invalidate height resources when a block below this one has changed.
|
2012-07-31 20:44:38 +00:00
|
|
|
void invalidateHeight() { InstrHeight = ~0u; HasValidInstrHeights = false; }
|
|
|
|
|
2013-03-07 23:55:49 +00:00
|
|
|
/// Assuming that this is a dominator of TBI, determine if it contains
|
|
|
|
/// useful instruction depths. A dominating block can be above the current
|
|
|
|
/// trace head, and any dependencies from such a far away dominator are not
|
|
|
|
/// expected to affect the critical path.
|
|
|
|
///
|
2012-10-08 22:06:44 +00:00
|
|
|
/// Also returns true when TBI == this.
|
2013-03-07 23:55:49 +00:00
|
|
|
bool isUsefulDominator(const TraceBlockInfo &TBI) const {
|
|
|
|
// The trace for TBI may not even be calculated yet.
|
|
|
|
if (!hasValidDepth() || !TBI.hasValidDepth())
|
|
|
|
return false;
|
|
|
|
// Instruction depths are only comparable if the traces share a head.
|
|
|
|
if (Head != TBI.Head)
|
|
|
|
return false;
|
|
|
|
// It is almost always the case that TBI belongs to the same trace as
|
|
|
|
// this block, but rare convoluted cases involving irreducible control
|
|
|
|
// flow, a dominator may share a trace head without actually being on the
|
|
|
|
// same trace as TBI. This is not a big problem as long as it doesn't
|
|
|
|
// increase the instruction depth.
|
|
|
|
return HasValidInstrDepths && InstrDepth <= TBI.InstrDepth;
|
2012-10-08 22:06:44 +00:00
|
|
|
}
|
|
|
|
|
2012-07-31 20:44:38 +00:00
|
|
|
// Data-dependency-related information. Per-instruction depth and height
|
|
|
|
// are computed from data dependencies in the current trace, using
|
|
|
|
// itinerary data.
|
|
|
|
|
|
|
|
/// Instruction depths have been computed. This implies hasValidDepth().
|
|
|
|
bool HasValidInstrDepths;
|
|
|
|
|
|
|
|
/// Instruction heights have been computed. This implies hasValidHeight().
|
|
|
|
bool HasValidInstrHeights;
|
2012-07-27 23:58:38 +00:00
|
|
|
|
2012-08-02 18:45:54 +00:00
|
|
|
/// Critical path length. This is the number of cycles in the longest data
|
|
|
|
/// dependency chain through the trace. This is only valid when both
|
|
|
|
/// HasValidInstrDepths and HasValidInstrHeights are set.
|
|
|
|
unsigned CriticalPath;
|
|
|
|
|
2012-08-01 22:36:00 +00:00
|
|
|
/// Live-in registers. These registers are defined above the current block
|
|
|
|
/// and used by this block or a block below it.
|
|
|
|
/// This does not include PHI uses in the current block, but it does
|
|
|
|
/// include PHI uses in deeper blocks.
|
|
|
|
SmallVector<LiveInReg, 4> LiveIns;
|
|
|
|
|
2012-07-27 23:58:38 +00:00
|
|
|
void print(raw_ostream&) const;
|
2012-07-26 18:38:11 +00:00
|
|
|
};
|
|
|
|
|
2012-08-07 18:02:19 +00:00
|
|
|
/// InstrCycles represents the cycle height and depth of an instruction in a
|
|
|
|
/// trace.
|
|
|
|
struct InstrCycles {
|
|
|
|
/// Earliest issue cycle as determined by data dependencies and instruction
|
|
|
|
/// latencies from the beginning of the trace. Data dependencies from
|
|
|
|
/// before the trace are not included.
|
|
|
|
unsigned Depth;
|
|
|
|
|
|
|
|
/// Minimum number of cycles from this instruction is issued to the of the
|
|
|
|
/// trace, as determined by data dependencies and instruction latencies.
|
|
|
|
unsigned Height;
|
|
|
|
};
|
|
|
|
|
2012-07-26 18:38:11 +00:00
|
|
|
/// A trace represents a plausible sequence of executed basic blocks that
|
|
|
|
/// passes through the current basic block one. The Trace class serves as a
|
|
|
|
/// handle to internal cached data structures.
|
|
|
|
class Trace {
|
|
|
|
Ensemble &TE;
|
|
|
|
TraceBlockInfo &TBI;
|
|
|
|
|
2012-08-07 18:02:19 +00:00
|
|
|
unsigned getBlockNum() const { return &TBI - &TE.BlockInfo[0]; }
|
|
|
|
|
2012-07-26 18:38:11 +00:00
|
|
|
public:
|
|
|
|
explicit Trace(Ensemble &te, TraceBlockInfo &tbi) : TE(te), TBI(tbi) {}
|
|
|
|
void print(raw_ostream&) const;
|
|
|
|
|
|
|
|
/// Compute the total number of instructions in the trace.
|
|
|
|
unsigned getInstrCount() const {
|
|
|
|
return TBI.InstrDepth + TBI.InstrHeight;
|
|
|
|
}
|
|
|
|
|
2012-08-07 18:32:57 +00:00
|
|
|
/// Return the resource depth of the top/bottom of the trace center block.
|
2012-08-07 18:02:19 +00:00
|
|
|
/// This is the number of cycles required to execute all instructions from
|
|
|
|
/// the trace head to the trace center block. The resource depth only
|
|
|
|
/// considers execution resources, it ignores data dependencies.
|
|
|
|
/// When Bottom is set, instructions in the trace center block are included.
|
|
|
|
unsigned getResourceDepth(bool Bottom) const;
|
|
|
|
|
2012-08-10 22:27:27 +00:00
|
|
|
/// Return the resource length of the trace. This is the number of cycles
|
|
|
|
/// required to execute the instructions in the trace if they were all
|
|
|
|
/// independent, exposing the maximum instruction-level parallelism.
|
|
|
|
///
|
|
|
|
/// Any blocks in Extrablocks are included as if they were part of the
|
2013-04-27 03:54:20 +00:00
|
|
|
/// trace. Likewise, extra resources required by the specified scheduling
|
|
|
|
/// classes are included. For the caller to account for extra machine
|
|
|
|
/// instructions, it must first resolve each instruction's scheduling class.
|
2013-05-05 00:40:33 +00:00
|
|
|
unsigned getResourceLength(
|
2014-08-03 21:35:39 +00:00
|
|
|
ArrayRef<const MachineBasicBlock *> Extrablocks = None,
|
|
|
|
ArrayRef<const MCSchedClassDesc *> ExtraInstrs = None,
|
|
|
|
ArrayRef<const MCSchedClassDesc *> RemoveInstrs = None) const;
|
2012-08-10 22:27:27 +00:00
|
|
|
|
2012-08-07 18:02:19 +00:00
|
|
|
/// Return the length of the (data dependency) critical path through the
|
|
|
|
/// trace.
|
|
|
|
unsigned getCriticalPath() const { return TBI.CriticalPath; }
|
|
|
|
|
|
|
|
/// Return the depth and height of MI. The depth is only valid for
|
|
|
|
/// instructions in or above the trace center block. The height is only
|
|
|
|
/// valid for instructions in or below the trace center block.
|
|
|
|
InstrCycles getInstrCycles(const MachineInstr *MI) const {
|
|
|
|
return TE.Cycles.lookup(MI);
|
|
|
|
}
|
2012-07-31 20:44:38 +00:00
|
|
|
|
2012-08-07 18:02:19 +00:00
|
|
|
/// Return the slack of MI. This is the number of cycles MI can be delayed
|
|
|
|
/// before the critical path becomes longer.
|
|
|
|
/// MI must be an instruction in the trace center block.
|
|
|
|
unsigned getInstrSlack(const MachineInstr *MI) const;
|
2012-08-10 22:27:27 +00:00
|
|
|
|
|
|
|
/// Return the Depth of a PHI instruction in a trace center block successor.
|
|
|
|
/// The PHI does not have to be part of the trace.
|
|
|
|
unsigned getPHIDepth(const MachineInstr *PHI) const;
|
2014-08-03 21:35:39 +00:00
|
|
|
|
|
|
|
/// A dependence is useful if the basic block of the defining instruction
|
|
|
|
/// is part of the trace of the user instruction. It is assumed that DefMI
|
|
|
|
/// dominates UseMI (see also isUsefulDominator).
|
|
|
|
bool isDepInTrace(const MachineInstr *DefMI,
|
|
|
|
const MachineInstr *UseMI) const;
|
2012-07-31 20:44:38 +00:00
|
|
|
};
|
|
|
|
|
2012-07-26 18:38:11 +00:00
|
|
|
/// A trace ensemble is a collection of traces selected using the same
|
|
|
|
/// strategy, for example 'minimum resource height'. There is one trace for
|
|
|
|
/// every block in the function.
|
|
|
|
class Ensemble {
|
|
|
|
SmallVector<TraceBlockInfo, 4> BlockInfo;
|
2012-07-31 20:44:38 +00:00
|
|
|
DenseMap<const MachineInstr*, InstrCycles> Cycles;
|
2013-04-02 17:49:51 +00:00
|
|
|
SmallVector<unsigned, 0> ProcResourceDepths;
|
|
|
|
SmallVector<unsigned, 0> ProcResourceHeights;
|
2012-07-26 18:38:11 +00:00
|
|
|
friend class Trace;
|
|
|
|
|
|
|
|
void computeTrace(const MachineBasicBlock*);
|
|
|
|
void computeDepthResources(const MachineBasicBlock*);
|
|
|
|
void computeHeightResources(const MachineBasicBlock*);
|
2012-08-02 18:45:54 +00:00
|
|
|
unsigned computeCrossBlockCriticalPath(const TraceBlockInfo&);
|
2012-07-31 20:44:38 +00:00
|
|
|
void computeInstrDepths(const MachineBasicBlock*);
|
|
|
|
void computeInstrHeights(const MachineBasicBlock*);
|
2012-10-11 16:46:07 +00:00
|
|
|
void addLiveIns(const MachineInstr *DefMI, unsigned DefOp,
|
2012-08-01 22:36:00 +00:00
|
|
|
ArrayRef<const MachineBasicBlock*> Trace);
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
protected:
|
2012-07-31 20:25:13 +00:00
|
|
|
MachineTraceMetrics &MTM;
|
2012-07-26 18:38:11 +00:00
|
|
|
virtual const MachineBasicBlock *pickTracePred(const MachineBasicBlock*) =0;
|
|
|
|
virtual const MachineBasicBlock *pickTraceSucc(const MachineBasicBlock*) =0;
|
|
|
|
explicit Ensemble(MachineTraceMetrics*);
|
2012-07-30 18:34:11 +00:00
|
|
|
const MachineLoop *getLoopFor(const MachineBasicBlock*) const;
|
2012-07-26 18:38:11 +00:00
|
|
|
const TraceBlockInfo *getDepthResources(const MachineBasicBlock*) const;
|
|
|
|
const TraceBlockInfo *getHeightResources(const MachineBasicBlock*) const;
|
2013-04-02 17:49:51 +00:00
|
|
|
ArrayRef<unsigned> getProcResourceDepths(unsigned MBBNum) const;
|
|
|
|
ArrayRef<unsigned> getProcResourceHeights(unsigned MBBNum) const;
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~Ensemble();
|
2012-07-27 23:58:38 +00:00
|
|
|
virtual const char *getName() const =0;
|
|
|
|
void print(raw_ostream&) const;
|
2012-07-26 18:38:11 +00:00
|
|
|
void invalidate(const MachineBasicBlock *MBB);
|
2012-07-30 18:34:11 +00:00
|
|
|
void verify() const;
|
2012-07-26 18:38:11 +00:00
|
|
|
|
|
|
|
/// Get the trace that passes through MBB.
|
|
|
|
/// The trace is computed on demand.
|
|
|
|
Trace getTrace(const MachineBasicBlock *MBB);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Strategies for selecting traces.
|
|
|
|
enum Strategy {
|
|
|
|
/// Select the trace through a block that has the fewest instructions.
|
|
|
|
TS_MinInstrCount,
|
|
|
|
|
|
|
|
TS_NumStrategies
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Get the trace ensemble representing the given trace selection strategy.
|
|
|
|
/// The returned Ensemble object is owned by the MachineTraceMetrics analysis,
|
|
|
|
/// and valid for the lifetime of the analysis pass.
|
|
|
|
Ensemble *getEnsemble(Strategy);
|
|
|
|
|
|
|
|
/// Invalidate cached information about MBB. This must be called *before* MBB
|
|
|
|
/// is erased, or the CFG is otherwise changed.
|
2012-07-30 21:16:22 +00:00
|
|
|
///
|
|
|
|
/// This invalidates per-block information about resource usage for MBB only,
|
|
|
|
/// and it invalidates per-trace information for any trace that passes
|
|
|
|
/// through MBB.
|
|
|
|
///
|
|
|
|
/// Call Ensemble::getTrace() again to update any trace handles.
|
2012-07-26 18:38:11 +00:00
|
|
|
void invalidate(const MachineBasicBlock *MBB);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// One entry per basic block, indexed by block number.
|
|
|
|
SmallVector<FixedBlockInfo, 4> BlockInfo;
|
|
|
|
|
2013-04-02 17:49:51 +00:00
|
|
|
// Cycles consumed on each processor resource per block.
|
|
|
|
// The number of processor resource kinds is constant for a given subtarget,
|
|
|
|
// but it is not known at compile time. The number of cycles consumed by
|
|
|
|
// block B on processor resource R is at ProcResourceCycles[B*Kinds + R]
|
|
|
|
// where Kinds = SchedModel.getNumProcResourceKinds().
|
|
|
|
SmallVector<unsigned, 0> ProcResourceCycles;
|
|
|
|
|
2012-07-26 18:38:11 +00:00
|
|
|
// One ensemble per strategy.
|
|
|
|
Ensemble* Ensembles[TS_NumStrategies];
|
2013-04-02 17:49:51 +00:00
|
|
|
|
|
|
|
// Convert scaled resource usage to a cycle count that can be compared with
|
|
|
|
// latencies.
|
|
|
|
unsigned getCycles(unsigned Scaled) {
|
|
|
|
unsigned Factor = SchedModel.getLatencyFactor();
|
|
|
|
return (Scaled + Factor - 1) / Factor;
|
|
|
|
}
|
2012-07-26 18:38:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS,
|
|
|
|
const MachineTraceMetrics::Trace &Tr) {
|
|
|
|
Tr.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
2012-07-27 23:58:38 +00:00
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS,
|
|
|
|
const MachineTraceMetrics::Ensemble &En) {
|
|
|
|
En.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
2012-07-26 18:38:11 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|