Functions for building arithmetic expressions.
More...
|
| Expression | sdfg::symbolic::add (const Expression lhs, const Expression rhs) |
| | Addition of two expressions.
|
| Expression | sdfg::symbolic::sub (const Expression lhs, const Expression rhs) |
| | Subtraction of two expressions.
|
| Expression | sdfg::symbolic::mul (const Expression lhs, const Expression rhs) |
| | Multiplication of two expressions.
|
| Expression | sdfg::symbolic::div (const Expression lhs, const Expression rhs) |
| | Integer division idiv(lhs, rhs) with the semantics of signed C/C++ lhs / rhs on int64.
|
| Expression | sdfg::symbolic::floor_div (const Expression lhs, const Expression divisor) |
| | Exact floor division floor(lhs / divisor) in terms of idiv.
|
| Expression | sdfg::symbolic::ceil_div (const Expression dividend, const Expression divisor) |
| | Exact ceiling division ceil(dividend / divisor) in terms of idiv.
|
| Expression | sdfg::symbolic::ceil_count (const Expression extent, const Expression chunk) |
| | Number of chunks of size chunk (positive) covering extent: max(0, ceil(extent / chunk)).
|
| Expression | sdfg::symbolic::min (const Expression lhs, const Expression rhs) |
| | Minimum of two expressions.
|
| Expression | sdfg::symbolic::max (const Expression lhs, const Expression rhs) |
| | Maximum of two expressions.
|
| Expression | sdfg::symbolic::abs (const Expression expr) |
| | Absolute value of an expression.
|
| Expression | sdfg::symbolic::mod (const Expression lhs, const Expression rhs) |
| | Integer remainder imod(lhs, rhs) with the semantics of signed C/C++ lhs % rhs on int64.
|
| Expression | sdfg::symbolic::bit_xor (const Expression lhs, const Expression rhs) |
| | Bitwise XOR operation (integer).
|
| Expression | sdfg::symbolic::pow (const Expression base, const Expression exp) |
| | Power/exponentiation operation.
|
| Expression | sdfg::symbolic::zext_i64 (const Expression expr) |
| | Zero-extend to 64-bit integer.
|
| Expression | sdfg::symbolic::trunc_i32 (const Expression expr) |
| | Truncate to 32-bit integer.
|
Functions for building arithmetic expressions.
These functions construct symbolic arithmetic expressions representing integer operations. They are used in address calculations (memlets) and loop bounds.
Expression add(const Expression lhs, const Expression rhs)
Addition of two expressions.
Expression mul(const Expression lhs, const Expression rhs)
Multiplication of two expressions.
Integer integer(int64_t value)
Creates an integer constant.
Symbol symbol(const std::string &name)
Creates a symbolic variable with the given name.
◆ abs()
Absolute value of an expression.
- Parameters
-
- Returns
- Expression representing |expr|
◆ add()
Addition of two expressions.
- Parameters
-
| lhs | Left-hand side expression |
| rhs | Right-hand side expression |
- Returns
- Expression representing (lhs + rhs)
◆ bit_xor()
Bitwise XOR operation (integer).
- Parameters
-
| lhs | Left operand |
| rhs | Right operand |
- Returns
- Expression representing (lhs ^ rhs); lowered to ^ by codegen. Used by swizzled shared-memory layouts (a bijection on a power-of-two range).
◆ ceil_count()
Number of chunks of size chunk (positive) covering extent: max(0, ceil(extent / chunk)).
For trip counts, grid sizes, page counts, etc. Cheaper than max(0, ceil_div(...)): idiv(extent + chunk - 1, chunk) is exact under the clamp.
◆ ceil_div()
Exact ceiling division ceil(dividend / divisor) in terms of idiv.
Integer literals fold for any non-zero divisor. Otherwise the divisor must be positive (a negative integer literal is normalized by negating both operands).
◆ div()
Integer division idiv(lhs, rhs) with the semantics of signed C/C++ lhs / rhs on int64.
The quotient is truncated toward zero, e.g. idiv(-7, 2) == -3; codegen emits /. Integer literals are folded unless the result is undefined in C (rhs == 0, INT64_MIN / -1).
◆ floor_div()
Exact floor division floor(lhs / divisor) in terms of idiv.
Integer literals fold for any non-zero divisor. Otherwise the divisor must be positive (a negative integer literal is normalized by negating both operands).
◆ max()
Maximum of two expressions.
- Parameters
-
| lhs | First expression |
| rhs | Second expression |
- Returns
- Expression representing max(lhs, rhs)
◆ min()
Minimum of two expressions.
- Parameters
-
| lhs | First expression |
| rhs | Second expression |
- Returns
- Expression representing min(lhs, rhs)
◆ mod()
Integer remainder imod(lhs, rhs) with the semantics of signed C/C++ lhs % rhs on int64.
The result has the sign of lhs and satisfies lhs == rhs * idiv(lhs, rhs) + imod(lhs, rhs), e.g. imod(-7, 2) == -1; codegen emits %. Folding follows the same rules as div.
◆ mul()
Multiplication of two expressions.
- Parameters
-
| lhs | Left-hand side expression |
| rhs | Right-hand side expression |
- Returns
- Expression representing (lhs * rhs)
◆ pow()
Power/exponentiation operation.
- Parameters
-
| base | Base expression |
| exp | Exponent expression |
- Returns
- Expression representing base^exp
◆ sub()
Subtraction of two expressions.
- Parameters
-
| lhs | Left-hand side expression |
| rhs | Right-hand side expression |
- Returns
- Expression representing (lhs - rhs)
◆ trunc_i32()
Truncate to 32-bit integer.
- Parameters
-
- Returns
- Expression representing the truncated value
◆ zext_i64()
Zero-extend to 64-bit integer.
- Parameters
-
- Returns
- Expression representing the zero-extended value