lower.cpp 1.1 KB

123456789101112131415161718192021222324252627282930
  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(llvm::LLVMContext& llvm_context,
  11. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
  12. std::optional<llvm::ArrayRef<Parse::GetTreeAndSubtreesFn>>
  13. tree_and_subtrees_getters_for_debug_info,
  14. llvm::StringRef module_name, const SemIR::File& sem_ir,
  15. const SemIR::InstNamer* inst_namer,
  16. llvm::raw_ostream* vlog_stream)
  17. -> std::unique_ptr<llvm::Module> {
  18. Context context(llvm_context, std::move(fs),
  19. tree_and_subtrees_getters_for_debug_info, module_name,
  20. vlog_stream);
  21. context.GetFileContext(&sem_ir, inst_namer).LowerDefinitions();
  22. return std::move(context).Finalize();
  23. }
  24. } // namespace Carbon::Lower