15 个版本
0.2.2 | 2020年11月16日 |
---|---|
0.2.1 | 2020年11月8日 |
0.1.11 | 2020年8月31日 |
0.1.0 | 2020年7月31日 |
#909 在 编程语言 中
每月 26 次下载
150KB
3.5K SLoC
为 Rust 提供的 LLVM IR 绑定
此 LLVM IR 绑定提供了用于分析现有 LLVM 模块的直观且组织良好的安全 Rust API。因此,整个库是线程安全的。此软件包不提供生成新 LLVM 模块或更改现有模块的功能。
如何使用
use llir;
// Create context
let context = llir::Context::create();
// Specify path to the byte code
let path = Path::new("path/to/your/llvm/bytecode.bc");
// Load the module with that path
let module = context.load_module(path)?;
// Iterate through functions, blocks, and instructions...
for func in module.iter_functions() {
for block in func.iter_blocks() {
for instr in block.iter_instructions() {
// Do things to instr...
}
}
}
文档
自动生成的文档托管在 docs.rs
作为库包含
请确保您已在机器上安装了 LLVM 10.0,并且可以通过路径访问。
然后进入您的 Cargo.toml
,并在依赖项下添加此行
# Cargo.toml
[dependencies]
llir = "0.1"
依赖项
~0.3–0.8MB
~16K SLoC