mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:31:05 +01:00
Support for lowering references to imported vars. (#5513)
Previously we walked the global variables defined by the current file and emitted an LLVM global variable definition for each of them. Now instead, when emitting a constant reference to a global variable, we emit an LLVM global variable declaration, and we then subsequently walk the global variables defined by the current file and convert each of them from a declaration to a definition. In order to make import of names of global variables work, add support for import of `var`, as well as support for importing `tuple_access` and `tuple_pattern` in the case where the `var` has a tuple pattern in its declaration. Also treat `bind_name`s that are reference bindings to `var`s as having the same constant reference value as their `var` so that we can properly import and lower them. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com> Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
Carbon Infra Bot
parent
c6f25e9018
commit
a23631f360
@@ -77,7 +77,7 @@ static auto LowerInstHelper(FunctionContext& context, SemIR::InstId inst_id,
|
||||
} else if constexpr (InstT::Kind.constant_kind() ==
|
||||
SemIR::InstConstantKind::Always ||
|
||||
InstT::Kind.constant_kind() ==
|
||||
SemIR::InstConstantKind::Unique) {
|
||||
SemIR::InstConstantKind::AlwaysUnique) {
|
||||
CARBON_FATAL("Missing constant value for constant instruction {0}", inst);
|
||||
} else if constexpr (InstT::Kind.is_type() == SemIR::InstIsType::Always) {
|
||||
// For instructions that are always of type `type`, produce the trivial
|
||||
|
||||
Reference in New Issue
Block a user