@@ -49,6 +49,19 @@ static auto MakeI32Literal(Context& context, Parse::NodeId node_id,
4949 .int_id = context.ints ().Add (i32_val)});
5050}
5151
52+ // Forms an IntLiteral instruction with type `BigInt` for a given literal
53+ // integer value, which is assumed to be unsigned.
54+ static auto MakeBigIntLiteral (Context& context, Parse::NodeId node_id,
55+ IntId int_id) -> SemIR::InstId {
56+ // TODO: `IntId`s with different bit-widths are considered different values
57+ // here. Decide how we want to canonicalize these. For now this is only used
58+ // by type literals, so we rely on the lexer picking some consistent rule.
59+ return context.AddInst <SemIR::IntLiteral>(
60+ node_id,
61+ {.type_id = context.GetBuiltinType (SemIR::BuiltinInstKind::BigIntType),
62+ .int_id = int_id});
63+ }
64+
5265auto HandleParseNode (Context& context, Parse::IntLiteralId node_id) -> bool {
5366 // Convert the literal to i32.
5467 // TODO: Form an integer literal value and a corresponding type here instead.
@@ -134,7 +147,7 @@ static auto HandleIntOrUnsignedIntTypeLiteral(Context& context,
134147 node_id, IntWidthNotMultipleOf8, int_kind.is_signed (),
135148 llvm::APSInt (context.ints ().Get (size_id), /* isUnsigned=*/ true ));
136149 }
137- auto width_id = MakeI32Literal (context, node_id, size_id);
150+ auto width_id = MakeBigIntLiteral (context, node_id, size_id);
138151 auto fn_inst_id = context.LookupNameInCore (
139152 node_id, int_kind == SemIR::IntKind::Signed ? " Int" : " UInt" );
140153 auto type_inst_id = PerformCall (context, node_id, fn_inst_id, {width_id});
@@ -175,7 +188,7 @@ auto HandleParseNode(Context& context, Parse::FloatTypeLiteralId node_id)
175188 }
176189 auto tok_id = context.parse_tree ().node_token (node_id);
177190 auto size_id = context.tokens ().GetTypeLiteralSize (tok_id);
178- auto width_id = MakeI32Literal (context, node_id, size_id);
191+ auto width_id = MakeBigIntLiteral (context, node_id, size_id);
179192 auto fn_inst_id = context.LookupNameInCore (node_id, " Float" );
180193 auto type_inst_id = PerformCall (context, node_id, fn_inst_id, {width_id});
181194 context.node_stack ().Push (node_id, type_inst_id);
0 commit comments