This is an archive of the discontinued LLVM Phabricator instance.

[mlir] LLVM dialect: Generate conversions between EnumAttrCase and LLVM API
ClosedPublic

Authored by ftynse on Jan 27 2020, 5:56 AM.

Details

Summary

MLIR materializes various enumeration-based LLVM IR operands as enumeration
attributes using ODS. This requires bidirectional conversion between different
but very similar enums, currently hardcoded. Extend the ODS modeling of
LLVM-specific enumeration attributes to include the name of the corresponding
enum in the LLVM C++ API as well as the names of specific enumerants. Use this
new information to automatically generate the conversion functions between enum
attributes and LLVM API enums in the two-way conversion between the LLVM
dialect and LLVM IR proper.

Use the generated conversion functions for Linkage attributes as an example.

Diff Detail

Event Timeline

ftynse created this revision.Jan 27 2020, 5:56 AM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

This should be deprecated in favor of https://reviews.llvm.org/D73362?

This is a follow-up to that.

flaub added a subscriber: flaub.Jan 30 2020, 8:22 AM

Great, once this lands I can go add the missing volatile attribute to the new atomic ops.

Unit tests: fail. 62346 tests passed, 1 failed and 839 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp

clang-tidy: pass.

clang-format: pass.

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

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

antiagainst accepted this revision.Jan 30 2020, 12:12 PM

This is a follow-up to that.

Oh, sorry, wasn't checking carefully. :)

mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
66–67

We've have quite a few *Sym here. What about adding some documentation for them (potentially with a good example)?

83–91

Same here.

mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp
292

"to LLVM IR" to be specific. LLVM can mean both the C++ API and the IR.

This revision is now accepted and ready to land.Jan 30 2020, 12:12 PM
ftynse updated this revision to Diff 241553.Jan 30 2020, 12:54 PM

Split "from" and "to" conversion generation and added more doc as requested.

Without the splitting, it would generate functions that eneded up being unused
by the respective conversions, leading to warnings.

This revision was automatically updated to reflect the committed changes.

Unit tests: fail. 62354 tests passed, 1 failed and 839 were skipped.

failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp

clang-tidy: pass.

clang-format: pass.

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

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.