Lower CppOverloadSetValue (#6101)

Following up on comments from
[#5891](https://github.com/carbon-language/carbon-lang/pull/5891) ([
1](https://github.com/carbon-language/carbon-lang/pull/5891#discussion_r2317244981),
[2](https://github.com/carbon-language/carbon-lang/pull/5891#discussion_r2317266756)).

Lowering `CppOverloadSetValue` as an empty struct value, using
`context.GetLiteralAsValue()`. Also changed its constant kind to
`InstConstantKind::Always`.

Part of https://github.com/carbon-language/carbon-lang/issues/5915
This commit is contained in:
Ivana Ivanovska
2025-10-01 16:25:05 +00:00
committed by GitHub
parent 4a6376cf59
commit a24598f069
40 changed files with 838 additions and 698 deletions
@@ -38,7 +38,7 @@ fn F() {
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %.fc4: type = cpp_overload_set_type @ImplicitAs.Convert [concrete]
// CHECK:STDOUT: %empty_struct.cca: %.fc4 = struct_value () [concrete]
// CHECK:STDOUT: %.6a4: %.fc4 = cpp_overload_set_value @ImplicitAs.Convert [concrete]
// CHECK:STDOUT: %int_42.20e: Core.IntLiteral = int_value 42 [concrete]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
@@ -63,7 +63,7 @@ fn F() {
// CHECK:STDOUT: %pattern_type.7da: type = pattern_type %S [concrete]
// CHECK:STDOUT: %S.val: %S = struct_value () [concrete]
// CHECK:STDOUT: %.289: type = cpp_overload_set_type @Core.IntLiteral.as.ImplicitAs.impl.Convert [concrete]
// CHECK:STDOUT: %empty_struct.269: %.289 = struct_value () [concrete]
// CHECK:STDOUT: %.7c2: %.289 = cpp_overload_set_value @Core.IntLiteral.as.ImplicitAs.impl.Convert [concrete]
// CHECK:STDOUT: %const: type = const_type %S [concrete]
// CHECK:STDOUT: %ptr.ff5: type = ptr_type %const [concrete]
// CHECK:STDOUT: %TakesConstS__carbon_thunk.type: type = fn_type @TakesConstS__carbon_thunk [concrete]
@@ -82,7 +82,7 @@ fn F() {
// CHECK:STDOUT: .TakesConstS = %.7c2
// CHECK:STDOUT: import Cpp//...
// CHECK:STDOUT: }
// CHECK:STDOUT: %.6a4: %.fc4 = cpp_overload_set_value @ImplicitAs.Convert [concrete = constants.%empty_struct.cca]
// CHECK:STDOUT: %.6a4: %.fc4 = cpp_overload_set_value @ImplicitAs.Convert [concrete = constants.%.6a4]
// CHECK:STDOUT: %TakesConstInt.decl: %TakesConstInt.type = fn_decl @TakesConstInt [concrete = constants.%TakesConstInt] {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: } {
@@ -91,7 +91,7 @@ fn F() {
// CHECK:STDOUT: %Core.import_ref.ee7: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.340) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.1c0)]
// CHECK:STDOUT: %ImplicitAs.impl_witness_table.9e9 = impl_witness_table (%Core.import_ref.ee7), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
// CHECK:STDOUT: %S.decl: type = class_decl @S [concrete = constants.%S] {} {}
// CHECK:STDOUT: %.7c2: %.289 = cpp_overload_set_value @Core.IntLiteral.as.ImplicitAs.impl.Convert [concrete = constants.%empty_struct.269]
// CHECK:STDOUT: %.7c2: %.289 = cpp_overload_set_value @Core.IntLiteral.as.ImplicitAs.impl.Convert [concrete = constants.%.7c2]
// CHECK:STDOUT: %TakesConstS__carbon_thunk.decl: %TakesConstS__carbon_thunk.type = fn_decl @TakesConstS__carbon_thunk [concrete = constants.%TakesConstS__carbon_thunk] {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: } {
@@ -102,7 +102,7 @@ fn F() {
// CHECK:STDOUT: fn @F() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %Cpp.ref.loc8: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %TakesConstInt.ref: %.fc4 = name_ref TakesConstInt, imports.%.6a4 [concrete = constants.%empty_struct.cca]
// CHECK:STDOUT: %TakesConstInt.ref: %.fc4 = name_ref TakesConstInt, imports.%.6a4 [concrete = constants.%.6a4]
// CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [concrete = constants.%int_42.20e]
// CHECK:STDOUT: %impl.elem0: %.1df = impl_witness_access constants.%ImplicitAs.impl_witness.204, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0]
// CHECK:STDOUT: %bound_method.loc8_21.1: <bound method> = bound_method %int_42, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
@@ -127,7 +127,7 @@ fn F() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %s: ref %S = bind_name s, %s.var
// CHECK:STDOUT: %Cpp.ref.loc11: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
// CHECK:STDOUT: %TakesConstS.ref: %.289 = name_ref TakesConstS, imports.%.7c2 [concrete = constants.%empty_struct.269]
// CHECK:STDOUT: %TakesConstS.ref: %.289 = name_ref TakesConstS, imports.%.7c2 [concrete = constants.%.7c2]
// CHECK:STDOUT: %s.ref: ref %S = name_ref s, %s
// CHECK:STDOUT: %.loc11_19.1: %S = bind_value %s.ref
// CHECK:STDOUT: %.loc11_19.2: ref %S = value_as_ref %.loc11_19.1