Tiramisu-Compiler / tiramisu

A polyhedral compiler for expressing fast and portable data parallel algorithms
http://tiramisu-compiler.org
MIT License
905 stars 131 forks source link

How to implement XOR operator of a expression #373

Closed hieuhv94 closed 1 year ago

hieuhv94 commented 1 year ago

How to implement XOR operator of a expression? Now, just the below operations is supported `enum op_t { // Unary operators // The argument of the following operators is a tiramisu::expr. o_minus, o_floor, o_sin, o_cos, o_tan, o_asin, o_acos, o_atan, o_sinh, o_cosh, o_tanh, o_asinh, o_acosh, o_atanh, o_abs, o_sqrt, o_expo, // exponential o_log, o_ceil, o_round, o_trunc, // The argument of the following operators is a string representing // the name of the buffer to allocate. o_allocate, o_free, // Other arguments o_cast, // The argument is an expression and a type. o_address, // The argument is a tiramisu::var() that represents a buffer.

// Binary operator
// The arguments are tiramisu::expr.
o_add,
o_sub,
o_mul,
o_div,
o_mod,
o_logical_and,
o_logical_or,
o_logical_not,
o_eq,
o_ne,
o_le,
o_lt,
o_ge,
o_gt,
o_max,
o_min,
o_right_shift,
o_left_shift,
o_memcpy,

// Ternary operators
// The arguments are tiramisu::expr.
o_select,
o_cond,
o_lerp,

// Operators taking a name and a vector of expressions.
o_call,
o_access,
o_address_of,
o_lin_index,
o_type,
o_dummy,
// just pass in the buffer
o_buffer,

o_none,

};`

rbaghdadi commented 1 year ago

You can create a C function that implements XOR and call it from Tiramisu code. You can call any C function from Tiramisu.

rbaghdadi commented 1 year ago

You can use the o_call operator to see how to call a function.

hieuhv94 commented 1 year ago

You can use the o_call operator to see how to call a function.

Great! Thank u so much