mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 22:02:45 +01:00
At present, lower depends on `Check::SemIRDiagnosticConverter` for debug info. That was to support a quick implementation of debug info, but isn't great because it's both an unusual dependency on check's implementation, and relying on diagnostic structures for debug info. This cleans that up by splitting relevant logic out to a library in sem_ir, and having lowering use sem_ir's library instead of check's. Additionally, a small refactoring of `Parse::TreeAndSubtrees` to allow getting locations in lowering without going through a `DiagnosticLoc`. I'm adding `Parse::GetTreeAndSubtreesFn` in because it's a complex signature to have in so many spots. I chose to have `ResolveNodeId` return a `SmallVector` because it seemed likely to be fairly compact, but that could also be using an optional callback to handle resolved node IDs, possibly just returning the last entry. This could be switched if preferred. Note this change shouldn't affect behavior, it's just moving code around. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
24 lines
900 B
C++
24 lines
900 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/lower/lower.h"
|
|
|
|
#include "toolchain/lower/file_context.h"
|
|
|
|
namespace Carbon::Lower {
|
|
|
|
auto LowerToLLVM(llvm::LLVMContext& llvm_context,
|
|
std::optional<llvm::ArrayRef<Parse::GetTreeAndSubtreesFn>>
|
|
all_trees_and_subtrees_for_debug_info,
|
|
llvm::StringRef module_name, const SemIR::File& sem_ir,
|
|
const SemIR::InstNamer* inst_namer,
|
|
llvm::raw_ostream* vlog_stream)
|
|
-> std::unique_ptr<llvm::Module> {
|
|
FileContext context(llvm_context, all_trees_and_subtrees_for_debug_info,
|
|
module_name, sem_ir, inst_namer, vlog_stream);
|
|
return context.Run();
|
|
}
|
|
|
|
} // namespace Carbon::Lower
|