From 9b35640a31d0591329bf8cfd882a8e80727920a8 Mon Sep 17 00:00:00 2001 From: Boaz Brickner Date: Tue, 16 Sep 2025 11:29:10 +0200 Subject: [PATCH] C++ interop: Add `Cpp.` (#6047) Based on proposal #5448. Defining all `Cpp.` names. Still unsupported types on LP64: `long long`, `unsigned long long` and `long double`. Still unsupported types on LLP64: `long`, `unsigned long` and `long double`. C++ Interop Demo (on LP64): ```c++ // half.h auto Half(long x) -> float; auto PrintLong(long x) -> void; auto PrintFloat(float x) -> void; ``` ```c++ // half.cpp #include auto Half(long x) -> float { return static_cast(x) / 2; } auto PrintLong(long x) -> void { printf("%ld\n", x); } auto PrintFloat(float x) -> void { printf("%f\n", x); } ``` ```carbon // main.carbon library "Main"; import Cpp library "half.h"; fn Run() -> i32 { let x: Cpp.long = 5; Cpp.PrintLong(x); let y: Cpp.float = Cpp.Half(x); Cpp.PrintFloat(y); return 0; } ``` ```shell $ clang -c half.cpp $ bazel-bin/toolchain/carbon compile main.carbon $ bazel-bin/toolchain/carbon link half.o main.o --output=demo $ ./demo 5 2.500000 ``` Part of #5263. --- toolchain/check/import_cpp.cpp | 63 ++ .../testdata/interop/cpp/builtins.carbon | 609 ++++++++++++++++++ .../interop/cpp/builtins.llp64.carbon | 268 ++++++++ .../testdata/interop/cpp/builtins.lp64.carbon | 268 ++++++++ 4 files changed, 1208 insertions(+) create mode 100644 toolchain/check/testdata/interop/cpp/builtins.carbon create mode 100644 toolchain/check/testdata/interop/cpp/builtins.llp64.carbon create mode 100644 toolchain/check/testdata/interop/cpp/builtins.lp64.carbon diff --git a/toolchain/check/import_cpp.cpp b/toolchain/check/import_cpp.cpp index 50cc3c826095..e654e306f41b 100644 --- a/toolchain/check/import_cpp.cpp +++ b/toolchain/check/import_cpp.cpp @@ -1970,6 +1970,61 @@ static auto ImportNameDeclIntoScope(Context& context, SemIR::LocId loc_id, access_kind); } +// Returns true if the scope is the top `Cpp` scope. +static auto IsTopCppScope(Context& context, SemIR::NameScopeId scope_id) + -> bool { + const SemIR::NameScope& name_scope = context.name_scopes().Get(scope_id); + CARBON_CHECK(name_scope.is_cpp_scope()); + return name_scope.parent_scope_id() == SemIR::NameScopeId::Package; +} + +// For builtin names like `Cpp.long`, return the associated types. +static auto LookupBuiltInTypes(Context& context, SemIR::LocId loc_id, + SemIR::NameScopeId scope_id, + SemIR::NameId name_id) -> SemIR::InstId { + if (!IsTopCppScope(context, scope_id)) { + return SemIR::InstId::None; + } + + auto name = context.names().GetAsStringIfIdentifier(name_id); + if (!name) { + return SemIR::InstId::None; + } + + const clang::ASTContext& ast_context = context.ast_context(); + + // List of types based on + // https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p5448.md#details + auto builtin_type = + llvm::StringSwitch(*name) + .Case("signed_char", ast_context.SignedCharTy) + .Case("short", ast_context.ShortTy) + .Case("int", ast_context.IntTy) + .Case("long", ast_context.LongTy) + .Case("long_long", ast_context.LongLongTy) + .Case("unsigned_char", ast_context.UnsignedCharTy) + .Case("unsigned_short", ast_context.UnsignedShortTy) + .Case("unsigned_int", ast_context.UnsignedIntTy) + .Case("unsigned_long", ast_context.UnsignedLongTy) + .Case("unsigned_long_long", ast_context.UnsignedLongLongTy) + .Case("float", ast_context.FloatTy) + .Case("double", ast_context.DoubleTy) + .Case("long_double", ast_context.LongDoubleTy) + .Default(clang::QualType()); + if (builtin_type.isNull()) { + return SemIR::InstId::None; + } + + SemIR::InstId inst_id = + MapNonWrapperType(context, loc_id, builtin_type).inst_id; + if (!inst_id.has_value()) { + context.TODO(loc_id, llvm::formatv("Unsupported: builtin type: {0}", + builtin_type.getAsString())); + return SemIR::ErrorInst::InstId; + } + return inst_id; +} + // Imports an overloaded function set from Clang to Carbon. static auto ImportCppOverloadSet(Context& context, SemIR::NameScopeId scope_id, SemIR::NameId name_id, @@ -2058,6 +2113,14 @@ auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id, auto lookup = ClangLookupName(context, scope_id, name_id); if (!lookup) { + SemIR::InstId builtin_inst_id = + LookupBuiltInTypes(context, loc_id, scope_id, name_id); + if (builtin_inst_id.has_value()) { + AddNameToScope(context, scope_id, name_id, SemIR::AccessKind::Public, + builtin_inst_id); + return SemIR::ScopeLookupResult::MakeWrappedLookupResult( + builtin_inst_id, SemIR::AccessKind::Public); + } return SemIR::ScopeLookupResult::MakeNotFound(); } diff --git a/toolchain/check/testdata/interop/cpp/builtins.carbon b/toolchain/check/testdata/interop/cpp/builtins.carbon new file mode 100644 index 000000000000..a50a563ed5df --- /dev/null +++ b/toolchain/check/testdata/interop/cpp/builtins.carbon @@ -0,0 +1,609 @@ +// 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-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/builtins.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/builtins.carbon + +// --- supported_types.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + //@dump-sem-ir-begin + let cpp_signed_char : Cpp.signed_char = 1 as i8; + let carbon_signed_char: i8 = cpp_signed_char; + + let cpp_short : Cpp.short = 1 as i16; + let carbon_short: i16 = cpp_short; + + let cpp_int : Cpp.int = 1 as i32; + let carbon_int: i32 = cpp_int; + + let cpp_unsigned_char : Cpp.unsigned_char = 1 as u8; + let carbon_unsigned_char: u8 = cpp_unsigned_char; + + let cpp_unsigned_short : Cpp.unsigned_short = 1 as u16; + let carbon_unsigned_short: u16 = cpp_unsigned_short; + + let cpp_unsigned_int : Cpp.unsigned_int = 1 as u32; + let carbon_unsigned_int: u32 = cpp_unsigned_int; + + let cpp_float : Cpp.float = 1.0 as f32; + let carbon_float: f32 = cpp_float; + + let cpp_double : Cpp.double = 1.0 as f64; + let carbon_double: f64 = cpp_double; + //@dump-sem-ir-end +} + +// --- fail_todo_unsupported_types.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + //@dump-sem-ir-begin + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+7]]:25: error: semantics TODO: `Unsupported: builtin type: long double` [SemanticsTodo] + // CHECK:STDERR: let cpp_long_double : Cpp.long_double = 1.0 as f64; + // CHECK:STDERR: ^~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+4]]:25: note: in `Cpp` name lookup for `long_double` [InCppNameLookup] + // CHECK:STDERR: let cpp_long_double : Cpp.long_double = 1.0 as f64; + // CHECK:STDERR: ^~~~~~~~~~~~~~~ + // CHECK:STDERR: + let cpp_long_double : Cpp.long_double = 1.0 as f64; + let carbon_long_double: f64 = cpp_long_double; + //@dump-sem-ir-end +} + +// --- fail_not_builtin.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + // CHECK:STDERR: fail_not_builtin.carbon:[[@LINE+4]]:21: error: member name `not_builtin` not found in `Cpp` [MemberNameNotFoundInInstScope] + // CHECK:STDERR: let not_builtin : Cpp.not_builtin = 1; + // CHECK:STDERR: ^~~~~~~~~~~~~~~ + // CHECK:STDERR: + let not_builtin : Cpp.not_builtin = 1; +} + +// --- fail_lookup_in_other_scopes.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ''' +namespace MyNamespace {} +'''; + +fn F() { + // CHECK:STDERR: fail_lookup_in_other_scopes.carbon:[[@LINE+4]]:14: error: member name `long` not found in `Cpp.MyNamespace` [MemberNameNotFoundInInstScope] + // CHECK:STDERR: let long : Cpp.MyNamespace.long = 1; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + let long : Cpp.MyNamespace.long = 1; +} + +// --- override_builtin.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ''' +struct unsigned_int { + auto foo() -> unsigned int; +}; +'''; + +fn F() { + //@dump-sem-ir-begin + var unsigned_int : Cpp.unsigned_int; + let x: u32 = unsigned_int.foo(); + //@dump-sem-ir-end +} + +// CHECK:STDOUT: --- supported_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete] +// CHECK:STDOUT: %i8: type = class_type @Int, @Int(%int_8) [concrete] +// CHECK:STDOUT: %pattern_type.e3f: type = pattern_type %i8 [concrete] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %As.type.7d7: type = facet_type <@As, @As(%i8)> [concrete] +// CHECK:STDOUT: %As.Convert.type.cc1: type = fn_type @As.Convert, @As(%i8) [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.565: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d2c: %Core.IntLiteral.as.As.impl.Convert.type.565 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.d74: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.83e: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.e8b: %Core.IntLiteral.as.As.impl.Convert.type.83e = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.09b: %As.type.7d7 = facet_value Core.IntLiteral, (%As.impl_witness.d74) [concrete] +// CHECK:STDOUT: %.95e: type = fn_type_with_self_type %As.Convert.type.cc1, %As.facet.09b [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.09b: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.e8b [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.2e1: = specific_function %Core.IntLiteral.as.As.impl.Convert.e8b, @Core.IntLiteral.as.As.impl.Convert.1(%int_8) [concrete] +// CHECK:STDOUT: %bound_method.967: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.2e1 [concrete] +// CHECK:STDOUT: %int_1.30e: %i8 = int_value 1 [concrete] +// CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete] +// CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete] +// CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete] +// CHECK:STDOUT: %As.type.771: type = facet_type <@As, @As(%i16)> [concrete] +// CHECK:STDOUT: %As.Convert.type.be5: type = fn_type @As.Convert, @As(%i16) [concrete] +// CHECK:STDOUT: %As.impl_witness.2d2: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.38a: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.97a: %Core.IntLiteral.as.As.impl.Convert.type.38a = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.56b: %As.type.771 = facet_value Core.IntLiteral, (%As.impl_witness.2d2) [concrete] +// CHECK:STDOUT: %.026: type = fn_type_with_self_type %As.Convert.type.be5, %As.facet.56b [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.3fb: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.97a [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.613: = specific_function %Core.IntLiteral.as.As.impl.Convert.97a, @Core.IntLiteral.as.As.impl.Convert.1(%int_16) [concrete] +// CHECK:STDOUT: %bound_method.7be: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.613 [concrete] +// CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete] +// CHECK:STDOUT: %As.type.dbd: type = facet_type <@As, @As(%i32)> [concrete] +// CHECK:STDOUT: %As.Convert.type.99b: type = fn_type @As.Convert, @As(%i32) [concrete] +// CHECK:STDOUT: %As.impl_witness.080: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.aaf: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.414: %Core.IntLiteral.as.As.impl.Convert.type.aaf = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.b49: %As.type.dbd = facet_value Core.IntLiteral, (%As.impl_witness.080) [concrete] +// CHECK:STDOUT: %.351: type = fn_type_with_self_type %As.Convert.type.99b, %As.facet.b49 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.9f3: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.414 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.478: = specific_function %Core.IntLiteral.as.As.impl.Convert.414, @Core.IntLiteral.as.As.impl.Convert.1(%int_32) [concrete] +// CHECK:STDOUT: %bound_method.fb8: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.478 [concrete] +// CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete] +// CHECK:STDOUT: %u8: type = class_type @UInt, @UInt(%int_8) [concrete] +// CHECK:STDOUT: %pattern_type.8f3: type = pattern_type %u8 [concrete] +// CHECK:STDOUT: %As.type.340: type = facet_type <@As, @As(%u8)> [concrete] +// CHECK:STDOUT: %As.Convert.type.a56: type = fn_type @As.Convert, @As(%u8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.972: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.276: %Core.IntLiteral.as.As.impl.Convert.type.972 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.fb4: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.d25: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_8) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.cd6: %Core.IntLiteral.as.As.impl.Convert.type.d25 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.81d: %As.type.340 = facet_value Core.IntLiteral, (%As.impl_witness.fb4) [concrete] +// CHECK:STDOUT: %.3dd: type = fn_type_with_self_type %As.Convert.type.a56, %As.facet.81d [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.d14: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.cd6 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.95d: = specific_function %Core.IntLiteral.as.As.impl.Convert.cd6, @Core.IntLiteral.as.As.impl.Convert.2(%int_8) [concrete] +// CHECK:STDOUT: %bound_method.084: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.95d [concrete] +// CHECK:STDOUT: %int_1.e80: %u8 = int_value 1 [concrete] +// CHECK:STDOUT: %u16: type = class_type @UInt, @UInt(%int_16) [concrete] +// CHECK:STDOUT: %pattern_type.9db: type = pattern_type %u16 [concrete] +// CHECK:STDOUT: %As.type.e67: type = facet_type <@As, @As(%u16)> [concrete] +// CHECK:STDOUT: %As.Convert.type.c7c: type = fn_type @As.Convert, @As(%u16) [concrete] +// CHECK:STDOUT: %As.impl_witness.262: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.8e7: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_16) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d77: %Core.IntLiteral.as.As.impl.Convert.type.8e7 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.626: %As.type.e67 = facet_value Core.IntLiteral, (%As.impl_witness.262) [concrete] +// CHECK:STDOUT: %.982: type = fn_type_with_self_type %As.Convert.type.c7c, %As.facet.626 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.37a: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.d77 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.427: = specific_function %Core.IntLiteral.as.As.impl.Convert.d77, @Core.IntLiteral.as.As.impl.Convert.2(%int_16) [concrete] +// CHECK:STDOUT: %bound_method.552: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.427 [concrete] +// CHECK:STDOUT: %int_1.3e8: %u16 = int_value 1 [concrete] +// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.4a9: type = pattern_type %u32 [concrete] +// CHECK:STDOUT: %As.type.45b: type = facet_type <@As, @As(%u32)> [concrete] +// CHECK:STDOUT: %As.Convert.type.b94: type = fn_type @As.Convert, @As(%u32) [concrete] +// CHECK:STDOUT: %As.impl_witness.556: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.847: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_32) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.51e: %Core.IntLiteral.as.As.impl.Convert.type.847 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.66b: %As.type.45b = facet_value Core.IntLiteral, (%As.impl_witness.556) [concrete] +// CHECK:STDOUT: %.97b: type = fn_type_with_self_type %As.Convert.type.b94, %As.facet.66b [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.8e2: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.51e [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.c3d: = specific_function %Core.IntLiteral.as.As.impl.Convert.51e, @Core.IntLiteral.as.As.impl.Convert.2(%int_32) [concrete] +// CHECK:STDOUT: %bound_method.640: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.c3d [concrete] +// CHECK:STDOUT: %int_1.c1d: %u32 = int_value 1 [concrete] +// CHECK:STDOUT: %f32.97e: type = class_type @Float, @Float(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.201: type = pattern_type %f32.97e [concrete] +// CHECK:STDOUT: %float.674bbc.1: Core.FloatLiteral = float_literal_value 10e-1 [concrete] +// CHECK:STDOUT: %As.type.d27: type = facet_type <@As, @As(%f32.97e)> [concrete] +// CHECK:STDOUT: %As.Convert.type.f5e: type = fn_type @As.Convert, @As(%f32.97e) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.d83: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.f91: %Core.FloatLiteral.as.As.impl.Convert.type.d83 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.f72: = impl_witness imports.%As.impl_witness_table.e98, @Core.FloatLiteral.as.As.impl(%int_32) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.4e7: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%int_32) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.890: %Core.FloatLiteral.as.As.impl.Convert.type.4e7 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.885: %As.type.d27 = facet_value Core.FloatLiteral, (%As.impl_witness.f72) [concrete] +// CHECK:STDOUT: %.47f: type = fn_type_with_self_type %As.Convert.type.f5e, %As.facet.885 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bound.b9c: = bound_method %float.674bbc.1, %Core.FloatLiteral.as.As.impl.Convert.890 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.specific_fn.a94: = specific_function %Core.FloatLiteral.as.As.impl.Convert.890, @Core.FloatLiteral.as.As.impl.Convert(%int_32) [concrete] +// CHECK:STDOUT: %bound_method.355: = bound_method %float.674bbc.1, %Core.FloatLiteral.as.As.impl.Convert.specific_fn.a94 [concrete] +// CHECK:STDOUT: %float.e3b: %f32.97e = float_value 1 [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.0ae: type = pattern_type %f64.d77 [concrete] +// CHECK:STDOUT: %float.674bbc.2: Core.FloatLiteral = float_literal_value 10e-1 [concrete] +// CHECK:STDOUT: %As.type.6a8: type = facet_type <@As, @As(%f64.d77)> [concrete] +// CHECK:STDOUT: %As.Convert.type.8fc: type = fn_type @As.Convert, @As(%f64.d77) [concrete] +// CHECK:STDOUT: %As.impl_witness.6b0: = impl_witness imports.%As.impl_witness_table.e98, @Core.FloatLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.50a: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.09c: %Core.FloatLiteral.as.As.impl.Convert.type.50a = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.2ea: %As.type.6a8 = facet_value Core.FloatLiteral, (%As.impl_witness.6b0) [concrete] +// CHECK:STDOUT: %.bee: type = fn_type_with_self_type %As.Convert.type.8fc, %As.facet.2ea [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bound.d51: = bound_method %float.674bbc.2, %Core.FloatLiteral.as.As.impl.Convert.09c [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.specific_fn.905: = specific_function %Core.FloatLiteral.as.As.impl.Convert.09c, @Core.FloatLiteral.as.As.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.60f: = bound_method %float.674bbc.2, %Core.FloatLiteral.as.As.impl.Convert.specific_fn.905 [concrete] +// CHECK:STDOUT: %float.d20: %f64.d77 = float_value 1 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .signed_char = @F.%i8.1 +// CHECK:STDOUT: .short = @F.%i16.1 +// CHECK:STDOUT: .int = @F.%i32.1 +// CHECK:STDOUT: .unsigned_char = @F.%u8.1 +// CHECK:STDOUT: .unsigned_short = @F.%u16.1 +// CHECK:STDOUT: .unsigned_int = @F.%u32.1 +// CHECK:STDOUT: .float = @F.%f32.1 +// CHECK:STDOUT: .double = @F.%f64.1 +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.99c: @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.565) = import_ref Core//prelude/parts/int, loc32_39, loaded [symbolic = @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.d2c)] +// CHECK:STDOUT: %As.impl_witness_table.5ad = impl_witness_table (%Core.import_ref.99c), @Core.IntLiteral.as.As.impl.dc4 [concrete] +// CHECK:STDOUT: %Core.import_ref.611: @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.972) = import_ref Core//prelude/parts/uint, loc32_40, loaded [symbolic = @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.276)] +// CHECK:STDOUT: %As.impl_witness_table.e4e = impl_witness_table (%Core.import_ref.611), @Core.IntLiteral.as.As.impl.cc4 [concrete] +// CHECK:STDOUT: %Core.import_ref.ea0: @Core.FloatLiteral.as.As.impl.%Core.FloatLiteral.as.As.impl.Convert.type (%Core.FloatLiteral.as.As.impl.Convert.type.d83) = import_ref Core//prelude/parts/float, loc25_41, loaded [symbolic = @Core.FloatLiteral.as.As.impl.%Core.FloatLiteral.as.As.impl.Convert (constants.%Core.FloatLiteral.as.As.impl.Convert.f91)] +// CHECK:STDOUT: %As.impl_witness_table.e98 = impl_witness_table (%Core.import_ref.ea0), @Core.FloatLiteral.as.As.impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_signed_char.patt: %pattern_type.e3f = binding_pattern cpp_signed_char [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc8: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_8.loc8: Core.IntLiteral = int_value 8 [concrete = constants.%int_8] +// CHECK:STDOUT: %i8.loc8: type = class_type @Int, @Int(constants.%int_8) [concrete = constants.%i8] +// CHECK:STDOUT: %impl.elem0.loc8: %.95e = impl_witness_access constants.%As.impl_witness.d74, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.e8b] +// CHECK:STDOUT: %bound_method.loc8_45.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.09b] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_8) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.2e1] +// CHECK:STDOUT: %bound_method.loc8_45.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.967] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc8: init %i8 = call %bound_method.loc8_45.2(%int_1.loc8) [concrete = constants.%int_1.30e] +// CHECK:STDOUT: %.loc8_45.1: %i8 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc8 [concrete = constants.%int_1.30e] +// CHECK:STDOUT: %.loc8_45.2: %i8 = converted %int_1.loc8, %.loc8_45.1 [concrete = constants.%int_1.30e] +// CHECK:STDOUT: %.loc8_28: type = splice_block %signed_char.ref [concrete = constants.%i8] { +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %signed_char.ref: type = name_ref signed_char, %i8.1 [concrete = constants.%i8] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_signed_char: %i8 = bind_name cpp_signed_char, %.loc8_45.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_signed_char.patt: %pattern_type.e3f = binding_pattern carbon_signed_char [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_signed_char.ref: %i8 = name_ref cpp_signed_char, %cpp_signed_char +// CHECK:STDOUT: %.loc9: type = splice_block %i8.loc9 [concrete = constants.%i8] { +// CHECK:STDOUT: %int_8.loc9: Core.IntLiteral = int_value 8 [concrete = constants.%int_8] +// CHECK:STDOUT: %i8.loc9: type = class_type @Int, @Int(constants.%int_8) [concrete = constants.%i8] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_signed_char: %i8 = bind_name carbon_signed_char, %cpp_signed_char.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_short.patt: %pattern_type.2f8 = binding_pattern cpp_short [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_16.loc11: Core.IntLiteral = int_value 16 [concrete = constants.%int_16] +// CHECK:STDOUT: %i16.loc11: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16] +// CHECK:STDOUT: %impl.elem0.loc11: %.026 = impl_witness_access constants.%As.impl_witness.2d2, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.97a] +// CHECK:STDOUT: %bound_method.loc11_33.1: = bound_method %int_1.loc11, %impl.elem0.loc11 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.3fb] +// CHECK:STDOUT: %specific_fn.loc11: = specific_function %impl.elem0.loc11, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.613] +// CHECK:STDOUT: %bound_method.loc11_33.2: = bound_method %int_1.loc11, %specific_fn.loc11 [concrete = constants.%bound_method.7be] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc11: init %i16 = call %bound_method.loc11_33.2(%int_1.loc11) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc11_33.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc11 [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc11_33.2: %i16 = converted %int_1.loc11, %.loc11_33.1 [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc11_22: type = splice_block %short.ref [concrete = constants.%i16] { +// CHECK:STDOUT: %Cpp.ref.loc11: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %short.ref: type = name_ref short, %i16.1 [concrete = constants.%i16] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_short: %i16 = bind_name cpp_short, %.loc11_33.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_short.patt: %pattern_type.2f8 = binding_pattern carbon_short [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_short.ref: %i16 = name_ref cpp_short, %cpp_short +// CHECK:STDOUT: %.loc12: type = splice_block %i16.loc12 [concrete = constants.%i16] { +// CHECK:STDOUT: %int_16.loc12: Core.IntLiteral = int_value 16 [concrete = constants.%int_16] +// CHECK:STDOUT: %i16.loc12: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_short: %i16 = bind_name carbon_short, %cpp_short.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_int.patt: %pattern_type.7ce = binding_pattern cpp_int [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: %impl.elem0.loc14: %.351 = impl_witness_access constants.%As.impl_witness.080, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.414] +// CHECK:STDOUT: %bound_method.loc14_29.1: = bound_method %int_1.loc14, %impl.elem0.loc14 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.9f3] +// CHECK:STDOUT: %specific_fn.loc14: = specific_function %impl.elem0.loc14, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.478] +// CHECK:STDOUT: %bound_method.loc14_29.2: = bound_method %int_1.loc14, %specific_fn.loc14 [concrete = constants.%bound_method.fb8] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc14: init %i32 = call %bound_method.loc14_29.2(%int_1.loc14) [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_29.1: %i32 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc14 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_29.2: %i32 = converted %int_1.loc14, %.loc14_29.1 [concrete = constants.%int_1.5d2] +// CHECK:STDOUT: %.loc14_20: type = splice_block %int.ref [concrete = constants.%i32] { +// CHECK:STDOUT: %Cpp.ref.loc14: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %int.ref: type = name_ref int, %i32.1 [concrete = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_int: %i32 = bind_name cpp_int, %.loc14_29.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_int.patt: %pattern_type.7ce = binding_pattern carbon_int [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_int.ref: %i32 = name_ref cpp_int, %cpp_int +// CHECK:STDOUT: %.loc15: type = splice_block %i32.loc15 [concrete = constants.%i32] { +// CHECK:STDOUT: %int_32.loc15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %i32.loc15: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_int: %i32 = bind_name carbon_int, %cpp_int.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_char.patt: %pattern_type.8f3 = binding_pattern cpp_unsigned_char [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc17: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_8.loc17: Core.IntLiteral = int_value 8 [concrete = constants.%int_8] +// CHECK:STDOUT: %u8.loc17: type = class_type @UInt, @UInt(constants.%int_8) [concrete = constants.%u8] +// CHECK:STDOUT: %impl.elem0.loc17: %.3dd = impl_witness_access constants.%As.impl_witness.fb4, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.cd6] +// CHECK:STDOUT: %bound_method.loc17_49.1: = bound_method %int_1.loc17, %impl.elem0.loc17 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.d14] +// CHECK:STDOUT: %specific_fn.loc17: = specific_function %impl.elem0.loc17, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_8) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.95d] +// CHECK:STDOUT: %bound_method.loc17_49.2: = bound_method %int_1.loc17, %specific_fn.loc17 [concrete = constants.%bound_method.084] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc17: init %u8 = call %bound_method.loc17_49.2(%int_1.loc17) [concrete = constants.%int_1.e80] +// CHECK:STDOUT: %.loc17_49.1: %u8 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc17 [concrete = constants.%int_1.e80] +// CHECK:STDOUT: %.loc17_49.2: %u8 = converted %int_1.loc17, %.loc17_49.1 [concrete = constants.%int_1.e80] +// CHECK:STDOUT: %.loc17_30: type = splice_block %unsigned_char.ref [concrete = constants.%u8] { +// CHECK:STDOUT: %Cpp.ref.loc17: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %unsigned_char.ref: type = name_ref unsigned_char, %u8.1 [concrete = constants.%u8] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_char: %u8 = bind_name cpp_unsigned_char, %.loc17_49.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_char.patt: %pattern_type.8f3 = binding_pattern carbon_unsigned_char [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_char.ref: %u8 = name_ref cpp_unsigned_char, %cpp_unsigned_char +// CHECK:STDOUT: %.loc18: type = splice_block %u8.loc18 [concrete = constants.%u8] { +// CHECK:STDOUT: %int_8.loc18: Core.IntLiteral = int_value 8 [concrete = constants.%int_8] +// CHECK:STDOUT: %u8.loc18: type = class_type @UInt, @UInt(constants.%int_8) [concrete = constants.%u8] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_char: %u8 = bind_name carbon_unsigned_char, %cpp_unsigned_char.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_short.patt: %pattern_type.9db = binding_pattern cpp_unsigned_short [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc20: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_16.loc20: Core.IntLiteral = int_value 16 [concrete = constants.%int_16] +// CHECK:STDOUT: %u16.loc20: type = class_type @UInt, @UInt(constants.%int_16) [concrete = constants.%u16] +// CHECK:STDOUT: %impl.elem0.loc20: %.982 = impl_witness_access constants.%As.impl_witness.262, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.d77] +// CHECK:STDOUT: %bound_method.loc20_51.1: = bound_method %int_1.loc20, %impl.elem0.loc20 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.37a] +// CHECK:STDOUT: %specific_fn.loc20: = specific_function %impl.elem0.loc20, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.427] +// CHECK:STDOUT: %bound_method.loc20_51.2: = bound_method %int_1.loc20, %specific_fn.loc20 [concrete = constants.%bound_method.552] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc20: init %u16 = call %bound_method.loc20_51.2(%int_1.loc20) [concrete = constants.%int_1.3e8] +// CHECK:STDOUT: %.loc20_51.1: %u16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc20 [concrete = constants.%int_1.3e8] +// CHECK:STDOUT: %.loc20_51.2: %u16 = converted %int_1.loc20, %.loc20_51.1 [concrete = constants.%int_1.3e8] +// CHECK:STDOUT: %.loc20_31: type = splice_block %unsigned_short.ref [concrete = constants.%u16] { +// CHECK:STDOUT: %Cpp.ref.loc20: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %unsigned_short.ref: type = name_ref unsigned_short, %u16.1 [concrete = constants.%u16] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_short: %u16 = bind_name cpp_unsigned_short, %.loc20_51.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_short.patt: %pattern_type.9db = binding_pattern carbon_unsigned_short [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_short.ref: %u16 = name_ref cpp_unsigned_short, %cpp_unsigned_short +// CHECK:STDOUT: %.loc21: type = splice_block %u16.loc21 [concrete = constants.%u16] { +// CHECK:STDOUT: %int_16.loc21: Core.IntLiteral = int_value 16 [concrete = constants.%int_16] +// CHECK:STDOUT: %u16.loc21: type = class_type @UInt, @UInt(constants.%int_16) [concrete = constants.%u16] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_short: %u16 = bind_name carbon_unsigned_short, %cpp_unsigned_short.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_int.patt: %pattern_type.4a9 = binding_pattern cpp_unsigned_int [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc23: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_32.loc23: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %u32.loc23: type = class_type @UInt, @UInt(constants.%int_32) [concrete = constants.%u32] +// CHECK:STDOUT: %impl.elem0.loc23: %.97b = impl_witness_access constants.%As.impl_witness.556, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.51e] +// CHECK:STDOUT: %bound_method.loc23_47.1: = bound_method %int_1.loc23, %impl.elem0.loc23 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.8e2] +// CHECK:STDOUT: %specific_fn.loc23: = specific_function %impl.elem0.loc23, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.c3d] +// CHECK:STDOUT: %bound_method.loc23_47.2: = bound_method %int_1.loc23, %specific_fn.loc23 [concrete = constants.%bound_method.640] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc23: init %u32 = call %bound_method.loc23_47.2(%int_1.loc23) [concrete = constants.%int_1.c1d] +// CHECK:STDOUT: %.loc23_47.1: %u32 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc23 [concrete = constants.%int_1.c1d] +// CHECK:STDOUT: %.loc23_47.2: %u32 = converted %int_1.loc23, %.loc23_47.1 [concrete = constants.%int_1.c1d] +// CHECK:STDOUT: %.loc23_29: type = splice_block %unsigned_int.ref [concrete = constants.%u32] { +// CHECK:STDOUT: %Cpp.ref.loc23: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %unsigned_int.ref: type = name_ref unsigned_int, %u32.1 [concrete = constants.%u32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_int: %u32 = bind_name cpp_unsigned_int, %.loc23_47.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_int.patt: %pattern_type.4a9 = binding_pattern carbon_unsigned_int [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_int.ref: %u32 = name_ref cpp_unsigned_int, %cpp_unsigned_int +// CHECK:STDOUT: %.loc24: type = splice_block %u32.loc24 [concrete = constants.%u32] { +// CHECK:STDOUT: %int_32.loc24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %u32.loc24: type = class_type @UInt, @UInt(constants.%int_32) [concrete = constants.%u32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_int: %u32 = bind_name carbon_unsigned_int, %cpp_unsigned_int.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_float.patt: %pattern_type.201 = binding_pattern cpp_float [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %float.loc26: Core.FloatLiteral = float_literal_value 10e-1 [concrete = constants.%float.674bbc.1] +// CHECK:STDOUT: %int_32.loc26: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %f32.loc26: type = class_type @Float, @Float(constants.%int_32) [concrete = constants.%f32.97e] +// CHECK:STDOUT: %impl.elem0.loc26: %.47f = impl_witness_access constants.%As.impl_witness.f72, element0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.890] +// CHECK:STDOUT: %bound_method.loc26_35.1: = bound_method %float.loc26, %impl.elem0.loc26 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.bound.b9c] +// CHECK:STDOUT: %specific_fn.loc26: = specific_function %impl.elem0.loc26, @Core.FloatLiteral.as.As.impl.Convert(constants.%int_32) [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.specific_fn.a94] +// CHECK:STDOUT: %bound_method.loc26_35.2: = bound_method %float.loc26, %specific_fn.loc26 [concrete = constants.%bound_method.355] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call.loc26: init %f32.97e = call %bound_method.loc26_35.2(%float.loc26) [concrete = constants.%float.e3b] +// CHECK:STDOUT: %.loc26_35.1: %f32.97e = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call.loc26 [concrete = constants.%float.e3b] +// CHECK:STDOUT: %.loc26_35.2: %f32.97e = converted %float.loc26, %.loc26_35.1 [concrete = constants.%float.e3b] +// CHECK:STDOUT: %.loc26_22: type = splice_block %float.ref [concrete = constants.%f32.97e] { +// CHECK:STDOUT: %Cpp.ref.loc26: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %float.ref: type = name_ref float, %f32.1 [concrete = constants.%f32.97e] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_float: %f32.97e = bind_name cpp_float, %.loc26_35.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_float.patt: %pattern_type.201 = binding_pattern carbon_float [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_float.ref: %f32.97e = name_ref cpp_float, %cpp_float +// CHECK:STDOUT: %.loc27: type = splice_block %f32.loc27 [concrete = constants.%f32.97e] { +// CHECK:STDOUT: %int_32.loc27: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %f32.loc27: type = class_type @Float, @Float(constants.%int_32) [concrete = constants.%f32.97e] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_float: %f32.97e = bind_name carbon_float, %cpp_float.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_double.patt: %pattern_type.0ae = binding_pattern cpp_double [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %float.loc29: Core.FloatLiteral = float_literal_value 10e-1 [concrete = constants.%float.674bbc.2] +// CHECK:STDOUT: %int_64.loc29: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %f64.loc29: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] +// CHECK:STDOUT: %impl.elem0.loc29: %.bee = impl_witness_access constants.%As.impl_witness.6b0, element0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.09c] +// CHECK:STDOUT: %bound_method.loc29_37.1: = bound_method %float.loc29, %impl.elem0.loc29 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.bound.d51] +// CHECK:STDOUT: %specific_fn.loc29: = specific_function %impl.elem0.loc29, @Core.FloatLiteral.as.As.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.specific_fn.905] +// CHECK:STDOUT: %bound_method.loc29_37.2: = bound_method %float.loc29, %specific_fn.loc29 [concrete = constants.%bound_method.60f] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call.loc29: init %f64.d77 = call %bound_method.loc29_37.2(%float.loc29) [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc29_37.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call.loc29 [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc29_37.2: %f64.d77 = converted %float.loc29, %.loc29_37.1 [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc29_23: type = splice_block %double.ref [concrete = constants.%f64.d77] { +// CHECK:STDOUT: %Cpp.ref.loc29: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %double.ref: type = name_ref double, %f64.1 [concrete = constants.%f64.d77] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_double: %f64.d77 = bind_name cpp_double, %.loc29_37.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_double.patt: %pattern_type.0ae = binding_pattern carbon_double [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_double.ref: %f64.d77 = name_ref cpp_double, %cpp_double +// CHECK:STDOUT: %.loc30: type = splice_block %f64.loc30 [concrete = constants.%f64.d77] { +// CHECK:STDOUT: %int_64.loc30: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %f64.loc30: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_double: %f64.d77 = bind_name carbon_double, %cpp_double.ref +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_unsupported_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %float.674: Core.FloatLiteral = float_literal_value 10e-1 [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %f64.d77: type = class_type @Float, @Float(%int_64) [concrete] +// CHECK:STDOUT: %As.type.6a8: type = facet_type <@As, @As(%f64.d77)> [concrete] +// CHECK:STDOUT: %As.Convert.type.8fc: type = fn_type @As.Convert, @As(%f64.d77) [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.d83: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%To) [symbolic] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.f91: %Core.FloatLiteral.as.As.impl.Convert.type.d83 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.6b0: = impl_witness imports.%As.impl_witness_table, @Core.FloatLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.type.50a: type = fn_type @Core.FloatLiteral.as.As.impl.Convert, @Core.FloatLiteral.as.As.impl(%int_64) [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.09c: %Core.FloatLiteral.as.As.impl.Convert.type.50a = struct_value () [concrete] +// CHECK:STDOUT: %As.facet: %As.type.6a8 = facet_value Core.FloatLiteral, (%As.impl_witness.6b0) [concrete] +// CHECK:STDOUT: %.bee: type = fn_type_with_self_type %As.Convert.type.8fc, %As.facet [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.bound: = bound_method %float.674, %Core.FloatLiteral.as.As.impl.Convert.09c [concrete] +// CHECK:STDOUT: %pattern_type.0ae: type = pattern_type %f64.d77 [concrete] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.specific_fn: = specific_function %Core.FloatLiteral.as.As.impl.Convert.09c, @Core.FloatLiteral.as.As.impl.Convert(%int_64) [concrete] +// CHECK:STDOUT: %bound_method: = bound_method %float.674, %Core.FloatLiteral.as.As.impl.Convert.specific_fn [concrete] +// CHECK:STDOUT: %float.d20: %f64.d77 = float_value 1 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core.import_ref.ea0: @Core.FloatLiteral.as.As.impl.%Core.FloatLiteral.as.As.impl.Convert.type (%Core.FloatLiteral.as.As.impl.Convert.type.d83) = import_ref Core//prelude/parts/float, loc25_41, loaded [symbolic = @Core.FloatLiteral.as.As.impl.%Core.FloatLiteral.as.As.impl.Convert (constants.%Core.FloatLiteral.as.As.impl.Convert.f91)] +// CHECK:STDOUT: %As.impl_witness_table = impl_witness_table (%Core.import_ref.ea0), @Core.FloatLiteral.as.As.impl [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_long_double.patt: = binding_pattern cpp_long_double [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %float: Core.FloatLiteral = float_literal_value 10e-1 [concrete = constants.%float.674] +// CHECK:STDOUT: %int_64.loc15: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %f64.loc15: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] +// CHECK:STDOUT: %impl.elem0: %.bee = impl_witness_access constants.%As.impl_witness.6b0, element0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.09c] +// CHECK:STDOUT: %bound_method.loc15_47.1: = bound_method %float, %impl.elem0 [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.bound] +// CHECK:STDOUT: %specific_fn: = specific_function %impl.elem0, @Core.FloatLiteral.as.As.impl.Convert(constants.%int_64) [concrete = constants.%Core.FloatLiteral.as.As.impl.Convert.specific_fn] +// CHECK:STDOUT: %bound_method.loc15_47.2: = bound_method %float, %specific_fn [concrete = constants.%bound_method] +// CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_47.2(%float) [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc15_47.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc15_47.2: %f64.d77 = converted %float, %.loc15_47.1 [concrete = constants.%float.d20] +// CHECK:STDOUT: +// CHECK:STDOUT: %cpp_long_double: = bind_name cpp_long_double, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_long_double.patt: %pattern_type.0ae = binding_pattern carbon_long_double [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long_double.ref: = name_ref cpp_long_double, %cpp_long_double [concrete = ] +// CHECK:STDOUT: %.loc16: type = splice_block %f64.loc16 [concrete = constants.%f64.d77] { +// CHECK:STDOUT: %int_64.loc16: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %f64.loc16: type = class_type @Float, @Float(constants.%int_64) [concrete = constants.%f64.d77] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_long_double: %f64.d77 = bind_name carbon_long_double, [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- override_builtin.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] +// CHECK:STDOUT: %unsigned_int: type = class_type @unsigned_int [concrete] +// CHECK:STDOUT: %pattern_type.5ec: type = pattern_type %unsigned_int [concrete] +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete] +// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete] +// CHECK:STDOUT: %pattern_type.4a9: type = pattern_type %u32 [concrete] +// CHECK:STDOUT: %.15a: type = cpp_overload_set_type @unsigned_int.foo [concrete] +// CHECK:STDOUT: %empty_struct: %.15a = struct_value () [concrete] +// CHECK:STDOUT: %ptr.d47: type = ptr_type %unsigned_int [concrete] +// CHECK:STDOUT: %unsigned_int.foo.type: type = fn_type @unsigned_int.foo [concrete] +// CHECK:STDOUT: %unsigned_int.foo: %unsigned_int.foo.type = struct_value () [concrete] +// CHECK:STDOUT: %T.as.Destroy.impl.Op.type.66e: type = fn_type @T.as.Destroy.impl.Op, @T.as.Destroy.impl(%unsigned_int) [concrete] +// CHECK:STDOUT: %T.as.Destroy.impl.Op.428: %T.as.Destroy.impl.Op.type.66e = struct_value () [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .unsigned_int = %unsigned_int.decl +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %unsigned_int.decl: type = class_decl @unsigned_int [concrete = constants.%unsigned_int] {} {} +// CHECK:STDOUT: %.afb: %.15a = cpp_overload_set_value @unsigned_int.foo [concrete = constants.%empty_struct] +// CHECK:STDOUT: %unsigned_int.foo.decl: %unsigned_int.foo.type = fn_decl @unsigned_int.foo [concrete = constants.%unsigned_int.foo] { +// CHECK:STDOUT: +// CHECK:STDOUT: } { +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %unsigned_int.patt: %pattern_type.5ec = binding_pattern unsigned_int [concrete] +// CHECK:STDOUT: %unsigned_int.var_patt: %pattern_type.5ec = var_pattern %unsigned_int.patt [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %unsigned_int.var: ref %unsigned_int = var %unsigned_int.var_patt +// CHECK:STDOUT: %.loc12: type = splice_block %unsigned_int.ref.loc12 [concrete = constants.%unsigned_int] { +// CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: %unsigned_int.ref.loc12: type = name_ref unsigned_int, imports.%unsigned_int.decl [concrete = constants.%unsigned_int] +// CHECK:STDOUT: } +// CHECK:STDOUT: %unsigned_int: ref %unsigned_int = bind_name unsigned_int, %unsigned_int.var +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %x.patt: %pattern_type.4a9 = binding_pattern x [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %unsigned_int.ref.loc13: ref %unsigned_int = name_ref unsigned_int, %unsigned_int +// CHECK:STDOUT: %foo.ref: %.15a = name_ref foo, imports.%.afb [concrete = constants.%empty_struct] +// CHECK:STDOUT: %bound_method.loc13: = bound_method %unsigned_int.ref.loc13, %foo.ref +// CHECK:STDOUT: %addr.loc13: %ptr.d47 = addr_of %unsigned_int.ref.loc13 +// CHECK:STDOUT: %unsigned_int.foo.call: init %u32 = call imports.%unsigned_int.foo.decl(%addr.loc13) +// CHECK:STDOUT: %.loc13_10: type = splice_block %u32 [concrete = constants.%u32] { +// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32] +// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(constants.%int_32) [concrete = constants.%u32] +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc13_33.1: %u32 = value_of_initializer %unsigned_int.foo.call +// CHECK:STDOUT: %.loc13_33.2: %u32 = converted %unsigned_int.foo.call, %.loc13_33.1 +// CHECK:STDOUT: %x: %u32 = bind_name x, %.loc13_33.2 +// CHECK:STDOUT: %T.as.Destroy.impl.Op.bound: = bound_method %unsigned_int.var, constants.%T.as.Destroy.impl.Op.428 +// CHECK:STDOUT: +// CHECK:STDOUT: %bound_method.loc12: = bound_method %unsigned_int.var, %T.as.Destroy.impl.Op.specific_fn +// CHECK:STDOUT: %addr.loc12: %ptr.d47 = addr_of %unsigned_int.var +// CHECK:STDOUT: %T.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method.loc12(%addr.loc12) +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/builtins.llp64.carbon b/toolchain/check/testdata/interop/cpp/builtins.llp64.carbon new file mode 100644 index 000000000000..0115c3b5812d --- /dev/null +++ b/toolchain/check/testdata/interop/cpp/builtins.llp64.carbon @@ -0,0 +1,268 @@ +// 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-FILE: toolchain/testing/testdata/min_prelude/uint.carbon +// EXTRA-ARGS: --target=x86_64-pc-windows-msvc --clang-arg=-fno-PIE +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/builtins.llp64.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/builtins.llp64.carbon + +// --- supported_types.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + //@dump-sem-ir-begin + let cpp_long_long : Cpp.long_long = 1 as i64; + let carbon_long_long: i64 = cpp_long_long; + + let cpp_unsigned_long_long : Cpp.unsigned_long_long = 1 as u64; + let carbon_unsigned_long_long: u64 = cpp_unsigned_long_long; + //@dump-sem-ir-end +} + +// --- fail_todo_unsupported_types.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + //@dump-sem-ir-begin + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+7]]:18: error: semantics TODO: `Unsupported: builtin type: long` [SemanticsTodo] + // CHECK:STDERR: let cpp_long : Cpp.long = 1 as i64; + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+4]]:18: note: in `Cpp` name lookup for `long` [InCppNameLookup] + // CHECK:STDERR: let cpp_long : Cpp.long = 1 as i64; + // CHECK:STDERR: ^~~~~~~~ + // CHECK:STDERR: + let cpp_long : Cpp.long = 1 as i64; + let carbon_long: i64 = cpp_long; + + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+7]]:27: error: semantics TODO: `Unsupported: builtin type: unsigned long` [SemanticsTodo] + // CHECK:STDERR: let cpp_unsigned_long : Cpp.unsigned_long = 1 as u64; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+4]]:27: note: in `Cpp` name lookup for `unsigned_long` [InCppNameLookup] + // CHECK:STDERR: let cpp_unsigned_long : Cpp.unsigned_long = 1 as u64; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + let cpp_unsigned_long : Cpp.unsigned_long = 1 as u64; + let carbon_unsigned_long: u64 = cpp_unsigned_long; + //@dump-sem-ir-end +} + +// CHECK:STDOUT: --- supported_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.95b: type = pattern_type %i64 [concrete] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %As.type.bbb: type = facet_type <@As, @As(%i64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.d57: type = fn_type @As.Convert, @As(%i64) [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.565: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d2c: %Core.IntLiteral.as.As.impl.Convert.type.565 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.4f1: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.9ac: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.fe2: %Core.IntLiteral.as.As.impl.Convert.type.9ac = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.888: %As.type.bbb = facet_value Core.IntLiteral, (%As.impl_witness.4f1) [concrete] +// CHECK:STDOUT: %.b12: type = fn_type_with_self_type %As.Convert.type.d57, %As.facet.888 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.0c0: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.fe2 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b: = specific_function %Core.IntLiteral.as.As.impl.Convert.fe2, @Core.IntLiteral.as.As.impl.Convert.1(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.b11: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b [concrete] +// CHECK:STDOUT: %int_1.41a: %i64 = int_value 1 [concrete] +// CHECK:STDOUT: %u64: type = class_type @UInt, @UInt(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.157: type = pattern_type %u64 [concrete] +// CHECK:STDOUT: %As.type.465: type = facet_type <@As, @As(%u64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.7eb: type = fn_type @As.Convert, @As(%u64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.972: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.276: %Core.IntLiteral.as.As.impl.Convert.type.972 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.feb: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.da0: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.467: %Core.IntLiteral.as.As.impl.Convert.type.da0 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.218: %As.type.465 = facet_value Core.IntLiteral, (%As.impl_witness.feb) [concrete] +// CHECK:STDOUT: %.e88: type = fn_type_with_self_type %As.Convert.type.7eb, %As.facet.218 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.fec: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.467 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5: = specific_function %Core.IntLiteral.as.As.impl.Convert.467, @Core.IntLiteral.as.As.impl.Convert.2(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.290: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5 [concrete] +// CHECK:STDOUT: %int_1.f23: %u64 = int_value 1 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .long_long = @F.%i64.1 +// CHECK:STDOUT: .unsigned_long_long = @F.%u64.1 +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.99c: @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.565) = import_ref Core//prelude/parts/int, loc32_39, loaded [symbolic = @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.d2c)] +// CHECK:STDOUT: %As.impl_witness_table.5ad = impl_witness_table (%Core.import_ref.99c), @Core.IntLiteral.as.As.impl.dc4 [concrete] +// CHECK:STDOUT: %Core.import_ref.611: @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.972) = import_ref Core//prelude/parts/uint, loc32_40, loaded [symbolic = @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.276)] +// CHECK:STDOUT: %As.impl_witness_table.e4e = impl_witness_table (%Core.import_ref.611), @Core.IntLiteral.as.As.impl.cc4 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_long_long.patt: %pattern_type.95b = binding_pattern cpp_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc8: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc8: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc8: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: %impl.elem0.loc8: %.b12 = impl_witness_access constants.%As.impl_witness.4f1, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.fe2] +// CHECK:STDOUT: %bound_method.loc8_41.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.0c0] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.96b] +// CHECK:STDOUT: %bound_method.loc8_41.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.b11] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc8: init %i64 = call %bound_method.loc8_41.2(%int_1.loc8) [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc8_41.1: %i64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc8 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc8_41.2: %i64 = converted %int_1.loc8, %.loc8_41.1 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc8_26: type = splice_block %long_long.ref [concrete = constants.%i64] { +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %long_long.ref: type = name_ref long_long, %i64.1 [concrete = constants.%i64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long_long: %i64 = bind_name cpp_long_long, %.loc8_41.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_long_long.patt: %pattern_type.95b = binding_pattern carbon_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long_long.ref: %i64 = name_ref cpp_long_long, %cpp_long_long +// CHECK:STDOUT: %.loc9: type = splice_block %i64.loc9 [concrete = constants.%i64] { +// CHECK:STDOUT: %int_64.loc9: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc9: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_long_long: %i64 = bind_name carbon_long_long, %cpp_long_long.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_long_long.patt: %pattern_type.157 = binding_pattern cpp_unsigned_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc11: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc11: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: %impl.elem0.loc11: %.e88 = impl_witness_access constants.%As.impl_witness.feb, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.467] +// CHECK:STDOUT: %bound_method.loc11_59.1: = bound_method %int_1.loc11, %impl.elem0.loc11 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.fec] +// CHECK:STDOUT: %specific_fn.loc11: = specific_function %impl.elem0.loc11, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5] +// CHECK:STDOUT: %bound_method.loc11_59.2: = bound_method %int_1.loc11, %specific_fn.loc11 [concrete = constants.%bound_method.290] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc11: init %u64 = call %bound_method.loc11_59.2(%int_1.loc11) [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc11_59.1: %u64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc11 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc11_59.2: %u64 = converted %int_1.loc11, %.loc11_59.1 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc11_35: type = splice_block %unsigned_long_long.ref [concrete = constants.%u64] { +// CHECK:STDOUT: %Cpp.ref.loc11: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %unsigned_long_long.ref: type = name_ref unsigned_long_long, %u64.1 [concrete = constants.%u64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_long_long: %u64 = bind_name cpp_unsigned_long_long, %.loc11_59.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_long_long.patt: %pattern_type.157 = binding_pattern carbon_unsigned_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_long_long.ref: %u64 = name_ref cpp_unsigned_long_long, %cpp_unsigned_long_long +// CHECK:STDOUT: %.loc12: type = splice_block %u64.loc12 [concrete = constants.%u64] { +// CHECK:STDOUT: %int_64.loc12: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc12: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_long_long: %u64 = bind_name carbon_unsigned_long_long, %cpp_unsigned_long_long.ref +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_unsupported_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete] +// CHECK:STDOUT: %As.type.bbb: type = facet_type <@As, @As(%i64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.d57: type = fn_type @As.Convert, @As(%i64) [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.565: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d2c: %Core.IntLiteral.as.As.impl.Convert.type.565 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.4f1: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.9ac: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.fe2: %Core.IntLiteral.as.As.impl.Convert.type.9ac = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.888: %As.type.bbb = facet_value Core.IntLiteral, (%As.impl_witness.4f1) [concrete] +// CHECK:STDOUT: %.b12: type = fn_type_with_self_type %As.Convert.type.d57, %As.facet.888 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.0c0: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.fe2 [concrete] +// CHECK:STDOUT: %pattern_type.95b: type = pattern_type %i64 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b: = specific_function %Core.IntLiteral.as.As.impl.Convert.fe2, @Core.IntLiteral.as.As.impl.Convert.1(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.b11: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b [concrete] +// CHECK:STDOUT: %int_1.41a: %i64 = int_value 1 [concrete] +// CHECK:STDOUT: %u64: type = class_type @UInt, @UInt(%int_64) [concrete] +// CHECK:STDOUT: %As.type.465: type = facet_type <@As, @As(%u64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.7eb: type = fn_type @As.Convert, @As(%u64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.972: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.276: %Core.IntLiteral.as.As.impl.Convert.type.972 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.feb: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.da0: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.467: %Core.IntLiteral.as.As.impl.Convert.type.da0 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.218: %As.type.465 = facet_value Core.IntLiteral, (%As.impl_witness.feb) [concrete] +// CHECK:STDOUT: %.e88: type = fn_type_with_self_type %As.Convert.type.7eb, %As.facet.218 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.fec: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.467 [concrete] +// CHECK:STDOUT: %pattern_type.157: type = pattern_type %u64 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5: = specific_function %Core.IntLiteral.as.As.impl.Convert.467, @Core.IntLiteral.as.As.impl.Convert.2(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.290: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5 [concrete] +// CHECK:STDOUT: %int_1.f23: %u64 = int_value 1 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core.import_ref.99c: @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.565) = import_ref Core//prelude/parts/int, loc32_39, loaded [symbolic = @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.d2c)] +// CHECK:STDOUT: %As.impl_witness_table.5ad = impl_witness_table (%Core.import_ref.99c), @Core.IntLiteral.as.As.impl.dc4 [concrete] +// CHECK:STDOUT: %Core.import_ref.611: @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.972) = import_ref Core//prelude/parts/uint, loc32_40, loaded [symbolic = @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.276)] +// CHECK:STDOUT: %As.impl_witness_table.e4e = impl_witness_table (%Core.import_ref.611), @Core.IntLiteral.as.As.impl.cc4 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_long.patt: = binding_pattern cpp_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc15: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc15: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: %impl.elem0.loc15: %.b12 = impl_witness_access constants.%As.impl_witness.4f1, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.fe2] +// CHECK:STDOUT: %bound_method.loc15_31.1: = bound_method %int_1.loc15, %impl.elem0.loc15 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.0c0] +// CHECK:STDOUT: %specific_fn.loc15: = specific_function %impl.elem0.loc15, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.96b] +// CHECK:STDOUT: %bound_method.loc15_31.2: = bound_method %int_1.loc15, %specific_fn.loc15 [concrete = constants.%bound_method.b11] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc15: init %i64 = call %bound_method.loc15_31.2(%int_1.loc15) [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc15_31.1: %i64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc15 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc15_31.2: %i64 = converted %int_1.loc15, %.loc15_31.1 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: +// CHECK:STDOUT: %cpp_long: = bind_name cpp_long, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_long.patt: %pattern_type.95b = binding_pattern carbon_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long.ref: = name_ref cpp_long, %cpp_long [concrete = ] +// CHECK:STDOUT: %.loc16: type = splice_block %i64.loc16 [concrete = constants.%i64] { +// CHECK:STDOUT: %int_64.loc16: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc16: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_long: %i64 = bind_name carbon_long, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_long.patt: = binding_pattern cpp_unsigned_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc25: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc25: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: %impl.elem0.loc25: %.e88 = impl_witness_access constants.%As.impl_witness.feb, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.467] +// CHECK:STDOUT: %bound_method.loc25_49.1: = bound_method %int_1.loc25, %impl.elem0.loc25 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.fec] +// CHECK:STDOUT: %specific_fn.loc25: = specific_function %impl.elem0.loc25, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5] +// CHECK:STDOUT: %bound_method.loc25_49.2: = bound_method %int_1.loc25, %specific_fn.loc25 [concrete = constants.%bound_method.290] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc25: init %u64 = call %bound_method.loc25_49.2(%int_1.loc25) [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc25_49.1: %u64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc25 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc25_49.2: %u64 = converted %int_1.loc25, %.loc25_49.1 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: +// CHECK:STDOUT: %cpp_unsigned_long: = bind_name cpp_unsigned_long, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_long.patt: %pattern_type.157 = binding_pattern carbon_unsigned_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_long.ref: = name_ref cpp_unsigned_long, %cpp_unsigned_long [concrete = ] +// CHECK:STDOUT: %.loc26: type = splice_block %u64.loc26 [concrete = constants.%u64] { +// CHECK:STDOUT: %int_64.loc26: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc26: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_long: %u64 = bind_name carbon_unsigned_long, [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: diff --git a/toolchain/check/testdata/interop/cpp/builtins.lp64.carbon b/toolchain/check/testdata/interop/cpp/builtins.lp64.carbon new file mode 100644 index 000000000000..9c5ecb1da34f --- /dev/null +++ b/toolchain/check/testdata/interop/cpp/builtins.lp64.carbon @@ -0,0 +1,268 @@ +// 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-FILE: toolchain/testing/testdata/min_prelude/uint.carbon +// EXTRA-ARGS: --target=x86_64-linux-gnu +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/builtins.lp64.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/builtins.lp64.carbon + +// --- supported_types.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + //@dump-sem-ir-begin + let cpp_long : Cpp.long = 1 as i64; + let carbon_long: i64 = cpp_long; + + let cpp_unsigned_long : Cpp.unsigned_long = 1 as u64; + let carbon_unsigned_long: u64 = cpp_unsigned_long; + //@dump-sem-ir-end +} + +// --- fail_todo_unsupported_types.carbon + +library "[[@TEST_NAME]]"; + +import Cpp inline ""; + +fn F() { + //@dump-sem-ir-begin + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+7]]:23: error: semantics TODO: `Unsupported: builtin type: long long` [SemanticsTodo] + // CHECK:STDERR: let cpp_long_long : Cpp.long_long = 1 as i64; + // CHECK:STDERR: ^~~~~~~~~~~~~ + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+4]]:23: note: in `Cpp` name lookup for `long_long` [InCppNameLookup] + // CHECK:STDERR: let cpp_long_long : Cpp.long_long = 1 as i64; + // CHECK:STDERR: ^~~~~~~~~~~~~ + // CHECK:STDERR: + let cpp_long_long : Cpp.long_long = 1 as i64; + let carbon_long_long: i64 = cpp_long_long; + + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+7]]:32: error: semantics TODO: `Unsupported: builtin type: unsigned long long` [SemanticsTodo] + // CHECK:STDERR: let cpp_unsigned_long_long : Cpp.unsigned_long_long = 1 as u64; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_todo_unsupported_types.carbon:[[@LINE+4]]:32: note: in `Cpp` name lookup for `unsigned_long_long` [InCppNameLookup] + // CHECK:STDERR: let cpp_unsigned_long_long : Cpp.unsigned_long_long = 1 as u64; + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + let cpp_unsigned_long_long : Cpp.unsigned_long_long = 1 as u64; + let carbon_unsigned_long_long: u64 = cpp_unsigned_long_long; + //@dump-sem-ir-end +} + +// CHECK:STDOUT: --- supported_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.95b: type = pattern_type %i64 [concrete] +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %As.type.bbb: type = facet_type <@As, @As(%i64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.d57: type = fn_type @As.Convert, @As(%i64) [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.565: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d2c: %Core.IntLiteral.as.As.impl.Convert.type.565 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.4f1: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.9ac: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.fe2: %Core.IntLiteral.as.As.impl.Convert.type.9ac = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.888: %As.type.bbb = facet_value Core.IntLiteral, (%As.impl_witness.4f1) [concrete] +// CHECK:STDOUT: %.b12: type = fn_type_with_self_type %As.Convert.type.d57, %As.facet.888 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.0c0: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.fe2 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b: = specific_function %Core.IntLiteral.as.As.impl.Convert.fe2, @Core.IntLiteral.as.As.impl.Convert.1(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.b11: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b [concrete] +// CHECK:STDOUT: %int_1.41a: %i64 = int_value 1 [concrete] +// CHECK:STDOUT: %u64: type = class_type @UInt, @UInt(%int_64) [concrete] +// CHECK:STDOUT: %pattern_type.157: type = pattern_type %u64 [concrete] +// CHECK:STDOUT: %As.type.465: type = facet_type <@As, @As(%u64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.7eb: type = fn_type @As.Convert, @As(%u64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.972: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.276: %Core.IntLiteral.as.As.impl.Convert.type.972 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.feb: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.da0: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.467: %Core.IntLiteral.as.As.impl.Convert.type.da0 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.218: %As.type.465 = facet_value Core.IntLiteral, (%As.impl_witness.feb) [concrete] +// CHECK:STDOUT: %.e88: type = fn_type_with_self_type %As.Convert.type.7eb, %As.facet.218 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.fec: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.467 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5: = specific_function %Core.IntLiteral.as.As.impl.Convert.467, @Core.IntLiteral.as.As.impl.Convert.2(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.290: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5 [concrete] +// CHECK:STDOUT: %int_1.f23: %u64 = int_value 1 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Cpp: = namespace file.%Cpp.import_cpp, [concrete] { +// CHECK:STDOUT: .long = @F.%i64.1 +// CHECK:STDOUT: .unsigned_long = @F.%u64.1 +// CHECK:STDOUT: import Cpp//... +// CHECK:STDOUT: } +// CHECK:STDOUT: %Core.import_ref.99c: @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.565) = import_ref Core//prelude/parts/int, loc32_39, loaded [symbolic = @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.d2c)] +// CHECK:STDOUT: %As.impl_witness_table.5ad = impl_witness_table (%Core.import_ref.99c), @Core.IntLiteral.as.As.impl.dc4 [concrete] +// CHECK:STDOUT: %Core.import_ref.611: @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.972) = import_ref Core//prelude/parts/uint, loc32_40, loaded [symbolic = @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.276)] +// CHECK:STDOUT: %As.impl_witness_table.e4e = impl_witness_table (%Core.import_ref.611), @Core.IntLiteral.as.As.impl.cc4 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_long.patt: %pattern_type.95b = binding_pattern cpp_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc8: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc8: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc8: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: %impl.elem0.loc8: %.b12 = impl_witness_access constants.%As.impl_witness.4f1, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.fe2] +// CHECK:STDOUT: %bound_method.loc8_31.1: = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.0c0] +// CHECK:STDOUT: %specific_fn.loc8: = specific_function %impl.elem0.loc8, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.96b] +// CHECK:STDOUT: %bound_method.loc8_31.2: = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method.b11] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc8: init %i64 = call %bound_method.loc8_31.2(%int_1.loc8) [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc8_31.1: %i64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc8 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc8_31.2: %i64 = converted %int_1.loc8, %.loc8_31.1 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc8_21: type = splice_block %long.ref [concrete = constants.%i64] { +// CHECK:STDOUT: %Cpp.ref.loc8: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %long.ref: type = name_ref long, %i64.1 [concrete = constants.%i64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long: %i64 = bind_name cpp_long, %.loc8_31.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_long.patt: %pattern_type.95b = binding_pattern carbon_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long.ref: %i64 = name_ref cpp_long, %cpp_long +// CHECK:STDOUT: %.loc9: type = splice_block %i64.loc9 [concrete = constants.%i64] { +// CHECK:STDOUT: %int_64.loc9: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc9: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_long: %i64 = bind_name carbon_long, %cpp_long.ref +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_long.patt: %pattern_type.157 = binding_pattern cpp_unsigned_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc11: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc11: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: %impl.elem0.loc11: %.e88 = impl_witness_access constants.%As.impl_witness.feb, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.467] +// CHECK:STDOUT: %bound_method.loc11_49.1: = bound_method %int_1.loc11, %impl.elem0.loc11 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.fec] +// CHECK:STDOUT: %specific_fn.loc11: = specific_function %impl.elem0.loc11, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5] +// CHECK:STDOUT: %bound_method.loc11_49.2: = bound_method %int_1.loc11, %specific_fn.loc11 [concrete = constants.%bound_method.290] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc11: init %u64 = call %bound_method.loc11_49.2(%int_1.loc11) [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc11_49.1: %u64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc11 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc11_49.2: %u64 = converted %int_1.loc11, %.loc11_49.1 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc11_30: type = splice_block %unsigned_long.ref [concrete = constants.%u64] { +// CHECK:STDOUT: %Cpp.ref.loc11: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] +// CHECK:STDOUT: +// CHECK:STDOUT: %unsigned_long.ref: type = name_ref unsigned_long, %u64.1 [concrete = constants.%u64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_long: %u64 = bind_name cpp_unsigned_long, %.loc11_49.2 +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_long.patt: %pattern_type.157 = binding_pattern carbon_unsigned_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_long.ref: %u64 = name_ref cpp_unsigned_long, %cpp_unsigned_long +// CHECK:STDOUT: %.loc12: type = splice_block %u64.loc12 [concrete = constants.%u64] { +// CHECK:STDOUT: %int_64.loc12: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc12: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_long: %u64 = bind_name carbon_unsigned_long, %cpp_unsigned_long.ref +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- fail_todo_unsupported_types.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete] +// CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete] +// CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete] +// CHECK:STDOUT: %As.type.bbb: type = facet_type <@As, @As(%i64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.d57: type = fn_type @As.Convert, @As(%i64) [concrete] +// CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.565: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d2c: %Core.IntLiteral.as.As.impl.Convert.type.565 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.4f1: = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.9ac: type = fn_type @Core.IntLiteral.as.As.impl.Convert.1, @Core.IntLiteral.as.As.impl.dc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.fe2: %Core.IntLiteral.as.As.impl.Convert.type.9ac = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.888: %As.type.bbb = facet_value Core.IntLiteral, (%As.impl_witness.4f1) [concrete] +// CHECK:STDOUT: %.b12: type = fn_type_with_self_type %As.Convert.type.d57, %As.facet.888 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.0c0: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.fe2 [concrete] +// CHECK:STDOUT: %pattern_type.95b: type = pattern_type %i64 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b: = specific_function %Core.IntLiteral.as.As.impl.Convert.fe2, @Core.IntLiteral.as.As.impl.Convert.1(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.b11: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.96b [concrete] +// CHECK:STDOUT: %int_1.41a: %i64 = int_value 1 [concrete] +// CHECK:STDOUT: %u64: type = class_type @UInt, @UInt(%int_64) [concrete] +// CHECK:STDOUT: %As.type.465: type = facet_type <@As, @As(%u64)> [concrete] +// CHECK:STDOUT: %As.Convert.type.7eb: type = fn_type @As.Convert, @As(%u64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.972: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%To) [symbolic] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.276: %Core.IntLiteral.as.As.impl.Convert.type.972 = struct_value () [symbolic] +// CHECK:STDOUT: %As.impl_witness.feb: = impl_witness imports.%As.impl_witness_table.e4e, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.da0: type = fn_type @Core.IntLiteral.as.As.impl.Convert.2, @Core.IntLiteral.as.As.impl.cc4(%int_64) [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.467: %Core.IntLiteral.as.As.impl.Convert.type.da0 = struct_value () [concrete] +// CHECK:STDOUT: %As.facet.218: %As.type.465 = facet_value Core.IntLiteral, (%As.impl_witness.feb) [concrete] +// CHECK:STDOUT: %.e88: type = fn_type_with_self_type %As.Convert.type.7eb, %As.facet.218 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound.fec: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.467 [concrete] +// CHECK:STDOUT: %pattern_type.157: type = pattern_type %u64 [concrete] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5: = specific_function %Core.IntLiteral.as.As.impl.Convert.467, @Core.IntLiteral.as.As.impl.Convert.2(%int_64) [concrete] +// CHECK:STDOUT: %bound_method.290: = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5 [concrete] +// CHECK:STDOUT: %int_1.f23: %u64 = int_value 1 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %Core.import_ref.99c: @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.565) = import_ref Core//prelude/parts/int, loc32_39, loaded [symbolic = @Core.IntLiteral.as.As.impl.dc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.d2c)] +// CHECK:STDOUT: %As.impl_witness_table.5ad = impl_witness_table (%Core.import_ref.99c), @Core.IntLiteral.as.As.impl.dc4 [concrete] +// CHECK:STDOUT: %Core.import_ref.611: @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.972) = import_ref Core//prelude/parts/uint, loc32_40, loaded [symbolic = @Core.IntLiteral.as.As.impl.cc4.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.276)] +// CHECK:STDOUT: %As.impl_witness_table.e4e = impl_witness_table (%Core.import_ref.611), @Core.IntLiteral.as.As.impl.cc4 [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_long_long.patt: = binding_pattern cpp_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc15: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc15: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: %impl.elem0.loc15: %.b12 = impl_witness_access constants.%As.impl_witness.4f1, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.fe2] +// CHECK:STDOUT: %bound_method.loc15_41.1: = bound_method %int_1.loc15, %impl.elem0.loc15 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.0c0] +// CHECK:STDOUT: %specific_fn.loc15: = specific_function %impl.elem0.loc15, @Core.IntLiteral.as.As.impl.Convert.1(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.96b] +// CHECK:STDOUT: %bound_method.loc15_41.2: = bound_method %int_1.loc15, %specific_fn.loc15 [concrete = constants.%bound_method.b11] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc15: init %i64 = call %bound_method.loc15_41.2(%int_1.loc15) [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc15_41.1: %i64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc15 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: %.loc15_41.2: %i64 = converted %int_1.loc15, %.loc15_41.1 [concrete = constants.%int_1.41a] +// CHECK:STDOUT: +// CHECK:STDOUT: %cpp_long_long: = bind_name cpp_long_long, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_long_long.patt: %pattern_type.95b = binding_pattern carbon_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_long_long.ref: = name_ref cpp_long_long, %cpp_long_long [concrete = ] +// CHECK:STDOUT: %.loc16: type = splice_block %i64.loc16 [concrete = constants.%i64] { +// CHECK:STDOUT: %int_64.loc16: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %i64.loc16: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_long_long: %i64 = bind_name carbon_long_long, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %cpp_unsigned_long_long.patt: = binding_pattern cpp_unsigned_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %int_1.loc25: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8] +// CHECK:STDOUT: %int_64.loc25: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc25: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: %impl.elem0.loc25: %.e88 = impl_witness_access constants.%As.impl_witness.feb, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.467] +// CHECK:STDOUT: %bound_method.loc25_59.1: = bound_method %int_1.loc25, %impl.elem0.loc25 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound.fec] +// CHECK:STDOUT: %specific_fn.loc25: = specific_function %impl.elem0.loc25, @Core.IntLiteral.as.As.impl.Convert.2(constants.%int_64) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn.6f5] +// CHECK:STDOUT: %bound_method.loc25_59.2: = bound_method %int_1.loc25, %specific_fn.loc25 [concrete = constants.%bound_method.290] +// CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc25: init %u64 = call %bound_method.loc25_59.2(%int_1.loc25) [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc25_59.1: %u64 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc25 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: %.loc25_59.2: %u64 = converted %int_1.loc25, %.loc25_59.1 [concrete = constants.%int_1.f23] +// CHECK:STDOUT: +// CHECK:STDOUT: %cpp_unsigned_long_long: = bind_name cpp_unsigned_long_long, [concrete = ] +// CHECK:STDOUT: name_binding_decl { +// CHECK:STDOUT: %carbon_unsigned_long_long.patt: %pattern_type.157 = binding_pattern carbon_unsigned_long_long [concrete] +// CHECK:STDOUT: } +// CHECK:STDOUT: %cpp_unsigned_long_long.ref: = name_ref cpp_unsigned_long_long, %cpp_unsigned_long_long [concrete = ] +// CHECK:STDOUT: %.loc26: type = splice_block %u64.loc26 [concrete = constants.%u64] { +// CHECK:STDOUT: %int_64.loc26: Core.IntLiteral = int_value 64 [concrete = constants.%int_64] +// CHECK:STDOUT: %u64.loc26: type = class_type @UInt, @UInt(constants.%int_64) [concrete = constants.%u64] +// CHECK:STDOUT: } +// CHECK:STDOUT: %carbon_unsigned_long_long: %u64 = bind_name carbon_unsigned_long_long, [concrete = ] +// CHECK:STDOUT: +// CHECK:STDOUT: } +// CHECK:STDOUT: