https://github.com/jetafese/btor2mlir-2
An experiment in MLIR
https://github.com/jetafese/btor2mlir-2
clang llvm
Last synced: 12 months ago
JSON representation
An experiment in MLIR
- Host: GitHub
- URL: https://github.com/jetafese/btor2mlir-2
- Owner: jetafese
- Created: 2021-02-17T20:26:45.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-22T03:22:17.000Z (over 4 years ago)
- Last Synced: 2025-04-12T09:57:07.776Z (12 months ago)
- Topics: clang, llvm
- Language: C++
- Homepage:
- Size: 142 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Get LLVM project build
Get the project started using the following commands:
`git clone https://github.com/llvm/llvm-project.git`
`mkdir llvm-project/build`
`cd llvm-project/build && mkdir run`
`cmake -G Ninja ../llvm -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Debug -L -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" -DLLVM_ENABLE_LLD=ON -DCMAKE_BUILD_PREFIX=$(pwd)/run`
`cmake --build .`
# btor2mlir
Now, clone this repo into `llvm-project/mlir/examples/`. Erase the contents of `llvm-project/mlir/examples/CMakeLists.txt` and replace it with one line: `add_subdirectory(btor2mlir)`. This will let cmake compile the toy folder in our repo instead of the default toy folder.
As an interim way of building btor2mlir files within the MLIR repo, open `llvm-project/mlir/test/CMakeLists.txt` and find the following section:
```
if(LLVM_BUILD_EXAMPLES)
list(APPEND MLIR_TEST_DEPENDS
toyc-ch1
...
)
endif()
```
Append the executable name `btor2mlir` to the `list()`. The changed section should look like:
```
if(LLVM_BUILD_EXAMPLES)
list(APPEND MLIR_TEST_DEPENDS
toyc-ch1
...
btor2mlir-ch2
)
endif()
```
You can now build the `llvm-project` repo again and run the `btor2mlir` executable file in `llvm-project/build/bin`. Feel free to use the run script in this repository.
# Running the current state
To see the mlir that gets generated for our btor2 example, run the following command: `~/llvm-project/build/bin/btor2mlir-ch2 -emit=mlir`
On the other hand, to see the generated AST for our btor2 example, run this: `~/llvm-project/build/bin/btor2mlir-ch2 -emit=ast`
Keep in mind that we are currently using a debug build in the provided run script for development purposes