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
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
Array
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
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
impl AsRef<Constant> for ConstantRef
Source§impl From<AddrSpaceCast> for Constant
impl From<AddrSpaceCast> for Constant
Source§fn from(expr: AddrSpaceCast) -> Constant
fn from(expr: AddrSpaceCast) -> Constant
Source§impl From<ExtractElement> for Constant
impl From<ExtractElement> for Constant
Source§fn from(expr: ExtractElement) -> Constant
fn from(expr: ExtractElement) -> Constant
Source§impl From<ExtractValue> for Constant
impl From<ExtractValue> for Constant
Source§fn from(expr: ExtractValue) -> Constant
fn from(expr: ExtractValue) -> Constant
Source§impl From<GetElementPtr> for Constant
impl From<GetElementPtr> for Constant
Source§fn from(expr: GetElementPtr) -> Constant
fn from(expr: GetElementPtr) -> Constant
Source§impl From<InsertElement> for Constant
impl From<InsertElement> for Constant
Source§fn from(expr: InsertElement) -> Constant
fn from(expr: InsertElement) -> Constant
Source§impl From<InsertValue> for Constant
impl From<InsertValue> for Constant
Source§fn from(expr: InsertValue) -> Constant
fn from(expr: InsertValue) -> Constant
Source§impl From<ShuffleVector> for Constant
impl From<ShuffleVector> for Constant
Source§fn from(expr: ShuffleVector) -> Constant
fn from(expr: ShuffleVector) -> Constant
Source§impl TryFrom<Constant> for AddrSpaceCast
impl TryFrom<Constant> for AddrSpaceCast
Source§impl TryFrom<Constant> for ExtractElement
impl TryFrom<Constant> for ExtractElement
Source§impl TryFrom<Constant> for ExtractValue
impl TryFrom<Constant> for ExtractValue
Source§impl TryFrom<Constant> for GetElementPtr
impl TryFrom<Constant> for GetElementPtr
Source§impl TryFrom<Constant> for InsertElement
impl TryFrom<Constant> for InsertElement
Source§impl TryFrom<Constant> for InsertValue
impl TryFrom<Constant> for InsertValue
Source§impl TryFrom<Constant> for ShuffleVector
impl TryFrom<Constant> for ShuffleVector
impl StructuralPartialEq for Constant
Auto Trait Implementations§
impl Freeze for Constant
impl RefUnwindSafe for Constant
impl Send for Constant
impl Sync for Constant
impl Unpin for Constant
impl UnwindSafe for Constant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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