@@ -133,6 +133,18 @@ impl Context {
133
133
VoidType :: new ( void_type)
134
134
}
135
135
136
+ /// Gets the `IntType` representing 1 bit width. It will be assigned the current context.
137
+ ///
138
+ /// # Example
139
+ /// ```no_run
140
+ /// use inkwell::context::Context;
141
+ ///
142
+ /// let context = Context::create();
143
+ /// let bool_type = context.bool_type();
144
+ ///
145
+ /// assert_eq!(bool_type.get_bit_width(), 1);
146
+ /// assert_eq!(*bool_type.get_context(), context);
147
+ /// ```
136
148
pub fn bool_type ( & self ) -> IntType {
137
149
let bool_type = unsafe {
138
150
LLVMInt1TypeInContext ( * self . context )
@@ -141,6 +153,18 @@ impl Context {
141
153
IntType :: new ( bool_type)
142
154
}
143
155
156
+ /// Gets the `IntType` representing 8 bit width. It will be assigned the current context.
157
+ ///
158
+ /// # Example
159
+ /// ```no_run
160
+ /// use inkwell::context::Context;
161
+ ///
162
+ /// let context = Context::create();
163
+ /// let i8_type = context.i8_type();
164
+ ///
165
+ /// assert_eq!(i8_type.get_bit_width(), 8);
166
+ /// assert_eq!(*i8_type.get_context(), context);
167
+ /// ```
144
168
pub fn i8_type ( & self ) -> IntType {
145
169
let i8_type = unsafe {
146
170
LLVMInt8TypeInContext ( * self . context )
@@ -149,6 +173,18 @@ impl Context {
149
173
IntType :: new ( i8_type)
150
174
}
151
175
176
+ /// Gets the `IntType` representing 16 bit width. It will be assigned the current context.
177
+ ///
178
+ /// # Example
179
+ /// ```no_run
180
+ /// use inkwell::context::Context;
181
+ ///
182
+ /// let context = Context::create();
183
+ /// let i16_type = context.i16_type();
184
+ ///
185
+ /// assert_eq!(i16_type.get_bit_width(), 16);
186
+ /// assert_eq!(*i16_type.get_context(), context);
187
+ /// ```
152
188
pub fn i16_type ( & self ) -> IntType {
153
189
let i16_type = unsafe {
154
190
LLVMInt16TypeInContext ( * self . context )
@@ -157,6 +193,18 @@ impl Context {
157
193
IntType :: new ( i16_type)
158
194
}
159
195
196
+ /// Gets the `IntType` representing 32 bit width. It will be assigned the current context.
197
+ ///
198
+ /// # Example
199
+ /// ```no_run
200
+ /// use inkwell::context::Context;
201
+ ///
202
+ /// let context = Context::create();
203
+ /// let i32_type = context.i32_type();
204
+ ///
205
+ /// assert_eq!(i32_type.get_bit_width(), 32);
206
+ /// assert_eq!(*i32_type.get_context(), context);
207
+ /// ```
160
208
pub fn i32_type ( & self ) -> IntType {
161
209
let i32_type = unsafe {
162
210
LLVMInt32TypeInContext ( * self . context )
@@ -165,6 +213,18 @@ impl Context {
165
213
IntType :: new ( i32_type)
166
214
}
167
215
216
+ /// Gets the `IntType` representing 64 bit width. It will be assigned the current context.
217
+ ///
218
+ /// # Example
219
+ /// ```no_run
220
+ /// use inkwell::context::Context;
221
+ ///
222
+ /// let context = Context::create();
223
+ /// let i64_type = context.i64_type();
224
+ ///
225
+ /// assert_eq!(i64_type.get_bit_width(), 64);
226
+ /// assert_eq!(*i64_type.get_context(), context);
227
+ /// ```
168
228
pub fn i64_type ( & self ) -> IntType {
169
229
let i64_type = unsafe {
170
230
LLVMInt64TypeInContext ( * self . context )
@@ -173,13 +233,37 @@ impl Context {
173
233
IntType :: new ( i64_type)
174
234
}
175
235
236
+ /// Gets the `IntType` representing 128 bit width. It will be assigned the current context.
237
+ ///
238
+ /// # Example
239
+ /// ```no_run
240
+ /// use inkwell::context::Context;
241
+ ///
242
+ /// let context = Context::create();
243
+ /// let i128_type = context.i128_type();
244
+ ///
245
+ /// assert_eq!(i128_type.get_bit_width(), 128);
246
+ /// assert_eq!(*i128_type.get_context(), context);
247
+ /// ```
176
248
pub fn i128_type ( & self ) -> IntType {
177
249
// REVIEW: The docs says there's a LLVMInt128TypeInContext, but
178
250
// it might only be in a newer version
179
251
180
252
self . custom_width_int_type ( 128 )
181
253
}
182
254
255
+ /// Gets the `IntType` representing a custom bit width. It will be assigned the current context.
256
+ ///
257
+ /// # Example
258
+ /// ```no_run
259
+ /// use inkwell::context::Context;
260
+ ///
261
+ /// let context = Context::create();
262
+ /// let i42_type = context.custom_width_int_type(42);
263
+ ///
264
+ /// assert_eq!(i42_type.get_bit_width(), 42);
265
+ /// assert_eq!(*i42_type.get_context(), context);
266
+ /// ```
183
267
pub fn custom_width_int_type ( & self , bits : u32 ) -> IntType {
184
268
let int_type = unsafe {
185
269
LLVMIntTypeInContext ( * self . context , bits)
@@ -188,6 +272,19 @@ impl Context {
188
272
IntType :: new ( int_type)
189
273
}
190
274
275
+ /// Gets the `FloatType` representing a 16 bit width. It will be assigned the current context.
276
+ ///
277
+ /// # Example
278
+ ///
279
+ /// ```no_run
280
+ /// use inkwell::context::Context;
281
+ ///
282
+ /// let context = Context::create();
283
+ ///
284
+ /// let f16_type = context.f16_type();
285
+ ///
286
+ /// assert_eq!(*f16_type.get_context(), context);
287
+ /// ```
191
288
pub fn f16_type ( & self ) -> FloatType {
192
289
let f16_type = unsafe {
193
290
LLVMHalfTypeInContext ( * self . context )
@@ -196,6 +293,19 @@ impl Context {
196
293
FloatType :: new ( f16_type)
197
294
}
198
295
296
+ /// Gets the `FloatType` representing a 32 bit width. It will be assigned the current context.
297
+ ///
298
+ /// # Example
299
+ ///
300
+ /// ```no_run
301
+ /// use inkwell::context::Context;
302
+ ///
303
+ /// let context = Context::create();
304
+ ///
305
+ /// let f32_type = context.f32_type();
306
+ ///
307
+ /// assert_eq!(*f32_type.get_context(), context);
308
+ /// ```
199
309
pub fn f32_type ( & self ) -> FloatType {
200
310
let f32_type = unsafe {
201
311
LLVMFloatTypeInContext ( * self . context )
@@ -204,6 +314,19 @@ impl Context {
204
314
FloatType :: new ( f32_type)
205
315
}
206
316
317
+ /// Gets the `FloatType` representing a 64 bit width. It will be assigned the current context.
318
+ ///
319
+ /// # Example
320
+ ///
321
+ /// ```no_run
322
+ /// use inkwell::context::Context;
323
+ ///
324
+ /// let context = Context::create();
325
+ ///
326
+ /// let f64_type = context.f64_type();
327
+ ///
328
+ /// assert_eq!(*f64_type.get_context(), context);
329
+ /// ```
207
330
pub fn f64_type ( & self ) -> FloatType {
208
331
let f64_type = unsafe {
209
332
LLVMDoubleTypeInContext ( * self . context )
@@ -212,6 +335,19 @@ impl Context {
212
335
FloatType :: new ( f64_type)
213
336
}
214
337
338
+ /// Gets the `FloatType` representing a 128 bit width. It will be assigned the current context.
339
+ ///
340
+ /// # Example
341
+ ///
342
+ /// ```no_run
343
+ /// use inkwell::context::Context;
344
+ ///
345
+ /// let context = Context::create();
346
+ ///
347
+ /// let f128_type = context.f128_type();
348
+ ///
349
+ /// assert_eq!(*f128_type.get_context(), context);
350
+ /// ```
215
351
pub fn f128_type ( & self ) -> FloatType {
216
352
let f128_type = unsafe {
217
353
LLVMFP128TypeInContext ( * self . context )
@@ -220,6 +356,21 @@ impl Context {
220
356
FloatType :: new ( f128_type)
221
357
}
222
358
359
+ /// Gets the `FloatType` representing a 128 bit width. It will be assigned the current context.
360
+ ///
361
+ /// PPC is two 64 bits side by side rather than one single 128 bit float.
362
+ ///
363
+ /// # Example
364
+ ///
365
+ /// ```no_run
366
+ /// use inkwell::context::Context;
367
+ ///
368
+ /// let context = Context::create();
369
+ ///
370
+ /// let f128_type = context.ppc_f128_type();
371
+ ///
372
+ /// assert_eq!(*f128_type.get_context(), context);
373
+ /// ```
223
374
pub fn ppc_f128_type ( & self ) -> FloatType {
224
375
let f128_type = unsafe {
225
376
LLVMPPCFP128TypeInContext ( * self . context )
0 commit comments