the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / lib / CodeGen / Splitter.h
blob9fb1b8b301391e7316bcaa223db646cc5e77211c
1 //===-- llvm/CodeGen/Splitter.h - Splitter -*- C++ -*----------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
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"
17 #include <deque>
18 #include <map>
19 #include <string>
20 #include <vector>
22 namespace llvm {
24 class LiveInterval;
25 class LiveIntervals;
26 struct LiveRange;
27 class LoopSplit;
28 class MachineDominatorTree;
29 class MachineRegisterInfo;
30 class SlotIndexes;
31 class TargetInstrInfo;
32 class VNInfo;
34 class LoopSplitter : public MachineFunctionPass {
35 friend class LoopSplit;
36 public:
37 static char ID;
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();
50 private:
52 MachineFunction *mf;
53 LiveIntervals *lis;
54 MachineLoopInfo *mli;
55 MachineRegisterInfo *mri;
56 MachineDominatorTree *mdt;
57 SlotIndexes *sis;
58 const TargetInstrInfo *tii;
59 const TargetRegisterInfo *tri;
61 std::string fqn;
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,
84 MachineLoop &loop);
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();
101 #endif