Peeps.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. #include "PeepsMD.h"
  7. #if defined(_M_IX86) || defined(_M_X64)
  8. #include "AgenPeeps.h"
  9. #endif
  10. class Peeps
  11. {
  12. friend class PeepsMD;
  13. private:
  14. Func * func;
  15. #if defined(_M_IX86) || defined(_M_X64)
  16. AgenPeeps peepsAgen;
  17. #endif
  18. PeepsMD peepsMD;
  19. StackSym* regMap[RegNumCount];
  20. void ClearRegMap();
  21. public:
  22. #if defined(_M_IX86) || defined(_M_X64)
  23. Peeps(Func *func) : func(func), peepsMD(func), peepsAgen(func) {}
  24. #else
  25. Peeps(Func *func) : func(func), peepsMD(func) {}
  26. #endif
  27. void PeepFunc();
  28. IR::Instr * PeepAssign(IR::Instr *assign);
  29. static IR::LabelInstr *RetargetBrToBr(IR::BranchInstr *branchInstr, IR::LabelInstr * targetInstr);
  30. static IR::Instr * PeepBranch(IR::BranchInstr *branchInstr, bool *const peepedRef = nullptr);
  31. static IR::Instr * PeepUnreachableLabel(IR::LabelInstr *deadLabel, const bool isInHelper, bool *const peepedRef = nullptr);
  32. static IR::Instr * CleanupLabel(IR::LabelInstr * instr, IR::LabelInstr * instrNext);
  33. private:
  34. void SetReg(RegNum reg, StackSym *sym);
  35. void ClearReg(RegNum reg);
  36. static IR::Instr * RemoveDeadBlock(IR::Instr *instr, bool* wasStmtBoundaryKeptInDeadBlock = nullptr);
  37. #if defined(_M_IX86) || defined(_M_X64)
  38. IR::Instr * PeepRedundant(IR::Instr *instr);
  39. IR::Instr * PeepCondMove(IR::LabelInstr *labelInstr, IR::Instr *nextInstr, const bool isInHelper);
  40. static bool IsJccOrShiftInstr(IR::Instr *instr);
  41. IR::Instr * HoistSameInstructionAboveSplit(IR::BranchInstr *branchInstr, IR::Instr *instrNext);
  42. #endif
  43. };