This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Generalize intrinsic builders in the LLVM dialect definition
ClosedPublic

Authored by ftynse on Feb 20 2020, 1:30 AM.

Details

Summary

All LLVM IR intrinsics are constructed in a similar way. The ODS definition of
the LLVM dialect in MLIR also lists multiple intrinsics, many of which
reproduce the same (or similar enough) code stanza to translate the MLIR
operation into the LLVM IR intrinsic. Provide a single base class containing
parameterizable code to build LLVM IR intrinsics given their name and the lists
of overloadable operands and results. Use this class to remove (almost)
duplicate translations for intrinsics defined in LLVMOps.td.

Diff Detail

Event Timeline

ftynse created this revision.Feb 20 2020, 1:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2020, 1:30 AM

I like where this is going a lot. Some suggestions on the doc though

mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
78

If this is deprecated, add a TODO on the plan on the path forward (e.g. remove when ....)

125

typo: operation

140

in *the* LLVM sense

167

since this (and L157) is the class doc most people will read (and not the doc of the implementation oriented base class), some more doc on sample use would be useful.

E.g.
sample use:

LLVM_OneResultIntrOp<"name",  [0], [1], []>,   Arguments<(ins LLVM_Type, LLVM_Type)>;

means
....

ftynse updated this revision to Diff 245829.Feb 21 2020, 5:46 AM
ftynse marked 5 inline comments as done.

Address review

mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
78

After all, I'll update this and all users in the next commit.

aartbik accepted this revision.Feb 24 2020, 9:41 AM
This revision is now accepted and ready to land.Feb 24 2020, 9:41 AM
This revision was automatically updated to reflect the committed changes.
shraiysh added a subscriber: shraiysh.EditedMar 10 2020, 12:32 AM

Hi, I was trying to implement some llvm intrinsics and wanted to understand the purpose of overloaded operands. The LLVM reference manual does not say that prefetch is overloaded.

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

Can you please clarify why [0] is added to prefetch?