Do a scheduling pass ignoring anti-dependencies to identify candidate registers that...
[oota-llvm.git] / lib / CodeGen / AntiDepBreaker.h
1 //=- llvm/CodeGen/AntiDepBreaker.h - Anti-Dependence Breaking -*- 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 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the AntiDepBreaker class, which implements
11 // anti-dependence breaking heuristics for post-register-allocation scheduling.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_ANTIDEPBREAKER_H
16 #define LLVM_CODEGEN_ANTIDEPBREAKER_H
17
18 #include "llvm/CodeGen/MachineBasicBlock.h"
19 #include "llvm/CodeGen/MachineFrameInfo.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineRegisterInfo.h"
22 #include "llvm/CodeGen/ScheduleDAG.h"
23 #include "llvm/Target/TargetRegisterInfo.h"
24 #include "llvm/ADT/SmallSet.h"
25 #include "llvm/ADT/SmallVector.h"
26
27 namespace llvm {
28
29 /// AntiDepBreaker - This class works into conjunction with the
30 /// post-RA scheduler to rename registers to break register
31 /// anti-dependencies.
32 class AntiDepBreaker {
33 public:
34   typedef SmallSet<unsigned, 4> AntiDepRegSet;
35   typedef SmallVector<unsigned, 4> AntiDepRegVector;
36   typedef std::map<SUnit *, AntiDepRegVector> CandidateMap;
37
38   virtual ~AntiDepBreaker();
39
40   /// GetMaxTrials - Return the maximum number of anti-dependence
41   /// breaking attempts that will be made for a block.
42   virtual unsigned GetMaxTrials() =0;
43
44   /// NeedCandidates - Return true if the schedule must provide
45   /// candidates with BreakAntiDependencies().
46   virtual bool NeedCandidates() =0;
47
48   /// Start - Initialize anti-dep breaking for a new basic block.
49   virtual void StartBlock(MachineBasicBlock *BB) =0;
50
51   /// BreakAntiDependencies - Identifiy anti-dependencies within a
52   /// basic-block region and break them by renaming registers. Return
53   /// the number of anti-dependencies broken.
54   ///
55   virtual unsigned BreakAntiDependencies(std::vector<SUnit>& SUnits,
56                                 CandidateMap& Candidates,
57                                 MachineBasicBlock::iterator& Begin,
58                                 MachineBasicBlock::iterator& End,
59                                 unsigned InsertPosIndex) =0;
60   
61   /// Observe - Update liveness information to account for the current
62   /// instruction, which will not be scheduled.
63   ///
64   virtual void Observe(MachineInstr *MI, unsigned Count,
65                        unsigned InsertPosIndex) =0;
66   
67   /// Finish - Finish anti-dep breaking for a basic block.
68   virtual void FinishBlock() =0;
69 };
70
71 }
72
73 #endif