|
|
|||
File indexing completed on 2026-05-10 08:44:42
0001 //===- Scalarizer.h --- Scalarize vector operations -----------------------===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 /// \file 0010 /// This pass converts vector operations into scalar operations (or, optionally, 0011 /// operations on smaller vector widths), in order to expose optimization 0012 /// opportunities on the individual scalar operations. 0013 /// It is mainly intended for targets that do not have vector units, but it 0014 /// may also be useful for revectorizing code to different vector widths. 0015 // 0016 //===----------------------------------------------------------------------===// 0017 0018 #ifndef LLVM_TRANSFORMS_SCALAR_SCALARIZER_H 0019 #define LLVM_TRANSFORMS_SCALAR_SCALARIZER_H 0020 0021 #include "llvm/IR/PassManager.h" 0022 #include <optional> 0023 0024 namespace llvm { 0025 0026 class Function; 0027 class FunctionPass; 0028 0029 struct ScalarizerPassOptions { 0030 /// Instruct the scalarizer pass to attempt to keep values of a minimum number 0031 /// of bits. 0032 0033 /// Split vectors larger than this size into fragments, where each fragment is 0034 /// either a vector no larger than this size or a scalar. 0035 /// 0036 /// Instructions with operands or results of different sizes that would be 0037 /// split into a different number of fragments are currently left as-is. 0038 unsigned ScalarizeMinBits = 0; 0039 0040 /// Allow the scalarizer pass to scalarize insertelement/extractelement with 0041 /// variable index. 0042 bool ScalarizeVariableInsertExtract = true; 0043 0044 /// Allow the scalarizer pass to scalarize loads and store 0045 /// 0046 /// This is disabled by default because having separate loads and stores makes 0047 /// it more likely that the -combiner-alias-analysis limits will be reached. 0048 bool ScalarizeLoadStore = false; 0049 }; 0050 0051 class ScalarizerPass : public PassInfoMixin<ScalarizerPass> { 0052 ScalarizerPassOptions Options; 0053 0054 public: 0055 ScalarizerPass() = default; 0056 ScalarizerPass(const ScalarizerPassOptions &Options) : Options(Options) {} 0057 0058 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 0059 0060 void setScalarizeVariableInsertExtract(bool Value) { 0061 Options.ScalarizeVariableInsertExtract = Value; 0062 } 0063 void setScalarizeLoadStore(bool Value) { Options.ScalarizeLoadStore = Value; } 0064 void setScalarizeMinBits(unsigned Value) { Options.ScalarizeMinBits = Value; } 0065 }; 0066 0067 /// Create a legacy pass manager instance of the Scalarizer pass 0068 FunctionPass *createScalarizerPass( 0069 const ScalarizerPassOptions &Options = ScalarizerPassOptions()); 0070 } 0071 0072 #endif /* LLVM_TRANSFORMS_SCALAR_SCALARIZER_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|