options.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_LOWER_OPTIONS_H_
  5. #define CARBON_TOOLCHAIN_LOWER_OPTIONS_H_
  6. #include "llvm/Support/raw_ostream.h"
  7. namespace Carbon::Lower {
  8. enum class OptimizationLevel {
  9. // No optimizations beyond necessary ones like inlining always-inline
  10. // functions. Corresponds to Clang -O0.
  11. None,
  12. // Perform optimizations that make the build faster and don't degrade
  13. // debugging. Corresponds to Clang -O1 or -Og.
  14. Debug,
  15. // Optimize for binary size. Corresponds to Clang -Oz.
  16. Size,
  17. // Optimize for program execution speed. Corresponds to Clang -O3.
  18. Speed,
  19. };
  20. struct LowerToLLVMOptions {
  21. // Options must be set individually, not through initialization.
  22. explicit LowerToLLVMOptions() = default;
  23. // If set, enables LLVM IR verification.
  24. llvm::raw_ostream* llvm_verifier_stream = nullptr;
  25. // Whether to include debug info in lowered output.
  26. bool want_debug_info = false;
  27. // If set, enables verbose output.
  28. llvm::raw_ostream* vlog_stream = nullptr;
  29. // The optimization level to set on lowered functions by default.
  30. OptimizationLevel opt_level = OptimizationLevel::Debug;
  31. };
  32. } // namespace Carbon::Lower
  33. #endif // CARBON_TOOLCHAIN_LOWER_OPTIONS_H_