summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineTraceMetrics.h
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-08-07 18:02:19 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-08-07 18:02:19 +0000
commit84ef6ba44394f983d985b02e328cbb2dd779e4b0 (patch)
tree812ee61ad1b74460235e7a09aafd4d7f8da79249 /lib/CodeGen/MachineTraceMetrics.h
parent3f5d1a2396915ebff20ce4f5d668ee5c839d1d91 (diff)
downloadllvm-84ef6ba44394f983d985b02e328cbb2dd779e4b0.tar.gz
llvm-84ef6ba44394f983d985b02e328cbb2dd779e4b0.tar.bz2
llvm-84ef6ba44394f983d985b02e328cbb2dd779e4b0.tar.xz
Add trace accessor methods, implement primitive if-conversion heuristic.
Compare the critical paths of the two traces through an if-conversion candidate. If the difference is larger than the branch brediction penalty, reject the if-conversion. If would never pay. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161433 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineTraceMetrics.h')
-rw-r--r--lib/CodeGen/MachineTraceMetrics.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/lib/CodeGen/MachineTraceMetrics.h b/lib/CodeGen/MachineTraceMetrics.h
index 33c2d95988..626b28b322 100644
--- a/lib/CodeGen/MachineTraceMetrics.h
+++ b/lib/CodeGen/MachineTraceMetrics.h
@@ -188,6 +188,19 @@ public:
void print(raw_ostream&) const;
};
+ /// 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;
+ };
+
/// 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.
@@ -195,6 +208,8 @@ public:
Ensemble &TE;
TraceBlockInfo &TBI;
+ unsigned getBlockNum() const { return &TBI - &TE.BlockInfo[0]; }
+
public:
explicit Trace(Ensemble &te, TraceBlockInfo &tbi) : TE(te), TBI(tbi) {}
void print(raw_ostream&) const;
@@ -203,19 +218,29 @@ public:
unsigned getInstrCount() const {
return TBI.InstrDepth + TBI.InstrHeight;
}
- };
- /// 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;
+ /// Return the resource dpeth of the top/bottom of the trace center block.
+ /// 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;
+
+ /// 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);
+ }
- /// Minimum number of cycles from this instruction is issued to the of the
- /// trace, as determined by data dependencies and instruction latencies.
- unsigned Height;
+ /// 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;
};
/// A trace ensemble is a collection of traces selected using the same