1
//===---------------- lib/CodeGen/CalcSpillWeights.h ------------*- 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
//===----------------------------------------------------------------------===//
11
#ifndef LLVM_CODEGEN_CALCSPILLWEIGHTS_H
12
#define LLVM_CODEGEN_CALCSPILLWEIGHTS_H
14
#include "llvm/CodeGen/MachineFunctionPass.h"
15
#include "llvm/ADT/DenseMap.h"
21
class MachineLoopInfo;
23
/// VirtRegAuxInfo - Calculate auxiliary information for a virtual
24
/// register such as its spill weight and allocation hint.
25
class VirtRegAuxInfo {
28
const MachineLoopInfo &loops_;
29
DenseMap<unsigned, float> hint_;
31
VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis,
32
const MachineLoopInfo &loops) :
33
mf_(mf), lis_(lis), loops_(loops) {}
35
/// CalculateRegClass - recompute the register class for reg from its uses.
36
/// Since the register class can affect the allocation hint, this function
37
/// should be called before CalculateWeightAndHint if both are called.
38
void CalculateRegClass(unsigned reg);
40
/// CalculateWeightAndHint - (re)compute li's spill weight and allocation
42
void CalculateWeightAndHint(LiveInterval &li);
45
/// CalculateSpillWeights - Compute spill weights for all virtual register
47
class CalculateSpillWeights : public MachineFunctionPass {
51
CalculateSpillWeights() : MachineFunctionPass(ID) {}
53
virtual void getAnalysisUsage(AnalysisUsage &au) const;
55
virtual bool runOnMachineFunction(MachineFunction &fn);
58
/// Returns true if the given live interval is zero length.
59
bool isZeroLengthInterval(LiveInterval *li) const;
64
#endif // LLVM_CODEGEN_CALCSPILLWEIGHTS_H