lower.cpp 1.0 KB

12345678910111213141516171819202122232425262728
  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, bool want_debug_info,
  13. llvm::ArrayRef<Parse::GetTreeAndSubtreesFn> tree_and_subtrees_getters,
  14. llvm::StringRef module_name, const SemIR::File& sem_ir,
  15. const SemIR::InstNamer* inst_namer, llvm::raw_ostream* vlog_stream)
  16. -> std::unique_ptr<llvm::Module> {
  17. Context context(llvm_context, std::move(fs), want_debug_info,
  18. tree_and_subtrees_getters, module_name, vlog_stream);
  19. context.GetFileContext(&sem_ir, inst_namer).LowerDefinitions();
  20. return std::move(context).Finalize();
  21. }
  22. } // namespace Carbon::Lower