Skip to content

[MLIR][OpenMP][Docs] NFC: Document op naming conventions #107233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

skatrak
Copy link
Member

@skatrak skatrak commented Sep 4, 2024

This patch documents op naming conventions discussed in this RFC.

@llvmbot
Copy link
Member

llvmbot commented Sep 4, 2024

@llvm/pr-subscribers-mlir-openmp

@llvm/pr-subscribers-mlir

Author: Sergio Afonso (skatrak)

Changes

This patch documents op naming conventions discussed in this RFC.


Full diff: https://github.com/llvm/llvm-project/pull/107233.diff

1 Files Affected:

  • (modified) mlir/docs/Dialects/OpenMPDialect/_index.md (+27)
diff --git a/mlir/docs/Dialects/OpenMPDialect/_index.md b/mlir/docs/Dialects/OpenMPDialect/_index.md
index f4a468ca84da99..43e82a871db066 100644
--- a/mlir/docs/Dialects/OpenMPDialect/_index.md
+++ b/mlir/docs/Dialects/OpenMPDialect/_index.md
@@ -12,3 +12,30 @@ other definitions in this dialect, refer to the automatically-generated
 [ODS Documentation](ODS.md).
 
 [TOC]
+
+## Operation Naming Conventions
+
+This section aims to standardize how dialect operation names are chosen, to
+ensure a level of consistency. There are two categories of names: tablegen names
+and assembly names. The former also corresponds to the C++ class that is
+generated for the operation, whereas the latter is used to represent it in MLIR
+text form.
+
+Tablegen names are CamelCase, with the first letter capitalized and an "Op"
+suffix, whereas assembly names are snake_case, with all lowercase letters and
+words separated by underscores.
+
+If the operation corresponds to a directive, clause or other kind of definition
+in the OpenMP specification, it must use the same name split into words in the
+same way. For example, the `target data` directive would become `TargetDataOp` /
+`omp.target_data`, whereas `taskloop` would become `TaskloopOp` /
+`omp.taskloop`.
+
+Operations intended to carry extra information for another particular operation
+or clause must be named after that other operation or clause, followed by the
+name of the additional information. The assembly name must use a period to
+separate both parts. For example, the operation used to define some extra
+mapping information is named `MapInfoOp` / `omp.map.info`. The same rules are
+followed if multiple operations are created for different variants of the same
+directive, e.g. `atomic` becomes `Atomic{Read,Write,Update,Capture}Op` /
+`omp.atomic.{read,write,update,capture}`.

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@mjklemm mjklemm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from users/skatrak/mlir-omp-docs-01-reorg to main September 16, 2024 10:22
@skatrak skatrak force-pushed the users/skatrak/mlir-omp-docs-02-naming branch from 9affb19 to 83b1f04 Compare September 16, 2024 10:25
@skatrak skatrak merged commit 8b82fc6 into main Sep 16, 2024
5 of 8 checks passed
@skatrak skatrak deleted the users/skatrak/mlir-omp-docs-02-naming branch September 16, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants