This is an archive of the discontinued LLVM Phabricator instance.

[Flang][OpenMP] Improve support for `if` clause on combined constructs
ClosedPublic

Authored by skatrak on Jul 26 2023, 4:36 AM.

Details

Summary

This patch adds support for matching multiple OpenMP if clauses to their specified directive in a combined construct. It also enables this clause to be attached by name to simd and teams directives, in addition to the others that were already supported.

This patch on its own cannot yet be tested because there is currently no lowering to MLIR support for any combined construct containing two or more OpenMP directives that can have an if clause attached.

Depends on D155981.

Diff Detail

Event Timeline

skatrak created this revision.Jul 26 2023, 4:36 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 26 2023, 4:36 AM
skatrak requested review of this revision.Jul 26 2023, 4:36 AM

Please add tests for the parser/semantics changes.

skatrak updated this revision to Diff 544687.Jul 27 2023, 3:27 AM

Add parser/semantics unit test for all supported combined constructs. Fix some parser/semantics issues uncovered by testing.

Herald added a project: Restricted Project. · View Herald Transcript
kiranchandramohan accepted this revision.Aug 2 2023, 2:30 PM

Please add debug-dump-unparse or a debug-dump-parse-tree tests for the modifications in the parse-tree or the parser before you submit.

flang/lib/Lower/OpenMP.cpp
2483

Nit: While you are here, could you check whether it is possible to print the name of the directive?

This revision is now accepted and ready to land.Aug 2 2023, 2:30 PM
skatrak updated this revision to Diff 546848.Aug 3 2023, 7:05 AM

Add parser unit tests.

skatrak added inline comments.Aug 3 2023, 7:28 AM
flang/lib/Lower/OpenMP.cpp
2483

I looked into it and the only place where I saw that the llvm::omp::Directive enum is translated to a text representation is Unparse(). I suppose it would be possible to expose another specialization of that template function in unparse.h to allow printing that here, but it doesn't seem like a very good idea. Also creating a big switch with all options here doesn't seem right either.

I was looking into TableGen's DirectiveEmitter, and it looks like it would be possible to generate some sort of {stringify,symbolize}<Enum Name>() for the Directive and Clause enums, like it's done for MLIR EnumAttrs. That would make the string representation easily available. Let me know if this is a feasible solution, and I'll try to create a separate patch for it.

skatrak updated this revision to Diff 546870.Aug 3 2023, 7:43 AM

Print name of unhandled block directives.

skatrak marked an inline comment as done.Aug 3 2023, 7:51 AM

Thank you Kiran for looking into this, I think it's ready to land now.

flang/lib/Lower/OpenMP.cpp
2483

Sorry, nevermind. I missed the fact that such a function was already being generated there. This comment is addressed now.