Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7 KiB

  1. //===- llvm/Analysis/ScalarEvolutionNormalization.h - See below -*- 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 defines utilities for working with "normalized" ScalarEvolution
  11. // expressions.
  12. //
  13. // The following example illustrates post-increment uses and how normalized
  14. // expressions help.
  15. //
  16. // for (i=0; i!=n; ++i) {
  17. // ...
  18. // }
  19. // use(i);
  20. //
  21. // While the expression for most uses of i inside the loop is {0,+,1}<%L>, the
  22. // expression for the use of i outside the loop is {1,+,1}<%L>, since i is
  23. // incremented at the end of the loop body. This is inconveient, since it
  24. // suggests that we need two different induction variables, one that starts
  25. // at 0 and one that starts at 1. We'd prefer to be able to think of these as
  26. // the same induction variable, with uses inside the loop using the
  27. // "pre-incremented" value, and uses after the loop using the
  28. // "post-incremented" value.
  29. //
  30. // Expressions for post-incremented uses are represented as an expression
  31. // paired with a set of loops for which the expression is in "post-increment"
  32. // mode (there may be multiple loops).
  33. //
  34. //===----------------------------------------------------------------------===//
  35. #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
  36. #define LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
  37. #include "llvm/ADT/SmallPtrSet.h"
  38. namespace llvm {
  39. class Instruction;
  40. class DominatorTree;
  41. class Loop;
  42. class ScalarEvolution;
  43. class SCEV;
  44. class Value;
  45. /// TransformKind - Different types of transformations that
  46. /// TransformForPostIncUse can do.
  47. enum TransformKind {
  48. /// Normalize - Normalize according to the given loops.
  49. Normalize,
  50. /// NormalizeAutodetect - Detect post-inc opportunities on new expressions,
  51. /// update the given loop set, and normalize.
  52. NormalizeAutodetect,
  53. /// Denormalize - Perform the inverse transform on the expression with the
  54. /// given loop set.
  55. Denormalize
  56. };
  57. /// PostIncLoopSet - A set of loops.
  58. typedef SmallPtrSet<const Loop *, 2> PostIncLoopSet;
  59. /// TransformForPostIncUse - Transform the given expression according to the
  60. /// given transformation kind.
  61. const SCEV *TransformForPostIncUse(TransformKind Kind,
  62. const SCEV *S,
  63. Instruction *User,
  64. Value *OperandValToReplace,
  65. PostIncLoopSet &Loops,
  66. ScalarEvolution &SE,
  67. DominatorTree &DT);
  68. }
  69. #endif