#llvm #safe #wrapper

llvm_quick

Rust's wrapper for llvm

7 releases

181.0.0-alpha.7 Jul 7, 2024
181.0.0-alpha.5 Jul 6, 2024
181.0.0-alpha.4 Jul 5, 2024
181.0.0-alpha.2 Jul 4, 2024

#121 in FFI

Apache-2.0

330KB
10K SLoC

llvm_quick

中文

Rust wrapper around LLVM, based on llvm-sys

Example

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);

Characteristics

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.

Feedback and Suggestions

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.

Dependencies

~285–670KB
~14K SLoC