| David Goodwin | 2e7be61 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 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" | 
| David Goodwin | 4de099d | 2009-11-03 20:57:50 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/SmallSet.h" | 
|  | 25 | #include "llvm/ADT/SmallVector.h" | 
| Dan Gohman | 6ac0e76 | 2009-11-16 20:40:47 +0000 | [diff] [blame] | 26 | #include <map> | 
| David Goodwin | 2e7be61 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 27 |  | 
|  | 28 | namespace llvm { | 
|  | 29 |  | 
|  | 30 | /// AntiDepBreaker - This class works into conjunction with the | 
|  | 31 | /// post-RA scheduler to rename registers to break register | 
|  | 32 | /// anti-dependencies. | 
|  | 33 | class AntiDepBreaker { | 
|  | 34 | public: | 
| David Goodwin | 4de099d | 2009-11-03 20:57:50 +0000 | [diff] [blame] | 35 | typedef SmallSet<unsigned, 4> AntiDepRegSet; | 
|  | 36 | typedef SmallVector<unsigned, 4> AntiDepRegVector; | 
|  | 37 | typedef std::map<SUnit *, AntiDepRegVector> CandidateMap; | 
|  | 38 |  | 
| David Goodwin | ada0ef8 | 2009-10-26 19:41:00 +0000 | [diff] [blame] | 39 | virtual ~AntiDepBreaker(); | 
| David Goodwin | c932213 | 2009-10-26 19:00:47 +0000 | [diff] [blame] | 40 |  | 
| David Goodwin | e10deca | 2009-10-26 22:31:16 +0000 | [diff] [blame] | 41 | /// GetMaxTrials - Return the maximum number of anti-dependence | 
|  | 42 | /// breaking attempts that will be made for a block. | 
|  | 43 | virtual unsigned GetMaxTrials() =0; | 
|  | 44 |  | 
| David Goodwin | 4de099d | 2009-11-03 20:57:50 +0000 | [diff] [blame] | 45 | /// NeedCandidates - Return true if the schedule must provide | 
|  | 46 | /// candidates with BreakAntiDependencies(). | 
|  | 47 | virtual bool NeedCandidates() =0; | 
|  | 48 |  | 
| David Goodwin | 2e7be61 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 49 | /// Start - Initialize anti-dep breaking for a new basic block. | 
|  | 50 | virtual void StartBlock(MachineBasicBlock *BB) =0; | 
|  | 51 |  | 
|  | 52 | /// BreakAntiDependencies - Identifiy anti-dependencies within a | 
|  | 53 | /// basic-block region and break them by renaming registers. Return | 
|  | 54 | /// the number of anti-dependencies broken. | 
|  | 55 | /// | 
|  | 56 | virtual unsigned BreakAntiDependencies(std::vector<SUnit>& SUnits, | 
| David Goodwin | 4de099d | 2009-11-03 20:57:50 +0000 | [diff] [blame] | 57 | CandidateMap& Candidates, | 
|  | 58 | MachineBasicBlock::iterator& Begin, | 
|  | 59 | MachineBasicBlock::iterator& End, | 
|  | 60 | unsigned InsertPosIndex) =0; | 
| David Goodwin | 2e7be61 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 61 |  | 
|  | 62 | /// Observe - Update liveness information to account for the current | 
|  | 63 | /// instruction, which will not be scheduled. | 
|  | 64 | /// | 
|  | 65 | virtual void Observe(MachineInstr *MI, unsigned Count, | 
|  | 66 | unsigned InsertPosIndex) =0; | 
|  | 67 |  | 
|  | 68 | /// Finish - Finish anti-dep breaking for a basic block. | 
|  | 69 | virtual void FinishBlock() =0; | 
|  | 70 | }; | 
|  | 71 |  | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | #endif |