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:
@@ -7,7 +7,7 @@ function %nonsense(i32) {
|
||||
; check: digraph %nonsense {
|
||||
|
||||
ebb0(v1: i32):
|
||||
trap ; error: terminator instruction was encountered before the end
|
||||
trap user0 ; error: terminator instruction was encountered before the end
|
||||
brnz v1, ebb2 ; unordered: ebb0:inst1 -> ebb2
|
||||
jump ebb1 ; unordered: ebb0:inst2 -> ebb1
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ function %not_reached(i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32):
|
||||
brnz v0, ebb2 ; unordered: ebb0:inst0 -> ebb2
|
||||
trap
|
||||
trap user0
|
||||
|
||||
ebb1:
|
||||
v1 = iconst.i32 1
|
||||
|
||||
@@ -369,5 +369,5 @@ ebb1:
|
||||
|
||||
; asm: ebb2:
|
||||
ebb2:
|
||||
trap ; bin: 0f 0b
|
||||
trap user0 ; bin: 0f 0b
|
||||
}
|
||||
|
||||
@@ -861,5 +861,5 @@ ebb0:
|
||||
; asm: movl %r10d, %ecx
|
||||
[-,%rcx] v32 = uextend.i64 v13 ; bin: 44 89 d1
|
||||
|
||||
trap ; bin: 0f 0b
|
||||
trap user0 ; bin: 0f 0b
|
||||
}
|
||||
|
||||
@@ -9,22 +9,22 @@ isa intel
|
||||
|
||||
function %cond_trap(i32) {
|
||||
ebb0(v1: i32):
|
||||
trapz v1
|
||||
trapz v1, user67
|
||||
return
|
||||
; check: $ebb0($v1: i32):
|
||||
; nextln: brnz $v1, $(new=$EBB)
|
||||
; nextln: trap
|
||||
; nextln: trap user67
|
||||
; check: $new:
|
||||
; nextln: return
|
||||
}
|
||||
|
||||
function %cond_trap2(i32) {
|
||||
ebb0(v1: i32):
|
||||
trapnz v1
|
||||
trapnz v1, int_ovf
|
||||
return
|
||||
; check: $ebb0($v1: i32):
|
||||
; nextln: brz $v1, $(new=$EBB)
|
||||
; nextln: trap
|
||||
; nextln: trap int_ovf
|
||||
; check: $new:
|
||||
; nextln: return
|
||||
}
|
||||
@@ -32,11 +32,11 @@ ebb0(v1: i32):
|
||||
function %cond_trap_b1(i32) {
|
||||
ebb0(v1: i32):
|
||||
v2 = icmp_imm eq v1, 6
|
||||
trapz v2
|
||||
trapz v2, user7
|
||||
return
|
||||
; check: $ebb0($v1: i32):
|
||||
; check: brnz $v2, $(new=$EBB)
|
||||
; nextln: trap
|
||||
; nextln: trap user7
|
||||
; check: $new:
|
||||
; nextln: return
|
||||
}
|
||||
@@ -44,11 +44,11 @@ ebb0(v1: i32):
|
||||
function %cond_trap2_b1(i32) {
|
||||
ebb0(v1: i32):
|
||||
v2 = icmp_imm eq v1, 6
|
||||
trapnz v2
|
||||
trapnz v2, user9
|
||||
return
|
||||
; check: $ebb0($v1: i32):
|
||||
; check: brz $v2, $(new=$EBB)
|
||||
; nextln: trap
|
||||
; nextln: trap user9
|
||||
; check: $new:
|
||||
; nextln: return
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ ebb0(v0: i32, v999: i64):
|
||||
; Boundscheck code
|
||||
; check: $(oob=$V) = icmp
|
||||
; nextln: brz $oob, $(ok=$EBB)
|
||||
; nextln: trap
|
||||
; nextln: trap heap_oob
|
||||
; check: $ok:
|
||||
; Checks here are assuming that no pipehole opts fold the load offsets.
|
||||
; nextln: $(xoff=$V) = uextend.i64 $v0
|
||||
|
||||
@@ -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: }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -4,10 +4,10 @@ set return_at_end
|
||||
function %ok(i32) {
|
||||
ebb0(v0: i32):
|
||||
brnz v0, ebb1
|
||||
trap
|
||||
trap int_divz
|
||||
|
||||
ebb1:
|
||||
trapz v0
|
||||
trapz v0, user5
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,6 +17,6 @@ ebb0(v0: i32):
|
||||
return ; error: Internal return not allowed
|
||||
|
||||
ebb1:
|
||||
trapz v0
|
||||
trapz v0, user6
|
||||
return
|
||||
}
|
||||
|
||||
@@ -46,5 +46,5 @@ ebb1(v2: i32):
|
||||
|
||||
function %undefined() {
|
||||
ebb0:
|
||||
trap
|
||||
trap user0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user