Add FCmp to codegen

This commit is contained in:
Sofia 2025-07-22 15:01:02 +03:00
parent 9b9398ac26
commit 108cf6efa5

View File

@ -641,9 +641,8 @@ impl mir::Expression {
(mir::BinaryOperator::Mult, _, false) => Instr::Mul(lhs, rhs), (mir::BinaryOperator::Mult, _, false) => Instr::Mul(lhs, rhs),
(mir::BinaryOperator::Mult, _, true) => Instr::FMul(lhs, rhs), (mir::BinaryOperator::Mult, _, true) => Instr::FMul(lhs, rhs),
(mir::BinaryOperator::And, _, _) => Instr::And(lhs, rhs), (mir::BinaryOperator::And, _, _) => Instr::And(lhs, rhs),
(mir::BinaryOperator::Cmp(i), _, false) => { (mir::BinaryOperator::Cmp(i), _, false) => Instr::ICmp(i.predicate(), lhs, rhs),
Instr::ICmp(i.int_predicate(), lhs, rhs) (mir::BinaryOperator::Cmp(i), _, true) => Instr::FCmp(i.predicate(), lhs, rhs),
}
_ => todo!(), _ => todo!(),
}; };
Some(StackValue( Some(StackValue(
@ -771,7 +770,7 @@ impl mir::Expression {
*further_inner, *further_inner,
) )
} else { } else {
let TypeKind::Array(elem_ty, _) = *inner else { let TypeKind::Array(_, _) = *inner else {
panic!(); panic!();
}; };
( (
@ -1157,7 +1156,7 @@ impl mir::IfExpression {
} }
} }
impl mir::CmpOperator { impl mir::CmpOperator {
fn int_predicate(&self) -> CmpPredicate { fn predicate(&self) -> CmpPredicate {
match self { match self {
mir::CmpOperator::LT => CmpPredicate::LT, mir::CmpOperator::LT => CmpPredicate::LT,
mir::CmpOperator::GT => CmpPredicate::GT, mir::CmpOperator::GT => CmpPredicate::GT,
@ -1199,7 +1198,7 @@ impl mir::Literal {
mir::Literal::F80(val) => ConstValue::F80(val), mir::Literal::F80(val) => ConstValue::F80(val),
mir::Literal::F128(val) => ConstValue::F128(val), mir::Literal::F128(val) => ConstValue::F128(val),
mir::Literal::F128PPC(val) => ConstValue::F128PPC(val), mir::Literal::F128PPC(val) => ConstValue::F128PPC(val),
mir::Literal::Char(c) => todo!(), mir::Literal::Char(c) => ConstValue::U8(c as u8),
}) })
} }
} }