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