forked from M-Labs/nac3
1
0
Fork 0

binop: expand `not` operator as loglcal not

This commit is contained in:
occheung 2024-11-08 17:12:01 +08:00
parent c3927d0ef6
commit 979209a526
1 changed files with 6 additions and 1 deletions

View File

@ -1777,7 +1777,12 @@ pub fn gen_unaryop_expr_with_values<'ctx, G: CodeGenerator>(
ast::Unaryop::Invert => ctx.builder.build_not(val, "not").map(Into::into).unwrap(), ast::Unaryop::Invert => ctx.builder.build_not(val, "not").map(Into::into).unwrap(),
ast::Unaryop::Not => ctx ast::Unaryop::Not => ctx
.builder .builder
.build_xor(val, val.get_type().const_all_ones(), "not") .build_int_compare(
inkwell::IntPredicate::EQ,
val,
val.get_type().const_zero(),
"not",
)
.map(Into::into) .map(Into::into)
.unwrap(), .unwrap(),
ast::Unaryop::UAdd => val.into(), ast::Unaryop::UAdd => val.into(),