Add a function to check whether a ValueRef is a constant

This commit is contained in:
Björn Steinbrink 2013-07-25 10:51:45 +02:00
parent ba9c3ebc02
commit 75a08622e8

View file

@ -850,6 +850,12 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
}
}
pub fn is_const(v: ValueRef) -> bool {
unsafe {
llvm::LLVMIsConstant(v) == True
}
}
pub fn const_to_int(v: ValueRef) -> c_longlong {
unsafe {
llvm::LLVMConstIntGetSExtValue(v)