pub enum Constant {
Int {
value: i64,
bits: u8,
},
BigInt {
value: String,
bits: u8,
},
Float {
value: f64,
bits: u8,
},
String {
value: String,
},
Null,
Undef,
ZeroInit,
Aggregate {
elements: Vec<Constant>,
},
GlobalRef(ValueId),
}Expand description
Constant values in AIR.
Represents compile-time constant values that can appear as instruction operands.
Variants§
Int
Integer constant (signed, up to 128 bits).
Fields
BigInt
Large integer constant that doesn’t fit in i64 (stored as string).
Float
Floating point constant.
All floats are stored as f64 regardless of source precision.
This is lossless for f32 values because every IEEE 754 binary32
value is exactly representable as a binary64 value. The bits
field records the original source precision (32 or 64) for
informational purposes, but analyses should treat the value
field as the canonical representation and should not round-trip
it back to f32.
Fields
String
String constant (UTF-8).
Null
Null pointer constant.
Undef
Undefined/poison value.
ZeroInit
Zero initializer (for aggregates).
Aggregate
Aggregate constant (struct, array).
GlobalRef(ValueId)
Global reference (pointer to a global variable).
Used for global pointer initializers like @p = global ptr @target.
The ValueId identifies the target global’s address.