Rust에서 LLVM Intrinsics 호출하기
Posted: November 28, 2015 Filed under: Code, Tokamak Project | Tags: llvm, rust, tokamak Leave a comment요즘에는 내가 보려는 목적으로 기록을 하는 블로깅이 대부분인 듯 하다. Rust는 LLVM으로 구현되어 있고 LLVM 의 Intrinsics를 함수에 매핑해서 호출할 수 있는 기능이 공식적으로 제공된다. 예제는 아래와 같다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(link_llvm_intrinsics)] | |
extern { | |
#[link_name = “llvm.sqrt.f32”] | |
fn sqrt(x: f32) -> f32; | |
} | |
fn main(){ | |
unsafe { sqrt(32.0f32); } | |
} |