2
0

SccLiveness.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "Lifetime.h"
  7. struct OpHelperSpilledLifetime
  8. {
  9. Lifetime * lifetime;
  10. RegNum reg;
  11. bool spillAsArg;
  12. bool reload; // determines if we want to reload the lifetime at the end of the helper
  13. };
  14. class OpHelperBlock
  15. {
  16. public:
  17. OpHelperBlock(JitArenaAllocator * alloc) : spilledLifetime(alloc) {}
  18. IR::LabelInstr * opHelperLabel;
  19. IR::Instr * opHelperEndInstr;
  20. SList<OpHelperSpilledLifetime> spilledLifetime;
  21. public:
  22. uint Length() const;
  23. private:
  24. // Disable copy constructor
  25. OpHelperBlock(OpHelperBlock const&);
  26. };
  27. class SCCLiveness
  28. {
  29. private:
  30. Func * func;
  31. JitArenaAllocator *tempAlloc;
  32. Loop * curLoop;
  33. uint32 lastCall;
  34. uint32 lastNonOpHelperCall;
  35. uint16 loopNest;
  36. IR::LabelInstr * lastOpHelperLabel;
  37. Region * curRegion;
  38. SListBase<Loop*> * extendedLifetimesLoopList;
  39. public:
  40. SCCLiveness(Func *func, JitArenaAllocator *tempAlloc) : func(func),
  41. tempAlloc(tempAlloc), loopNest(0), lastCall(0), lastNonOpHelperCall(0),
  42. curLoop(NULL), lastOpHelperLabel(NULL), opHelperBlockList(tempAlloc),
  43. curRegion(NULL), lifetimeList(tempAlloc),
  44. totalOpHelperFullVisitedLength(0)
  45. {
  46. extendedLifetimesLoopList = JitAnew(tempAlloc, SListBase<Loop *>);
  47. }
  48. void Build();
  49. #if DBG_DUMP
  50. void Dump();
  51. #endif
  52. SList<Lifetime *> lifetimeList;
  53. SList<OpHelperBlock> opHelperBlockList;
  54. uint totalOpHelperFullVisitedLength;
  55. private:
  56. void ProcessSrc(IR::Opnd *src, IR::Instr *instr);
  57. void ProcessDst(IR::Opnd *dst, IR::Instr *instr);
  58. void ProcessRegUse(IR::RegOpnd *regUse, IR::Instr *instr);
  59. void ProcessRegDef(IR::RegOpnd *regDef, IR::Instr *instr);
  60. void ExtendLifetime(Lifetime *lifetime, IR::Instr *instr);
  61. void ProcessStackSymUse(StackSym * stackSym, IR::Instr * instr, int usageSize = MachPtr);
  62. void ProcessBailOutUses(IR::Instr * bailOutInstr);
  63. Lifetime * InsertLifetime(StackSym *stackSym, RegNum reg, IR::Instr *const currentInstr);
  64. void EndOpHelper(IR::Instr * instr);
  65. bool FoldIndir(IR::Instr *instr, IR::Opnd *opnd);
  66. uint CurrentOpHelperVisitedLength(IR::Instr *const currentInstr) const;
  67. };