cornell-zhang/hcl-dialect

[Op] Support of multiple if conditions

Closed this issue · 1 comments

We need to support the following imperative program with multiple conditions in a if statement, which is also useful to support general SelectOp.

with hcl.if_(hcl.all(i > j, j >= i + 1)): # affine.if
    A[i, j] += 1

To capture the high-level information, we can do the following steps:

  1. Create an hcl.logical_and op that can take in variadic arguments, each of which is a condition expression.
  2. Create a Python binding interface LogicalAndOp.
  3. Map the frontend hcl.all op to hcl_mlir.LogicalAndOp.
  4. In build_ir.py/make_if we allow the input of expression to be an LogicalAndOp, and take each of its arguments to individually traverse the expression tree and construct the affine expressions.

In this way, hcl.logical_and is actually not built as an IR node, but is directly lowered when building the MLIR code.