[][src]Struct inkwell::types::FloatType

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

A FloatType is the type of a floating point constant or variable.

Implementations

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

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

Creates a FunctionType with this FloatType for its return type.

Example

use inkwell::context::Context;

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

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

Creates an ArrayType with this FloatType for its element type.

Example

use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_array_type = f32_type.array_type(3);

assert_eq!(f32_array_type.len(), 3);
assert_eq!(f32_array_type.get_element_type().into_float_type(), f32_type);

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

Creates a VectorType with this FloatType for its element type.

Example

use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_vector_type = f32_type.vec_type(3);

assert_eq!(f32_vector_type.get_size(), 3);
assert_eq!(f32_vector_type.get_element_type().into_float_type(), f32_type);

pub fn const_float(self, value: f64) -> FloatValue<'ctx>[src]

Creates a FloatValue repesenting a constant value of this FloatType. It will be automatically assigned this FloatType's Context.

Example

use inkwell::context::Context;

// Local Context
let context = Context::create();
let f32_type = context.f32_type();
let f32_value = f32_type.const_float(42.);

pub fn const_float_from_string(self, slice: &str) -> FloatValue<'ctx>[src]

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

Example

use inkwell::context::Context;
use inkwell::values::AnyValue;

let context = Context::create();
let f64_type = context.f64_type();
let f64_val = f64_type.const_float_from_string("3.6");

assert_eq!(f64_val.print_to_string().to_string(), "double 3.600000e+00");

let f64_val = f64_type.const_float_from_string("3.");

assert_eq!(f64_val.print_to_string().to_string(), "double 3.000000e+00");

let f64_val = f64_type.const_float_from_string("3");

assert_eq!(f64_val.print_to_string().to_string(), "double 3.000000e+00");

let f64_val = f64_type.const_float_from_string("");

assert_eq!(f64_val.print_to_string().to_string(), "double 0.000000e+00");

let f64_val = f64_type.const_float_from_string("3.asd");

assert_eq!(f64_val.print_to_string().to_string(), "double 0x7FF0000000000000");

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

Creates a constant zero value of this FloatType.

Example

use inkwell::context::Context;
use inkwell::values::AnyValue;

let context = Context::create();
let f32_type = context.f32_type();
let f32_zero = f32_type.const_zero();

assert_eq!(f32_zero.print_to_string().to_string(), "float 0.000000e+00");

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

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

Example

use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_type_size = f32_type.size_of();

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

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

Example

use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_type_alignment = f32_type.get_alignment();

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

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

Example

use inkwell::context::Context;

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

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

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

Creates a PointerType with this FloatType for its element type.

Example

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

let context = Context::create();
let f32_type = context.f32_type();
let f32_ptr_type = f32_type.ptr_type(AddressSpace::Generic);

assert_eq!(f32_ptr_type.get_element_type().into_float_type(), f32_type);

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

Creates an undefined instance of a FloatType.

Example

use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_undef = f32_type.get_undef();

assert!(f32_undef.is_undef());

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

Creates a GenericValue for use with ExecutionEngines.

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

Creates a constant ArrayValue.

Example

use inkwell::context::Context;

let context = Context::create();
let f32_type = context.f32_type();
let f32_val = f32_type.const_float(0.);
let f32_val2 = f32_type.const_float(2.);
let f32_array = f32_type.const_array(&[f32_val, f32_val2]);

assert!(f32_array.is_const());

Trait Implementations

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

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

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

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

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

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

impl<'ctx> FloatMathType<'ctx> for FloatType<'ctx>[src]

type ValueType = FloatValue<'ctx>

The value instance of a float or float vector type.

type MathConvType = IntType<'ctx>

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

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

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

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

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

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

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

type Error = ()

The type returned in the event of a conversion error.

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

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'ctx> RefUnwindSafe for FloatType<'ctx>

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

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

impl<'ctx> Unpin for FloatType<'ctx>

impl<'ctx> UnwindSafe for FloatType<'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.