[mlir][OpenMP] Add support for using Opaque Pointers in the OpenMP Dialect
authorMarkus Böck <markus.boeck02@gmail.com>
Wed, 8 Feb 2023 14:37:17 +0000 (15:37 +0100)
committerMarkus Böck <markus.boeck02@gmail.com>
Fri, 10 Feb 2023 16:56:37 +0000 (17:56 +0100)
commit81767f52f49339be2c78fc9bf831856b9f57e2f0
tree6087a907fda6489ec8bc6ecd9dbec1517befa526
parent2ca46421f85a1f4acf0d0b56ee31d76ff99ae3a1
[mlir][OpenMP] Add support for using Opaque Pointers in the OpenMP Dialect

The current OpenMP implementation assumes the use of typed pointers (or rather typed pointer like types). Given the support for typed pointers in LLVM is now pending removal, the OpenMP Dialect should be able to support opaque pointers as well, given that any users of it must lower OpenMP through the LLVM Dialect.

This patch fixes the above and adds support for using LLVM opaque pointers with the OpenMP dialect. This is implemented by making all related code not make use of the element type of pointer arguments. The few (one) op requiring a pointer element type now use an explicit `TypeAttr` for representing the element type.
More concretely, the list of changes are:
* `omp.atomic.read` now has an extra `TypeAttr` (also in syntax) which is the element type of the values read and stored from the operands
* `omp.reduction` now has an type argument in the syntax for both the accmulator and operand since the operand type can no longer be inferred from the accumulator
* `OpenMPToLLVMIRTranslation.cpp` was rewritten to never query element types of pointers
* Adjusted the verifier to be able to handle pointers without element types

Differential Revision: https://reviews.llvm.org/D143582
16 files changed:
flang/lib/Lower/OpenMP.cpp
flang/test/Lower/OpenMP/atomic-read.f90
flang/test/Lower/OpenMP/wsloop-reduction-add.f90
flang/test/Lower/OpenMP/wsloop-reduction-logical-and.f90
flang/test/Lower/OpenMP/wsloop-reduction-mul.f90
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/include/mlir/Dialect/OpenMP/OpenMPTypeInterfaces.td
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
mlir/test/Dialect/OpenMP/invalid.mlir
mlir/test/Dialect/OpenMP/ops.mlir
mlir/test/Target/LLVMIR/openmp-llvm-invalid.mlir
mlir/test/Target/LLVMIR/openmp-llvm.mlir
mlir/test/Target/LLVMIR/openmp-reduction-typed-pointers.mlir [new file with mode: 0644]
mlir/test/Target/LLVMIR/openmp-reduction.mlir