Rust에서 LLVM Intrinsics 호출하기

요즘에는 내가 보려는 목적으로 기록을 하는 블로깅이 대부분인 듯 하다. Rust는 LLVM으로 구현되어 있고 LLVM 의 Intrinsics를 함수에 매핑해서 호출할 수 있는 기능이 공식적으로 제공된다. 예제는 아래와 같다.


#![feature(link_llvm_intrinsics)]
extern {
#[link_name = “llvm.sqrt.f32]
fn sqrt(x: f32) -> f32;
}
fn main(){
unsafe { sqrt(32.0f32); }
}

view raw

intrinsics.rs

hosted with ❤ by GitHub



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s