@@ -23,7 +23,7 @@ impl IntType {
23
23
}
24
24
}
25
25
26
- /// Gets the `IntType` representing 1 bit width. Will be automatically assigned the global context.
26
+ /// Gets the `IntType` representing 1 bit width. It will be automatically assigned the global context.
27
27
///
28
28
/// To use your own `Context`, see [inkwell::context::bool_type()](../context/struct.Context.html#method.bool_type)
29
29
///
@@ -45,7 +45,7 @@ impl IntType {
45
45
IntType :: new ( type_)
46
46
}
47
47
48
- /// Gets the `IntType` representing 8 bit width. Will be automatically assigned the global context.
48
+ /// Gets the `IntType` representing 8 bit width. It will be automatically assigned the global context.
49
49
///
50
50
/// To use your own `Context`, see [inkwell::context::i8_type()](../context/struct.Context.html#method.i8_type)
51
51
///
@@ -67,7 +67,7 @@ impl IntType {
67
67
IntType :: new ( type_)
68
68
}
69
69
70
- /// Gets the `IntType` representing 16 bit width. Will be automatically assigned the global context.
70
+ /// Gets the `IntType` representing 16 bit width. It will be automatically assigned the global context.
71
71
///
72
72
/// To use your own `Context`, see [inkwell::context::i16_type()](../context/struct.Context.html#method.i16_type)
73
73
///
@@ -89,7 +89,7 @@ impl IntType {
89
89
IntType :: new ( type_)
90
90
}
91
91
92
- /// Gets the `IntType` representing 32 bit width. Will be automatically assigned the global context.
92
+ /// Gets the `IntType` representing 32 bit width. It will be automatically assigned the global context.
93
93
///
94
94
/// To use your own `Context`, see [inkwell::context::i32_type()](../context/struct.Context.html#method.i32_type)
95
95
///
@@ -111,7 +111,7 @@ impl IntType {
111
111
IntType :: new ( type_)
112
112
}
113
113
114
- /// Gets the `IntType` representing 64 bit width. Will be automatically assigned the global context.
114
+ /// Gets the `IntType` representing 64 bit width. It will be automatically assigned the global context.
115
115
///
116
116
/// To use your own `Context`, see [inkwell::context::i64_type()](../context/struct.Context.html#method.i64_type)
117
117
///
@@ -133,7 +133,7 @@ impl IntType {
133
133
IntType :: new ( type_)
134
134
}
135
135
136
- /// Gets the `IntType` representing 128 bit width. Will be automatically assigned the global context.
136
+ /// Gets the `IntType` representing 128 bit width. It will be automatically assigned the global context.
137
137
///
138
138
/// To use your own `Context`, see [inkwell::context::i128_type()](../context/struct.Context.html#method.i128_type)
139
139
///
@@ -154,7 +154,7 @@ impl IntType {
154
154
Self :: custom_width_int_type ( 128 )
155
155
}
156
156
157
- /// Gets the `IntType` representing a custom bit width. Will be automatically assigned the global context.
157
+ /// Gets the `IntType` representing a custom bit width. It will be automatically assigned the global context.
158
158
///
159
159
/// To use your own `Context`, see [inkwell::context::custom_width_int_type()](../context/struct.Context.html#method.custom_width_int_type)
160
160
///
@@ -176,6 +176,23 @@ impl IntType {
176
176
IntType :: new ( type_)
177
177
}
178
178
179
+ /// Creates an `IntValue` repesenting a constant value of this `IntType`. It will be automatically assigned this `IntType`'s `Context`.
180
+ ///
181
+ /// # Example
182
+ /// ```
183
+ /// use inkwell::context::Context;
184
+ /// use inkwell::types::IntType;
185
+ ///
186
+ /// // Global Context
187
+ /// let i32_type = IntType::i32_type();
188
+ /// let i32_value = i32_type.const_int(42, false);
189
+ ///
190
+ /// // Custom Context
191
+ /// let context = Context::create();
192
+ /// let i32_type = context.i32_type();
193
+ /// let i32_value = i32_type.const_int(42, false);
194
+ /// ```
195
+ // TODOC: Maybe better explain sign extension
179
196
pub fn const_int ( & self , value : u64 , sign_extend : bool ) -> IntValue {
180
197
let value = unsafe {
181
198
LLVMConstInt ( self . as_type_ref ( ) , value, sign_extend as i32 )
@@ -196,6 +213,22 @@ impl IntType {
196
213
IntValue :: new ( value)
197
214
}
198
215
216
+ /// Creates an `IntValue` representing a constant value of all one bits of this `IntType`. It will be automatically assigned this `IntType`'s `Context`.
217
+ ///
218
+ /// # Example
219
+ /// ```
220
+ /// use inkwell::context::Context;
221
+ /// use inkwell::types::IntType;
222
+ ///
223
+ /// // Global Context
224
+ /// let i32_type = IntType::i32_type();
225
+ /// let i32_ptr_value = i32_type.const_all_ones();
226
+ ///
227
+ /// // Custom Context
228
+ /// let context = Context::create();
229
+ /// let i32_type = context.i32_type();
230
+ /// let i32_ptr_value = i32_type.const_all_ones();
231
+ /// ```
199
232
pub fn const_all_ones ( & self ) -> IntValue {
200
233
let value = unsafe {
201
234
LLVMConstAllOnes ( self . as_type_ref ( ) )
@@ -204,6 +237,22 @@ impl IntType {
204
237
IntValue :: new ( value)
205
238
}
206
239
240
+ /// Creates a `PointerValue` representing a constant value of zero (null pointer) pointing to this `IntType`. It will be automatically assigned this `IntType`'s `Context`.
241
+ ///
242
+ /// # Example
243
+ /// ```
244
+ /// use inkwell::context::Context;
245
+ /// use inkwell::types::IntType;
246
+ ///
247
+ /// // Global Context
248
+ /// let i32_type = IntType::i32_type();
249
+ /// let i32_value = i32_type.const_null_ptr();
250
+ ///
251
+ /// // Custom Context
252
+ /// let context = Context::create();
253
+ /// let i32_type = context.i32_type();
254
+ /// let i32_value = i32_type.const_null_ptr();
255
+ /// ```
207
256
pub fn const_null_ptr ( & self ) -> PointerValue {
208
257
self . int_type . const_null_ptr ( )
209
258
}
0 commit comments