#[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
UnknownOpcode
The target has no such opcode.
OperandCount
The instruction has the wrong number of explicit operands. (For
pcopy, an odd number.)
Fields
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.
RegClass
A register operand is of the wrong class (or, for a tied use or a copy, not of its partner’s class).
ImmediateRange
An immediate is outside the range its position takes. Load wider
constants into a register first (mov64ri).
TooManyMemOperands
The instruction has more memory operands than the target allows in one instruction (one, on x86-64).
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
ArgClass
A branch argument’s class differs from its parameter’s.
DuplicateDestination
A parallel copy writes the same register or slot twice.
BadParam
A block parameter that is not a register or a whole stack slot.
BadArg
A branch argument that is not a register, a whole stack slot, or an immediate.
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.
MissingTerminator
A block does not end with a terminator (jump, branch, return, trap), or is empty.
MisplacedTerminator
A terminator is followed by more instructions in its block.
NoBlocks
The function has no blocks.
NotACall
A call-site record (stack map or landing pad) names an instruction that is not a call.
UndefinedVReg
A virtual register is used but never defined
(Function::verify_ssa).
NotDominated
A use of a virtual register in a block reachable from the entry is not
dominated by its definition (Function::verify_ssa).
Limit
A table of the function (instructions, operands, blocks, …) would
exceed its 32-bit ids, or virtual registers would exceed
VReg::MAX.
Trait Implementations§
impl Copy for MirError
impl Eq for MirError
Source§impl Error for MirError
impl Error for MirError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()