David Goodwin | 8370485 | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H |
| 16 | #define LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 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 | 80a03cc | 2009-11-20 19:32:48 +0000 | [diff] [blame] | 24 | #include <vector> |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 25 | |
| 26 | namespace llvm { |
| 27 | |
Sanjay Patel | d649235 | 2014-09-21 14:48:16 +0000 | [diff] [blame] | 28 | /// This class works in conjunction with the post-RA scheduler to rename |
| 29 | /// registers to break register anti-dependencies (WAR hazards). |
Benjamin Kramer | f4c2025 | 2015-07-01 14:47:39 +0000 | [diff] [blame] | 30 | class LLVM_LIBRARY_VISIBILITY AntiDepBreaker { |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 31 | public: |
Devang Patel | f02a376 | 2011-06-02 21:26:52 +0000 | [diff] [blame] | 32 | typedef std::vector<std::pair<MachineInstr *, MachineInstr *> > |
| 33 | DbgValueVector; |
| 34 | |
David Goodwin | 661ea98 | 2009-10-26 19:41:00 +0000 | [diff] [blame] | 35 | virtual ~AntiDepBreaker(); |
David Goodwin | 6b16b5e | 2009-10-26 19:00:47 +0000 | [diff] [blame] | 36 | |
Sanjay Patel | d649235 | 2014-09-21 14:48:16 +0000 | [diff] [blame] | 37 | /// Initialize anti-dep breaking for a new basic block. |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 38 | virtual void StartBlock(MachineBasicBlock *BB) =0; |
| 39 | |
Sanjay Patel | d649235 | 2014-09-21 14:48:16 +0000 | [diff] [blame] | 40 | /// Identifiy anti-dependencies within a basic-block region and break them by |
| 41 | /// renaming registers. Return the number of anti-dependencies broken. |
Dan Gohman | 35bc4d4 | 2010-04-19 23:11:58 +0000 | [diff] [blame] | 42 | virtual unsigned BreakAntiDependencies(const std::vector<SUnit>& SUnits, |
Devang Patel | f02a376 | 2011-06-02 21:26:52 +0000 | [diff] [blame] | 43 | MachineBasicBlock::iterator Begin, |
| 44 | MachineBasicBlock::iterator End, |
| 45 | unsigned InsertPosIndex, |
| 46 | DbgValueVector &DbgValues) = 0; |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 47 | |
Sanjay Patel | d649235 | 2014-09-21 14:48:16 +0000 | [diff] [blame] | 48 | /// Update liveness information to account for the current |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 49 | /// instruction, which will not be scheduled. |
Duncan P. N. Exon Smith | 5e6e8c7 | 2016-02-27 19:33:37 +0000 | [diff] [blame] | 50 | virtual void Observe(MachineInstr &MI, unsigned Count, |
| 51 | unsigned InsertPosIndex) = 0; |
| 52 | |
Sanjay Patel | d649235 | 2014-09-21 14:48:16 +0000 | [diff] [blame] | 53 | /// Finish anti-dep breaking for a basic block. |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 54 | virtual void FinishBlock() =0; |
Devang Patel | f02a376 | 2011-06-02 21:26:52 +0000 | [diff] [blame] | 55 | |
Sanjay Patel | d649235 | 2014-09-21 14:48:16 +0000 | [diff] [blame] | 56 | /// Update DBG_VALUE if dependency breaker is updating |
Devang Patel | f02a376 | 2011-06-02 21:26:52 +0000 | [diff] [blame] | 57 | /// other machine instruction to use NewReg. |
Duncan P. N. Exon Smith | 5e6e8c7 | 2016-02-27 19:33:37 +0000 | [diff] [blame] | 58 | void UpdateDbgValue(MachineInstr &MI, unsigned OldReg, unsigned NewReg) { |
| 59 | assert(MI.isDebugValue() && "MI is not DBG_VALUE!"); |
| 60 | if (MI.getOperand(0).isReg() && MI.getOperand(0).getReg() == OldReg) |
| 61 | MI.getOperand(0).setReg(NewReg); |
Devang Patel | f02a376 | 2011-06-02 21:26:52 +0000 | [diff] [blame] | 62 | } |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 65 | } |
David Goodwin | 8370485 | 2009-10-26 16:59:04 +0000 | [diff] [blame] | 66 | |
| 67 | #endif |