Implement SystemV struct argument passing

This commit is contained in:
bjorn3
2020-04-20 12:01:53 +02:00
committed by Benjamin Bouvier
parent 2f368ed5d6
commit 4431ac1108
15 changed files with 298 additions and 50 deletions

View File

@@ -0,0 +1,57 @@
test compile
set is_pic
target x86_64
function u0:0(i64 sarg(64)) -> i8 system_v {
block0(v0: i64):
v1 = load.i8 v0
return v1
}
; check: function u0:0(sarg__ sarg(64) [0], i64 fp [%rbp]) -> i8 [%rax], i64 fp [%rbp] system_v {
; nextln: ss0 = incoming_arg 64, offset 0
; nextln: ss1 = incoming_arg 16, offset -16
; check: block0(v3: sarg__ [ss0], v5: i64 [%rbp]):
; nextln: [RexOp1pushq#50] x86_push v5
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
; nextln: [RexOp1spaddr_id#808d,%rax] v2 = stack_addr.i64 ss0
; nextln: v0 -> v2
; nextln: [RexOp2ld#4b6,%rax] v4 = uload8.i32 v2
; nextln: [null#00,%rax] v1 = ireduce.i8 v4
; nextln: [RexOp1popq#58,%rbp] v6 = x86_pop.i64
; nextln: [Op1ret#c3] return v1, v6
; nextln: }
function u0:1(i64) -> i8 system_v {
fn1 = u0:0(i64 sarg(64)) -> i8 system_v
block0(v0: i64):
v1 = call fn1(v0)
return v1
}
; check: function u0:1(i64 [%rdi], i64 fp [%rbp]) -> i8 [%rax], i64 fp [%rbp] system_v {
; nextln: ss0 = outgoing_arg 64, offset 0
; nextln: ss1 = incoming_arg 16, offset -16
; nextln: sig0 = (sarg__ sarg(64) [0]) -> i8 [%rax] system_v
; nextln: sig1 = (i64 [%rdi], i64 [%rsi], i64 [%rdx]) system_v
; nextln: fn1 = u0:0 sig0
; nextln: fn2 = %Memcpy sig1
; check: block0(v0: i64 [%rdi], v5: i64 [%rbp]):
; nextln: [RexOp1pushq#50] x86_push v5
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
; nextln: [RexOp1adjustsp_ib#d083] adjust_sp_down_imm 64
; nextln: [RexOp1spaddr_id#808d,%rax] v2 = stack_addr.i64 ss0
; nextln: [RexOp1pu_id#b8,%rcx] v3 = iconst.i64 64
; nextln: [RexOp1rmov#8089] regmove v0, %rdi -> %rsi
; nextln: [RexOp1rmov#8089] regmove v2, %rax -> %rdi
; nextln: [RexOp1rmov#8089] regmove v3, %rcx -> %rdx
; nextln: [Op1call_plt_id#e8] call fn2(v2, v0, v3)
; nextln: [dummy_sarg__#00,ss0] v4 = dummy_sarg__
; nextln: [Op1call_plt_id#e8,%rax] v1 = call fn1(v4)
; nextln: [RexOp1adjustsp_ib#8083] adjust_sp_up_imm 64
; nextln: [RexOp1popq#58,%rbp] v6 = x86_pop.i64
; nextln: [Op1ret#c3] return v1, v6
; nextln: }