Merge commit '2bb3996244' into sync_cg_clif-2022-12-14
This commit is contained in:
parent
f7c76ad662
commit
98a276b589
53 changed files with 1675 additions and 1012 deletions
12
src/base.rs
12
src/base.rs
|
|
@ -59,7 +59,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||
|
||||
// Declare function
|
||||
let symbol_name = tcx.symbol_name(instance).name.to_string();
|
||||
let sig = get_function_sig(tcx, module.isa().triple(), instance);
|
||||
let sig = get_function_sig(tcx, module.target_config().default_call_conv, instance);
|
||||
let func_id = module.declare_function(&symbol_name, Linkage::Local, &sig).unwrap();
|
||||
|
||||
// Make the FunctionBuilder
|
||||
|
|
@ -390,11 +390,9 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
|||
_ => unreachable!("{:?}", targets),
|
||||
};
|
||||
|
||||
let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr);
|
||||
let (discr, is_inverted) =
|
||||
crate::optimize::peephole::maybe_unwrap_bool_not(&mut fx.bcx, discr);
|
||||
let test_zero = if is_inverted { !test_zero } else { test_zero };
|
||||
let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr);
|
||||
if let Some(taken) = crate::optimize::peephole::maybe_known_branch_taken(
|
||||
&fx.bcx, discr, test_zero,
|
||||
) {
|
||||
|
|
@ -571,7 +569,7 @@ fn codegen_stmt<'tcx>(
|
|||
UnOp::Not => match layout.ty.kind() {
|
||||
ty::Bool => {
|
||||
let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0);
|
||||
CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout)
|
||||
CValue::by_val(res, layout)
|
||||
}
|
||||
ty::Uint(_) | ty::Int(_) => {
|
||||
CValue::by_val(fx.bcx.ins().bnot(val), layout)
|
||||
|
|
@ -579,12 +577,6 @@ fn codegen_stmt<'tcx>(
|
|||
_ => unreachable!("un op Not for {:?}", layout.ty),
|
||||
},
|
||||
UnOp::Neg => match layout.ty.kind() {
|
||||
ty::Int(IntTy::I128) => {
|
||||
// FIXME remove this case once ineg.i128 works
|
||||
let zero =
|
||||
CValue::const_val(fx, layout, ty::ScalarInt::null(layout.size));
|
||||
crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand)
|
||||
}
|
||||
ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout),
|
||||
ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout),
|
||||
_ => unreachable!("un op Neg for {:?}", layout.ty),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue