lower.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_LOWER_H_
  5. #define CARBON_TOOLCHAIN_LOWER_LOWER_H_
  6. #include "llvm/ADT/ArrayRef.h"
  7. #include "llvm/IR/LLVMContext.h"
  8. #include "llvm/IR/Module.h"
  9. #include "toolchain/parse/tree_and_subtrees.h"
  10. #include "toolchain/sem_ir/file.h"
  11. #include "toolchain/sem_ir/inst_namer.h"
  12. namespace Carbon::Lower {
  13. struct LowerToLLVMOptions {
  14. // Options must be set individually, not through initialization.
  15. explicit LowerToLLVMOptions() = default;
  16. // If set, enables LLVM IR verification.
  17. llvm::raw_ostream* llvm_verifier_stream = nullptr;
  18. // Whether to include debug info in lowered output.
  19. bool want_debug_info = false;
  20. // If set, enables verbose output.
  21. llvm::raw_ostream* vlog_stream = nullptr;
  22. // If set, LLVM IR will be dumped to this in textual form.
  23. llvm::raw_ostream* dump_stream = nullptr;
  24. };
  25. // Lowers SemIR to LLVM IR.
  26. auto LowerToLLVM(
  27. llvm::LLVMContext& llvm_context,
  28. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
  29. const Parse::GetTreeAndSubtreesStore& tree_and_subtrees_getters,
  30. const SemIR::File& sem_ir, int total_ir_count,
  31. const LowerToLLVMOptions& options) -> std::unique_ptr<llvm::Module>;
  32. } // namespace Carbon::Lower
  33. #endif // CARBON_TOOLCHAIN_LOWER_LOWER_H_