[mlir][llvm] Fastmath flags import from LLVM IR.
authorTobias Gysi <tobias.gysi@nextsilicon.com>
Fri, 16 Dec 2022 07:05:34 +0000 (08:05 +0100)
committerTobias Gysi <tobias.gysi@nextsilicon.com>
Fri, 16 Dec 2022 07:07:10 +0000 (08:07 +0100)
commitb6ebeccf00c00484aedf5119bb2fc1a58f58e633
treeb30709645b33968839e658357d580933463bfeec
parent66bf54abb54e6eafb08fcece87cf5d9d32fedcd3
[mlir][llvm] Fastmath flags import from LLVM IR.

This revision adds support to import fastmath flags from LLVMIR. It
implement the import using a listener attached to the builder. The
listener gets notified if an operation is created and then checks if
there are fastmath flags to import from LLVM IR to the MLIR. The
listener based approach allows us to perform the import without changing
the mlirBuilders used to create the imported operations.

An alternative solution, could be to update the builders so that they
return the created operation using FailureOr<Operation*> instead of
LogicalResult. However, this solution implies an LLVM IR instruction
always maps to exatly one MLIR operation. While mostly true, there are
already exceptions to this such as the PHI instruciton. Additionally, an
mlirBuilder based solution also further complicates the builder
implementations, which led to the listener based solution.

Depends on D139405

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D139620
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
mlir/test/Target/LLVMIR/Import/fastmath.ll [new file with mode: 0644]