diff options
| author | Björn Steinbrink <bsteinbr@gmail.com> | 2013-07-25 10:51:45 +0200 |
|---|---|---|
| committer | Björn Steinbrink <bsteinbr@gmail.com> | 2013-07-25 12:06:57 +0200 |
| commit | 75a08622e8754dbc43ccd2f08031227527645d39 (patch) | |
| tree | 6a7fca7c9d441ea8b604f7e84d281f5d9adafcb2 | |
| parent | ba9c3ebc02716252cf46944e4dd3a866cc51947c (diff) | |
| download | rust-75a08622e8754dbc43ccd2f08031227527645d39.tar.gz rust-75a08622e8754dbc43ccd2f08031227527645d39.zip | |
Add a function to check whether a ValueRef is a constant
| -rw-r--r-- | src/librustc/middle/trans/common.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 713939a5d83..4099f642637 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -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) |
