llvm-project
770a2732 - [flang][OpenMP] Lower iterator modifiers in map and motion clauses

Commit
15 days ago
[flang][OpenMP] Lower iterator modifiers in map and motion clauses Add iterator lowering for `target data`, `target enter/exit data`, `target update`, and map clauses inside `declare mapper`. For example: ```fortran !$omp target update to(iterator(i=1:n): a(i), b) ``` Conceptually, this becomes: ```text entries = omp.iterator(i = 1 through n) { yield map_info(base = a, bounds = element i) } target_update(iterated_maps = entries, ordinary_maps = [b]) ``` Keeping the array base and expressing selections through bounds lets the same approach handle array elements, sections, and descriptor-backed arrays. Each locator is expanded only over the iterators that appear in it: ```text iterator(i=1:n, j=1:m): a(i), b(j), c(i,j) | | | i j i x j ``` Iterator ranges use the same canonical loop semantics throughout lowering: ```text trip_count = canonicalTripCount(lower, upper, step, inclusive) if any trip_count == 0: result = [] skip iterator region ``` These rules preserve source behavior in edge cases. Fortran ranges include the endpoint, so lowering marks them inclusive instead of dropping the last entry. A range such as `5:1:1` is empty and yields no entries instead of being mistaken for a large range. Bounds and reconstructed iterator values keep their source integer width, preventing `INTEGER(16)` values from being truncated. Supports explicit and default mappers, including mapper declarations imported from other modules. This PR stacked on top of #197047 and #197752. This patch is part of feature work for #188061. Assisted with codex.
Author
Committer
Parents
Loading