InductionVariable.h 1.5 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. class InductionVariable;
  7. typedef JsUtil::BaseHashSet<InductionVariable, JitArenaAllocator, PowerOf2SizePolicy, SymID> InductionVariableSet;
  8. class InductionVariable
  9. {
  10. public:
  11. static const int ChangeMagnitudeLimitForLoopCountBasedHoisting;
  12. private:
  13. StackSym *sym;
  14. ValueNumber symValueNumber;
  15. IntConstantBounds changeBounds;
  16. bool isChangeDeterminate;
  17. public:
  18. InductionVariable();
  19. InductionVariable(StackSym *const sym, const ValueNumber symValueNumber, const int change);
  20. #if DBG
  21. private:
  22. bool IsValid() const;
  23. #endif
  24. public:
  25. StackSym *Sym() const;
  26. ValueNumber SymValueNumber() const;
  27. void SetSymValueNumber(const ValueNumber symValueNumber);
  28. bool IsChangeDeterminate() const;
  29. void SetChangeIsIndeterminate();
  30. const IntConstantBounds &ChangeBounds() const;
  31. bool IsChangeUnidirectional() const;
  32. public:
  33. bool Add(const int n);
  34. void ExpandInnerLoopChange();
  35. public:
  36. void Merge(const InductionVariable &other);
  37. };
  38. template<>
  39. inline SymID JsUtil::ValueToKey<SymID, InductionVariable>::ToKey(const InductionVariable &inductionVariable)
  40. {
  41. return inductionVariable.Sym()->m_id;
  42. }