buddy-compiler / buddy-mlir

An MLIR-based compiler framework bridges DSLs (domain-specific languages) to DSAs (domain-specific architectures).
https://buddy-compiler.github.io/
Apache License 2.0
514 stars 167 forks source link

[frontend] Add frontend generator. #352

Open CBalaa opened 3 months ago

CBalaa commented 3 months ago

How to build

FrontendGen is designed for generate mlir project quickly by writing fegen files.

  1. Build LLVM/MLIR with RTTI and EH enabled.

    $ cd buddy-mlir
    $ mkdir llvm/build
    $ cd llvm/build
    $ cmake -G Ninja ../llvm \
    -DLLVM_ENABLE_PROJECTS="mlir" \
    -DLLVM_TARGETS_TO_BUILD="host;RISCV" \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DCMAKE_BUILD_TYPE=RELEASE \
    -DLLVM_ENABLE_RTTI=ON \
    -DLLVM_ENABLE_EH=ON
    $ ninja check-mlir
  2. Build FrontendGen. The FeGen option should be enabled.

$ cmake -G Ninja .. \
    -DMLIR_DIR=$PWD/../llvm/build/lib/cmake/mlir \
    -DLLVM_DIR=$PWD/../llvm/build/lib/cmake/llvm \
    -DLLVM_ENABLE_ASSERTIONS=ON \
    -DFeGen=ON \
    -DCMAKE_BUILD_TYPE=RELEASE
$ ninja buddy-frontendgen