File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 7875dae83fac23fdf59765eb548c2237850d6b15
2
+ refs/heads/master: 2e93e386fd228176aeb1100bfdf961bdae2b51b9
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: b3317d68910900f135f9f38e43a7a699bc736b4a
5
5
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf
Original file line number Diff line number Diff line change @@ -1976,6 +1976,7 @@ extern {
1976
1976
pub fn LLVMIsAArgument ( value_ref : ValueRef ) -> ValueRef ;
1977
1977
1978
1978
pub fn LLVMIsAAllocaInst ( value_ref : ValueRef ) -> ValueRef ;
1979
+ pub fn LLVMIsAConstantInt ( value_ref : ValueRef ) -> ValueRef ;
1979
1980
1980
1981
pub fn LLVMInitializeX86TargetInfo ( ) ;
1981
1982
pub fn LLVMInitializeX86Target ( ) ;
Original file line number Diff line number Diff line change @@ -963,6 +963,32 @@ pub fn const_to_uint(v: ValueRef) -> u64 {
963
963
}
964
964
}
965
965
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
+
966
992
pub fn is_undef ( val : ValueRef ) -> bool {
967
993
unsafe {
968
994
llvm:: LLVMIsUndef ( val) != False
You can’t perform that action at this time.
0 commit comments