1*9880d681SAndroid Build Coastguard Worker //=- llvm/CodeGen/AntiDepBreaker.h - Anti-Dependence Breaking -*- C++ -*-=// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file implements the AntiDepBreaker class, which implements 11*9880d681SAndroid Build Coastguard Worker // anti-dependence breaking heuristics for post-register-allocation scheduling. 12*9880d681SAndroid Build Coastguard Worker // 13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H 16*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineBasicBlock.h" 19*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFrameInfo.h" 20*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFunction.h" 21*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineRegisterInfo.h" 22*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/ScheduleDAG.h" 23*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetRegisterInfo.h" 24*9880d681SAndroid Build Coastguard Worker #include <vector> 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker namespace llvm { 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker /// This class works in conjunction with the post-RA scheduler to rename 29*9880d681SAndroid Build Coastguard Worker /// registers to break register anti-dependencies (WAR hazards). 30*9880d681SAndroid Build Coastguard Worker class LLVM_LIBRARY_VISIBILITY AntiDepBreaker { 31*9880d681SAndroid Build Coastguard Worker public: 32*9880d681SAndroid Build Coastguard Worker typedef std::vector<std::pair<MachineInstr *, MachineInstr *> > 33*9880d681SAndroid Build Coastguard Worker DbgValueVector; 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker virtual ~AntiDepBreaker(); 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker /// Initialize anti-dep breaking for a new basic block. 38*9880d681SAndroid Build Coastguard Worker virtual void StartBlock(MachineBasicBlock *BB) =0; 39*9880d681SAndroid Build Coastguard Worker 40*9880d681SAndroid Build Coastguard Worker /// Identifiy anti-dependencies within a basic-block region and break them by 41*9880d681SAndroid Build Coastguard Worker /// renaming registers. Return the number of anti-dependencies broken. 42*9880d681SAndroid Build Coastguard Worker virtual unsigned BreakAntiDependencies(const std::vector<SUnit>& SUnits, 43*9880d681SAndroid Build Coastguard Worker MachineBasicBlock::iterator Begin, 44*9880d681SAndroid Build Coastguard Worker MachineBasicBlock::iterator End, 45*9880d681SAndroid Build Coastguard Worker unsigned InsertPosIndex, 46*9880d681SAndroid Build Coastguard Worker DbgValueVector &DbgValues) = 0; 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Worker /// Update liveness information to account for the current 49*9880d681SAndroid Build Coastguard Worker /// instruction, which will not be scheduled. 50*9880d681SAndroid Build Coastguard Worker virtual void Observe(MachineInstr &MI, unsigned Count, 51*9880d681SAndroid Build Coastguard Worker unsigned InsertPosIndex) = 0; 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker /// Finish anti-dep breaking for a basic block. 54*9880d681SAndroid Build Coastguard Worker virtual void FinishBlock() =0; 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker /// Update DBG_VALUE if dependency breaker is updating 57*9880d681SAndroid Build Coastguard Worker /// other machine instruction to use NewReg. UpdateDbgValue(MachineInstr & MI,unsigned OldReg,unsigned NewReg)58*9880d681SAndroid Build Coastguard Worker void UpdateDbgValue(MachineInstr &MI, unsigned OldReg, unsigned NewReg) { 59*9880d681SAndroid Build Coastguard Worker assert(MI.isDebugValue() && "MI is not DBG_VALUE!"); 60*9880d681SAndroid Build Coastguard Worker if (MI.getOperand(0).isReg() && MI.getOperand(0).getReg() == OldReg) 61*9880d681SAndroid Build Coastguard Worker MI.getOperand(0).setReg(NewReg); 62*9880d681SAndroid Build Coastguard Worker } 63*9880d681SAndroid Build Coastguard Worker }; 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker } 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Worker #endif 68