@@ -35,17 +35,29 @@ public struct IntType: IRType {
35
35
return null ( )
36
36
}
37
37
38
- /// Creates an integer constant value with the given Swift integer value.
38
+ /// Creates an unsigned integer constant value with the given Swift integer value.
39
39
///
40
40
/// - parameter value: A Swift integer value.
41
41
/// - parameter signExtend: Whether to sign-extend this value to fit this
42
42
/// type's bit width. Defaults to `false`.
43
- public func constant< IntTy: Integer > ( _ value: IntTy , signExtend: Bool = false ) -> IRValue {
44
- return LLVMConstInt ( asLLVM ( ) ,
45
- UInt64 ( bitPattern : value. toIntMax ( ) ) ,
46
- signExtend. llvm)
43
+ public func constant< IntTy: UnsignedInteger > ( _ value: IntTy , signExtend: Bool = false ) -> Constant {
44
+ return Constant ( llvm : LLVMConstInt ( asLLVM ( ) ,
45
+ unsafeBitCast ( value. toIntMax ( ) , to : UInt64 . self ) ,
46
+ signExtend. llvm) , representation : . unsigned )
47
47
}
48
48
49
+ /// Creates a signed integer constant value with the given Swift integer value.
50
+ ///
51
+ /// - parameter value: A Swift integer value.
52
+ /// - parameter signExtend: Whether to sign-extend this value to fit this
53
+ /// type's bit width. Defaults to `false`.
54
+ public func constant< IntTy: SignedInteger > ( _ value: IntTy , signExtend: Bool = false ) -> Constant {
55
+ return Constant ( llvm: LLVMConstInt ( asLLVM ( ) ,
56
+ unsafeBitCast ( value. toIntMax ( ) , to: UInt64 . self) ,
57
+ signExtend. llvm) , representation: . signed)
58
+ }
59
+
60
+
49
61
/// Retrieves an integer value of this type's bit width consisting of all
50
62
/// one-bits.
51
63
///
0 commit comments