LLVM API Documentation
00001 //=- llvm/CodeGen/CriticalAntiDepBreaker.h - Anti-Dep Support -*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the CriticalAntiDepBreaker class, which 00011 // implements register anti-dependence breaking along a blocks 00012 // critical path during post-RA scheduler. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_LIB_CODEGEN_CRITICALANTIDEPBREAKER_H 00017 #define LLVM_LIB_CODEGEN_CRITICALANTIDEPBREAKER_H 00018 00019 #include "AntiDepBreaker.h" 00020 #include "llvm/ADT/BitVector.h" 00021 #include "llvm/CodeGen/MachineBasicBlock.h" 00022 #include "llvm/CodeGen/MachineFrameInfo.h" 00023 #include "llvm/CodeGen/MachineFunction.h" 00024 #include "llvm/CodeGen/MachineRegisterInfo.h" 00025 #include "llvm/CodeGen/RegisterClassInfo.h" 00026 #include "llvm/CodeGen/ScheduleDAG.h" 00027 #include <map> 00028 00029 namespace llvm { 00030 class RegisterClassInfo; 00031 class TargetInstrInfo; 00032 class TargetRegisterInfo; 00033 00034 class CriticalAntiDepBreaker : public AntiDepBreaker { 00035 MachineFunction& MF; 00036 MachineRegisterInfo &MRI; 00037 const TargetInstrInfo *TII; 00038 const TargetRegisterInfo *TRI; 00039 const RegisterClassInfo &RegClassInfo; 00040 00041 /// AllocatableSet - The set of allocatable registers. 00042 /// We'll be ignoring anti-dependencies on non-allocatable registers, 00043 /// because they may not be safe to break. 00044 const BitVector AllocatableSet; 00045 00046 /// Classes - For live regs that are only used in one register class in a 00047 /// live range, the register class. If the register is not live, the 00048 /// corresponding value is null. If the register is live but used in 00049 /// multiple register classes, the corresponding value is -1 casted to a 00050 /// pointer. 00051 std::vector<const TargetRegisterClass*> Classes; 00052 00053 /// RegRefs - Map registers to all their references within a live range. 00054 std::multimap<unsigned, MachineOperand *> RegRefs; 00055 typedef std::multimap<unsigned, MachineOperand *>::const_iterator 00056 RegRefIter; 00057 00058 /// KillIndices - The index of the most recent kill (proceeding bottom-up), 00059 /// or ~0u if the register is not live. 00060 std::vector<unsigned> KillIndices; 00061 00062 /// DefIndices - The index of the most recent complete def (proceeding 00063 /// bottom up), or ~0u if the register is live. 00064 std::vector<unsigned> DefIndices; 00065 00066 /// KeepRegs - A set of registers which are live and cannot be changed to 00067 /// break anti-dependencies. 00068 BitVector KeepRegs; 00069 00070 public: 00071 CriticalAntiDepBreaker(MachineFunction& MFi, const RegisterClassInfo&); 00072 ~CriticalAntiDepBreaker(); 00073 00074 /// Start - Initialize anti-dep breaking for a new basic block. 00075 void StartBlock(MachineBasicBlock *BB) override; 00076 00077 /// BreakAntiDependencies - Identifiy anti-dependencies along the critical 00078 /// path 00079 /// of the ScheduleDAG and break them by renaming registers. 00080 /// 00081 unsigned BreakAntiDependencies(const std::vector<SUnit>& SUnits, 00082 MachineBasicBlock::iterator Begin, 00083 MachineBasicBlock::iterator End, 00084 unsigned InsertPosIndex, 00085 DbgValueVector &DbgValues) override; 00086 00087 /// Observe - Update liveness information to account for the current 00088 /// instruction, which will not be scheduled. 00089 /// 00090 void Observe(MachineInstr *MI, unsigned Count, 00091 unsigned InsertPosIndex) override; 00092 00093 /// Finish - Finish anti-dep breaking for a basic block. 00094 void FinishBlock() override; 00095 00096 private: 00097 void PrescanInstruction(MachineInstr *MI); 00098 void ScanInstruction(MachineInstr *MI, unsigned Count); 00099 bool isNewRegClobberedByRefs(RegRefIter RegRefBegin, 00100 RegRefIter RegRefEnd, 00101 unsigned NewReg); 00102 unsigned findSuitableFreeRegister(RegRefIter RegRefBegin, 00103 RegRefIter RegRefEnd, 00104 unsigned AntiDepReg, 00105 unsigned LastNewReg, 00106 const TargetRegisterClass *RC, 00107 SmallVectorImpl<unsigned> &Forbid); 00108 }; 00109 } 00110 00111 #endif