LLVM API Documentation

AntiDepBreaker.h
Go to the documentation of this file.
00001 //=- llvm/CodeGen/AntiDepBreaker.h - Anti-Dependence Breaking -*- 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 AntiDepBreaker class, which implements
00011 // anti-dependence breaking heuristics for post-register-allocation scheduling.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H
00016 #define LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H
00017 
00018 #include "llvm/CodeGen/MachineBasicBlock.h"
00019 #include "llvm/CodeGen/MachineFrameInfo.h"
00020 #include "llvm/CodeGen/MachineFunction.h"
00021 #include "llvm/CodeGen/MachineRegisterInfo.h"
00022 #include "llvm/CodeGen/ScheduleDAG.h"
00023 #include "llvm/Target/TargetRegisterInfo.h"
00024 #include <vector>
00025 
00026 namespace llvm {
00027 
00028 /// AntiDepBreaker - This class works into conjunction with the
00029 /// post-RA scheduler to rename registers to break register
00030 /// anti-dependencies.
00031 class AntiDepBreaker {
00032 public:
00033   typedef std::vector<std::pair<MachineInstr *, MachineInstr *> > 
00034     DbgValueVector;
00035 
00036   virtual ~AntiDepBreaker();
00037 
00038   /// Start - Initialize anti-dep breaking for a new basic block.
00039   virtual void StartBlock(MachineBasicBlock *BB) =0;
00040 
00041   /// BreakAntiDependencies - Identifiy anti-dependencies within a
00042   /// basic-block region and break them by renaming registers. Return
00043   /// the number of anti-dependencies broken.
00044   ///
00045   virtual unsigned BreakAntiDependencies(const std::vector<SUnit>& SUnits,
00046                                          MachineBasicBlock::iterator Begin,
00047                                          MachineBasicBlock::iterator End,
00048                                          unsigned InsertPosIndex,
00049                                          DbgValueVector &DbgValues) = 0;
00050   
00051   /// Observe - Update liveness information to account for the current
00052   /// instruction, which will not be scheduled.
00053   ///
00054   virtual void Observe(MachineInstr *MI, unsigned Count,
00055                        unsigned InsertPosIndex) =0;
00056   
00057   /// Finish - Finish anti-dep breaking for a basic block.
00058   virtual void FinishBlock() =0;
00059 
00060   /// UpdateDbgValue - Update DBG_VALUE if dependency breaker is updating
00061   /// other machine instruction to use NewReg.
00062   void UpdateDbgValue(MachineInstr *MI, unsigned OldReg, unsigned NewReg) {
00063     assert (MI->isDebugValue() && "MI is not DBG_VALUE!");
00064     if (MI && MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == OldReg)
00065       MI->getOperand(0).setReg(NewReg);
00066   }
00067 };
00068 
00069 }
00070 
00071 #endif