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

name: Option<String>
values: Vec<ConstantRef>
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: 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)

Trait Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.