René's URL Explorer Experiment


Title: MLIR — Writing Our First Pass || Math ∩ Programming

Open Graph Title: MLIR — Writing Our First Pass

Open Graph Description: Table of Contents This series is an introduction to MLIR and an onboarding tutorial for the HEIR project. Last time we saw how to run and test a basic lowering. This time we will write some simple passes to illustrate the various parts of the MLIR API and the pass infrastructure. As mentioned previously, the main work in MLIR is defining passes that either optimize part of a program, lower from parts of one dialect to others, or perform various normalization and canonicalization operations.

Keywords:

Mail addresses
mathintersectprogramming@gmail.com
mathintersectprogramming@gmail.com

Opengraph URL: https://www.jeremykun.com/2023/08/10/mlir-writing-our-first-pass/

direct link

Domain: jeremykun.com

NoneAugust 10, 2023
HandheldFriendlyTrue
MobileOptimized320
msapplication-TileColor#da532c
theme-color#ffffff
og:typearticle
article:sectionposts
article:published_time2023-08-10T14:39:42+00:00
article:modified_time2023-08-10T14:39:42+00:00
og:site_nameMath ∩ Programming

Links:

Math ∩ Programminghttps://jeremykun.com/
Postshttps://jeremykun.com/posts/
Main Contenthttps://jeremykun.com/main-content/
Primershttps://jeremykun.com/primers/
All articleshttps://jeremykun.com/posts/
Abouthttps://jeremykun.com/about/
rsshttps://jeremykun.com/rss/
#compilershttps://www.jeremykun.com/tags/compilers/
#llvmhttps://www.jeremykun.com/tags/llvm/
#mathematicshttps://www.jeremykun.com/tags/mathematics/
#programminghttps://www.jeremykun.com/tags/programming/
here,https://jeremykun.wordpress.com/2023/08/10/mlir-writing-our-first-pass/
Table of Contentshttps://github.com/j2kun/mlir-tutorial#mlir-tutorial
HEIR projecthttps://github.com/google/heir
Last timehttps://jeremykun.com/2023/08/10/mlir-running-and-testing-a-lowering/
this pull requesthttps://github.com/j2kun/mlir-tutorial/pull/4
affine dialecthttps://mlir.llvm.org/docs/Dialects/Affine/
polyhedral loop analysishttps://en.wikipedia.org/wiki/Polytope_model
for operationhttps://mlir.llvm.org/docs/Dialects/Affine/#affinefor-affineaffineforop
SSA formhttps://en.wikipedia.org/wiki/Static_single-assignment_form
this MLIR dochttps://mlir.llvm.org/docs/LangRef/#high-level-structure
utility methodhttps://github.com/llvm/llvm-project/blob/dea01f5e00e45dec4319475a001024c6ee882283/mlir/include/mlir/Dialect/Affine/LoopUtils.h#L46
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/79fa49ecc0790aecc037d48b628675613eeadcc4
OperationPass base classhttps://github.com/llvm/llvm-project/blob/9ab34689b08ee66f0868d38456fccc8b80d1b656/mlir/include/mlir/Pass/Pass.h#L390
PassWrapperhttps://github.com/llvm/llvm-project/blob/9ab34689b08ee66f0868d38456fccc8b80d1b656/mlir/include/mlir/Pass/Pass.h#L441
Curiously Recurring Template Pattern (CRTP)https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
what is required of an OperationPasshttps://mlir.llvm.org/docs/PassManagement/#operation-pass-static-filtering-by-op-type
the commit for this sectionhttps://github.com/j2kun/mlir-tutorial/pull/4/commits/79fa49ecc0790aecc037d48b628675613eeadcc4
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/b7b87b4e9ccdc7b192cb5c876daf232c0c95d346
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/8a699456fb3cafb02418d7c874470474083cffb0
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/26b712539bd5d8dc595652cb25fcd640ea661678
walk methodhttps://github.com/llvm/llvm-project/blob/7cc0be01a0068946ea3613dc2cb45c81b0f45860/mlir/include/mlir/IR/Operation.h#L738
post-orderhttps://en.wikipedia.org/wiki/Tree_traversal#Post-order,_LRN
subsequent commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/bc24d45d88c5b3356252ed6bbc82571a0a4f99db
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/cdf57f38198541f991070e386e26d4b706d4d72b
OpRewritePatternhttps://github.com/llvm/llvm-project/blob/9654bc3960c460bd9d8b06cfa4cfe0e52c6582bd/mlir/include/mlir/IR/PatternMatch.h#L356
LogicalResulthttps://github.com/llvm/llvm-project/blob/d5241e48743ca2235bd3328d5e1584f70df8e601/mlir/include/mlir/Support/LogicalResult.h#L26
FailureOrhttps://github.com/llvm/llvm-project/blob/d5241e48743ca2235bd3328d5e1584f70df8e601/mlir/include/mlir/Support/LogicalResult.h#L78
optionalhttps://en.cppreference.com/w/cpp/utility/optional
PatternRewriterhttps://mlir.llvm.org/docs/PatternRewriter/#pattern-rewriter
certain orderhttps://mlir.llvm.org/docs/PatternRewriter/#greedy-pattern-rewrite-driver
This commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/fe5852665df4feb93cabaabab767278c83b27990
This commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/9af82b78622cf44cf2eb10ec8e9046658615680a
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/34f98a9476d34d0c29e6de85c3761687d332a2ac
classic bit-twiddling trickhttps://stackoverflow.com/a/1053594/438830
attributehttps://mlir.llvm.org/docs/LangRef/#attributes
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/49f4d4df9adf3d61257ae4f5a01b464d38d2938d
arith dialecthttps://mlir.llvm.org/docs/Dialects/ArithOps/
ArithOps.td tablegen filehttps://github.com/llvm/llvm-project/blob/4e85e1ffcaf161736e27a24c291c1177be865976/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td#L4
motivation behind the pattern rewrite enginehttps://mlir.llvm.org/docs/Rationale/RationaleGenericDAGRewriter/
common subexpression eliminationhttps://en.wikipedia.org/wiki/Common_subexpression_elimination
clangd LSPhttps://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#clangd
Hedron Vision’s compile_commands extractorhttps://github.com/hedronvision/bazel-compile-commands-extractor
this commithttps://github.com/j2kun/mlir-tutorial/pull/4/commits/cc5ae88d6d08c6d5581b2dc4d47423ad342203ab
the generated json filehttps://clang.llvm.org/docs/JSONCompilationDatabase.html
this commit.https://github.com/j2kun/mlir-tutorial/pull/4/commits/b17efb4fdc98f9f48a680ef771ccb9e165d255f5
post a webmentionhttps://webmention.io/www.jeremykun.com/webmention
elsewhere on the internethttps://jeremykun.com/about/
https://doi.org/10.59350/46txm-t5b81https://doi.org/10.59350/46txm-t5b81
← Previous: MLIR — Running and Testing a Lowering https://www.jeremykun.com/2023/08/10/mlir-running-and-testing-a-lowering/
Next: MLIR — Using Tablegen for Passes →https://www.jeremykun.com/2023/08/10/mlir-using-tablegen-for-passes/

Viewport: width=device-width,initial-scale=1


URLs of crawlers that visited me.