This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Generator converting LLVM intrinsics defs to MLIR ODS
ClosedPublic

Authored by ftynse on Jan 17 2020, 7:48 AM.

Details

Summary

Introduce a new generator for MLIR tablegen driver that consumes LLVM IR
intrinsic definitions and produces MLIR ODS definitions. This is useful to
bulk-generate MLIR operations equivalent to existing LLVM IR intrinsics, such
as additional arithmetic instructions or NVVM.

A test exercising the generation is also added. It reads the main LLVM
intrinsics file and produces ODS to make sure the TableGen model remains in
sync with what is used in LLVM.

Diff Detail

Event Timeline

ftynse created this revision.Jan 17 2020, 7:48 AM

Unit tests: pass. 61956 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Cool stuff! I don't see this generator is actually used though; is that in a following up CL?

mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
57

We don't need the {} at the end given nothing inside.

mlir/test/mlir-tblgen/intrinsics.td
1 ↗(On Diff #238779)

Rename this file to llvm-intrinsics.td to be clear?

mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
154

Can use interleaveComma for llvm::join(..., ", ").

antiagainst accepted this revision.Jan 17 2020, 9:15 AM

Just minor comments in the above. So LGTM.

This revision is now accepted and ready to land.Jan 17 2020, 9:15 AM
ftynse marked 3 inline comments as done.Jan 17 2020, 9:19 AM

I would like to make it a bit more useful (e.g. let the caller insert custom builders/printers/parsers) before plugging it into the flow directly. So it will come in several follow-ups. I'll make the requested changes directly in the commit.

ftynse updated this revision to Diff 238804.Jan 17 2020, 9:20 AM

address review

This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.Jan 17 2020, 9:26 AM
mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
20

Are all of these headers necessary?

128

Note you are going to have to provide the expected types here if any of them are overloaded.

Looks great. Thanks Alex!

mlir/test/mlir-tblgen/intrinsics.td
22 ↗(On Diff #238779)

Great to have this test. Thanks for adding...

mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp
81

assert(llvm::all_of(record.getValueAsListOfDefs(fieldResults) ...

Unit tests: pass. 61970 tests passed, 0 failed and 783 were skipped.

clang-tidy: unknown.

clang-format: pass.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml