Scalarizer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- Scalarizer.h --- Scalarize vector operations -----------------------===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. /// \file
  15. /// This pass converts vector operations into scalar operations, in order
  16. /// to expose optimization opportunities on the individual scalar operations.
  17. /// It is mainly intended for targets that do not have vector units, but it
  18. /// may also be useful for revectorizing code to different vector widths.
  19. //
  20. //===----------------------------------------------------------------------===//
  21. #ifndef LLVM_TRANSFORMS_SCALAR_SCALARIZER_H
  22. #define LLVM_TRANSFORMS_SCALAR_SCALARIZER_H
  23. #include "llvm/IR/PassManager.h"
  24. #include <optional>
  25. namespace llvm {
  26. class Function;
  27. class FunctionPass;
  28. struct ScalarizerPassOptions {
  29. // These optional booleans correspond 1:1 to cl::opt<bool> options defined in
  30. // Scalarizer.cpp. When the cl::opt are specified, they take precedence.
  31. // When the cl::opt are not specified, the present optional booleans allow to
  32. // override the cl::opt's default values.
  33. std::optional<bool> ScalarizeVariableInsertExtract;
  34. std::optional<bool> ScalarizeLoadStore;
  35. };
  36. class ScalarizerPass : public PassInfoMixin<ScalarizerPass> {
  37. ScalarizerPassOptions Options;
  38. public:
  39. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  40. void setScalarizeVariableInsertExtract(bool Value) {
  41. Options.ScalarizeVariableInsertExtract = Value;
  42. }
  43. void setScalarizeLoadStore(bool Value) { Options.ScalarizeLoadStore = Value; }
  44. };
  45. /// Create a legacy pass manager instance of the Scalarizer pass
  46. FunctionPass *createScalarizerPass();
  47. }
  48. #endif /* LLVM_TRANSFORMS_SCALAR_SCALARIZER_H */
  49. #ifdef __GNUC__
  50. #pragma GCC diagnostic pop
  51. #endif