This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][LLVMDialect] Added volatile and nontemporal attributes to load and store
ClosedPublic

Authored by georgemitenkov on Jul 23 2020, 5:12 AM.

Details

Summary

This patch introduces 2 new optional attributes to llvm.load
and llvm.store ops: isVolatile and isNonTemporal. These attributes
are translated into proper LLVM as a volatile marker and a metadata node
respectively. They are also helpful with SPIR-V to LLVM dialect conversion
since they are the mappings for Volatile and NonTemporal Memory Operands.

Diff Detail

Event Timeline

georgemitenkov created this revision.Jul 23 2020, 5:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 5:12 AM

There is also a bit of duplication when setting the attributes. I kept it like this for now, as I am not sure what is the best practise for handling duplication in builders in tablegen?

There is also a bit of duplication when setting the attributes. I kept it like this for now, as I am not sure what is the best practise for handling duplication in builders in tablegen?

Builders are just C++ code. You can call helper functions, including other builders. There are many places where we call the auto-generated builder from the custom builder after casting the types and adding the missing default arguments.

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
285

I'd use UnitAttr instead. Optional<Bool> gives you a tri-state attribute, but volatile is actually and non-temporal are actually bi-state. The presence of the attribute is meaningful by itself, so is its absence.

286

Nit: the convention seems to lean towards using property-like names (e.g. volatile) as opposed to function-like names (e.g. isVolatile) for attributes. I understand this generates less meaningful function names, but let's be consistent.

302

This looks long enough to go to the .cpp file instead.

ftynse requested changes to this revision.Jul 23 2020, 5:33 AM
This revision now requires changes to proceed.Jul 23 2020, 5:33 AM
georgemitenkov marked 3 inline comments as done.

Used _volatile and nontemporal UnitAttr instead of optional bool attribute.
Builder code is moved to .cpp file, and prining is also prettier now.

ftynse accepted this revision.Jul 24 2020, 5:01 AM
ftynse added inline comments.
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
34 ↗(On Diff #280407)

Let's use a trailing underscore, names with leading underscores are often reserved, and also mess up with alphabetically-ordered lists.

203 ↗(On Diff #280407)

Since we have a custom printer anyway, we should drop the underscore from the pretty syntax.

This revision is now accepted and ready to land.Jul 24 2020, 5:01 AM
georgemitenkov marked 2 inline comments as done.

Addressed comments: put underscore in the end and removed it when printing.

This revision was automatically updated to reflect the committed changes.