1; For ELFv2 ABI, we can avoid allocating the parameter area in the stack frame of the caller function
2; if all the arguments can be passed to the callee in registers.
3; For ELFv1 ABI, we always need to allocate the parameter area.
4
5; Tests for ELFv2 ABI
6; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=PPC64-ELFV2
7; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv2 < %s | FileCheck %s -check-prefix=PPC64-ELFV2
8
9; Tests for ELFv1 ABI
10; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=PPC64-ELFV1
11; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -target-abi elfv1 < %s | FileCheck %s -check-prefix=PPC64-ELFV1
12
13; If the callee has at most eight integer args, parameter area can be ommited for ELFv2 ABI.
14
15; PPC64-ELFV2-LABEL: WithoutParamArea1:
16; PPC64-ELFV2-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
17; PPC64-ELFV2: stdu 1, -32(1)
18; PPC64-ELFV2: addi 1, 1, 32
19; PPC64-ELFV2-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
20; PPC64-ELFV1-LABEL: WithoutParamArea1:
21; PPC64-ELFV1-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
22; PPC64-ELFV1: stdu 1, -112(1)
23; PPC64-ELFV1: addi 1, 1, 112
24; PPC64-ELFV1-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
25define signext i32 @WithoutParamArea1(i32 signext %a) local_unnamed_addr #0 {
26entry:
27  %call = tail call signext i32 @onearg(i32 signext %a) #2
28  ret i32 %call
29}
30
31; PPC64-ELFV2-LABEL: WithoutParamArea2:
32; PPC64-ELFV2-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
33; PPC64-ELFV2: stdu 1, -32(1)
34; PPC64-ELFV2: addi 1, 1, 32
35; PPC64-ELFV2-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
36; PPC64-ELFV1-LABEL: WithoutParamArea2:
37; PPC64-ELFV1-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
38; PPC64-ELFV1: stdu 1, -112(1)
39; PPC64-ELFV1: addi 1, 1, 112
40; PPC64-ELFV1-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
41define signext i32 @WithoutParamArea2(i32 signext %a) local_unnamed_addr #0 {
42entry:
43  %call = tail call signext i32 @eightargs(i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a) #2
44  ret i32 %call
45}
46
47; If the callee has more than eight integer args or variable number of args,
48; parameter area cannot be ommited even for ELFv2 ABI
49
50; PPC64-ELFV2-LABEL: WithParamArea1:
51; PPC64-ELFV2-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
52; PPC64-ELFV2: stdu 1, -96(1)
53; PPC64-ELFV2: addi 1, 1, 96
54; PPC64-ELFV2-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
55; PPC64-ELFV1-LABEL: WithParamArea1:
56; PPC64-ELFV1-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
57; PPC64-ELFV1: stdu 1, -112(1)
58; PPC64-ELFV1: addi 1, 1, 112
59; PPC64-ELFV1-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
60define signext i32 @WithParamArea1(i32 signext %a) local_unnamed_addr #0 {
61entry:
62  %call = tail call signext i32 (i32, ...) @varargs(i32 signext %a, i32 signext %a) #2
63  ret i32 %call
64}
65
66; PPC64-ELFV2-LABEL: WithParamArea2:
67; PPC64-ELFV2-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
68; PPC64-ELFV2: stdu 1, -112(1)
69; PPC64-ELFV2: addi 1, 1, 112
70; PPC64-ELFV2-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
71; PPC64-ELFV1-LABEL: WithParamArea2:
72; PPC64-ELFV1-NOT: stw {{[0-9]+}}, -{{[0-9]+}}(1)
73; PPC64-ELFV1: stdu 1, -128(1)
74; PPC64-ELFV1: addi 1, 1, 128
75; PPC64-ELFV1-NOT: lwz {{[0-9]+}}, -{{[0-9]+}}(1)
76define signext i32 @WithParamArea2(i32 signext %a) local_unnamed_addr #0 {
77entry:
78  %call = tail call signext i32 @nineargs(i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a, i32 signext %a) #2
79  ret i32 %call
80}
81
82declare signext i32 @onearg(i32 signext) local_unnamed_addr #1
83declare signext i32 @eightargs(i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext) local_unnamed_addr #1
84declare signext i32 @nineargs(i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext, i32 signext) local_unnamed_addr #1
85declare signext i32 @varargs(i32 signext, ...) local_unnamed_addr #1
86
87