mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Slightly simplify int value lowering. (#4767)
Refactor to use the new `GetAtWidth` function.
This commit is contained in:
@@ -199,12 +199,9 @@ static auto EmitAsConstant(ConstantContext& context, SemIR::IntValue inst)
|
||||
return int_literal_value;
|
||||
}
|
||||
|
||||
auto val = context.sem_ir().ints().Get(inst.int_id);
|
||||
int bit_width = int_type->getBitWidth();
|
||||
bool is_signed =
|
||||
context.sem_ir().types().GetIntTypeInfo(inst.type_id).is_signed;
|
||||
return llvm::ConstantInt::get(type, is_signed ? val.sextOrTrunc(bit_width)
|
||||
: val.zextOrTrunc(bit_width));
|
||||
auto val = context.sem_ir().ints().GetAtWidth(inst.int_id, bit_width);
|
||||
return llvm::ConstantInt::get(type, val);
|
||||
}
|
||||
|
||||
static auto EmitAsConstant(ConstantContext& context, SemIR::Namespace inst)
|
||||
|
||||
Reference in New Issue
Block a user