Vectorize.h 4.3 KB

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