This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Tablegen based operation import from LLVM IR.
ClosedPublic

Authored by gysit on Oct 11 2022, 1:28 PM.

Details

Summary

The revision uses tablegen generated builders to convert the most common
LLVM IR instructions to MLIR LLVM dialect operations. All instructions
with special handlers, except for alloca and fence, still use manual
handlers. The revision also introduces an additional "instructions.ll"
test file to test the import of instructions that have tablegen builders
(except for the resume instruction whose test remains untouched). A part
of the test cases are new, for example the integer instruction test,
while others are migrated from the "basic.ll" test file.

Diff Detail

Event Timeline

gysit created this revision.Oct 11 2022, 1:28 PM
Herald added a project: Restricted Project. · View Herald Transcript
gysit requested review of this revision.Oct 11 2022, 1:28 PM
ftynse accepted this revision.Oct 12 2022, 1:57 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
1786–1800

I'd prefer to minimize the amount of C++ embedded into Tablegen. A couple of lines is okay, especially if they use substitution. A dozen -- less so. It becomes difficult to navigate and update over time, and doesn't benefit from any code tooling. One possibility is to factor out the C++ code that doesn't need $-substitutions into a function and just call it here.

mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
188–195

If the function is not stored anywhere, prefer function_ref to avoid dynamic allocations.

This revision is now accepted and ready to land.Oct 12 2022, 1:57 AM
gysit updated this revision to Diff 467076.Oct 12 2022, 3:01 AM

Address comments.

gysit marked 2 inline comments as done.Oct 12 2022, 3:05 AM
gysit added inline comments.
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
1786–1800

Makes sense. I factored out a method and also added an llvm_unreachable to fail if the sync scope id is invalid.

This revision was automatically updated to reflect the committed changes.
gysit marked an inline comment as done.