Skip to content

Commit a6df297

Browse files
committed
---
yaml --- r: 196219 b: refs/heads/tmp c: 2e93e38 h: refs/heads/master i: 196217: e58805b 196215: 11ee5bf v: v3
1 parent 8f99281 commit a6df297

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 9854143cba679834bc4ef932858cd5303f015a0e
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 7875dae83fac23fdf59765eb548c2237850d6b15
35+
refs/heads/tmp: 2e93e386fd228176aeb1100bfdf961bdae2b51b9
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 53a183f0274316596bf9405944d4f0468d8c93e4
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/librustc_llvm/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,7 @@ extern {
19761976
pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
19771977

19781978
pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
1979+
pub fn LLVMIsAConstantInt(value_ref: ValueRef) -> ValueRef;
19791980

19801981
pub fn LLVMInitializeX86TargetInfo();
19811982
pub fn LLVMInitializeX86Target();

branches/tmp/src/librustc_trans/trans/common.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,32 @@ pub fn const_to_uint(v: ValueRef) -> u64 {
963963
}
964964
}
965965

966+
fn is_const_integral(v: ValueRef) -> bool {
967+
unsafe {
968+
!llvm::LLVMIsAConstantInt(v).is_null()
969+
}
970+
}
971+
972+
pub fn const_to_opt_int(v: ValueRef) -> Option<i64> {
973+
unsafe {
974+
if is_const_integral(v) {
975+
Some(llvm::LLVMConstIntGetSExtValue(v))
976+
} else {
977+
None
978+
}
979+
}
980+
}
981+
982+
pub fn const_to_opt_uint(v: ValueRef) -> Option<u64> {
983+
unsafe {
984+
if is_const_integral(v) {
985+
Some(llvm::LLVMConstIntGetZExtValue(v))
986+
} else {
987+
None
988+
}
989+
}
990+
}
991+
966992
pub fn is_undef(val: ValueRef) -> bool {
967993
unsafe {
968994
llvm::LLVMIsUndef(val) != False

0 commit comments

Comments
 (0)