xo-expression: + operator >=
This commit is contained in:
parent
813407310c
commit
7d220ede27
5 changed files with 43 additions and 3 deletions
|
|
@ -43,7 +43,9 @@ namespace xo {
|
|||
/** create apply-expression for greater-than comparison of two 64-bit integers **/
|
||||
static rp<Apply> make_cmp_gt_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
|
||||
/** create apply-expression for greater-than-or-equal comparison of two 64-bit integers **/
|
||||
static rp<Apply> make_cmp_ge_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
/** create apply-expression to add two 64-bit integers **/
|
||||
static rp<Apply> make_add2_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
|
|
|
|||
|
|
@ -210,6 +210,8 @@ namespace xo {
|
|||
static rp<PrimitiveType> make_cmp_le2_i64();
|
||||
/** gt2_i64: compare two 64-bit integers for greaterthan **/
|
||||
static rp<PrimitiveType> make_cmp_gt2_i64();
|
||||
/** ge2_i64: compare two 64-bit integers for greaterthan **/
|
||||
static rp<PrimitiveType> make_cmp_ge2_i64();
|
||||
};
|
||||
|
||||
/** builtin primitives :: i64 x i64 -> i64 **/
|
||||
|
|
|
|||
|
|
@ -72,6 +72,14 @@ namespace xo {
|
|||
{lhs, rhs});
|
||||
}
|
||||
|
||||
rp<Apply>
|
||||
Apply::make_cmp_ge_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs)
|
||||
{
|
||||
return Apply::make(Primitive_cmp_i64::make_cmp_ge2_i64(),
|
||||
{lhs, rhs});
|
||||
}
|
||||
|
||||
// ----- integer arithmetic -----
|
||||
|
||||
rp<Apply>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ extern "C" {
|
|||
return x > y;
|
||||
}
|
||||
|
||||
bool
|
||||
cmp_ge2_i64(std::int64_t x, std::int64_t y) {
|
||||
return x >= y;
|
||||
}
|
||||
|
||||
std::int64_t
|
||||
add2_i64(std::int64_t x, std::int64_t y) {
|
||||
return x + y;
|
||||
|
|
@ -150,6 +155,20 @@ namespace xo {
|
|||
return s_retval;
|
||||
}
|
||||
|
||||
auto
|
||||
Primitive_cmp_i64::make_cmp_ge2_i64() -> rp<PrimitiveType>
|
||||
{
|
||||
static rp<PrimitiveType> s_retval;
|
||||
|
||||
if (!s_retval)
|
||||
s_retval = Primitive::make("cmp_ge2_i64",
|
||||
&cmp_ge2_i64,
|
||||
true /*explicit_symbol_def*/,
|
||||
llvmintrinsic::i_sge);
|
||||
|
||||
return s_retval;
|
||||
}
|
||||
|
||||
/* TODO: remaining integer arithmetic */
|
||||
|
||||
auto
|
||||
|
|
|
|||
|
|
@ -191,6 +191,9 @@ namespace xo {
|
|||
}
|
||||
break;
|
||||
|
||||
case optype::op_not_equal:
|
||||
assert(false);
|
||||
|
||||
case optype::op_less:
|
||||
// TODO: floating-point less-than
|
||||
|
||||
|
|
@ -204,8 +207,14 @@ namespace xo {
|
|||
break;
|
||||
|
||||
case optype::op_less_equal:
|
||||
case optype::op_not_equal:
|
||||
assert(false);
|
||||
if (lhs_->valuetype()->is_i64() && rhs_->valuetype()->is_i64()) {
|
||||
return Apply::make_cmp_le_i64(lhs_, rhs_);
|
||||
} else {
|
||||
this->apply_type_error(c_self_name,
|
||||
op_type_, lhs_, rhs_, p_psm);
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
|
||||
case optype::op_great:
|
||||
if (lhs_->valuetype()->is_i64() && rhs_->valuetype()->is_i64()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue