lower.cpp 1.1 KB

1234567891011121314151617181920212223242526272829
  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. #include "toolchain/lower/lower.h"
  5. #include <memory>
  6. #include <optional>
  7. #include "toolchain/lower/context.h"
  8. #include "toolchain/lower/file_context.h"
  9. namespace Carbon::Lower {
  10. auto LowerToLLVM(
  11. llvm::LLVMContext& llvm_context,
  12. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
  13. llvm::raw_ostream* llvm_verifier_stream, bool want_debug_info,
  14. llvm::ArrayRef<Parse::GetTreeAndSubtreesFn> tree_and_subtrees_getters,
  15. llvm::StringRef module_name, const SemIR::File& sem_ir,
  16. const SemIR::InstNamer* inst_namer, llvm::raw_ostream* vlog_stream)
  17. -> std::unique_ptr<llvm::Module> {
  18. Context context(llvm_context, std::move(fs), want_debug_info,
  19. tree_and_subtrees_getters, module_name, vlog_stream);
  20. context.GetFileContext(&sem_ir, inst_namer).LowerDefinitions();
  21. return std::move(context).Finalize(llvm_verifier_stream);
  22. }
  23. } // namespace Carbon::Lower