Vectorize.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //===-- Vectorize.h - Vectorization Transformations -------------*- 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 header file defines prototypes for accessor functions that expose passes
  11. // in the Vectorize transformations library.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_TRANSFORMS_VECTORIZE_H
  15. #define LLVM_TRANSFORMS_VECTORIZE_H
  16. namespace llvm {
  17. class BasicBlock;
  18. class BasicBlockPass;
  19. class Pass;
  20. //===----------------------------------------------------------------------===//
  21. /// @brief Vectorize configuration.
  22. struct VectorizeConfig {
  23. //===--------------------------------------------------------------------===//
  24. // Target architecture related parameters
  25. /// @brief The size of the native vector registers.
  26. unsigned VectorBits;
  27. /// @brief Vectorize boolean values.
  28. bool VectorizeBools;
  29. /// @brief Vectorize integer values.
  30. bool VectorizeInts;
  31. /// @brief Vectorize floating-point values.
  32. bool VectorizeFloats;
  33. /// @brief Vectorize pointer values.
  34. bool VectorizePointers;
  35. /// @brief Vectorize casting (conversion) operations.
  36. bool VectorizeCasts;
  37. /// @brief Vectorize floating-point math intrinsics.
  38. bool VectorizeMath;
  39. /// @brief Vectorize bit intrinsics.
  40. bool VectorizeBitManipulations;
  41. /// @brief Vectorize the fused-multiply-add intrinsic.
  42. bool VectorizeFMA;
  43. /// @brief Vectorize select instructions.
  44. bool VectorizeSelect;
  45. /// @brief Vectorize comparison instructions.
  46. bool VectorizeCmp;
  47. /// @brief Vectorize getelementptr instructions.
  48. bool VectorizeGEP;
  49. /// @brief Vectorize loads and stores.
  50. bool VectorizeMemOps;
  51. /// @brief Only generate aligned loads and stores.
  52. bool AlignedOnly;
  53. //===--------------------------------------------------------------------===//
  54. // Misc parameters
  55. /// @brief The required chain depth for vectorization.
  56. unsigned ReqChainDepth;
  57. /// @brief The maximum search distance for instruction pairs.
  58. unsigned SearchLimit;
  59. /// @brief The maximum number of candidate pairs with which to use a full
  60. /// cycle check.
  61. unsigned MaxCandPairsForCycleCheck;
  62. /// @brief Replicating one element to a pair breaks the chain.
  63. bool SplatBreaksChain;
  64. /// @brief The maximum number of pairable instructions per group.
  65. unsigned MaxInsts;
  66. /// @brief The maximum number of candidate instruction pairs per group.
  67. unsigned MaxPairs;
  68. /// @brief The maximum number of pairing iterations.
  69. unsigned MaxIter;
  70. /// @brief Don't try to form odd-length vectors.
  71. bool Pow2LenOnly;
  72. /// @brief Don't boost the chain-depth contribution of loads and stores.
  73. bool NoMemOpBoost;
  74. /// @brief Use a fast instruction dependency analysis.
  75. bool FastDep;
  76. /// @brief Initialize the VectorizeConfig from command line options.
  77. VectorizeConfig();
  78. };
  79. //===----------------------------------------------------------------------===//
  80. //
  81. // BBVectorize - A basic-block vectorization pass.
  82. //
  83. BasicBlockPass *
  84. createBBVectorizePass(const VectorizeConfig &C = VectorizeConfig());
  85. //===----------------------------------------------------------------------===//
  86. //
  87. // LoopVectorize - Create a loop vectorization pass.
  88. //
  89. Pass *createLoopVectorizePass(bool NoUnrolling = false,
  90. bool AlwaysVectorize = true);
  91. //===----------------------------------------------------------------------===//
  92. //
  93. // SLPVectorizer - Create a bottom-up SLP vectorizer pass.
  94. //
  95. Pass *createSLPVectorizerPass();
  96. // //
  97. ///////////////////////////////////////////////////////////////////////////////
  98. /// @brief Vectorize the BasicBlock.
  99. ///
  100. /// @param BB The BasicBlock to be vectorized
  101. /// @param P The current running pass, should require AliasAnalysis and
  102. /// ScalarEvolution. After the vectorization, AliasAnalysis,
  103. /// ScalarEvolution and CFG are preserved.
  104. ///
  105. /// @return True if the BB is changed, false otherwise.
  106. ///
  107. bool vectorizeBasicBlock(Pass *P, BasicBlock &BB,
  108. const VectorizeConfig &C = VectorizeConfig());
  109. } // End llvm namespace
  110. #endif