1 //===- ScheduleDAGILP.h - ILP metric for ScheduleDAGInstrs ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Definition of an ILP metric for machine level instruction scheduling.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_SCHEDULEDAGILP_H
15 #define LLVM_CODEGEN_SCHEDULEDAGILP_H
17 #include "llvm/Support/DataTypes.h"
23 class ScheduleDAGInstrs;
26 /// \brief Represent the ILP of the subDAG rooted at a DAG node.
31 ILPValue(): InstrCount(0), Cycles(0) {}
33 ILPValue(unsigned count, unsigned cycles):
34 InstrCount(count), Cycles(cycles) {}
36 bool isValid() const { return Cycles > 0; }
38 // Order by the ILP metric's value.
39 bool operator<(ILPValue RHS) const {
40 return (uint64_t)InstrCount * RHS.Cycles
41 < (uint64_t)Cycles * RHS.InstrCount;
43 bool operator>(ILPValue RHS) const {
46 bool operator<=(ILPValue RHS) const {
47 return (uint64_t)InstrCount * RHS.Cycles
48 <= (uint64_t)Cycles * RHS.InstrCount;
50 bool operator>=(ILPValue RHS) const {
54 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
55 void print(raw_ostream &OS) const;
61 /// \brief Compute the values of each DAG node for an ILP metric.
63 /// This metric assumes that the DAG is a forest of trees with roots at the
64 /// bottom of the schedule.
65 class ScheduleDAGILP {
67 std::vector<ILPValue> ILPValues;
70 ScheduleDAGILP(bool IsBU): IsBottomUp(IsBU) {}
72 /// \brief Initialize the result data with the size of the DAG.
73 void resize(unsigned NumSUnits);
75 /// \brief Compute the ILP metric for the subDAG at this root.
76 void computeILP(const SUnit *Root);
78 /// \brief Get the ILP value for a DAG node.
79 ILPValue getILP(const SUnit *SU);
82 raw_ostream &operator<<(raw_ostream &OS, const ILPValue &Val);