From 46777633bc9298188d1f5be9aba116cb46b35464 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 27 Jul 2025 18:19:54 -0400 Subject: [PATCH] xo-expression: less-than-or-equal --- include/xo/expression/Apply.hpp | 3 +++ include/xo/expression/Primitive.hpp | 2 ++ src/expression/Apply.cpp | 8 ++++++++ src/expression/Primitive.cpp | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/include/xo/expression/Apply.hpp b/include/xo/expression/Apply.hpp index 69e830c4..f01fe2a5 100644 --- a/include/xo/expression/Apply.hpp +++ b/include/xo/expression/Apply.hpp @@ -37,6 +37,9 @@ namespace xo { /** create apply-expression for less-than comparison of two 64-bit integers **/ static rp make_cmp_lt_i64(const rp & lhs, const rp & rhs); + /** create apply-expression for less-than-or-equal comparison of two 64-bit integers **/ + static rp make_cmp_le_i64(const rp & lhs, + const rp & rhs); /** create apply-expression for greater-than comparison of two 64-bit integers **/ static rp make_cmp_gt_i64(const rp & lhs, const rp & rhs); diff --git a/include/xo/expression/Primitive.hpp b/include/xo/expression/Primitive.hpp index e2283f33..619d943e 100644 --- a/include/xo/expression/Primitive.hpp +++ b/include/xo/expression/Primitive.hpp @@ -206,6 +206,8 @@ namespace xo { static rp make_cmp_ne2_i64(); /** lt2_i64: compare two 64-bit integers for lessthan **/ static rp make_cmp_lt2_i64(); + /** lt2_i64: compare two 64-bit integers for lessthanorequal **/ + static rp make_cmp_le2_i64(); /** gt2_i64: compare two 64-bit integers for greaterthan **/ static rp make_cmp_gt2_i64(); }; diff --git a/src/expression/Apply.cpp b/src/expression/Apply.cpp index 3dfc5a6c..70f4bf95 100644 --- a/src/expression/Apply.cpp +++ b/src/expression/Apply.cpp @@ -56,6 +56,14 @@ namespace xo { {lhs, rhs}); } + rp + Apply::make_cmp_le_i64(const rp & lhs, + const rp & rhs) + { + return Apply::make(Primitive_cmp_i64::make_cmp_le2_i64(), + {lhs, rhs}); + } + rp Apply::make_cmp_gt_i64(const rp & lhs, const rp & rhs) diff --git a/src/expression/Primitive.cpp b/src/expression/Primitive.cpp index cafaffb1..234edd88 100644 --- a/src/expression/Primitive.cpp +++ b/src/expression/Primitive.cpp @@ -27,6 +27,11 @@ extern "C" { return x < y; } + bool + cmp_le2_i64(std::int64_t x, std::int64_t y) { + return x <= y; + } + bool cmp_gt2_i64(std::int64_t x, std::int64_t y) { return x > y; @@ -117,6 +122,20 @@ namespace xo { return s_retval; } + auto + Primitive_cmp_i64::make_cmp_le2_i64() -> rp + { + static rp s_retval; + + if (!s_retval) + s_retval = Primitive::make("cmp_le2_i64", + &cmp_le2_i64, + true /*explicit_symbol_def*/, + llvmintrinsic::i_sle); + + return s_retval; + } + auto Primitive_cmp_i64::make_cmp_gt2_i64() -> rp {