2004-07-23 19:56:30 +02:00
|
|
|
//===-- LiveIntervalAnalysis.h - Live Interval Analysis ---------*- C++ -*-===//
|
2003-11-20 04:32:25 +01:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2003-11-20 04:32:25 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2004-07-19 04:13:59 +02:00
|
|
|
// This file implements the LiveInterval analysis pass. Given some numbering of
|
|
|
|
// each the machine instructions (in this implemention depth-first order) an
|
|
|
|
// interval [i, j) is said to be a live interval for register v if there is no
|
2008-03-14 00:04:27 +01:00
|
|
|
// instruction with number j' > j such that v is live at j' and there is no
|
2004-07-19 04:13:59 +02:00
|
|
|
// instruction with number i' < i such that v is live at i'. In this
|
|
|
|
// implementation intervals can have holes, i.e. an interval might look like
|
|
|
|
// [1,20), [50,65), [1000,1001).
|
2003-11-20 04:32:25 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-07-23 19:56:30 +02:00
|
|
|
#ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
|
|
|
#define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H
|
2003-11-20 04:32:25 +01:00
|
|
|
|
2012-06-22 22:37:52 +02:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2009-08-19 22:52:54 +02:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2003-11-20 04:32:25 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2005-09-21 06:19:09 +02:00
|
|
|
#include "llvm/CodeGen/LiveInterval.h"
|
2009-11-04 00:52:08 +01:00
|
|
|
#include "llvm/CodeGen/SlotIndexes.h"
|
2007-02-15 06:59:24 +01:00
|
|
|
#include "llvm/ADT/BitVector.h"
|
2012-06-22 22:37:52 +02:00
|
|
|
#include "llvm/ADT/IndexedMap.h"
|
2009-01-07 03:08:57 +01:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2007-08-14 01:45:17 +02:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2007-09-05 23:46:51 +02:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2007-11-14 00:04:28 +01:00
|
|
|
#include <cmath>
|
2009-11-04 00:52:08 +01:00
|
|
|
#include <iterator>
|
2003-11-20 04:32:25 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2008-07-25 02:02:30 +02:00
|
|
|
class AliasAnalysis;
|
2012-06-06 00:02:15 +02:00
|
|
|
class LiveRangeCalc;
|
2004-08-04 11:46:26 +02:00
|
|
|
class LiveVariables;
|
2012-06-06 00:02:15 +02:00
|
|
|
class MachineDominatorTree;
|
2007-12-11 03:09:15 +01:00
|
|
|
class MachineLoopInfo;
|
2008-02-10 19:45:23 +01:00
|
|
|
class TargetRegisterInfo;
|
2007-12-31 05:13:23 +01:00
|
|
|
class MachineRegisterInfo;
|
Allow the live interval analysis pass to be a bit more aggressive about
numbering values in live ranges for physical registers.
The alpha backend currently generates code that looks like this:
vreg = preg
...
preg = vreg
use preg
...
preg = vreg
use preg
etc. Because vreg contains the value of preg coming in, each of the
copies back into preg contain that initial value as well.
In the case of the Alpha, this allows this testcase:
void "foo"(int %blah) {
store int 5, int *%MyVar
store int 12, int* %MyVar2
ret void
}
to compile to:
foo:
ldgp $29, 0($27)
ldiq $0,5
stl $0,MyVar
ldiq $0,12
stl $0,MyVar2
ret $31,($26),1
instead of:
foo:
ldgp $29, 0($27)
bis $29,$29,$0
ldiq $1,5
bis $0,$0,$29
stl $1,MyVar
ldiq $1,12
bis $0,$0,$29
stl $1,MyVar2
ret $31,($26),1
This does not seem to have any noticable effect on X86 code.
This fixes PR535.
llvm-svn: 20536
2005-03-10 00:05:19 +01:00
|
|
|
class TargetInstrInfo;
|
2007-04-17 22:32:26 +02:00
|
|
|
class TargetRegisterClass;
|
2004-08-04 11:46:26 +02:00
|
|
|
class VirtRegMap;
|
2010-08-12 22:01:23 +02:00
|
|
|
|
2004-08-04 11:46:26 +02:00
|
|
|
class LiveIntervals : public MachineFunctionPass {
|
2012-06-05 00:39:14 +02:00
|
|
|
MachineFunction* MF;
|
|
|
|
MachineRegisterInfo* MRI;
|
|
|
|
const TargetMachine* TM;
|
|
|
|
const TargetRegisterInfo* TRI;
|
|
|
|
const TargetInstrInfo* TII;
|
|
|
|
AliasAnalysis *AA;
|
|
|
|
LiveVariables* LV;
|
|
|
|
SlotIndexes* Indexes;
|
2012-06-06 00:02:15 +02:00
|
|
|
MachineDominatorTree *DomTree;
|
|
|
|
LiveRangeCalc *LRCalc;
|
2004-08-04 11:46:26 +02:00
|
|
|
|
2007-09-05 23:46:51 +02:00
|
|
|
/// Special pool allocator for VNInfo's (LiveInterval val#).
|
|
|
|
///
|
2010-03-30 22:16:45 +02:00
|
|
|
VNInfo::Allocator VNInfoAllocator;
|
2007-09-05 23:46:51 +02:00
|
|
|
|
2012-06-22 22:37:52 +02:00
|
|
|
/// Live interval pointers for all the virtual registers.
|
|
|
|
IndexedMap<LiveInterval*, VirtReg2IndexFunctor> VirtRegIntervals;
|
2004-08-04 11:46:26 +02:00
|
|
|
|
2012-06-05 00:39:14 +02:00
|
|
|
/// AllocatableRegs - A bit vector of allocatable registers.
|
|
|
|
BitVector AllocatableRegs;
|
2007-03-01 03:03:03 +01:00
|
|
|
|
2012-06-05 00:39:14 +02:00
|
|
|
/// ReservedRegs - A bit vector of reserved registers.
|
|
|
|
BitVector ReservedRegs;
|
2012-02-14 19:51:53 +01:00
|
|
|
|
2012-02-08 18:33:45 +01:00
|
|
|
/// RegMaskSlots - Sorted list of instructions with register mask operands.
|
|
|
|
/// Always use the 'r' slot, RegMasks are normal clobbers, not early
|
|
|
|
/// clobbers.
|
|
|
|
SmallVector<SlotIndex, 8> RegMaskSlots;
|
|
|
|
|
|
|
|
/// RegMaskBits - This vector is parallel to RegMaskSlots, it holds a
|
|
|
|
/// pointer to the corresponding register mask. This pointer can be
|
|
|
|
/// recomputed as:
|
|
|
|
///
|
|
|
|
/// MI = Indexes->getInstructionFromIndex(RegMaskSlot[N]);
|
|
|
|
/// unsigned OpNum = findRegMaskOperand(MI);
|
|
|
|
/// RegMaskBits[N] = MI->getOperand(OpNum).getRegMask();
|
|
|
|
///
|
|
|
|
/// This is kept in a separate vector partly because some standard
|
|
|
|
/// libraries don't support lower_bound() with mixed objects, partly to
|
|
|
|
/// improve locality when searching in RegMaskSlots.
|
|
|
|
/// Also see the comment in LiveInterval::find().
|
|
|
|
SmallVector<const uint32_t*, 8> RegMaskBits;
|
|
|
|
|
2012-02-10 02:26:29 +01:00
|
|
|
/// For each basic block number, keep (begin, size) pairs indexing into the
|
|
|
|
/// RegMaskSlots and RegMaskBits arrays.
|
|
|
|
/// Note that basic block numbers may not be layout contiguous, that's why
|
|
|
|
/// we can't just keep track of the first register mask in each basic
|
|
|
|
/// block.
|
|
|
|
SmallVector<std::pair<unsigned, unsigned>, 8> RegMaskBlocks;
|
|
|
|
|
2012-06-06 00:02:15 +02:00
|
|
|
/// RegUnitIntervals - Keep a live interval for each register unit as a way
|
|
|
|
/// of tracking fixed physreg interference.
|
|
|
|
SmallVector<LiveInterval*, 0> RegUnitIntervals;
|
|
|
|
|
2004-08-04 11:46:26 +02:00
|
|
|
public:
|
2007-05-06 15:37:16 +02:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2012-06-06 00:02:15 +02:00
|
|
|
LiveIntervals();
|
|
|
|
virtual ~LiveIntervals();
|
2007-05-01 23:15:47 +02:00
|
|
|
|
2010-03-01 21:59:38 +01:00
|
|
|
// Calculate the spill weight to assign to a single instruction.
|
|
|
|
static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth);
|
2007-11-12 07:35:08 +01:00
|
|
|
|
2012-06-22 22:37:52 +02:00
|
|
|
LiveInterval &getInterval(unsigned Reg) {
|
|
|
|
LiveInterval *LI = VirtRegIntervals[Reg];
|
|
|
|
assert(LI && "Interval does not exist for virtual register");
|
|
|
|
return *LI;
|
2004-08-04 11:46:26 +02:00
|
|
|
}
|
|
|
|
|
2012-06-22 22:37:52 +02:00
|
|
|
const LiveInterval &getInterval(unsigned Reg) const {
|
|
|
|
return const_cast<LiveIntervals*>(this)->getInterval(Reg);
|
2004-08-04 11:46:26 +02:00
|
|
|
}
|
|
|
|
|
2012-06-22 22:37:52 +02:00
|
|
|
bool hasInterval(unsigned Reg) const {
|
|
|
|
return VirtRegIntervals.inBounds(Reg) && VirtRegIntervals[Reg];
|
2007-02-19 22:49:54 +01:00
|
|
|
}
|
|
|
|
|
2010-08-10 02:02:26 +02:00
|
|
|
/// isAllocatable - is the physical register reg allocatable in the current
|
|
|
|
/// function?
|
|
|
|
bool isAllocatable(unsigned reg) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return AllocatableRegs.test(reg);
|
2010-08-10 02:02:26 +02:00
|
|
|
}
|
|
|
|
|
2012-02-14 19:51:53 +01:00
|
|
|
/// isReserved - is the physical register reg reserved in the current
|
|
|
|
/// function
|
|
|
|
bool isReserved(unsigned reg) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return ReservedRegs.test(reg);
|
2012-02-14 19:51:53 +01:00
|
|
|
}
|
|
|
|
|
2012-06-22 22:37:52 +02:00
|
|
|
// Interval creation.
|
|
|
|
LiveInterval &getOrCreateInterval(unsigned Reg) {
|
|
|
|
if (!hasInterval(Reg)) {
|
|
|
|
VirtRegIntervals.grow(Reg);
|
|
|
|
VirtRegIntervals[Reg] = createInterval(Reg);
|
|
|
|
}
|
|
|
|
return getInterval(Reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Interval removal.
|
|
|
|
void removeInterval(unsigned Reg) {
|
|
|
|
delete VirtRegIntervals[Reg];
|
|
|
|
VirtRegIntervals[Reg] = 0;
|
2007-06-08 19:18:56 +02:00
|
|
|
}
|
2009-02-08 12:04:35 +01:00
|
|
|
|
2008-06-05 19:15:43 +02:00
|
|
|
/// addLiveRangeToEndOfBlock - Given a register and an instruction,
|
|
|
|
/// adds a live range from that instruction to the end of its MBB.
|
|
|
|
LiveRange addLiveRangeToEndOfBlock(unsigned reg,
|
2009-09-04 22:41:11 +02:00
|
|
|
MachineInstr* startInst);
|
2004-08-04 11:46:26 +02:00
|
|
|
|
2011-02-08 01:03:05 +01:00
|
|
|
/// shrinkToUses - After removing some uses of a register, shrink its live
|
|
|
|
/// range to just the remaining uses. This method does not compute reaching
|
|
|
|
/// defs for new uses, and it doesn't remove dead defs.
|
|
|
|
/// Dead PHIDef values are marked as unused.
|
2011-03-08 00:29:10 +01:00
|
|
|
/// New dead machine instructions are added to the dead vector.
|
2011-03-17 21:37:07 +01:00
|
|
|
/// Return true if the interval may have been separated into multiple
|
|
|
|
/// connected components.
|
|
|
|
bool shrinkToUses(LiveInterval *li,
|
2011-03-08 00:29:10 +01:00
|
|
|
SmallVectorImpl<MachineInstr*> *dead = 0);
|
2011-02-08 01:03:05 +01:00
|
|
|
|
2012-09-18 01:03:25 +02:00
|
|
|
/// extendToIndices - Extend the live range of LI to reach all points in
|
|
|
|
/// Indices. The points in the Indices array must be jointly dominated by
|
|
|
|
/// existing defs in LI. PHI-defs are added as needed to maintain SSA form.
|
|
|
|
///
|
|
|
|
/// If a SlotIndex in Indices is the end index of a basic block, LI will be
|
|
|
|
/// extended to be live out of the basic block.
|
|
|
|
///
|
|
|
|
/// See also LiveRangeCalc::extend().
|
|
|
|
void extendToIndices(LiveInterval *LI, ArrayRef<SlotIndex> Indices);
|
|
|
|
|
|
|
|
/// pruneValue - If an LI value is live at Kill, prune its live range by
|
|
|
|
/// removing any liveness reachable from Kill. Add live range end points to
|
|
|
|
/// EndPoints such that extendToIndices(LI, EndPoints) will reconstruct the
|
|
|
|
/// value's live range.
|
|
|
|
///
|
|
|
|
/// Calling pruneValue() and extendToIndices() can be used to reconstruct
|
|
|
|
/// SSA form after adding defs to a virtual register.
|
|
|
|
void pruneValue(LiveInterval *LI, SlotIndex Kill,
|
|
|
|
SmallVectorImpl<SlotIndex> *EndPoints);
|
|
|
|
|
2011-01-12 23:28:48 +01:00
|
|
|
SlotIndexes *getSlotIndexes() const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes;
|
2011-01-12 23:28:48 +01:00
|
|
|
}
|
|
|
|
|
2012-06-05 03:06:12 +02:00
|
|
|
AliasAnalysis *getAliasAnalysis() const {
|
|
|
|
return AA;
|
|
|
|
}
|
|
|
|
|
2009-04-22 00:46:52 +02:00
|
|
|
/// isNotInMIMap - returns true if the specified machine instr has been
|
|
|
|
/// removed or was never entered in the map.
|
2009-11-04 00:52:08 +01:00
|
|
|
bool isNotInMIMap(const MachineInstr* Instr) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return !Indexes->hasIndex(Instr);
|
2009-11-04 00:52:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns the base index of the given instruction.
|
|
|
|
SlotIndex getInstructionIndex(const MachineInstr *instr) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->getInstructionIndex(instr);
|
2009-11-04 00:52:08 +01:00
|
|
|
}
|
2010-08-12 22:01:23 +02:00
|
|
|
|
2009-11-04 00:52:08 +01:00
|
|
|
/// Returns the instruction associated with the given index.
|
|
|
|
MachineInstr* getInstructionFromIndex(SlotIndex index) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->getInstructionFromIndex(index);
|
2009-11-04 00:52:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Return the first index in the given basic block.
|
|
|
|
SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->getMBBStartIdx(mbb);
|
2010-08-12 22:01:23 +02:00
|
|
|
}
|
2009-11-04 00:52:08 +01:00
|
|
|
|
|
|
|
/// Return the last index in the given basic block.
|
|
|
|
SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->getMBBEndIdx(mbb);
|
2010-08-12 22:01:23 +02:00
|
|
|
}
|
2009-11-04 00:52:08 +01:00
|
|
|
|
2010-07-17 09:34:01 +02:00
|
|
|
bool isLiveInToMBB(const LiveInterval &li,
|
|
|
|
const MachineBasicBlock *mbb) const {
|
|
|
|
return li.liveAt(getMBBStartIdx(mbb));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLiveOutOfMBB(const LiveInterval &li,
|
|
|
|
const MachineBasicBlock *mbb) const {
|
|
|
|
return li.liveAt(getMBBEndIdx(mbb).getPrevSlot());
|
|
|
|
}
|
|
|
|
|
2009-11-04 00:52:08 +01:00
|
|
|
MachineBasicBlock* getMBBFromIndex(SlotIndex index) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->getMBBFromIndex(index);
|
2009-11-04 00:52:08 +01:00
|
|
|
}
|
|
|
|
|
2009-11-14 01:02:51 +01:00
|
|
|
SlotIndex InsertMachineInstrInMaps(MachineInstr *MI) {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->insertMachineInstrInMaps(MI);
|
2007-02-23 00:03:39 +01:00
|
|
|
}
|
|
|
|
|
2006-08-25 00:43:55 +02:00
|
|
|
void RemoveMachineInstrFromMaps(MachineInstr *MI) {
|
2012-06-05 00:39:14 +02:00
|
|
|
Indexes->removeMachineInstrFromMaps(MI);
|
2006-08-25 00:43:55 +02:00
|
|
|
}
|
2007-06-08 19:18:56 +02:00
|
|
|
|
2008-02-13 04:01:43 +01:00
|
|
|
void ReplaceMachineInstrInMaps(MachineInstr *MI, MachineInstr *NewMI) {
|
2012-06-05 00:39:14 +02:00
|
|
|
Indexes->replaceMachineInstrInMaps(MI, NewMI);
|
2009-11-04 00:52:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool findLiveInMBBs(SlotIndex Start, SlotIndex End,
|
|
|
|
SmallVectorImpl<MachineBasicBlock*> &MBBs) const {
|
2012-06-05 00:39:14 +02:00
|
|
|
return Indexes->findLiveInMBBs(Start, End, MBBs);
|
2009-11-04 00:52:08 +01:00
|
|
|
}
|
|
|
|
|
2010-03-30 22:16:45 +02:00
|
|
|
VNInfo::Allocator& getVNInfoAllocator() { return VNInfoAllocator; }
|
2007-09-05 23:46:51 +02:00
|
|
|
|
2007-06-08 19:18:56 +02:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
|
|
virtual void releaseMemory();
|
|
|
|
|
|
|
|
/// runOnMachineFunction - pass entry point
|
|
|
|
virtual bool runOnMachineFunction(MachineFunction&);
|
|
|
|
|
|
|
|
/// print - Implement the dump method.
|
2009-08-23 08:03:38 +02:00
|
|
|
virtual void print(raw_ostream &O, const Module* = 0) const;
|
2007-06-08 19:18:56 +02:00
|
|
|
|
2012-02-10 02:23:55 +01:00
|
|
|
/// intervalIsInOneMBB - If LI is confined to a single basic block, return
|
|
|
|
/// a pointer to that block. If LI is live in to or out of any block,
|
|
|
|
/// return NULL.
|
|
|
|
MachineBasicBlock *intervalIsInOneMBB(const LiveInterval &LI) const;
|
2009-01-13 07:05:10 +01:00
|
|
|
|
2012-08-03 22:10:24 +02:00
|
|
|
/// Returns true if VNI is killed by any PHI-def values in LI.
|
|
|
|
/// This may conservatively return true to avoid expensive computations.
|
|
|
|
bool hasPHIKill(const LiveInterval &LI, const VNInfo *VNI) const;
|
|
|
|
|
2011-02-08 22:13:03 +01:00
|
|
|
/// addKillFlags - Add kill flags to any instruction that kills a virtual
|
|
|
|
/// register.
|
2012-09-06 20:15:18 +02:00
|
|
|
void addKillFlags(const VirtRegMap*);
|
2011-02-08 22:13:03 +01:00
|
|
|
|
2012-02-15 02:23:52 +01:00
|
|
|
/// handleMove - call this method to notify LiveIntervals that
|
|
|
|
/// instruction 'mi' has been moved within a basic block. This will update
|
|
|
|
/// the live intervals for all operands of mi. Moves between basic blocks
|
|
|
|
/// are not supported.
|
2012-02-21 23:29:38 +01:00
|
|
|
void handleMove(MachineInstr* MI);
|
|
|
|
|
|
|
|
/// moveIntoBundle - Update intervals for operands of MI so that they
|
|
|
|
/// begin/end on the SlotIndex for BundleStart.
|
|
|
|
///
|
|
|
|
/// Requires MI and BundleStart to have SlotIndexes, and assumes
|
|
|
|
/// existing liveness is accurate. BundleStart should be the first
|
|
|
|
/// instruction in the Bundle.
|
|
|
|
void handleMoveIntoBundle(MachineInstr* MI, MachineInstr* BundleStart);
|
2012-01-27 23:36:19 +01:00
|
|
|
|
2012-02-08 18:33:45 +01:00
|
|
|
// Register mask functions.
|
|
|
|
//
|
|
|
|
// Machine instructions may use a register mask operand to indicate that a
|
|
|
|
// large number of registers are clobbered by the instruction. This is
|
|
|
|
// typically used for calls.
|
|
|
|
//
|
|
|
|
// For compile time performance reasons, these clobbers are not recorded in
|
|
|
|
// the live intervals for individual physical registers. Instead,
|
|
|
|
// LiveIntervalAnalysis maintains a sorted list of instructions with
|
|
|
|
// register mask operands.
|
|
|
|
|
2012-02-10 02:26:29 +01:00
|
|
|
/// getRegMaskSlots - Returns a sorted array of slot indices of all
|
2012-02-08 18:33:45 +01:00
|
|
|
/// instructions with register mask operands.
|
|
|
|
ArrayRef<SlotIndex> getRegMaskSlots() const { return RegMaskSlots; }
|
|
|
|
|
2012-02-10 02:26:29 +01:00
|
|
|
/// getRegMaskSlotsInBlock - Returns a sorted array of slot indices of all
|
|
|
|
/// instructions with register mask operands in the basic block numbered
|
|
|
|
/// MBBNum.
|
|
|
|
ArrayRef<SlotIndex> getRegMaskSlotsInBlock(unsigned MBBNum) const {
|
|
|
|
std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
|
|
|
|
return getRegMaskSlots().slice(P.first, P.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getRegMaskBits() - Returns an array of register mask pointers
|
|
|
|
/// corresponding to getRegMaskSlots().
|
|
|
|
ArrayRef<const uint32_t*> getRegMaskBits() const { return RegMaskBits; }
|
|
|
|
|
|
|
|
/// getRegMaskBitsInBlock - Returns an array of mask pointers corresponding
|
|
|
|
/// to getRegMaskSlotsInBlock(MBBNum).
|
|
|
|
ArrayRef<const uint32_t*> getRegMaskBitsInBlock(unsigned MBBNum) const {
|
|
|
|
std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
|
|
|
|
return getRegMaskBits().slice(P.first, P.second);
|
|
|
|
}
|
|
|
|
|
2012-02-08 18:33:45 +01:00
|
|
|
/// checkRegMaskInterference - Test if LI is live across any register mask
|
|
|
|
/// instructions, and compute a bit mask of physical registers that are not
|
|
|
|
/// clobbered by any of them.
|
|
|
|
///
|
|
|
|
/// Returns false if LI doesn't cross any register mask instructions. In
|
|
|
|
/// that case, the bit vector is not filled in.
|
|
|
|
bool checkRegMaskInterference(LiveInterval &LI,
|
|
|
|
BitVector &UsableRegs);
|
|
|
|
|
2012-06-06 00:02:15 +02:00
|
|
|
// Register unit functions.
|
|
|
|
//
|
|
|
|
// Fixed interference occurs when MachineInstrs use physregs directly
|
|
|
|
// instead of virtual registers. This typically happens when passing
|
|
|
|
// arguments to a function call, or when instructions require operands in
|
|
|
|
// fixed registers.
|
|
|
|
//
|
|
|
|
// Each physreg has one or more register units, see MCRegisterInfo. We
|
|
|
|
// track liveness per register unit to handle aliasing registers more
|
|
|
|
// efficiently.
|
|
|
|
|
|
|
|
/// getRegUnit - Return the live range for Unit.
|
|
|
|
/// It will be computed if it doesn't exist.
|
|
|
|
LiveInterval &getRegUnit(unsigned Unit) {
|
|
|
|
LiveInterval *LI = RegUnitIntervals[Unit];
|
|
|
|
if (!LI) {
|
|
|
|
// Compute missing ranges on demand.
|
|
|
|
RegUnitIntervals[Unit] = LI = new LiveInterval(Unit, HUGE_VALF);
|
|
|
|
computeRegUnitInterval(LI);
|
|
|
|
}
|
|
|
|
return *LI;
|
|
|
|
}
|
|
|
|
|
2012-06-20 20:00:57 +02:00
|
|
|
/// getCachedRegUnit - Return the live range for Unit if it has already
|
|
|
|
/// been computed, or NULL if it hasn't been computed yet.
|
|
|
|
LiveInterval *getCachedRegUnit(unsigned Unit) {
|
|
|
|
return RegUnitIntervals[Unit];
|
|
|
|
}
|
|
|
|
|
2010-08-12 22:01:23 +02:00
|
|
|
private:
|
2006-09-15 05:57:23 +02:00
|
|
|
/// computeIntervals - Compute live intervals.
|
2006-09-14 08:42:17 +02:00
|
|
|
void computeIntervals();
|
2009-09-14 23:33:42 +02:00
|
|
|
|
2012-07-27 23:56:39 +02:00
|
|
|
/// Compute live intervals for all virtual registers.
|
|
|
|
void computeVirtRegs();
|
|
|
|
|
|
|
|
/// Compute RegMaskSlots and RegMaskBits.
|
|
|
|
void computeRegMasks();
|
|
|
|
|
2004-08-04 11:46:26 +02:00
|
|
|
/// handleRegisterDef - update intervals for a register def
|
2012-06-22 20:20:50 +02:00
|
|
|
/// (calls handleVirtualRegisterDef)
|
2006-09-03 10:07:11 +02:00
|
|
|
void handleRegisterDef(MachineBasicBlock *MBB,
|
2009-09-04 22:41:11 +02:00
|
|
|
MachineBasicBlock::iterator MI,
|
2009-11-04 00:52:08 +01:00
|
|
|
SlotIndex MIIdx,
|
2008-07-10 09:35:43 +02:00
|
|
|
MachineOperand& MO, unsigned MOIdx);
|
2004-08-04 11:46:26 +02:00
|
|
|
|
2010-05-05 20:27:40 +02:00
|
|
|
/// isPartialRedef - Return true if the specified def at the specific index
|
|
|
|
/// is partially re-defining the specified live interval. A common case of
|
2010-08-12 22:01:23 +02:00
|
|
|
/// this is a definition of the sub-register.
|
2010-05-05 20:27:40 +02:00
|
|
|
bool isPartialRedef(SlotIndex MIIdx, MachineOperand &MO,
|
|
|
|
LiveInterval &interval);
|
|
|
|
|
2004-08-04 11:46:26 +02:00
|
|
|
/// handleVirtualRegisterDef - update intervals for a virtual
|
|
|
|
/// register def
|
2006-09-03 10:07:11 +02:00
|
|
|
void handleVirtualRegisterDef(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
2009-11-04 00:52:08 +01:00
|
|
|
SlotIndex MIIdx, MachineOperand& MO,
|
2009-09-04 22:41:11 +02:00
|
|
|
unsigned MOIdx,
|
|
|
|
LiveInterval& interval);
|
2004-08-04 11:46:26 +02:00
|
|
|
|
2008-08-13 23:49:13 +02:00
|
|
|
static LiveInterval* createInterval(unsigned Reg);
|
2004-08-04 11:46:26 +02:00
|
|
|
|
2009-09-14 23:33:42 +02:00
|
|
|
void printInstrs(raw_ostream &O) const;
|
|
|
|
void dumpInstrs() const;
|
2012-02-17 19:44:18 +01:00
|
|
|
|
2012-06-06 00:02:15 +02:00
|
|
|
void computeLiveInRegUnits();
|
|
|
|
void computeRegUnitInterval(LiveInterval*);
|
2012-07-27 22:58:46 +02:00
|
|
|
void computeVirtRegInterval(LiveInterval*);
|
2012-06-06 00:02:15 +02:00
|
|
|
|
2012-02-17 19:44:18 +01:00
|
|
|
class HMEditor;
|
2004-08-04 11:46:26 +02:00
|
|
|
};
|
2003-11-20 04:32:25 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|