2009-12-14 07:49:42 +01:00
|
|
|
//===---------------- lib/CodeGen/CalcSpillWeights.h ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_CALCSPILLWEIGHTS_H
|
|
|
|
#define LLVM_CODEGEN_CALCSPILLWEIGHTS_H
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2010-08-10 02:02:26 +02:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2009-12-14 07:49:42 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class LiveInterval;
|
2010-08-10 02:02:26 +02:00
|
|
|
class LiveIntervals;
|
|
|
|
class MachineLoopInfo;
|
|
|
|
|
|
|
|
/// VirtRegAuxInfo - Calculate auxiliary information for a virtual
|
|
|
|
/// register such as its spill weight and allocation hint.
|
|
|
|
class VirtRegAuxInfo {
|
|
|
|
MachineFunction &mf_;
|
|
|
|
LiveIntervals &lis_;
|
2010-08-10 19:07:22 +02:00
|
|
|
const MachineLoopInfo &loops_;
|
2010-08-10 02:02:26 +02:00
|
|
|
DenseMap<unsigned, float> hint_;
|
|
|
|
public:
|
|
|
|
VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis,
|
2010-08-10 19:07:22 +02:00
|
|
|
const MachineLoopInfo &loops) :
|
2010-08-10 02:02:26 +02:00
|
|
|
mf_(mf), lis_(lis), loops_(loops) {}
|
|
|
|
|
2010-08-10 20:37:40 +02:00
|
|
|
/// CalculateRegClass - recompute the register class for reg from its uses.
|
2010-08-10 02:02:26 +02:00
|
|
|
/// Since the register class can affect the allocation hint, this function
|
|
|
|
/// should be called before CalculateWeightAndHint if both are called.
|
2010-08-10 20:37:40 +02:00
|
|
|
void CalculateRegClass(unsigned reg);
|
2010-08-10 02:02:26 +02:00
|
|
|
|
|
|
|
/// CalculateWeightAndHint - (re)compute li's spill weight and allocation
|
|
|
|
/// hint.
|
|
|
|
void CalculateWeightAndHint(LiveInterval &li);
|
|
|
|
};
|
2009-12-14 07:49:42 +01:00
|
|
|
|
|
|
|
/// CalculateSpillWeights - Compute spill weights for all virtual register
|
|
|
|
/// live intervals.
|
|
|
|
class CalculateSpillWeights : public MachineFunctionPass {
|
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
|
2010-10-19 19:21:58 +02:00
|
|
|
CalculateSpillWeights() : MachineFunctionPass(ID) {
|
|
|
|
initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2009-12-14 07:49:42 +01:00
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &au) const;
|
|
|
|
|
2010-08-10 02:02:26 +02:00
|
|
|
virtual bool runOnMachineFunction(MachineFunction &fn);
|
2009-12-14 07:49:42 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Returns true if the given live interval is zero length.
|
|
|
|
bool isZeroLengthInterval(LiveInterval *li) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // LLVM_CODEGEN_CALCSPILLWEIGHTS_H
|