[][src]Struct inkwell::types::IntType

pub struct IntType<'ctx> { /* fields omitted */ }

An IntType is the type of an integer constant or variable.

Implementations

impl<'ctx> IntType<'ctx>[src]

pub fn const_int(self, value: u64, sign_extend: bool) -> IntValue<'ctx>[src]

Creates an IntValue repesenting a constant value of this IntType. It will be automatically assigned this IntType's Context.

Example

use inkwell::context::Context;

// Local Context
let context = Context::create();
let i32_type = context.i32_type();
let i32_value = i32_type.const_int(42, false);

pub fn const_int_from_string(
    self,
    slice: &str,
    radix: StringRadix
) -> Option<IntValue<'ctx>>
[src]

Create an IntValue from a string and radix. LLVM provides no error handling here, so this may produce unexpected results and should not be relied upon for validation.

Example

use std::convert::TryFrom;

use inkwell::context::Context;
use inkwell::types::StringRadix;

let context = Context::create();
let i8_type = context.i8_type();
let i8_val = i8_type.const_int_from_string("0121", StringRadix::Decimal).unwrap();

assert_eq!(i8_val.print_to_string().to_string(), "i8 121");

let i8_val = i8_type.const_int_from_string("0121", StringRadix::try_from(10).unwrap()).unwrap();

assert_eq!(i8_val.print_to_string().to_string(), "i8 16");

let i8_val = i8_type.const_int_from_string("0121", StringRadix::Binary);
assert!(i8_val.is_none());

let i8_val = i8_type.const_int_from_string("ABCD", StringRadix::Binary);
assert!(i8_val.is_none());

pub fn const_int_arbitrary_precision(self, words: &[u64]) -> IntValue<'ctx>[src]

Create a constant IntValue of arbitrary precision.

Example

use inkwell::context::Context;

let context = Context::create();
let i64_type = context.i64_type();
let i64_val = i64_type.const_int_arbitrary_precision(&[1, 2]);

pub fn const_all_ones(self) -> IntValue<'ctx>[src]

Creates an IntValue representing a constant value of all one bits of this IntType. It will be automatically assigned this IntType's Context.

Example

use inkwell::context::Context;

// Local Context
let context = Context::create();
let i32_type = context.i32_type();
let i32_ptr_value = i32_type.const_all_ones();

pub fn const_zero(self) -> IntValue<'ctx>[src]

Creates a constant zero value of this IntType.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let i8_zero = i8_type.const_zero();

assert_eq!(i8_zero.print_to_string().to_string(), "i8 0");

pub fn fn_type(
    self,
    param_types: &[BasicTypeEnum<'ctx>],
    is_var_args: bool
) -> FunctionType<'ctx>
[src]

Creates a FunctionType with this IntType for its return type.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let fn_type = i8_type.fn_type(&[], false);

pub fn array_type(self, size: u32) -> ArrayType<'ctx>[src]

Creates an ArrayType with this IntType for its element type.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let i8_array_type = i8_type.array_type(3);

assert_eq!(i8_array_type.len(), 3);
assert_eq!(i8_array_type.get_element_type().into_int_type(), i8_type);

pub fn vec_type(self, size: u32) -> VectorType<'ctx>[src]

Creates a VectorType with this IntType for its element type.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let i8_vector_type = i8_type.vec_type(3);

assert_eq!(i8_vector_type.get_size(), 3);
assert_eq!(i8_vector_type.get_element_type().into_int_type(), i8_type);

pub fn get_context(self) -> ContextRef<'ctx>[src]

Gets a reference to the Context this IntType was created in.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();

assert_eq!(*i8_type.get_context(), context);

pub fn size_of(self) -> IntValue<'ctx>[src]

Gets the size of this IntType. Value may vary depending on the target architecture.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let i8_type_size = i8_type.size_of();

pub fn get_alignment(self) -> IntValue<'ctx>[src]

Gets the alignment of this IntType. Value may vary depending on the target architecture.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let i8_type_alignment = i8_type.get_alignment();

pub fn ptr_type(self, address_space: AddressSpace) -> PointerType<'ctx>[src]

Creates a PointerType with this IntType for its element type.

Example

use inkwell::context::Context;
use inkwell::AddressSpace;

let context = Context::create();
let i8_type = context.i8_type();
let i8_ptr_type = i8_type.ptr_type(AddressSpace::Generic);

assert_eq!(i8_ptr_type.get_element_type().into_int_type(), i8_type);

pub fn get_bit_width(self) -> u32[src]

Gets the bit width of an IntType.

Example

use inkwell::context::Context;

let context = Context::create();
let bool_type = context.bool_type();

assert_eq!(bool_type.get_bit_width(), 1);

pub fn print_to_string(self) -> LLVMString[src]

Prints the definition of an IntType to a LLVMString.

pub fn get_undef(self) -> IntValue<'ctx>[src]

Creates an undefined instance of an IntType.

Example

use inkwell::context::Context;
use inkwell::AddressSpace;

let context = Context::create();
let i8_type = context.i8_type();
let i8_undef = i8_type.get_undef();

assert!(i8_undef.is_undef());

pub fn create_generic_value(
    self,
    value: u64,
    is_signed: bool
) -> GenericValue<'ctx>
[src]

Creates a GenericValue for use with ExecutionEngines.

pub fn const_array(self, values: &[IntValue<'ctx>]) -> ArrayValue<'ctx>[src]

Creates a constant ArrayValue.

Example

use inkwell::context::Context;

let context = Context::create();
let i8_type = context.i8_type();
let i8_val = i8_type.const_int(0, false);
let i8_val2 = i8_type.const_int(2, false);
let i8_array = i8_type.const_array(&[i8_val, i8_val2]);

assert!(i8_array.is_const());

Trait Implementations

impl<'ctx> AnyType<'ctx> for IntType<'ctx>[src]

impl<'ctx> BasicType<'ctx> for IntType<'ctx>[src]

impl<'ctx> Clone for IntType<'ctx>[src]

impl<'ctx> Copy for IntType<'ctx>[src]

impl<'ctx> Debug for IntType<'ctx>[src]

impl<'ctx> Eq for IntType<'ctx>[src]

impl<'ctx> From<IntType<'ctx>> for AnyTypeEnum<'ctx>[src]

impl<'ctx> From<IntType<'ctx>> for BasicTypeEnum<'ctx>[src]

impl<'ctx> IntMathType<'ctx> for IntType<'ctx>[src]

type ValueType = IntValue<'ctx>

The value instance of an int or int vector type.

type MathConvType = FloatType<'ctx>

The type for int to float or int vector to float vector conversions.

type PtrConvType = PointerType<'ctx>

The type for int to pointer or int vector to pointer vector conversions.

impl<'ctx> PartialEq<IntType<'ctx>> for IntType<'ctx>[src]

impl<'ctx> StructuralEq for IntType<'ctx>[src]

impl<'ctx> StructuralPartialEq for IntType<'ctx>[src]

impl<'ctx> TryFrom<AnyTypeEnum<'ctx>> for IntType<'ctx>[src]

type Error = ()

The type returned in the event of a conversion error.

impl<'ctx> TryFrom<BasicTypeEnum<'ctx>> for IntType<'ctx>[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'ctx> RefUnwindSafe for IntType<'ctx>

impl<'ctx> !Send for IntType<'ctx>

impl<'ctx> !Sync for IntType<'ctx>

impl<'ctx> Unpin for IntType<'ctx>

impl<'ctx> UnwindSafe for IntType<'ctx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.