cranelift-interpreter: Implement call_indirect and return_call_indirect (#5877)

* cranelift-interpreter: Implement `call_indirect`

* cranelift: Fix typo

* riscv64: Enable `call_indirect` tests
This commit is contained in:
Afonso Bordado
2023-02-25 13:16:59 +00:00
committed by GitHub
parent 36e92add6f
commit e9095050be
6 changed files with 321 additions and 69 deletions

View File

@@ -1,9 +1,11 @@
test interpret
test run
target x86_64
target aarch64
target aarch64 sign_return_address
target aarch64 has_pauth sign_return_address
target s390x
target riscv64gc
function %callee_indirect(i64) -> i64 {

View File

@@ -0,0 +1,76 @@
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
; sig0 = (i64) -> i64 tail
block0(v0: i64):
v1 = func_addr.i64 fn0
return_call_indirect sig0, v1(v0)
}
; run: %call_i64(10) == 20
;;;; Test colocated tail calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function %colocated_i64(i64) -> i64 tail {
fn0 = colocated %callee_i64(i64) -> i64 tail
; sig0 = (i64) -> i64 tail
block0(v0: i64):
v1 = func_addr.i64 fn0
return_call_indirect sig0, v1(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
; sig0 = (f64) -> f64 tail
block0(v0: f64):
v1 = func_addr.i64 fn0
return_call_indirect sig0, v1(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
; sig0 = (i8) -> i8 tail
block0(v0: i8):
v1 = func_addr.i64 fn0
return_call_indirect sig0, v1(v0)
}
; run: %call_i8(1) == 0
; run: %call_i8(0) == 1