Cranelift: Introduce support for return_call in the interpreter (#5697)

Co-authored-by: Jamey Sharp <jsharp@fastly.com>
This commit is contained in:
Nick Fitzgerald
2023-02-03 15:53:54 -08:00
committed by GitHub
parent 72c8513411
commit e18d4cb711
3 changed files with 154 additions and 70 deletions

View File

@@ -0,0 +1,68 @@
test interpret
;; test run
;; target x86_64
;; target aarch64
;; target aarch64 sign_return_address
;; target aarch64 has_pauth sign_return_address
;; target s390x
;;;; Test passing `i64`s ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function %callee_i64(i64) -> i64 tail {
block0(v0: i64):
v1 = iadd_imm.i64 v0, 10
return v1
}
function %call_i64(i64) -> i64 tail {
fn0 = %callee_i64(i64) -> i64 tail
block0(v0: i64):
return_call fn0(v0)
}
; run: %call_i64(10) == 20
;;;; Test colocated tail calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function %colocated_i64(i64) -> i64 tail {
fn0 = colocated %callee_i64(i64) -> i64 tail
block0(v0: i64):
return_call fn0(v0)
}
; run: %colocated_i64(10) == 20
;;;; Test passing `f64`s ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function %callee_f64(f64) -> f64 tail {
block0(v0: f64):
v1 = f64const 0x10.0
v2 = fadd.f64 v0, v1
return v2
}
function %call_f64(f64) -> f64 tail {
fn0 = %callee_f64(f64) -> f64 tail
block0(v0: f64):
return_call fn0(v0)
}
; run: %call_f64(0x10.0) == 0x20.0
;;;; Test passing `i8`s ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function %callee_i8(i8) -> i8 tail {
block0(v0: i8):
v1 = iconst.i8 0
v2 = icmp eq v0, v1
return v2
}
function %call_i8(i8) -> i8 tail {
fn0 = %callee_i8(i8) -> i8 tail
block0(v0: i8):
return_call fn0(v0)
}
; run: %call_i8(1) == 0
; run: %call_i8(0) == 1