Add a trapif instruction.
This is a conditional trap controlled by integer CPU flags. Compare to brif.
This commit is contained in:
@@ -380,6 +380,7 @@ is zero.
|
|||||||
.. autoinst:: trap
|
.. autoinst:: trap
|
||||||
.. autoinst:: trapz
|
.. autoinst:: trapz
|
||||||
.. autoinst:: trapnz
|
.. autoinst:: trapnz
|
||||||
|
.. autoinst:: trapif
|
||||||
|
|
||||||
|
|
||||||
Function calls
|
Function calls
|
||||||
|
|||||||
@@ -210,3 +210,18 @@ ebb0:
|
|||||||
; nextln: copy_special %20 -> %10
|
; nextln: copy_special %20 -> %10
|
||||||
; nextln: return
|
; nextln: return
|
||||||
; nextln: }
|
; nextln: }
|
||||||
|
|
||||||
|
function %cond_traps(i32) {
|
||||||
|
ebb0(v0: i32):
|
||||||
|
trapz v0, stk_ovf
|
||||||
|
v1 = ifcmp_imm v0, 5
|
||||||
|
trapif ugt v1, oob
|
||||||
|
return
|
||||||
|
}
|
||||||
|
; sameln: function %cond_traps(i32)
|
||||||
|
; nextln: ebb0($v0: i32):
|
||||||
|
; nextln: trapz $v0, stk_ovf
|
||||||
|
; nextln: $v1 = ifcmp_imm v0, 5
|
||||||
|
; nextln: trapif ugt $v1, oob
|
||||||
|
; nextln: return
|
||||||
|
; nextln: }
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ RegFill = InstructionFormat(
|
|||||||
|
|
||||||
Trap = InstructionFormat(trapcode)
|
Trap = InstructionFormat(trapcode)
|
||||||
CondTrap = InstructionFormat(VALUE, trapcode)
|
CondTrap = InstructionFormat(VALUE, trapcode)
|
||||||
|
IntCondTrap = InstructionFormat(intcc, VALUE, trapcode)
|
||||||
|
|
||||||
# Finally extract the names of global variables in this module.
|
# Finally extract the names of global variables in this module.
|
||||||
InstructionFormat.extract_names(globals())
|
InstructionFormat.extract_names(globals())
|
||||||
|
|||||||
@@ -167,6 +167,15 @@ trapnz = Instruction(
|
|||||||
""",
|
""",
|
||||||
ins=(c, code), can_trap=True)
|
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')
|
rvals = Operand('rvals', VARIABLE_ARGS, doc='return values')
|
||||||
|
|
||||||
x_return = Instruction(
|
x_return = Instruction(
|
||||||
|
|||||||
@@ -264,6 +264,12 @@ pub enum InstructionData {
|
|||||||
arg: Value,
|
arg: Value,
|
||||||
code: ir::TrapCode,
|
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
|
/// A variable list of `Value` operands used for function call arguments and passing arguments to
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ impl<'a> Verifier<'a> {
|
|||||||
CopySpecial { .. } |
|
CopySpecial { .. } |
|
||||||
Trap { .. } |
|
Trap { .. } |
|
||||||
CondTrap { .. } |
|
CondTrap { .. } |
|
||||||
|
IntCondTrap { .. } |
|
||||||
NullAry { .. } => {}
|
NullAry { .. } => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -428,6 +428,7 @@ pub fn write_operands(
|
|||||||
}
|
}
|
||||||
Trap { code, .. } => write!(w, " {}", code),
|
Trap { code, .. } => write!(w, " {}", code),
|
||||||
CondTrap { arg, code, .. } => write!(w, " {}, {}", arg, 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")?;
|
let code = self.match_enum("expected trap code")?;
|
||||||
InstructionData::CondTrap { opcode, arg, 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)
|
Ok(idata)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user