1 //===-- llvm/CodeGen/Splitter.h - Splitter -*- 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 #ifndef LLVM_CODEGEN_SPLITTER_H
11 #define LLVM_CODEGEN_SPLITTER_H
13 #include "llvm/CodeGen/MachineFunctionPass.h"
14 #include "llvm/CodeGen/MachineLoopInfo.h"
15 #include "llvm/CodeGen/SlotIndexes.h"
28 class MachineDominatorTree
;
29 class MachineRegisterInfo
;
31 class TargetInstrInfo
;
34 class LoopSplitter
: public MachineFunctionPass
{
35 friend class LoopSplit
;
39 LoopSplitter() : MachineFunctionPass(ID
) {
40 initializeLoopSplitterPass(*PassRegistry::getPassRegistry());
43 virtual void getAnalysisUsage(AnalysisUsage
&au
) const;
45 virtual bool runOnMachineFunction(MachineFunction
&fn
);
47 virtual void releaseMemory();
55 MachineRegisterInfo
*mri
;
56 MachineDominatorTree
*mdt
;
58 const TargetInstrInfo
*tii
;
59 const TargetRegisterInfo
*tri
;
62 std::deque
<LiveInterval
*> intervals
;
64 typedef std::pair
<SlotIndex
, SlotIndex
> SlotPair
;
65 typedef std::vector
<SlotPair
> LoopRanges
;
66 typedef std::map
<MachineLoop
*, LoopRanges
> LoopRangeMap
;
67 LoopRangeMap loopRangeMap
;
69 void dumpLoopInfo(MachineLoop
&loop
);
71 void dumpOddTerminators();
73 void updateTerminators(MachineBasicBlock
&mbb
);
75 bool canInsertPreHeader(MachineLoop
&loop
);
76 MachineBasicBlock
& insertPreHeader(MachineLoop
&loop
);
78 bool isCriticalEdge(MachineLoop::Edge
&edge
);
79 bool canSplitEdge(MachineLoop::Edge
&edge
);
80 MachineBasicBlock
& splitEdge(MachineLoop::Edge
&edge
, MachineLoop
&loop
);
82 LoopRanges
& getLoopRanges(MachineLoop
&loop
);
83 std::pair
<bool, SlotPair
> getLoopSubRange(const LiveRange
&lr
,
86 void dumpLoopRanges(MachineLoop
&loop
);
88 void processHeader(LoopSplit
&split
);
89 void processLoopExits(LoopSplit
&split
);
90 void processLoopUses(LoopSplit
&split
);
92 bool splitOverLoop(LiveInterval
&li
, MachineLoop
&loop
);
94 void processInterval(LiveInterval
&li
);
96 void processIntervals();