Skip to content

Commit 4ba81fc

Browse files
committed
codegen for Binop::Less
1 parent ece41e2 commit 4ba81fc

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/jit.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,24 @@ impl<'a> FunctionTranslator<'a> {
549549
todo!()
550550
}
551551
}
552+
Binop::Less => {
553+
let lhs = self.translate_expr(lhs_id, decl, decls);
554+
let rhs = self.translate_expr(rhs_id, decl, decls);
555+
let t = decl.types[lhs_id];
556+
557+
match *t {
558+
crate::types::Type::Int32 | crate::types::Type::Int8 => {
559+
self.builder.ins().icmp(IntCC::SignedLessThan, lhs, rhs)
560+
}
561+
crate::types::Type::UInt32 | crate::types::Type::UInt8 => {
562+
self.builder.ins().icmp(IntCC::UnsignedLessThan, lhs, rhs)
563+
}
564+
crate::types::Type::Float32 | crate::types::Type::Float64 => {
565+
self.builder.ins().fcmp(FloatCC::LessThan, lhs, rhs)
566+
}
567+
_ => todo!(),
568+
}
569+
}
552570
Binop::And => {
553571
let lhs = self.translate_expr(lhs_id, decl, decls);
554572
let rhs = self.translate_expr(rhs_id, decl, decls);

tests/cases/arith/numeric_equality.lyte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ main {
99
assert(1 == 1)
1010
assert(2 != 1)
1111
assert(1 != 2)
12+
assert(1 < 2)
1213
//assert(1 <= 1)
1314
//assert(1 <= 2)
1415
//assert(1 >= 1)

0 commit comments

Comments
 (0)