[Flang][OpenMP][OMPIRBuilder] Add lowering of TargetOp for device codegen
authorSergio Afonso <safonsof@amd.com>
Mon, 10 Apr 2023 13:24:25 +0000 (14:24 +0100)
committerSergio Afonso <safonsof@amd.com>
Thu, 18 May 2023 14:14:03 +0000 (15:14 +0100)
commit06b3f6086c7b46c4caccb868b0f7d09702848222
treee1ca7cafb368f6eb0e64f85a39e09dc3d523d198
parent8e82376863460f6dc2dbb7fe6754af3ba69cc9c4
[Flang][OpenMP][OMPIRBuilder] Add lowering of TargetOp for device codegen

This patch adds support in the `OpenMPIRBuilder` for generating working
device code for OpenMP target regions. It generates and handles the
result of a call to `__kmpc_target_init()` at the beginning of the
function resulting from outlining each target region, and it also
generates the matching `__kmpc_target_deinit()` call before returning.

It relies on the implementation of target region outlining for host
codegen to handle the production of the new function and the lowering of
its body based on the contents of the associated target region.

Depends on D147172

Differential Revision: https://reviews.llvm.org/D147940
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/omptarget-region-device-llvm.mlir [new file with mode: 0644]