This is an archive of the discontinued LLVM Phabricator instance.

[WIP] PoC Lowering of dialect attribute on builtin.module via DialectConversion
AbandonedPublic

Authored by skatrak on May 10 2023, 8:42 AM.

Details

Summary

This is just a proof-of-concept showing one way to do codegen for OpenMP
dialect discardable attributes attached to builtin.module in MLIR without
relying on LLVMTranslationDialectInterface::amendOperation(). Downstream
users of the OpenMP dialect interested on doing their own lowering within MLIR
could implement something similar to this, although there could be other better
ways to achieve the same. This is related to a discussion in patch D147219, and
not intended to be merged.

It can be tested in this way:

$ flang-new -fc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -fopenmp \
            -mrelocation-model static -target-cpu x86-64 -mmlir \
            -mlir-print-ir-after-all -o requires-host.bc -x f95-cpp-input \
            llvm-project/flang/test/Lower/OpenMP/requires.f90 &> host.mlir
$ flang-new -fc1 -triple amdgcn-amd-amdhsa -emit-llvm-bc -fopenmp \
            -mrelocation-model pic -pic-level 2 -target-cpu gfx1030 \
            -fopenmp-host-ir-file-path requires-host.bc -fopenmp-is-device \
            -mmlir -mlir-print-ir-after-all -o requires-device.bc -x \
            f95-cpp-input llvm-project/flang/test/Lower/OpenMP/requires.f90 \
            &> device.mlir
$ llvm-dis requires-host.bc
$ llvm-dis requires-device.bc

Depends on D147218

Diff Detail