Enum Constant

Source
pub enum Constant {
Show 51 variants Int { bits: u32, value: u64, }, Float(Float), Null(TypeRef), AggregateZero(TypeRef), Struct { name: Option<String>, values: Vec<ConstantRef>, is_packed: bool, }, Array { element_type: TypeRef, elements: Vec<ConstantRef>, }, Vector(Vec<ConstantRef>), Undef(TypeRef), BlockAddress, GlobalReference { name: Name, ty: TypeRef, }, TokenNone, Add(Add), Sub(Sub), Mul(Mul), UDiv(UDiv), SDiv(SDiv), URem(URem), SRem(SRem), And(And), Or(Or), Xor(Xor), Shl(Shl), LShr(LShr), AShr(AShr), FAdd(FAdd), FSub(FSub), FMul(FMul), FDiv(FDiv), FRem(FRem), ExtractElement(ExtractElement), InsertElement(InsertElement), ShuffleVector(ShuffleVector), ExtractValue(ExtractValue), InsertValue(InsertValue), GetElementPtr(GetElementPtr), Trunc(Trunc), ZExt(ZExt), SExt(SExt), FPTrunc(FPTrunc), FPExt(FPExt), FPToUI(FPToUI), FPToSI(FPToSI), UIToFP(UIToFP), SIToFP(SIToFP), PtrToInt(PtrToInt), IntToPtr(IntToPtr), BitCast(BitCast), AddrSpaceCast(AddrSpaceCast), ICmp(ICmp), FCmp(FCmp), Select(Select),
}
Expand description

See LLVM 14 docs on Constants. Constants can be either values, or expressions involving other constants (see LLVM 14 docs on Constant Expressions).

Variants§

§

Int

Fields

§bits: u32

Number of bits in the constant integer

§value: u64

The constant value itself.

If bits == 64, this is the value.

If bits < 64, the constant value is zero-extended to fit in this field.

If bits > 64, the constant value is truncated to fit in this field; but if this truncation would change the value (i.e., if the value is

= 2^64 when interpreted as unsigned) then Module::from_bc_path() will fail. See #5.

§

Float(Float)

§

Null(TypeRef)

The TypeRef here must be to a PointerType. See LLVM 14 docs on Simple Constants

§

AggregateZero(TypeRef)

A zero-initialized array or struct (or scalar).

§

Struct

Fields

§is_packed: bool
§

Array

Fields

§element_type: TypeRef
§elements: Vec<ConstantRef>
§

Vector(Vec<ConstantRef>)

§

Undef(TypeRef)

Undef can be used anywhere a constant is expected. See LLVM 14 docs on Undefined Values

§

BlockAddress

The address of the given (non-entry) BasicBlock. See LLVM 14 docs on Addresses of Basic Blocks. BlockAddress needs more fields, but the necessary getter functions are apparently not exposed in the LLVM C API (only the C++ API)

§

GlobalReference

Global variable or function

Fields

§name: Name
§

TokenNone

§

Add(Add)

§

Sub(Sub)

§

Mul(Mul)

§

UDiv(UDiv)

§

SDiv(SDiv)

§

URem(URem)

§

SRem(SRem)

§

And(And)

§

Or(Or)

§

Xor(Xor)

§

Shl(Shl)

§

LShr(LShr)

§

AShr(AShr)

§

FAdd(FAdd)

§

FSub(FSub)

§

FMul(FMul)

§

FDiv(FDiv)

§

FRem(FRem)

§

ExtractElement(ExtractElement)

§

InsertElement(InsertElement)

§

ShuffleVector(ShuffleVector)

§

ExtractValue(ExtractValue)

§

InsertValue(InsertValue)

§

GetElementPtr(GetElementPtr)

§

Trunc(Trunc)

§

ZExt(ZExt)

§

SExt(SExt)

§

FPTrunc(FPTrunc)

§

FPExt(FPExt)

§

FPToUI(FPToUI)

§

FPToSI(FPToSI)

§

UIToFP(UIToFP)

§

SIToFP(SIToFP)

§

PtrToInt(PtrToInt)

§

IntToPtr(IntToPtr)

§

BitCast(BitCast)

§

AddrSpaceCast(AddrSpaceCast)

§

ICmp(ICmp)

§

FCmp(FCmp)

§

Select(Select)

Trait Implementations§

Source§

impl AsRef<Constant> for ConstantRef

Source§

fn as_ref(&self) -> &Constant

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Constant

Source§

fn clone(&self) -> Constant

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Constant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Constant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<AShr> for Constant

Source§

fn from(expr: AShr) -> Constant

Converts to this type from the input type.
Source§

impl From<Add> for Constant

Source§

fn from(expr: Add) -> Constant

Converts to this type from the input type.
Source§

impl From<AddrSpaceCast> for Constant

Source§

fn from(expr: AddrSpaceCast) -> Constant

Converts to this type from the input type.
Source§

impl From<And> for Constant

Source§

fn from(expr: And) -> Constant

Converts to this type from the input type.
Source§

impl From<BitCast> for Constant

Source§

fn from(expr: BitCast) -> Constant

Converts to this type from the input type.
Source§

impl From<ExtractElement> for Constant

Source§

fn from(expr: ExtractElement) -> Constant

Converts to this type from the input type.
Source§

impl From<ExtractValue> for Constant

Source§

fn from(expr: ExtractValue) -> Constant

Converts to this type from the input type.
Source§

impl From<FAdd> for Constant

Source§

fn from(expr: FAdd) -> Constant

Converts to this type from the input type.
Source§

impl From<FCmp> for Constant

Source§

fn from(expr: FCmp) -> Constant

Converts to this type from the input type.
Source§

impl From<FDiv> for Constant

Source§

fn from(expr: FDiv) -> Constant

Converts to this type from the input type.
Source§

impl From<FMul> for Constant

Source§

fn from(expr: FMul) -> Constant

Converts to this type from the input type.
Source§

impl From<FPExt> for Constant

Source§

fn from(expr: FPExt) -> Constant

Converts to this type from the input type.
Source§

impl From<FPToSI> for Constant

Source§

fn from(expr: FPToSI) -> Constant

Converts to this type from the input type.
Source§

impl From<FPToUI> for Constant

Source§

fn from(expr: FPToUI) -> Constant

Converts to this type from the input type.
Source§

impl From<FPTrunc> for Constant

Source§

fn from(expr: FPTrunc) -> Constant

Converts to this type from the input type.
Source§

impl From<FRem> for Constant

Source§

fn from(expr: FRem) -> Constant

Converts to this type from the input type.
Source§

impl From<FSub> for Constant

Source§

fn from(expr: FSub) -> Constant

Converts to this type from the input type.
Source§

impl From<GetElementPtr> for Constant

Source§

fn from(expr: GetElementPtr) -> Constant

Converts to this type from the input type.
Source§

impl From<ICmp> for Constant

Source§

fn from(expr: ICmp) -> Constant

Converts to this type from the input type.
Source§

impl From<InsertElement> for Constant

Source§

fn from(expr: InsertElement) -> Constant

Converts to this type from the input type.
Source§

impl From<InsertValue> for Constant

Source§

fn from(expr: InsertValue) -> Constant

Converts to this type from the input type.
Source§

impl From<IntToPtr> for Constant

Source§

fn from(expr: IntToPtr) -> Constant

Converts to this type from the input type.
Source§

impl From<LShr> for Constant

Source§

fn from(expr: LShr) -> Constant

Converts to this type from the input type.
Source§

impl From<Mul> for Constant

Source§

fn from(expr: Mul) -> Constant

Converts to this type from the input type.
Source§

impl From<Or> for Constant

Source§

fn from(expr: Or) -> Constant

Converts to this type from the input type.
Source§

impl From<PtrToInt> for Constant

Source§

fn from(expr: PtrToInt) -> Constant

Converts to this type from the input type.
Source§

impl From<SDiv> for Constant

Source§

fn from(expr: SDiv) -> Constant

Converts to this type from the input type.
Source§

impl From<SExt> for Constant

Source§

fn from(expr: SExt) -> Constant

Converts to this type from the input type.
Source§

impl From<SIToFP> for Constant

Source§

fn from(expr: SIToFP) -> Constant

Converts to this type from the input type.
Source§

impl From<SRem> for Constant

Source§

fn from(expr: SRem) -> Constant

Converts to this type from the input type.
Source§

impl From<Select> for Constant

Source§

fn from(expr: Select) -> Constant

Converts to this type from the input type.
Source§

impl From<Shl> for Constant

Source§

fn from(expr: Shl) -> Constant

Converts to this type from the input type.
Source§

impl From<ShuffleVector> for Constant

Source§

fn from(expr: ShuffleVector) -> Constant

Converts to this type from the input type.
Source§

impl From<Sub> for Constant

Source§

fn from(expr: Sub) -> Constant

Converts to this type from the input type.
Source§

impl From<Trunc> for Constant

Source§

fn from(expr: Trunc) -> Constant

Converts to this type from the input type.
Source§

impl From<UDiv> for Constant

Source§

fn from(expr: UDiv) -> Constant

Converts to this type from the input type.
Source§

impl From<UIToFP> for Constant

Source§

fn from(expr: UIToFP) -> Constant

Converts to this type from the input type.
Source§

impl From<URem> for Constant

Source§

fn from(expr: URem) -> Constant

Converts to this type from the input type.
Source§

impl From<Xor> for Constant

Source§

fn from(expr: Xor) -> Constant

Converts to this type from the input type.
Source§

impl From<ZExt> for Constant

Source§

fn from(expr: ZExt) -> Constant

Converts to this type from the input type.
Source§

impl Hash for Constant

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Constant

Source§

fn eq(&self, other: &Constant) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Constant> for AShr

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Add

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for AddrSpaceCast

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for And

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for BitCast

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for ExtractElement

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for ExtractValue

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FAdd

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FCmp

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FDiv

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FMul

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FPExt

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FPToSI

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FPToUI

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FPTrunc

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FRem

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for FSub

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for GetElementPtr

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for ICmp

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for InsertElement

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for InsertValue

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for IntToPtr

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for LShr

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Mul

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Or

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for PtrToInt

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for SDiv

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for SExt

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for SIToFP

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for SRem

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Select

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Shl

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for ShuffleVector

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Sub

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Trunc

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for UDiv

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for UIToFP

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for URem

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for Xor

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Constant> for ZExt

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(constant: Constant) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Typed for Constant

Source§

fn get_type(&self, types: &Types) -> TypeRef

Source§

impl StructuralPartialEq for Constant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.