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: String, 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

Fields

§name: String

Globals’ names must be strings

Global variable or function

§

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 copy 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 PartialEq<Constant> for Constant

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Constant> for AShr

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.