Switch to using Core.BigInt as the type of the size of a type literal. (#4450)

This removes one of the few ways in which `i32` is special and gets us
closer to removing it as a special case.
This commit is contained in:
Richard Smith
2024-10-28 23:35:08 +00:00
committed by GitHub
parent 7ec8ceac73
commit df68bf9f71
29 changed files with 485 additions and 448 deletions
+11 -2
View File
@@ -206,8 +206,17 @@ static auto EmitAsConstant(ConstantContext& /*context*/,
static auto EmitAsConstant(ConstantContext& context, SemIR::IntLiteral inst)
-> llvm::Constant* {
return llvm::ConstantInt::get(context.GetType(inst.type_id),
context.sem_ir().ints().Get(inst.int_id));
auto* type = context.GetType(inst.type_id);
// BigInt is represented as an empty struct. All other integer types are
// represented as an LLVM integer type.
if (!llvm::isa<llvm::IntegerType>(type)) {
auto* struct_type = llvm::dyn_cast<llvm::StructType>(type);
CARBON_CHECK(struct_type && struct_type->getNumElements() == 0);
return llvm::ConstantStruct::get(struct_type);
}
return llvm::ConstantInt::get(type, context.sem_ir().ints().Get(inst.int_id));
}
static auto EmitAsConstant(ConstantContext& context, SemIR::Namespace inst)