Add a trapif instruction.
This is a conditional trap controlled by integer CPU flags. Compare to brif.
This commit is contained in:
@@ -74,6 +74,7 @@ RegFill = InstructionFormat(
|
||||
|
||||
Trap = InstructionFormat(trapcode)
|
||||
CondTrap = InstructionFormat(VALUE, trapcode)
|
||||
IntCondTrap = InstructionFormat(intcc, VALUE, trapcode)
|
||||
|
||||
# Finally extract the names of global variables in this module.
|
||||
InstructionFormat.extract_names(globals())
|
||||
|
||||
@@ -167,6 +167,15 @@ trapnz = Instruction(
|
||||
""",
|
||||
ins=(c, code), can_trap=True)
|
||||
|
||||
Cond = Operand('Cond', intcc)
|
||||
f = Operand('f', iflags)
|
||||
|
||||
trapif = Instruction(
|
||||
'trapif', r"""
|
||||
Trap when condition is true in integer CPU flags.
|
||||
""",
|
||||
ins=(Cond, f, code), can_trap=True)
|
||||
|
||||
rvals = Operand('rvals', VARIABLE_ARGS, doc='return values')
|
||||
|
||||
x_return = Instruction(
|
||||
|
||||
@@ -264,6 +264,12 @@ pub enum InstructionData {
|
||||
arg: Value,
|
||||
code: ir::TrapCode,
|
||||
},
|
||||
IntCondTrap {
|
||||
opcode: Opcode,
|
||||
cond: IntCC,
|
||||
arg: Value,
|
||||
code: ir::TrapCode,
|
||||
},
|
||||
}
|
||||
|
||||
/// A variable list of `Value` operands used for function call arguments and passing arguments to
|
||||
|
||||
@@ -365,6 +365,7 @@ impl<'a> Verifier<'a> {
|
||||
CopySpecial { .. } |
|
||||
Trap { .. } |
|
||||
CondTrap { .. } |
|
||||
IntCondTrap { .. } |
|
||||
NullAry { .. } => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -428,6 +428,7 @@ pub fn write_operands(
|
||||
}
|
||||
Trap { code, .. } => write!(w, " {}", code),
|
||||
CondTrap { arg, code, .. } => write!(w, " {}, {}", arg, code),
|
||||
IntCondTrap { cond, arg, code, .. } => write!(w, " {} {}, {}", cond, arg, code),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2348,6 +2348,21 @@ impl<'a> Parser<'a> {
|
||||
let code = self.match_enum("expected trap code")?;
|
||||
InstructionData::CondTrap { opcode, arg, code }
|
||||
}
|
||||
InstructionFormat::IntCondTrap => {
|
||||
let cond = self.match_enum("expected intcc condition code")?;
|
||||
let arg = self.match_value("expected SSA value operand")?;
|
||||
self.match_token(
|
||||
Token::Comma,
|
||||
"expected ',' between operands",
|
||||
)?;
|
||||
let code = self.match_enum("expected trap code")?;
|
||||
InstructionData::IntCondTrap {
|
||||
opcode,
|
||||
cond,
|
||||
arg,
|
||||
code,
|
||||
}
|
||||
}
|
||||
};
|
||||
Ok(idata)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user