Skip to content

Commit 0811d99

Browse files
authored
Finish renaming BindName and related insts. (#6281)
Resolves the TODO from #6235
1 parent 5e0201e commit 0811d99

File tree

482 files changed

+26205
-26211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

482 files changed

+26205
-26211
lines changed

toolchain/check/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class Context {
176176
// TODO: Consider putting this behind a narrower API to guard against emitting
177177
// multiple times.
178178
struct BindingPatternInfo {
179-
// The corresponding AnyBindName inst.
179+
// The corresponding AnyBinding inst.
180180
SemIR::InstId bind_name_id;
181181
// The region of insts that computes the type of the binding.
182182
SemIR::ExprRegionId type_expr_region_id;

toolchain/check/convert.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ static auto PerformBuiltinConversion(
10151015
{.type_id = target.type_id, .source_id = value_id});
10161016

10171017
if (need_value_binding) {
1018-
value_id = AddInst<SemIR::BindValue>(
1018+
value_id = AddInst<SemIR::AcquireValue>(
10191019
context, loc_id,
10201020
{.type_id = target.type_id, .value_id = value_id});
10211021
}
@@ -1226,9 +1226,9 @@ static auto PerformBuiltinConversion(
12261226
// converting back to the type of the original symbolic binding facet
12271227
// value.
12281228
//
1229-
// In the case where the FacetAccessType wraps a BindSymbolicName with the
1229+
// In the case where the FacetAccessType wraps a SymbolicBinding with the
12301230
// exact facet type that we are converting to, the resulting FacetValue
1231-
// would evaluate back to the original BindSymbolicName as its canonical
1231+
// would evaluate back to the original SymbolicBinding as its canonical
12321232
// form. We can skip past the whole impl lookup step then and do that
12331233
// here.
12341234
//
@@ -1576,7 +1576,7 @@ auto Convert(Context& context, SemIR::LocId loc_id, SemIR::InstId expr_id,
15761576

15771577
// If we have a reference and don't want one, form a value binding.
15781578
// TODO: Support types with custom value representations.
1579-
expr_id = AddInst<SemIR::BindValue>(
1579+
expr_id = AddInst<SemIR::AcquireValue>(
15801580
context, SemIR::LocId(expr_id),
15811581
{.type_id = target.type_id, .value_id = expr_id});
15821582
// We now have a value expression.

toolchain/check/deduce.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ auto DeductionContext::Deduce() -> bool {
375375
// Deducing a symbolic binding appearing within an expression against a
376376
// constant value deduces the binding as having that value. For example,
377377
// deducing `[T:! type](x: T)` against `("foo")` deduces `T` as `String`.
378-
case CARBON_KIND(SemIR::BindSymbolicName bind): {
378+
case CARBON_KIND(SemIR::SymbolicBinding bind): {
379379
auto& entity_name = context().entity_names().Get(bind.entity_name_id);
380380
auto index = entity_name.bind_index();
381381
if (!index.has_value() || index < first_deduced_index_ ||
@@ -465,7 +465,7 @@ static auto GetEntityNameForGenericBinding(Context& context,
465465
binding_id = context.constant_values().GetConstantInstId(binding_id);
466466

467467
if (auto bind_name =
468-
context.insts().TryGetAs<SemIR::AnyBindName>(binding_id)) {
468+
context.insts().TryGetAs<SemIR::AnyBinding>(binding_id)) {
469469
return context.entity_names().Get(bind_name->entity_name_id).name_id;
470470
} else {
471471
CARBON_FATAL("Instruction without entity name in generic binding position");

toolchain/check/eval.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class EvalContext {
8585

8686
// Gets the value of the specified compile-time binding in this context.
8787
// Returns `None` if the value is not fixed in this context.
88-
auto GetCompileTimeBindValue(SemIR::CompileTimeBindIndex bind_index)
88+
auto GetCompileTimeAcquireValue(SemIR::CompileTimeBindIndex bind_index)
8989
-> SemIR::ConstantId {
9090
if (!bind_index.has_value() || !specific_id_.has_value()) {
9191
return SemIR::ConstantId::None;
@@ -2142,18 +2142,18 @@ auto TryEvalTypedInst<SemIR::ImportRefLoaded>(EvalContext& /*eval_context*/,
21422142
// Symbolic bindings are a special case because they can reach into the eval
21432143
// context and produce a context-specific value.
21442144
template <>
2145-
auto TryEvalTypedInst<SemIR::BindSymbolicName>(EvalContext& eval_context,
2146-
SemIR::InstId inst_id,
2147-
SemIR::Inst inst)
2145+
auto TryEvalTypedInst<SemIR::SymbolicBinding>(EvalContext& eval_context,
2146+
SemIR::InstId inst_id,
2147+
SemIR::Inst inst)
21482148
-> SemIR::ConstantId {
2149-
auto bind = inst.As<SemIR::BindSymbolicName>();
2149+
auto bind = inst.As<SemIR::SymbolicBinding>();
21502150

21512151
// If we know which specific we're evaluating within and this is an argument
21522152
// of that specific, its constant value is the corresponding argument value.
21532153
const auto& bind_name = eval_context.entity_names().Get(bind.entity_name_id);
21542154
if (bind_name.bind_index().has_value()) {
21552155
if (auto value =
2156-
eval_context.GetCompileTimeBindValue(bind_name.bind_index());
2156+
eval_context.GetCompileTimeAcquireValue(bind_name.bind_index());
21572157
value.has_value()) {
21582158
return value;
21592159
}
@@ -2165,7 +2165,7 @@ auto TryEvalTypedInst<SemIR::BindSymbolicName>(EvalContext& eval_context,
21652165
bind.value_id = SemIR::InstId::None;
21662166
if (!ReplaceTypeWithConstantValue(eval_context, inst_id, &bind, &phase) ||
21672167
!ReplaceFieldWithConstantValue(eval_context, &bind,
2168-
&SemIR::BindSymbolicName::entity_name_id,
2168+
&SemIR::SymbolicBinding::entity_name_id,
21692169
&phase)) {
21702170
return SemIR::ConstantId::NotConstant;
21712171
}
@@ -2184,14 +2184,14 @@ auto TryEvalTypedInst<SemIR::SymbolicBindingType>(EvalContext& eval_context,
21842184
inst.As<SemIR::SymbolicBindingType>().entity_name_id);
21852185
if (bind_name.bind_index().has_value()) {
21862186
if (auto value =
2187-
eval_context.GetCompileTimeBindValue(bind_name.bind_index());
2187+
eval_context.GetCompileTimeAcquireValue(bind_name.bind_index());
21882188
value.has_value()) {
21892189
auto value_inst_id = eval_context.constant_values().GetInstId(value);
21902190

21912191
// A SymbolicBindingType can evaluate to a FacetAccessType if the new
21922192
// value of the entity is a facet value that that does not have a concrete
21932193
// type (a FacetType) and does not have a new EntityName to point to (a
2194-
// BindSymbolicName).
2194+
// SymbolicBinding).
21952195
auto access = SemIR::FacetAccessType{
21962196
.type_id = SemIR::TypeType::TypeId,
21972197
.facet_value_inst_id = value_inst_id,

toolchain/check/eval_inst.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ auto EvalConstantInst(Context& context, SemIR::AsCompatible inst)
9898
return ConstantEvalResult::NewAnyPhase(value_inst);
9999
}
100100

101-
auto EvalConstantInst(Context& context, SemIR::BindAlias inst)
101+
auto EvalConstantInst(Context& context, SemIR::AliasBinding inst)
102102
-> ConstantEvalResult {
103103
// An alias evaluates to the value it's bound to.
104104
return ConstantEvalResult::Existing(
@@ -121,7 +121,7 @@ auto EvalConstantInst(Context& /*context*/, SemIR::ValueBinding /*inst*/)
121121
return ConstantEvalResult::NotConstant;
122122
}
123123

124-
auto EvalConstantInst(Context& /*context*/, SemIR::BindValue /*inst*/)
124+
auto EvalConstantInst(Context& /*context*/, SemIR::AcquireValue /*inst*/)
125125
-> ConstantEvalResult {
126126
// TODO: Handle this once we've decided how to represent constant values of
127127
// reference expressions.
@@ -204,7 +204,7 @@ auto EvalConstantInst(Context& context, SemIR::FacetAccessType inst)
204204
context.constant_values().Get(facet_value->type_inst_id));
205205
}
206206

207-
if (auto bind_name = context.insts().TryGetAs<SemIR::BindSymbolicName>(
207+
if (auto bind_name = context.insts().TryGetAs<SemIR::SymbolicBinding>(
208208
inst.facet_value_inst_id)) {
209209
return ConstantEvalResult::NewSamePhase(SemIR::SymbolicBindingType{
210210
.type_id = SemIR::TypeType::TypeId,
@@ -233,13 +233,13 @@ auto EvalConstantInst(Context& context, SemIR::FacetAccessType inst)
233233

234234
auto EvalConstantInst(Context& context, SemIR::FacetValue inst)
235235
-> ConstantEvalResult {
236-
// A FacetValue that just wraps a BindSymbolicName without adding/removing any
237-
// witnesses is evaluated back to the BindSymbolicName itself.
236+
// A FacetValue that just wraps a SymbolicBinding without adding/removing any
237+
// witnesses is evaluated back to the SymbolicBinding itself.
238238
if (auto bind_as_type = context.insts().TryGetAs<SemIR::SymbolicBindingType>(
239239
inst.type_inst_id)) {
240240
// TODO: Look in ScopeStack with the entity_name_id to find the facet value.
241241
auto bind_id = bind_as_type->facet_value_inst_id;
242-
auto bind = context.insts().GetAs<SemIR::BindSymbolicName>(bind_id);
242+
auto bind = context.insts().GetAs<SemIR::SymbolicBinding>(bind_id);
243243
// If the FacetTypes are the same, then the FacetValue didn't add/remove
244244
// any witnesses.
245245
if (bind.type_id == inst.type_id) {

toolchain/check/facet_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ auto MakePeriodSelfFacetValue(Context& context, SemIR::TypeId self_type_id)
636636
.parent_scope_id = context.scope_stack().PeekNameScopeId(),
637637
});
638638
auto inst_id = AddInst(
639-
context, SemIR::LocIdAndInst::NoLoc<SemIR::BindSymbolicName>({
639+
context, SemIR::LocIdAndInst::NoLoc<SemIR::SymbolicBinding>({
640640
.type_id = self_type_id,
641641
.entity_name_id = entity_name_id,
642642
// `None` because there is no equivalent non-symbolic value.

toolchain/check/facet_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ auto ResolveFacetTypeRewriteConstraints(
107107
-> bool;
108108

109109
// Introduce `.Self` as a symbolic binding into the current scope, and return
110-
// the `BindSymbolicName` instruction.
110+
// the `SymbolicBinding` instruction.
111111
//
112112
// The `self_type_id` is either a facet type (as `FacetType`) or `type` (as
113113
// `TypeType`).

toolchain/check/generic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class RebuildGenericConstantInEvalBlockCallbacks : public SubstInstCallbacks {
149149
auto ReuseUnchanged(SemIR::InstId orig_inst_id) -> SemIR::InstId override {
150150
auto inst = context().insts().Get(orig_inst_id);
151151
CARBON_CHECK(
152-
inst.Is<SemIR::BindSymbolicName>() ||
152+
inst.Is<SemIR::SymbolicBinding>() ||
153153
inst.Is<SemIR::SymbolicBindingPattern>(),
154154
"Instruction {0} has symbolic constant value but no symbolic operands",
155155
inst);

toolchain/check/handle_alias.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ auto HandleParseNode(Context& context, Parse::AliasId /*node_id*/) -> bool {
6666
alias_type_id = SemIR::ErrorInst::TypeId;
6767
alias_value_id = SemIR::ErrorInst::InstId;
6868
}
69-
auto alias_id = AddInst<SemIR::BindAlias>(context, name_context.loc_id,
70-
{.type_id = alias_type_id,
71-
.entity_name_id = entity_name_id,
72-
.value_id = alias_value_id});
69+
auto alias_id =
70+
AddInst<SemIR::AliasBinding>(context, name_context.loc_id,
71+
{.type_id = alias_type_id,
72+
.entity_name_id = entity_name_id,
73+
.value_id = alias_value_id});
7374

7475
// Add the name of the binding to the current scope.
7576
context.decl_name_stack().PopScope();

toolchain/check/handle_binding_pattern.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
7474
AddBindingPattern(context, name_node, name_id, cast_type_id,
7575
type_expr_region_id, pattern_inst_kind, is_template);
7676

77-
// TODO: If `is_generic`, then `binding.bind_id is a BindSymbolicName. Subst
77+
// TODO: If `is_generic`, then `binding.bind_id is a SymbolicBinding. Subst
7878
// the `.Self` of type `type` in the `cast_type_id` type (a `FacetType`)
7979
// with the `binding.bind_id` itself, and build a new pattern with that.
8080
// This is kind of cyclical. So we need to reuse the EntityNameId, which
81-
// will also reuse the CompileTimeBinding for the new BindSymbolicName.
81+
// will also reuse the CompileTimeBinding for the new SymbolicBinding.
8282

8383
if (name_id != SemIR::NameId::Underscore) {
8484
// Add name to lookup immediately, so it can be used in the rest of the

0 commit comments

Comments
 (0)