Skip to content

Commit 019b875

Browse files
committed
Clearer docs
1 parent 342d3e0 commit 019b875

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

examples/demo_3f.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extern crate llvm_sys;
2+
extern crate llvm;
3+
use llvm::*;
4+
use llvm::Attribute::*;
5+
fn main() {
6+
let ctx = Context::new();
7+
let module = Module::new("simple", &ctx);
8+
type N = f64;
9+
type T = extern "C" fn(N) -> N;
10+
let func = module.add_function(
11+
"thr", Type::get::<T>(&ctx));
12+
func.add_attributes(&[NoUnwind, ReadNone]);
13+
let entry = func.append("entry");
14+
let builder = Builder::new(&ctx);
15+
fn n(x: N) -> N { x }
16+
let three_r = n(3 as N).compile(&ctx);
17+
builder.position_at_end(entry);
18+
builder.build_ret(three_r);
19+
module.verify().unwrap();
20+
21+
let ee = llvm::JitEngine::new(
22+
&module, llvm::JitOptions {opt_level: 0}).unwrap();
23+
println!("{:?}", module);
24+
ee.with_function(func, |thr: T| {
25+
for i in 0..3 {
26+
println!("thr {} = {}", i, thr(0 as N))
27+
}
28+
});
29+
}

src/value.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,6 @@ impl Function {
238238
pub fn get_entry(&self) -> Option<&BasicBlock> {
239239
unsafe { mem::transmute(core::LLVMGetEntryBasicBlock(self.into())) }
240240
}
241-
/// Returns the name of this function.
242-
pub fn get_name(&self) -> &str {
243-
unsafe {
244-
let c_name = core::LLVMGetValueName(self.into());
245-
util::to_str(c_name as *mut i8)
246-
}
247-
}
248241
/// Returns the function signature representing this function's signature.
249242
pub fn get_signature(&self) -> &FunctionType {
250243
unsafe {
@@ -338,7 +331,7 @@ pub enum Attribute {
338331
NoRedZone = 0b1000000000000000000,
339332
/// Disable implicit float instructions.
340333
NoImplicitFloat = 0b10000000000000000000,
341-
/// Naked function.
334+
/// Only allows native assembly code in the function.
342335
Naked = 0b100000000000000000000,
343336
/// The source language has marked this function as inline.
344337
InlineHint = 0b1000000000000000000000,

0 commit comments

Comments
 (0)