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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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. |
Used _volatile and nontemporal UnitAttr instead of optional bool attribute.
Builder code is moved to .cpp file, and prining is also prettier now.
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. |
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.