akmaru / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
0 stars 0 forks source link

Deep dive into standalone-opt #2

Open akmaru opened 1 year ago

akmaru commented 1 year ago

https://github.com/akmaru/llvm-project/tree/llvmorg-16.0.6/mlir/examples/standalone

akmaru commented 1 year ago

Build

READMEに従えば良い。

BUILD_DIRは相対パス指定だとエラーになったので、絶対パス指定だと通過した。

cd llvm-project/mlir/examples/standalone
mkdir build && cd build
cmake -G Ninja .. -DMLIR_DIR=$BUILD_DIR/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=$BUILD_DIR/bin/llvm-lit
cmake --build . --target check-standalone
cmake --build . --target mlir-doc
akmaru commented 1 year ago

standalone-opt.cppを見てみる。

mlir::DialectRegistry で使用するDialectを登録出来るようだ。なるほど。

registerAllDialects(registry) を呼び出すと、全てのMLIR Core Dialectを登録出来るらしい。

  // Add the following to include *all* MLIR Core dialects, or selectively
  // include what you need like above. You only need to register dialects that
  // will be *parsed* by the tool, not the one generated
  // registerAllDialects(registry);