This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVMIR] Add support for translating from some simple LLVM instructions
ClosedPublic

Authored by myhsu on May 17 2022, 10:43 AM.

Details

Summary

Add support for translating from llvm::Select, llvm::FNeg, and llvm::Unreachable. This patch also cleans up (NFC) the opcode map for simple instructions and adds // clang-format off/on comments to prevent those lines from being churned by clang-format between commits.

Diff Detail

Event Timeline

myhsu created this revision.May 17 2022, 10:43 AM
myhsu requested review of this revision.May 17 2022, 10:43 AM
Mogball added inline comments.May 17 2022, 6:05 PM
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
591

Not part of this patch?

Nit: could you please update the commit message to specify the translation _from LLVM IR_. Otherwise, it may trick a casual reader into thinking that we haven't supported translating simple instructions _to LLVM IR_ until this point.

mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
622

Nit: I'd consider wrapping this block into // clang-format off + // clang-format on and manually formatting it to have one instruction per line. This would reformatting-caused churn on every change and make it easy to find relevant instructions (which can be ordered alphabetically or follow their order in LLVM's LangRef).

ftynse accepted this revision.May 18 2022, 1:20 AM
This revision is now accepted and ready to land.May 18 2022, 1:20 AM
myhsu updated this revision to Diff 430738.May 19 2022, 10:40 AM
myhsu marked 2 inline comments as done.
myhsu retitled this revision from [mlir][LLVMIR] Add support for translating some simple instructions to [mlir][LLVMIR] Add support for translating from some simple LLVM instructions.
myhsu edited the summary of this revision. (Show Details)

Cleanup the opcode map for simple instructions and add // clang-format off/on comments on those lines (NFC).

Just a FYI: the simple opcode map is sorted by instruction ordering listed in LangRef.

mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
591

llvm::Invoke had already been implemented previously. I would like to do some NFC clean up on this block of code as part of the // clang-format off/on Alex suggested below.

622

yes, sounds like a good idea, personally I also prefer one instruction per line.