This patch continues the work of D147658. It adds the omp.canonical_loop operation as the basic block for everything loop-related in OpenMP, such as worksharing-loop, distribute, loop transformation, etc.
In contrast to the current omp.wsloop approach
- Loop-related semantics need to be implemented only once
- Is composable with OpenMP loop transformations such as unrolling, tiling.
- Is supposed to eventually support non-rectangular loops
- Supports expressing non-perfectly nested loops
This patch only adds the MLIR representation; to something useful, I still have to implement lowering from Flang with at least the DO construct, and lowering to LLVM-IR using the OpenMPIRBuilder.
The pretty syntax currently is
omp.canonical_loop $iv in [0, %tripcount) { ... }
where [0, %tripcount) represents the half-open integer range of an OpenMP logical iteration space. Unbalanced parentheses/brackets and 0 keyword might not be universally liked. I could think of alternatives such as
omp.canonical_loop $iv = range(%tripcount) { ... }
SingleBlockImplicitTerminator will enforce the requirement for a single block in the loop and hence would disallow branches inside the loop.