Remove trapif and trapff (#5162)
This branch removes the trapif and trapff instructions, in favor of using an explicit comparison and trapnz. This moves us closer to removing iflags and fflags, but introduces the need to implement instructions like iadd_cout in the x64 and aarch64 backends.
This commit is contained in:
@@ -11,13 +11,12 @@ block0:
|
||||
|
||||
function %trap_iadd_ifcout(i64, i64) {
|
||||
block0(v0: i64, v1: i64):
|
||||
v2, v3 = iadd_ifcout v0, v1
|
||||
trapif ult v3, user0
|
||||
v2 = uadd_overflow_trap v0, v1, user0
|
||||
return
|
||||
}
|
||||
|
||||
; block0:
|
||||
; adds x3, x0, x1
|
||||
; b.hs 8 ; udf
|
||||
; b.lo 8 ; udf
|
||||
; ret
|
||||
|
||||
|
||||
@@ -13,16 +13,19 @@ block0:
|
||||
function %g(i64) {
|
||||
block0(v0: i64):
|
||||
v1 = iconst.i64 42
|
||||
v2 = ifcmp v0, v1
|
||||
trapif eq v2, user0
|
||||
v2 = icmp eq v0, v1
|
||||
trapnz v2, user0
|
||||
return
|
||||
}
|
||||
|
||||
; block0:
|
||||
; li t2,42
|
||||
; eq a1,a0,t2##ty=i64
|
||||
; trap_if a1,user0
|
||||
; ne a1,a0,t2##ty=i64
|
||||
; bne a1,zero,taken(label1),not_taken(label2)
|
||||
; block1:
|
||||
; ret
|
||||
; block2:
|
||||
; udf##trap_code=user0
|
||||
|
||||
function %h() {
|
||||
block0:
|
||||
|
||||
@@ -14,8 +14,7 @@ block0:
|
||||
|
||||
function %trap_iadd_ifcout(i64, i64) {
|
||||
block0(v0: i64, v1: i64):
|
||||
v2, v3 = iadd_ifcout v0, v1
|
||||
trapif ult v3, user0
|
||||
v2 = uadd_overflow_trap v0, v1, user0
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -176,20 +176,20 @@ block0(v1: i32):
|
||||
function %cond_traps(i32) {
|
||||
block0(v0: i32):
|
||||
trapz v0, stk_ovf
|
||||
v1 = ifcmp_imm v0, 5
|
||||
trapif ugt v1, heap_oob
|
||||
v1 = icmp_imm ugt v0, 5
|
||||
trapnz v1, heap_oob
|
||||
v2 = bitcast.f32 v1
|
||||
v3 = ffcmp v2, v2
|
||||
trapff uno v3, int_ovf
|
||||
v3 = fcmp uno v2, v2
|
||||
trapnz v3, int_ovf
|
||||
return
|
||||
}
|
||||
; sameln: function %cond_traps(i32)
|
||||
; nextln: block0(v0: i32):
|
||||
; nextln: trapz v0, stk_ovf
|
||||
; nextln: v1 = ifcmp_imm v0, 5
|
||||
; nextln: trapif ugt v1, heap_oob
|
||||
; nextln: v1 = icmp_imm ugt v0, 5
|
||||
; nextln: trapnz v1, heap_oob
|
||||
; nextln: v2 = bitcast.f32 v1
|
||||
; nextln: v3 = ffcmp v2, v2
|
||||
; nextln: trapff uno v3, int_ovf
|
||||
; nextln: v3 = fcmp uno v2, v2
|
||||
; nextln: trapnz v3, int_ovf
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
|
||||
Reference in New Issue
Block a user