mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-23 18:32:40 +00:00
Slightly simplify int value lowering. (#4767)
Refactor to use the new `GetAtWidth` function.
This commit is contained in:
1 parent
74395ce693
commit
f6d0cdabf8
1 file changed
+2
-5
@@ -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