Add a trapff instruction.

This is the floating point equivalent of trapif: Trap when a given
condition is in the floating-point flags.

Define Intel encodings comparable to the trapif encodings.
This commit is contained in:
Jakob Stoklund Olesen
2018-02-20 14:35:41 -08:00
parent 1e56d44465
commit b9b1d0fcd5
12 changed files with 91 additions and 1 deletions

View File

@@ -357,6 +357,8 @@ I64.enc(base.trap, *r.trap(0x0f, 0x0b))
# Using a standard EncRecipe, not the TailRecipe.
I32.enc(base.trapif, r.trapif, 0)
I64.enc(base.trapif, r.trapif, 0)
I32.enc(base.trapff, r.trapff, 0)
I64.enc(base.trapff, r.trapff, 0)
#
# Comparisons

View File

@@ -8,7 +8,7 @@ from cdsl.registers import RegClass
from base.formats import Unary, UnaryImm, Binary, BinaryImm, MultiAry, NullAry
from base.formats import Trap, Call, IndirectCall, Store, Load
from base.formats import IntCompare, FloatCompare, IntCond, FloatCond
from base.formats import IntSelect, IntCondTrap
from base.formats import IntSelect, IntCondTrap, FloatCondTrap
from base.formats import Jump, Branch, BranchInt, BranchFloat
from base.formats import Ternary, FuncAddr, UnaryGlobalVar
from base.formats import RegMove, RegSpill, RegFill, CopySpecial
@@ -292,6 +292,20 @@ trapif = EncRecipe(
sink.put1(0x0b);
''')
trapff = EncRecipe(
'trapff', FloatCondTrap, size=4, ins=FLAG.eflags, outs=(),
clobbers_flags=False,
instp=floatccs(FloatCondTrap),
emit='''
// Jump over a 2-byte ud2.
sink.put1(0x70 | (fcc2opc(cond.inverse()) as u8));
sink.put1(2);
// ud2.
sink.put1(0x0f);
sink.put1(0x0b);
''')
# XX /r
rr = TailRecipe(
'rr', Binary, size=1, ins=(GPR, GPR), outs=0,