pub trait Target:
Clone
+ Debug
+ Eq
+ Hash
+ Sized
+ 'static {
type TypeRef: Clone + Eq + Hash + Debug;
type MethodRef: Clone + Eq + Hash + Debug;
type FieldRef: Clone + Eq + Hash + Debug;
type SigRef: Clone + Eq + Hash + Debug;
type ExceptionKind: Clone + Eq + Debug;
type Type: Clone + Eq + Hash + Debug;
type OriginalInstruction: Clone + Debug;
type LocalSignature: Clone + Debug;
type Capability: Copy + Eq + Hash + Debug + 'static;
Show 43 methods
// Required methods
fn ptr_bytes(&self) -> u32;
fn synthetic_instruction() -> Self::OriginalInstruction;
fn unknown_type() -> Self::Type;
fn is_integer(t: &Self::Type) -> bool;
fn is_floating(t: &Self::Type) -> bool;
fn is_signed(t: &Self::Type) -> bool;
fn is_pointer(t: &Self::Type) -> bool;
fn is_reference(t: &Self::Type) -> bool;
fn is_unknown(t: &Self::Type) -> bool;
fn bit_width(t: &Self::Type) -> Option<u32>;
fn instruction_mnemonic(instr: &Self::OriginalInstruction) -> &'static str;
fn instruction_rva(instr: &Self::OriginalInstruction) -> u64;
fn is_filter_handler(flags: &Self::ExceptionKind) -> bool;
// Provided methods
fn endianness(&self) -> Endianness { ... }
fn is_vector(t: &Self::Type) -> bool { ... }
fn vector_shape(_t: &Self::Type) -> Option<VectorShape> { ... }
fn scalable_vector_shape(_t: &Self::Type) -> Option<ScalableVectorShape> { ... }
fn vector_descriptor(t: &Self::Type) -> Option<VectorDescriptor> { ... }
fn vector_type(_shape: VectorShape) -> Option<Self::Type> { ... }
fn scalable_vector_type(_shape: ScalableVectorShape) -> Option<Self::Type> { ... }
fn vector_lane_type(_shape: VectorShape) -> Option<Self::Type> { ... }
fn scalable_vector_lane_type(
_shape: ScalableVectorShape,
) -> Option<Self::Type> { ... }
fn vector_descriptor_lane_type(
shape: VectorDescriptor,
) -> Option<Self::Type> { ... }
fn vector_mask_shape(_t: &Self::Type) -> Option<VectorMaskShape> { ... }
fn scalable_vector_mask_shape(
_t: &Self::Type,
) -> Option<ScalableVectorMaskShape> { ... }
fn vector_mask_descriptor(t: &Self::Type) -> Option<VectorMaskDescriptor> { ... }
fn vector_mask_type(_shape: VectorMaskShape) -> Option<Self::Type> { ... }
fn scalable_vector_mask_type(
_shape: ScalableVectorMaskShape,
) -> Option<Self::Type> { ... }
fn vector_mask_descriptor_type(
shape: VectorMaskDescriptor,
) -> Option<Self::Type> { ... }
fn field_member_index(_field: &Self::FieldRef) -> Option<u32> { ... }
fn result_type_for_const(_value: &ConstValue<Self>) -> Option<Self::Type> { ... }
fn comparison_result_type() -> Option<Self::Type> { ... }
fn arithmetic_result_type() -> Option<Self::Type> { ... }
fn native_int_result_type() -> Option<Self::Type> { ... }
fn ckfinite_result_type() -> Option<Self::Type> { ... }
fn function_ptr_result_type() -> Option<Self::Type> { ... }
fn object_result_type() -> Option<Self::Type> { ... }
fn value_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type> { ... }
fn byref_value_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type> { ... }
fn byref_class_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type> { ... }
fn convert_const(
_value: &ConstValue<Self>,
_target_type: &Self::Type,
_unsigned_source: bool,
_ptr_bytes: u32,
) -> Option<ConstValue<Self>> { ... }
fn convert_const_checked(
_value: &ConstValue<Self>,
_target_type: &Self::Type,
_unsigned_source: bool,
_ptr_bytes: u32,
) -> Option<ConstValue<Self>> { ... }
fn evaluate_int_conv(
_value: i64,
_target_type: &Self::Type,
_unsigned: bool,
_ptr_bytes: u32,
) -> Option<ConstValue<Self>> { ... }
}Expand description
The abstraction that makes the SSA IR core generic over an instruction set. See module docs.
Clone + Debug + Eq + Hash supertraits exist so derive macros on the
generic IR types (ConstValue<T>, SsaOp<T>, SsaInstruction<T>,
SsaFunction<T>, MemoryLocation<T>, …) do not need manual impls. The
implementation cost is negligible for marker-style impls.
Required Associated Types§
Sourcetype TypeRef: Clone + Eq + Hash + Debug
type TypeRef: Clone + Eq + Hash + Debug
Reference to a user-defined or built-in type in the host’s metadata.
Sourcetype SigRef: Clone + Eq + Hash + Debug
type SigRef: Clone + Eq + Hash + Debug
Reference to a standalone signature in the host’s metadata.
Sourcetype ExceptionKind: Clone + Eq + Debug
type ExceptionKind: Clone + Eq + Debug
Host-defined exception-handler kind (e.g. EXCEPTION/FINALLY/FILTER on CIL).
Sourcetype OriginalInstruction: Clone + Debug
type OriginalInstruction: Clone + Debug
Original-instruction breadcrumb retained on each SsaInstruction for
debugging and source mapping. Hosts that don’t want this can use ().
Sourcetype LocalSignature: Clone + Debug
type LocalSignature: Clone + Debug
Local-variable signature data preserved through SSA construction. Used by codegen to recover types that aren’t structurally reconstructible from the SSA op stream.
Sourcetype Capability: Copy + Eq + Hash + Debug + 'static
type Capability: Copy + Eq + Hash + Debug + 'static
Pass-pipeline capability tag used by the analyssa scheduler for
dependency-aware ordering. Hosts that don’t run the pass scheduler
can use (). Hosts that do should embed
crate::scheduling::DeobfuscationCapability in their concrete
enum so generic analyssa passes can declare provides/requires using
the shared deobfuscation vocabulary.
Required Methods§
Sourcefn ptr_bytes(&self) -> u32
fn ptr_bytes(&self) -> u32
Pointer width in bytes (typically 4 or 8). Runtime so bi-arch hosts can vary it per-instance.
Sourcefn synthetic_instruction() -> Self::OriginalInstruction
fn synthetic_instruction() -> Self::OriginalInstruction
Returns a placeholder original-instruction value for synthetic IR nodes (e.g., phi-node carriers, transform-inserted instructions).
Sourcefn unknown_type() -> Self::Type
fn unknown_type() -> Self::Type
The canonical “unknown / not-yet-inferred” type. Used by builders and fixtures that haven’t run inference.
Sourcefn is_integer(t: &Self::Type) -> bool
fn is_integer(t: &Self::Type) -> bool
true if t is an integer type (any width, signed or unsigned).
Sourcefn is_floating(t: &Self::Type) -> bool
fn is_floating(t: &Self::Type) -> bool
true if t is a floating-point type.
Sourcefn is_pointer(t: &Self::Type) -> bool
fn is_pointer(t: &Self::Type) -> bool
true if t is a pointer or managed reference (byref) to another type.
Sourcefn is_reference(t: &Self::Type) -> bool
fn is_reference(t: &Self::Type) -> bool
true if t is a reference type (object/string/class/array).
Sourcefn is_unknown(t: &Self::Type) -> bool
fn is_unknown(t: &Self::Type) -> bool
true if t is the unknown / not-yet-inferred type.
Sourcefn bit_width(t: &Self::Type) -> Option<u32>
fn bit_width(t: &Self::Type) -> Option<u32>
Bit-width for primitive types where it is statically known. None for
pointer-sized integers, references, and aggregates.
Sourcefn instruction_mnemonic(instr: &Self::OriginalInstruction) -> &'static str
fn instruction_mnemonic(instr: &Self::OriginalInstruction) -> &'static str
Mnemonic for the original instruction breadcrumb (e.g. "add", "ret").
Hosts that don’t carry a real instruction return a placeholder.
Sourcefn instruction_rva(instr: &Self::OriginalInstruction) -> u64
fn instruction_rva(instr: &Self::OriginalInstruction) -> u64
RVA of the original instruction. Hosts without source mapping return 0.
Sourcefn is_filter_handler(flags: &Self::ExceptionKind) -> bool
fn is_filter_handler(flags: &Self::ExceptionKind) -> bool
true if flags denotes a filter-style exception handler (i.e. one
that runs a user-supplied predicate before catching). Hosts without a
filter notion return false.
Provided Methods§
Sourcefn endianness(&self) -> Endianness
fn endianness(&self) -> Endianness
Byte ordering for multi-byte values in memory.
Returns Endianness::Little by default, which covers x86, RISC-V,
and the default mode of most modern ISAs. Hosts that target bi-endian
architectures (MIPS, ARM) or big-endian-only architectures (SPARC,
z/Arch) should override this.
Sourcefn vector_shape(_t: &Self::Type) -> Option<VectorShape>
fn vector_shape(_t: &Self::Type) -> Option<VectorShape>
Returns the target-independent vector shape for t, if known.
Sourcefn scalable_vector_shape(_t: &Self::Type) -> Option<ScalableVectorShape>
fn scalable_vector_shape(_t: &Self::Type) -> Option<ScalableVectorShape>
Returns the scalable vector shape for t, if known.
Sourcefn vector_descriptor(t: &Self::Type) -> Option<VectorDescriptor>
fn vector_descriptor(t: &Self::Type) -> Option<VectorDescriptor>
Returns the fixed or scalable vector descriptor for t, if known.
Sourcefn vector_type(_shape: VectorShape) -> Option<Self::Type>
fn vector_type(_shape: VectorShape) -> Option<Self::Type>
Returns the target type for shape, if the target supports it.
Sourcefn scalable_vector_type(_shape: ScalableVectorShape) -> Option<Self::Type>
fn scalable_vector_type(_shape: ScalableVectorShape) -> Option<Self::Type>
Returns the target type for scalable shape, if the target supports it.
Sourcefn vector_lane_type(_shape: VectorShape) -> Option<Self::Type>
fn vector_lane_type(_shape: VectorShape) -> Option<Self::Type>
Returns the scalar lane type for shape, if the target supports it.
Sourcefn scalable_vector_lane_type(_shape: ScalableVectorShape) -> Option<Self::Type>
fn scalable_vector_lane_type(_shape: ScalableVectorShape) -> Option<Self::Type>
Returns the scalar lane type for scalable shape, if the target supports it.
Sourcefn vector_descriptor_lane_type(shape: VectorDescriptor) -> Option<Self::Type>
fn vector_descriptor_lane_type(shape: VectorDescriptor) -> Option<Self::Type>
Returns the scalar lane type for fixed or scalable shape, if supported.
Sourcefn vector_mask_shape(_t: &Self::Type) -> Option<VectorMaskShape>
fn vector_mask_shape(_t: &Self::Type) -> Option<VectorMaskShape>
Returns the fixed vector mask shape for t, if known.
Sourcefn scalable_vector_mask_shape(
_t: &Self::Type,
) -> Option<ScalableVectorMaskShape>
fn scalable_vector_mask_shape( _t: &Self::Type, ) -> Option<ScalableVectorMaskShape>
Returns the scalable vector mask shape for t, if known.
Sourcefn vector_mask_descriptor(t: &Self::Type) -> Option<VectorMaskDescriptor>
fn vector_mask_descriptor(t: &Self::Type) -> Option<VectorMaskDescriptor>
Returns the fixed or scalable vector mask descriptor for t, if known.
Sourcefn vector_mask_type(_shape: VectorMaskShape) -> Option<Self::Type>
fn vector_mask_type(_shape: VectorMaskShape) -> Option<Self::Type>
Returns the target mask type for shape, if the target supports it.
Sourcefn scalable_vector_mask_type(
_shape: ScalableVectorMaskShape,
) -> Option<Self::Type>
fn scalable_vector_mask_type( _shape: ScalableVectorMaskShape, ) -> Option<Self::Type>
Returns the target scalable mask type for shape, if the target supports it.
Sourcefn vector_mask_descriptor_type(
shape: VectorMaskDescriptor,
) -> Option<Self::Type>
fn vector_mask_descriptor_type( shape: VectorMaskDescriptor, ) -> Option<Self::Type>
Returns the target mask type for fixed or scalable shape, if supported.
Sourcefn field_member_index(_field: &Self::FieldRef) -> Option<u32>
fn field_member_index(_field: &Self::FieldRef) -> Option<u32>
Declaration-order member index of field within its parent composite,
when the host has resolved one.
Field-sensitive analyses (points-to, alias partitioning) use this to keep
distinct members of the same object disjoint; None means the field is
unresolved and must fall back to the sound whole-object approximation.
Defaults to None, which is exactly that conservative fallback.
Sourcefn result_type_for_const(_value: &ConstValue<Self>) -> Option<Self::Type>
fn result_type_for_const(_value: &ConstValue<Self>) -> Option<Self::Type>
Result type for a Const op; mapped from the ConstValue variant.
Sourcefn comparison_result_type() -> Option<Self::Type>
fn comparison_result_type() -> Option<Self::Type>
Result type of a comparison op (Ceq, Clt, Cgt).
Sourcefn arithmetic_result_type() -> Option<Self::Type>
fn arithmetic_result_type() -> Option<Self::Type>
Result type of plain integer arithmetic ops (Add, Sub, …, SizeOf).
Sourcefn native_int_result_type() -> Option<Self::Type>
fn native_int_result_type() -> Option<Self::Type>
Result type of LocalAlloc and ArrayLength ops (CIL: native int).
Sourcefn ckfinite_result_type() -> Option<Self::Type>
fn ckfinite_result_type() -> Option<Self::Type>
Result type of Ckfinite (CIL: F64).
Sourcefn function_ptr_result_type() -> Option<Self::Type>
fn function_ptr_result_type() -> Option<Self::Type>
Result type of LoadFunctionPtr / LoadVirtFunctionPtr (CIL: native int).
Sourcefn object_result_type() -> Option<Self::Type>
fn object_result_type() -> Option<Self::Type>
Result type of object-producing ops (Box, NewObj, NewArr,
CastClass, IsInst).
Sourcefn value_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type>
fn value_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type>
Result type of UnboxAny / LoadObj: a value-typed view of r.
Sourcefn byref_value_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type>
fn byref_value_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type>
Result type of Unbox: a managed reference (byref) to the
value-typed view of r.
Sourcefn byref_class_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type>
fn byref_class_type_from_ref(_r: &Self::TypeRef) -> Option<Self::Type>
Result type of LoadElementAddr: a managed reference (byref) to a
class-typed element of r.
Sourcefn convert_const(
_value: &ConstValue<Self>,
_target_type: &Self::Type,
_unsigned_source: bool,
_ptr_bytes: u32,
) -> Option<ConstValue<Self>>
fn convert_const( _value: &ConstValue<Self>, _target_type: &Self::Type, _unsigned_source: bool, _ptr_bytes: u32, ) -> Option<ConstValue<Self>>
Convert a constant value to target_type. Used by ConstValue::convert_to
(CIL conv.* semantics). ptr_bytes is the host’s pointer width
(typically 4 or 8). Default None means “unsupported”.
Sourcefn convert_const_checked(
_value: &ConstValue<Self>,
_target_type: &Self::Type,
_unsigned_source: bool,
_ptr_bytes: u32,
) -> Option<ConstValue<Self>>
fn convert_const_checked( _value: &ConstValue<Self>, _target_type: &Self::Type, _unsigned_source: bool, _ptr_bytes: u32, ) -> Option<ConstValue<Self>>
Convert a constant value to target_type with overflow checking. Used
by ConstValue::convert_to_checked (CIL conv.ovf.* semantics).
Returns None if the conversion would overflow or is unsupported.
Sourcefn evaluate_int_conv(
_value: i64,
_target_type: &Self::Type,
_unsigned: bool,
_ptr_bytes: u32,
) -> Option<ConstValue<Self>>
fn evaluate_int_conv( _value: i64, _target_type: &Self::Type, _unsigned: bool, _ptr_bytes: u32, ) -> Option<ConstValue<Self>>
Evaluator-side integer conversion: produce a typed ConstValue from
a raw i64 value and a target type. Used by SsaEvaluator to apply
CIL conv.* truncation/extension semantics. Default None means the
caller falls back to wrapping the raw i64.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".