Crates.io | pliron-llvm |
lib.rs | pliron-llvm |
version | 0.3.2 |
source | src |
created_at | 2024-05-31 09:31:17.445728 |
updated_at | 2024-07-08 08:39:28.190323 |
description | LLVM dialect for pliron |
homepage | |
repository | https://github.com/vaivaswatha/pliron |
max_upload_size | |
id | 1257839 |
size | 147,201 |
This crate provides the following functionality:
inkwell
's LLVM representation.The latter uses llvm-sys, which requires LLVM to be installed on your system.
We currently support LLVM-17, and hence LLVM-17 needs to be on your computer.
On Ubuntu, this means, you require the libllvm17
and libpolly-17-dev
packages.
The llvm-opt
binary is provided to enable parsing LLVM bitcode binaries
into pliron
's LLVM dialect and to emit LLVM bitcode back from the dialect.
Example usage:
Compile fib.c into LLVM-IR:
$clang-17 -c -emit-llvm -o /tmp/fib.bc tests/resources/fib.c
Convert the LLVM bitcode to LLVM dialect in pliron
and back to
LLVM bitcode (the binary llvm-opt
, produced in your cargo's target
directory must be in $PATH):
$llvm-opt -S -i /tmp/fib.bc -o /tmp/fib.opt.ll
Compile the output fibonacci LLVM-IR, along with a main function into a binary:
$clang-17 -o /tmp/fib /tmp/fib.out.ll tests/resources/fib-main.c
Run the fibonacci binary to see the first few fibonacci numbers printed.
$/tmp/fib
fib(0): 0
fib(1): 0
fib(2): 1
fib(3): 1
fib(4): 2
Note: Implementation of the LLVM dialect is not complete, and the above is just a proof-of-concept.