Skip to content

Commit a02dfe0

Browse files
authored
Superficial support for Core.BigInt type (#4414)
Add a `Core.BigInt` type and a corresponding builtin type in the toolchain. See [corresponding section of the design](https://docs.carbon-lang.dev/docs/design/expressions/literals.html#defined-types). So far this type is not used for anything, and there is no way to create an instance of it.
1 parent 96964ee commit a02dfe0

File tree

310 files changed

+573
-419
lines changed

Some content is hidden

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

310 files changed

+573
-419
lines changed

core/prelude/types.carbon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export import library "prelude/types/bool";
1111
// noise in the toolchain tests.
1212
// import library "prelude/types/i32";
1313

14+
fn BigInt() -> type = "big_int.make_type";
1415
fn Int32() -> type = "int.make_type_32";
1516
fn Int(size: i32) -> type = "int.make_type_signed";
1617
fn UInt(size: i32) -> type = "int.make_type_unsigned";

toolchain/check/context.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ class TypeCompleter {
925925
case SemIR::BuiltinInstKind::Error:
926926
case SemIR::BuiltinInstKind::Invalid:
927927
case SemIR::BuiltinInstKind::BoolType:
928+
case SemIR::BuiltinInstKind::BigIntType:
928929
case SemIR::BuiltinInstKind::IntType:
929930
case SemIR::BuiltinInstKind::FloatType:
930931
case SemIR::BuiltinInstKind::NamespaceType:

toolchain/check/eval.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,10 @@ static auto MakeConstantForBuiltinCall(Context& context, SemIRLoc loc,
930930
return SemIR::ConstantId::NotConstant;
931931
}
932932

933+
case SemIR::BuiltinFunctionKind::BigIntMakeType: {
934+
return context.constant_values().Get(SemIR::InstId::BuiltinBigIntType);
935+
}
936+
933937
case SemIR::BuiltinFunctionKind::IntMakeType32: {
934938
return context.constant_values().Get(SemIR::InstId::BuiltinIntType);
935939
}

toolchain/check/testdata/alias/fail_builtins.carbon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ alias b = bool;
4242
// CHECK:STDOUT: import Core//prelude/operators/comparison
4343
// CHECK:STDOUT: import Core//prelude/types/bool
4444
// CHECK:STDOUT: }
45-
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
45+
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
4646
// CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
4747
// CHECK:STDOUT: }
4848
// CHECK:STDOUT:

toolchain/check/testdata/array/array_in_place.carbon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn G() {
4747
// CHECK:STDOUT: import Core//prelude/operators/comparison
4848
// CHECK:STDOUT: import Core//prelude/types/bool
4949
// CHECK:STDOUT: }
50-
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
50+
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
5151
// CHECK:STDOUT: }
5252
// CHECK:STDOUT:
5353
// CHECK:STDOUT: file {

toolchain/check/testdata/array/array_vs_tuple.carbon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn G() {
4747
// CHECK:STDOUT: import Core//prelude/operators/comparison
4848
// CHECK:STDOUT: import Core//prelude/types/bool
4949
// CHECK:STDOUT: }
50-
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
50+
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
5151
// CHECK:STDOUT: }
5252
// CHECK:STDOUT:
5353
// CHECK:STDOUT: file {

toolchain/check/testdata/array/assign_return_value.carbon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn Run() {
4545
// CHECK:STDOUT: import Core//prelude/operators/comparison
4646
// CHECK:STDOUT: import Core//prelude/types/bool
4747
// CHECK:STDOUT: }
48-
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
48+
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
4949
// CHECK:STDOUT: }
5050
// CHECK:STDOUT:
5151
// CHECK:STDOUT: file {

toolchain/check/testdata/array/assign_var.carbon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var b: [i32; 3] = a;
4141
// CHECK:STDOUT: import Core//prelude/operators/comparison
4242
// CHECK:STDOUT: import Core//prelude/types/bool
4343
// CHECK:STDOUT: }
44-
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
44+
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
4545
// CHECK:STDOUT: }
4646
// CHECK:STDOUT:
4747
// CHECK:STDOUT: file {

toolchain/check/testdata/array/base.carbon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ var c: [(); 5] = ((), (), (), (), (),);
5757
// CHECK:STDOUT: import Core//prelude/operators/comparison
5858
// CHECK:STDOUT: import Core//prelude/types/bool
5959
// CHECK:STDOUT: }
60-
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
61-
// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+38, loaded [template = constants.%Float]
60+
// CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
61+
// CHECK:STDOUT: %import_ref.2: %Float.type = import_ref Core//prelude/types, inst+42, loaded [template = constants.%Float]
6262
// CHECK:STDOUT: }
6363
// CHECK:STDOUT:
6464
// CHECK:STDOUT: file {

toolchain/check/testdata/array/canonicalize_index.carbon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let b: [i32; 3]* = &a;
4343
// CHECK:STDOUT: import Core//prelude/operators/comparison
4444
// CHECK:STDOUT: import Core//prelude/types/bool
4545
// CHECK:STDOUT: }
46-
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
46+
// CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+9, loaded [template = constants.%Int32]
4747
// CHECK:STDOUT: }
4848
// CHECK:STDOUT:
4949
// CHECK:STDOUT: file {

0 commit comments

Comments
 (0)