![lltz-logo](https://private-user-images.githubusercontent.com/63214188/252951879-a108fc50-5758-49a4-bbed-af31d7a62c80.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Mjg3OTEsIm5iZiI6MTczOTgyODQ5MSwicGF0aCI6Ii82MzIxNDE4OC8yNTI5NTE4NzktYTEwOGZjNTAtNTc1OC00OWE0LWJiZWQtYWYzMWQ3YTYyYzgwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDIxNDEzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2YjQ0NjhhZWVlOGM1MzRlMGE3YmNlZjRlODYyNGM5MWRiZWVlNzczM2ZjZWZiMzZmZGI5MjRlMjE5NDEwZWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.9DWrtVlme-mZocEMm1XcO8b3aavgxeIbh_mKsSNP5zs)
LLTZ is a compiler from MLIR to Michelson, VM of blockchain Tezos.
- Reusable and readable intermediate representation Michelson Dialect
- Compilation method with easy analysis and practical gas consumption
- World's first compiler from MLIR to a blockchain VM
- The following are compilers that utilize LLTZ:
![lltz_overview](https://private-user-images.githubusercontent.com/63214188/252952461-29ae6dce-7ded-4a4f-8e39-3a93f4023bd6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4Mjg3OTEsIm5iZiI6MTczOTgyODQ5MSwicGF0aCI6Ii82MzIxNDE4OC8yNTI5NTI0NjEtMjlhZTZkY2UtN2RlZC00YTRmLThlMzktM2E5M2Y0MDIzYmQ2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE3VDIxNDEzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4YzVkNzExYWFjYTYwZTgwMDFjMjExYjg3Y2YzZWNhNmJiNzI5NTEwMDA4ZTQ2YTcwNzRhMmRmYzZhY2NhYzkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._DR6MkiEY-Em2cJnhZSdu0bDynfFiEVJM8Vu-gYVMjA)
A Domain-Specific Language (DSL) is generally necessary to write smart contracts. These DSLs have contributed to the advancement of blockchain technology. However, these impose a high learning cost on developers, becoming a barrier to entry into blockchain ecosystems such as Tezos.
To address this issue and enable smart contract development using general-purpose programming languages, I've developed LLTZ as a first step. This compiler compiles MLIR, an intermediate representation defined by the LLVM compiler infrastructure, into Michelson. Unlike LLVM IR, JVM and WebAssembly, MLIR provides a higher level of abstraction with control structures and types and allows the definition of custom intermediate representations for specific domains through a feature called Dialect.
If smart contracts can be written in a general-purpose programming language, a single program can run both off-chain and on-chain.
- Working C and C++ toolchains(compiler, linker)
cmake
make
orninja
tezos-client
: Only required for running tests.
This software has been tested and verified to work correctly on the following operating systems:
Ubuntu 22.04.2 LTS
git clone --recursive https://github.com/woxjro/lltz
cd lltz
Build LLVM and MLIR:
$ cd llvm-project
$ mkdir build && cd build
$ cmake -G Ninja ../llvm \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=YES \
-DLLVM_CCACHE_BUILD=ON \
-DLLVM_CCACHE_DIR=$CCACHE_DIR \
-DCMAKE_C_COMPILER=clang-15 \
-DCMAKE_CXX_COMPILER=clang++-15
$ cmake --build . --parallel 7 --target check-mlir
Build michelson-mlir-opt
and michelson-mlir-lsp-server
:
$ pwd
<path/to/lltz>
$ cd mlir && mkdir build && cd build
$ cmake -G Ninja .. \
-DMLIR_DIR=$PWD/../../llvm-project/build/lib/cmake/mlir \
-DCMAKE_EXPORT_COMPILE_COMMANDS=YES
$ cmake --build .
There are sample and test code under the examples
directory.
You can compile them by the following command.
$ cargo run --bin cli -- --input ./examples/mlir/boomerang.mlir
To show details, run the following command.
$ cargo run --bin cli -- --help
This project is currently in the Proof of Concept (PoC) stage. Contributions are kindly requested to be postponed until further notice.