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

@@ -86,13 +86,13 @@ function %jumptable(i32) {
ebb10(v3: i32):
br_table v3, jt2
trap
trap user1
ebb20:
trap
trap user2
ebb30:
trap
trap user3
ebb40:
trap
trap user4
}
; sameln: function %jumptable(i32) native {
; nextln: jt0 = jump_table 0
@@ -100,14 +100,14 @@ ebb40:
; nextln:
; nextln: ebb0($v3: i32):
; nextln: br_table $v3, jt1
; nextln: trap
; nextln: trap user1
; nextln:
; nextln: ebb1:
; nextln: trap
; nextln: trap user2
; nextln:
; nextln: ebb2:
; nextln: trap
; nextln: trap user3
; nextln:
; nextln: ebb3:
; nextln: trap
; nextln: trap user4
; nextln: }

View File

@@ -7,7 +7,7 @@ isa riscv
function %foo(i32, i32) {
ebb1(v0: i32 [%x8], v1: i32):
[-,-] v2 = iadd v0, v1
[-] trap
[-] trap heap_oob
[R#1234, %x5, %x11] v6, v7 = iadd_cout v2, v0
[Rshamt#beef, %x25] v8 = ishl_imm v6, 2
v9 = iadd v8, v7
@@ -16,7 +16,7 @@ ebb1(v0: i32 [%x8], v1: i32):
; sameln: function %foo(i32, i32) native {
; nextln: $ebb1($v0: i32 [%x8], $v1: i32):
; nextln: [-,-]$WS $v2 = iadd $v0, $v1
; nextln: [-]$WS trap
; nextln: [-]$WS trap heap_oob
; nextln: [R#1234,%x5,%x11]$WS $v6, $v7 = iadd_cout $v2, $v0
; nextln: [Rshamt#beef,%x25]$WS $v8 = ishl_imm $v6, 2
; nextln: [-,-]$WS $v9 = iadd $v8, $v7

View File

@@ -13,13 +13,13 @@ function %defs() {
ebb100(v20: i32):
v1000 = iconst.i32x8 5
v9200 = f64const 0x4.0p0
trap
trap user4
}
; sameln: function %defs() native {
; nextln: $ebb100($v20: i32):
; nextln: $v1000 = iconst.i32x8 5
; nextln: $v9200 = f64const 0x1.0000000000000p2
; nextln: trap
; nextln: trap user4
; nextln: }
; Using values.

View File

@@ -3,11 +3,11 @@ test cat
; The smallest possible function.
function %minimal() {
ebb0:
trap
trap user0
}
; sameln: function %minimal() native {
; nextln: ebb0:
; nextln: trap
; nextln: trap user0
; nextln: }
; Create and use values.