This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Add atomic support to the LoadOp.
ClosedPublic

Authored by gysit on Feb 15 2023, 8:41 AM.

Details

Summary

This revision adds atomic support to the LoadOp. It chooses
to print the atomic keywords together with the syncscope and
ordering arguments, which simplifies parsing and printing compared
to the LLVM IR printer that puts the atomic keyword at the beginning.
It uses the ordering attribute to check if the load is atomic.

The revision also implements verifiers to ensure the constraints
that apply to atomic load operations are checked.

Diff Detail

Event Timeline

gysit created this revision.Feb 15 2023, 8:41 AM
Herald added a project: Restricted Project. · View Herald Transcript
gysit requested review of this revision.Feb 15 2023, 8:41 AM
zero9178 added inline comments.Feb 15 2023, 9:45 AM
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
825

nit: I think this error message is worded a bit confusingly with the 'or'.
I'd either do something like emitOpError("unsupported ordering ") << getOrderingAttr(); or reword it a bit. Maybe "'release' and 'acq_rel' ordering are not supported"

gysit updated this revision to Diff 497736.Feb 15 2023, 10:28 AM
gysit marked an inline comment as done.

Address review comment.

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
825

good point also improve the error message if the type is not supported.

A few nits

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
365–367
369–370
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
815

I don't like the sentinel value, I would prefer just returning false if !integerType

definelicht added inline comments.Feb 16 2023, 12:35 AM
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
816

Did you check if there's a helper function for this?

gysit updated this revision to Diff 497943.Feb 16 2023, 2:34 AM
gysit retitled this revision from [llvm][mlir] Add atomic support to the LoadOp. to [mlir][llvm] Add atomic support to the LoadOp..
gysit edited the summary of this revision. (Show Details)

Address review comments.

gysit marked 4 inline comments as done.Feb 16 2023, 2:36 AM
gysit added inline comments.
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
816

I could not find an existing method since this is very specific to atomics. I now use isCompatibleFloatingPointType followed by a check of the bit width and make now use in all places where this is used thanks to the isPointerTypeAllowed parameter (atomicrmw does not support pointers).

gysit updated this revision to Diff 497991.Feb 16 2023, 5:52 AM
gysit marked an inline comment as done.

Drop wrong hasCustomAssemblyFormat flag.

Dinistro accepted this revision.Feb 16 2023, 11:57 PM

Thanks for all the comment addressing. LGTM!

This revision is now accepted and ready to land.Feb 16 2023, 11:57 PM
This revision was automatically updated to reflect the committed changes.