x64: Migrate trapif and trapff to ISLE (#4545)
https://github.com/bytecodealliance/wasmtime/pull/4545
This commit is contained in:
@@ -926,65 +926,12 @@ fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
|
||||
| Opcode::FallthroughReturn
|
||||
| Opcode::Return
|
||||
| Opcode::Call
|
||||
| Opcode::CallIndirect => {
|
||||
| Opcode::CallIndirect
|
||||
| Opcode::Trapif
|
||||
| Opcode::Trapff => {
|
||||
implemented_in_isle(ctx);
|
||||
}
|
||||
|
||||
Opcode::Trapif | Opcode::Trapff => {
|
||||
let trap_code = ctx.data(insn).trap_code().unwrap();
|
||||
|
||||
if matches_input(ctx, inputs[0], Opcode::IaddIfcout).is_some() {
|
||||
let cond_code = ctx.data(insn).cond_code().unwrap();
|
||||
// The flags must not have been clobbered by any other instruction between the
|
||||
// iadd_ifcout and this instruction, as verified by the CLIF validator; so we can
|
||||
// simply use the flags here.
|
||||
let cc = CC::from_intcc(cond_code);
|
||||
|
||||
ctx.emit(Inst::TrapIf { trap_code, cc });
|
||||
} else if op == Opcode::Trapif {
|
||||
let cond_code = ctx.data(insn).cond_code().unwrap();
|
||||
|
||||
// Verification ensures that the input is always a single-def ifcmp.
|
||||
let ifcmp = matches_input(ctx, inputs[0], Opcode::Ifcmp).unwrap();
|
||||
let cond_code = emit_cmp(ctx, ifcmp, cond_code);
|
||||
let cc = CC::from_intcc(cond_code);
|
||||
|
||||
ctx.emit(Inst::TrapIf { trap_code, cc });
|
||||
} else {
|
||||
let cond_code = ctx.data(insn).fp_cond_code().unwrap();
|
||||
|
||||
// Verification ensures that the input is always a single-def ffcmp.
|
||||
let ffcmp = matches_input(ctx, inputs[0], Opcode::Ffcmp).unwrap();
|
||||
|
||||
match emit_fcmp(ctx, ffcmp, cond_code, FcmpSpec::Normal) {
|
||||
FcmpCondResult::Condition(cc) => ctx.emit(Inst::TrapIf { trap_code, cc }),
|
||||
FcmpCondResult::AndConditions(cc1, cc2) => {
|
||||
// A bit unfortunate, but materialize the flags in their own register, and
|
||||
// check against this.
|
||||
let tmp = ctx.alloc_tmp(types::I32).only_reg().unwrap();
|
||||
let tmp2 = ctx.alloc_tmp(types::I32).only_reg().unwrap();
|
||||
ctx.emit(Inst::setcc(cc1, tmp));
|
||||
ctx.emit(Inst::setcc(cc2, tmp2));
|
||||
ctx.emit(Inst::alu_rmi_r(
|
||||
OperandSize::Size32,
|
||||
AluRmiROpcode::And,
|
||||
RegMemImm::reg(tmp.to_reg()),
|
||||
tmp2,
|
||||
));
|
||||
ctx.emit(Inst::TrapIf {
|
||||
trap_code,
|
||||
cc: CC::NZ,
|
||||
});
|
||||
}
|
||||
FcmpCondResult::OrConditions(cc1, cc2) => {
|
||||
ctx.emit(Inst::TrapIf { trap_code, cc: cc1 });
|
||||
ctx.emit(Inst::TrapIf { trap_code, cc: cc2 });
|
||||
}
|
||||
FcmpCondResult::InvertedEqualOrConditions(_, _) => unreachable!(),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Opcode::FcvtFromSint => {
|
||||
let output_ty = ty.unwrap();
|
||||
if !output_ty.is_vector() {
|
||||
|
||||
Reference in New Issue
Block a user