AntiDepBreaker.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #ifndef LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H
  15. #define LLVM_LIB_CODEGEN_ANTIDEPBREAKER_H
  16. #include "llvm/CodeGen/MachineBasicBlock.h"
  17. #include "llvm/CodeGen/MachineFrameInfo.h"
  18. #include "llvm/CodeGen/MachineFunction.h"
  19. #include "llvm/CodeGen/MachineRegisterInfo.h"
  20. #include "llvm/CodeGen/ScheduleDAG.h"
  21. #include "llvm/Target/TargetRegisterInfo.h"
  22. #include <vector>
  23. namespace llvm {
  24. /// This class works in conjunction with the post-RA scheduler to rename
  25. /// registers to break register anti-dependencies (WAR hazards).
  26. class LLVM_LIBRARY_VISIBILITY AntiDepBreaker {
  27. public:
  28. typedef std::vector<std::pair<MachineInstr *, MachineInstr *> >
  29. DbgValueVector;
  30. virtual ~AntiDepBreaker();
  31. /// Initialize anti-dep breaking for a new basic block.
  32. virtual void StartBlock(MachineBasicBlock *BB) =0;
  33. /// Identifiy anti-dependencies within a basic-block region and break them by
  34. /// renaming registers. Return the number of anti-dependencies broken.
  35. virtual unsigned BreakAntiDependencies(const std::vector<SUnit>& SUnits,
  36. MachineBasicBlock::iterator Begin,
  37. MachineBasicBlock::iterator End,
  38. unsigned InsertPosIndex,
  39. DbgValueVector &DbgValues) = 0;
  40. /// Update liveness information to account for the current
  41. /// instruction, which will not be scheduled.
  42. virtual void Observe(MachineInstr *MI, unsigned Count,
  43. unsigned InsertPosIndex) =0;
  44. /// Finish anti-dep breaking for a basic block.
  45. virtual void FinishBlock() =0;
  46. /// Update DBG_VALUE if dependency breaker is updating
  47. /// other machine instruction to use NewReg.
  48. void UpdateDbgValue(MachineInstr *MI, unsigned OldReg, unsigned NewReg) {
  49. assert (MI->isDebugValue() && "MI is not DBG_VALUE!");
  50. if (MI && MI->getOperand(0).isReg() && MI->getOperand(0).getReg() == OldReg)
  51. MI->getOperand(0).setReg(NewReg);
  52. }
  53. };
  54. }
  55. #endif