Crates.io | llvm_quick |
lib.rs | llvm_quick |
version | 181.0.0-alpha.7 |
source | src |
created_at | 2024-07-04 14:36:19.368004 |
updated_at | 2024-07-07 00:26:51.817419 |
description | Rust's wrapper for llvm. |
homepage | |
repository | https://github.com/823984418/llvm_quick |
max_upload_size | |
id | 1291736 |
size | 348,553 |
Rust wrapper around LLVM, based on llvm-sys。
let context = Context::create();
let module = context.create_module(c"sum");
let builder = context.create_builder();
let i64_type = context.i64_type();
let function_type = i64_type.fun((i64_type, i64_type, i64_type));
let function = module.add_function(c"sum", function_type);
let bb = context.append_basic_block(function, c"entry");
builder.position_at_end(bb);
let (x, y, z) = function.get_params();
let sum = builder.add(x, y, c"sum.1");
let sum = builder.add(sum, z, c"sum.2");
builder.return_value(sum);
The wrapper aims to be as thin and fast as possible, mostly just wrapping the C-style API as associated methods.
Where APIs cannot safely be made safe, read-only access is made safe whenever possible, and write functions are marked as unsafe in those cases.
If you find any potential unsafe in the API or have suggestions for abstraction, please open an issue.
Note: This library is merely a wrapper around llvm-sys and does not concern itself with linking LLVM. If you have difficulties linking llvm, please head over to gitlab llvm-sys for assistance. Note: This library is merely a wrapper around llvm-sys and does not concern itself with linking LLVM. If you have difficulties linking, please head over to gitlab llvm-sys for assistance.