This is an archive of the discontinued LLVM Phabricator instance.

Make LLVM Linkage a first class attribute instead of using an integer attribute
ClosedPublic

Authored by mehdi_amini on Sep 2 2021, 8:08 PM.

Details

Summary

This makes the IR more readable, in particular when this will be used on
the builtin func outside of the LLVM dialect.

Diff Detail

Event Timeline

mehdi_amini created this revision.Sep 2 2021, 8:08 PM
mehdi_amini requested review of this revision.Sep 2 2021, 8:08 PM

Move using linkage::getMaxEnumValForLinkage; to the implementation file

wsmoses accepted this revision.Sep 3 2021, 12:39 PM

Yeah this is a lot nicer (as clearly evidenced by the llvm.mlir globals as well). For my own edification, is there documentation about the tablegen storageType/convertFromStorage parameters?

This revision is now accepted and ready to land.Sep 3 2021, 12:39 PM
rriddle added inline comments.Sep 3 2021, 12:41 PM
mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
34

Can you drop this.

Yeah this is a lot nicer (as clearly evidenced by the llvm.mlir globals as well). For my own edification, is there documentation about the tablegen storageType/convertFromStorage parameters?

Unfortunately not, the best may be: https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/OpBase.td#L823-L836
But it also impact the code generated for the builder of the operation using these attributes. For example the fact that storageType and returnType don't match here:

let storageType = "::mlir::LLVM::LinkageAttr";
let returnType = "::mlir::LLVM::Linkage";

means that when an operation declares a Linkage attribute in its argument list, an extra builder will be generated that takes directly an mlir::LLVM::Linkage enum value (but only because we also define let constBuilderCall = "::mlir::LLVM::LinkageAttr::get($_builder.getContext(), $0)"; which indicates how to build the attribute from the enum value...).

Remove the empty extraClassDeclaration

This revision was landed with ongoing or failed builds.Sep 3 2021, 2:26 PM
This revision was automatically updated to reflect the committed changes.