xo-reader: integer arithmetic + parser + pretty-printing adds
This commit is contained in:
parent
10cb2462f3
commit
c06df5ccb5
6 changed files with 165 additions and 4 deletions
|
|
@ -35,6 +35,19 @@ namespace xo {
|
|||
static rp<Apply> make_cmp_ne_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);
|
||||
/** create apply-expression to subtract two 64-bit integers **/
|
||||
static rp<Apply> make_sub2_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
/** create apply-expression to multiply two 64-bit integers **/
|
||||
static rp<Apply> make_mul2_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
/** create apply-expression to divide two 64-bit integers **/
|
||||
static rp<Apply> make_div2_i64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
|
||||
/** create apply-expression to add two 64-bit floating-point numbers **/
|
||||
static rp<Apply> make_add2_f64(const rp<Expression> & lhs,
|
||||
const rp<Expression> & rhs);
|
||||
|
|
|
|||
|
|
@ -191,6 +191,9 @@ namespace xo {
|
|||
return Primitive<FunctionPointer>::make(name, x, explicit_symbol_def, intrinsic);
|
||||
}
|
||||
|
||||
// NOTE: see xo-reader/src/reader/progress_xs.cpp
|
||||
// binding operators to primitive applications.
|
||||
|
||||
/** builtin primitives :: i64 x i64 -> bool **/
|
||||
class Primitive_cmp_i64 : public Primitive<bool (*)(std::int64_t, std::int64_t)> {
|
||||
public:
|
||||
|
|
@ -203,6 +206,22 @@ namespace xo {
|
|||
static rp<PrimitiveType> make_cmp_ne2_i64();
|
||||
};
|
||||
|
||||
/** builtin primitives :: i64 x i64 -> i64 **/
|
||||
class Primitive_i64 : public Primitive<std::int64_t (*)(std::int64_t, std::int64_t)> {
|
||||
public:
|
||||
using PrimitiveType = Primitive<std::int64_t (*)(std::int64_t, std::int64_t)>;
|
||||
|
||||
public:
|
||||
/** add2_i64: add two 64-bit integers **/
|
||||
static rp<PrimitiveType> make_add2_i64();
|
||||
/** sub2_i64: subtract two 64-bit integers **/
|
||||
static rp<PrimitiveType> make_sub2_i64();
|
||||
/** mul2_i64: multiply two 64-bit integers **/
|
||||
static rp<PrimitiveType> make_mul2_i64();
|
||||
/** div2_i64: divide two 64-bit integers **/
|
||||
static rp<PrimitiveType> make_div2_i64();
|
||||
};
|
||||
|
||||
/** builtin primitives :: f64 x f64 -> f64 **/
|
||||
class Primitive_f64 : public Primitive<double (*)(double, double)> {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ namespace xo {
|
|||
* NSW stands for 'no signed wrap' -> poison value if overflow (costs more)
|
||||
* NUW stands for 'no unsigned wrap' -> poison value if overflow (costs more)
|
||||
* @endnote
|
||||
*
|
||||
* See: xo-jit/src/jit/MachPipeline.cpp
|
||||
**/
|
||||
enum class llvmintrinsic {
|
||||
// see /nix/store/x5yz...llvm-18.1.5-dev/include/llvm/IR/IRBuilder.h
|
||||
|
|
@ -82,16 +84,16 @@ namespace xo {
|
|||
|
||||
// TODO: unsigned comparisons
|
||||
|
||||
/** -> IRBuilder::CreateFadd (add 2 floating-point numbers) **/
|
||||
/** -> IRBuilder::CreateFAdd (add 2 floating-point numbers) **/
|
||||
fp_add,
|
||||
|
||||
/** -> IRBuilder::CreateFsub (subtract 2 floating-pointer numbers) **/
|
||||
/** -> IRBuilder::CreateFSub (subtract 2 floating-pointer numbers) **/
|
||||
fp_sub,
|
||||
|
||||
/** -> IRBuilder::CreateFmul (multiply 2 floating-point numbers) **/
|
||||
/** -> IRBuilder::CreateFMul (multiply 2 floating-point numbers) **/
|
||||
fp_mul,
|
||||
|
||||
/** -> IRBuilder::CreateFdiv (divide 2 floating-point numbers) **/
|
||||
/** -> IRBuilder::CreateFDiv (divide 2 floating-point numbers) **/
|
||||
fp_div,
|
||||
|
||||
// TODO: floating-point comparisons
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue