Skip to main content

MirError

Enum MirError 

Source
#[non_exhaustive]
pub enum MirError {
Show 25 variants UnknownOpcode { inst: Inst, opcode: Opcode, }, OperandCount { inst: Inst, expected: usize, found: usize, }, OperandShape { inst: Inst, index: usize, }, RegClass { inst: Inst, index: usize, }, ImmediateRange { inst: Inst, index: usize, value: i64, }, TooManyMemOperands { inst: Inst, }, ArgCount { inst: Inst, block: Block, expected: usize, found: usize, }, ArgClass { inst: Inst, block: Block, index: usize, }, DuplicateDestination { inst: Inst, }, BadParam { block: Block, }, BadArg { block: Block, }, UnknownVReg(VReg), UnknownPReg(PReg), UnknownSlot(StackSlot), UnknownBlock(Block), UnknownSymbol(Symbol), UnknownClass(RegClass), MultipleDefs { vreg: VReg, }, MissingTerminator { block: Block, }, MisplacedTerminator { inst: Inst, }, NoBlocks, NotACall { inst: Inst, }, UndefinedVReg { vreg: VReg, }, NotDominated { vreg: VReg, inst: Inst, }, Limit,
}
Expand description

Why an instruction or function is malformed.

Every variant names where the problem is: the instruction (and operand index), the block, or the entity that does not exist.

§Examples

use backend_lang::mir::{Function, MirError, Operand};
use backend_lang::x86_64::{op, SYSV, XMM0};

let mut f = Function::new("f", &SYSV);
let b = f.block()?;
// A vector register where add64 wants a general-purpose one.
let err = f.push(b, op::ADD64, &[XMM0.into(), XMM0.into(), Operand::Imm(1)]).unwrap_err();
assert!(matches!(err, MirError::RegClass { index: 0, .. }));
assert_eq!(err.to_string(), "inst0: operand 0 is a register of the wrong class");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

UnknownOpcode

The target has no such opcode.

Fields

§inst: Inst

The instruction.

§opcode: Opcode

The opcode.

§

OperandCount

The instruction has the wrong number of explicit operands. (For pcopy, an odd number.)

Fields

§inst: Inst

The instruction.

§expected: usize

How many the opcode takes.

§found: usize

How many were given.

§

OperandShape

An operand has a shape its position does not take (a memory operand where only a register fits, a slot with an offset in a copy, an unknown condition code, …). The opcode’s OperandRules list what fits.

Fields

§inst: Inst

The instruction.

§index: usize

The operand’s position.

§

RegClass

A register operand is of the wrong class (or, for a tied use or a copy, not of its partner’s class).

Fields

§inst: Inst

The instruction.

§index: usize

The operand’s position.

§

ImmediateRange

An immediate is outside the range its position takes. Load wider constants into a register first (mov64ri).

Fields

§inst: Inst

The instruction.

§index: usize

The operand’s position.

§value: i64

The immediate.

§

TooManyMemOperands

The instruction has more memory operands than the target allows in one instruction (one, on x86-64).

Fields

§inst: Inst

The instruction.

§

ArgCount

A branch passes a different number of arguments than its target block has parameters. (Add a block’s parameters before branches to it.)

Fields

§inst: Inst

The branch.

§block: Block

The target block.

§expected: usize

The block’s parameter count.

§found: usize

The arguments given.

§

ArgClass

A branch argument’s class differs from its parameter’s.

Fields

§inst: Inst

The branch.

§block: Block

The target block.

§index: usize

The argument’s position.

§

DuplicateDestination

A parallel copy writes the same register or slot twice.

Fields

§inst: Inst

The copy.

§

BadParam

A block parameter that is not a register or a whole stack slot.

Fields

§block: Block

The block.

§

BadArg

A branch argument that is not a register, a whole stack slot, or an immediate.

Fields

§block: Block

The target block.

§

UnknownVReg(VReg)

A virtual register the function does not have.

§

UnknownPReg(PReg)

A physical register the target does not have.

§

UnknownSlot(StackSlot)

A stack slot the function does not have.

§

UnknownBlock(Block)

A block the function does not have, or a branch target this function did not make.

§

UnknownSymbol(Symbol)

A symbol the function does not have.

§

UnknownClass(RegClass)

A register class the target does not have.

§

MultipleDefs

A virtual register is defined more than once (by instructions or as a block parameter). Before register allocation MIR is in SSA form.

Fields

§vreg: VReg

The register.

§

MissingTerminator

A block does not end with a terminator (jump, branch, return, trap), or is empty.

Fields

§block: Block

The block.

§

MisplacedTerminator

A terminator is followed by more instructions in its block.

Fields

§inst: Inst

The terminator.

§

NoBlocks

The function has no blocks.

§

NotACall

A call-site record (stack map or landing pad) names an instruction that is not a call.

Fields

§inst: Inst

The instruction.

§

UndefinedVReg

A virtual register is used but never defined (Function::verify_ssa).

Fields

§vreg: VReg

The register.

§

NotDominated

A use of a virtual register in a block reachable from the entry is not dominated by its definition (Function::verify_ssa).

Fields

§vreg: VReg

The register.

§inst: Inst

The instruction that uses it.

§

Limit

A table of the function (instructions, operands, blocks, …) would exceed its 32-bit ids, or virtual registers would exceed VReg::MAX.

Trait Implementations§

Source§

impl Clone for MirError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MirError

Source§

impl Debug for MirError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for MirError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for MirError

Source§

impl Error for MirError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<MirError> for IselError

Source§

fn from(e: MirError) -> IselError

Converts to this type from the input type.
Source§

impl From<MirError> for RegAllocError

Source§

fn from(e: MirError) -> RegAllocError

Converts to this type from the input type.
Source§

impl From<MirError> for EmitError

Source§

fn from(e: MirError) -> EmitError

Converts to this type from the input type.
Source§

impl Hash for MirError

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MirError

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MirError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.