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