Add trap codes to the Cretonne IL.

The trap and trapz/trapnz instructions now take a trap code immediate
operand which indicates the reason for trapping.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-20 13:58:57 -07:00
parent 0f21fd342a
commit e8723be33f
28 changed files with 199 additions and 62 deletions

View File

@@ -11,6 +11,7 @@ from cdsl.instructions import Instruction, InstructionGroup
from base.types import f32, f64, b1
from base.immediates import imm64, uimm8, uimm32, ieee32, ieee64, offset32
from base.immediates import boolean, intcc, floatcc, memflags, regunit
from base.immediates import trapcode
from base import entities
from cdsl.ti import WiderOrEq
import base.formats # noqa
@@ -126,11 +127,12 @@ br_table = Instruction(
""",
ins=(x, JT), is_branch=True)
code = Operand('code', trapcode)
trap = Instruction(
'trap', r"""
Terminate execution unconditionally.
""",
is_terminator=True, can_trap=True)
ins=code, is_terminator=True, can_trap=True)
trapz = Instruction(
'trapz', r"""
@@ -138,7 +140,7 @@ trapz = Instruction(
if ``c`` is non-zero, execution continues at the following instruction.
""",
ins=c, can_trap=True)
ins=(c, code), can_trap=True)
trapnz = Instruction(
'trapnz', r"""
@@ -146,7 +148,7 @@ trapnz = Instruction(
if ``c`` is zero, execution continues at the following instruction.
""",
ins=c, can_trap=True)
ins=(c, code), can_trap=True)
rvals = Operand('rvals', VARIABLE_ARGS, doc='return values')