xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/mips64-padding-arg.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang -target mipsel-unknown-linux -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32
2*f4a2713aSLionel Sambuc // RUN: %clang -target mips64el-unknown-linux -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64
3*f4a2713aSLionel Sambuc // RUN: %clang -target mipsel-unknown-linux -mfp64 -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc typedef struct {
6*f4a2713aSLionel Sambuc   double d;
7*f4a2713aSLionel Sambuc   long double ld;
8*f4a2713aSLionel Sambuc } S0;
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc // Insert padding to ensure arguments of type S0 are aligned to 16-byte boundaries.
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc // N64-LABEL: define void @foo1(i32 %a0, i64, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 %b, i64, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
13*f4a2713aSLionel Sambuc // N64: tail call void @foo2(i32 1, i32 2, i32 %a0, i64 undef, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 3, i64 undef, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
14*f4a2713aSLionel Sambuc // N64: declare void @foo2(i32, i32, i32, i64, double, i64, i64, i64, double, i64, i64, i64, i32, i64, double, i64, i64, i64)
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc extern void foo2(int, int, int, S0, S0, int, S0);
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc void foo1(int a0, S0 a1, S0 a2, int b, S0 a3) {
19*f4a2713aSLionel Sambuc   foo2(1, 2, a0, a1, a2, 3, a3);
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // Insert padding before long double argument.
23*f4a2713aSLionel Sambuc //
24*f4a2713aSLionel Sambuc // N64-LABEL: define void @foo3(i32 %a0, i64, fp128 %a1)
25*f4a2713aSLionel Sambuc // N64: tail call void @foo4(i32 1, i32 2, i32 %a0, i64 undef, fp128 %a1)
26*f4a2713aSLionel Sambuc // N64: declare void @foo4(i32, i32, i32, i64, fp128)
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc extern void foo4(int, int, int, long double);
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc void foo3(int a0, long double a1) {
31*f4a2713aSLionel Sambuc   foo4(1, 2, a0, a1);
32*f4a2713aSLionel Sambuc }
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc // Insert padding after hidden argument.
35*f4a2713aSLionel Sambuc //
36*f4a2713aSLionel Sambuc // N64-LABEL: define void @foo5(%struct.S0* noalias sret %agg.result, i64, fp128 %a0)
37*f4a2713aSLionel Sambuc // N64: call void @foo6(%struct.S0* sret %agg.result, i32 1, i32 2, i64 undef, fp128 %a0)
38*f4a2713aSLionel Sambuc // N64: declare void @foo6(%struct.S0* sret, i32, i32, i64, fp128)
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc extern S0 foo6(int, int, long double);
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc S0 foo5(long double a0) {
43*f4a2713aSLionel Sambuc   return foo6(1, 2, a0);
44*f4a2713aSLionel Sambuc }
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc // Do not insert padding if ABI is O32.
47*f4a2713aSLionel Sambuc //
48*f4a2713aSLionel Sambuc // O32-LABEL: define void @foo7(float %a0, double %a1)
49*f4a2713aSLionel Sambuc // O32: declare void @foo8(float, double)
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc extern void foo8(float, double);
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc void foo7(float a0, double a1) {
54*f4a2713aSLionel Sambuc   foo8(a0 + 1.0f, a1 + 2.0);
55*f4a2713aSLionel Sambuc }
56*f4a2713aSLionel Sambuc 
57*f4a2713aSLionel Sambuc // O32-LABEL: define void @foo9()
58*f4a2713aSLionel Sambuc // O32: declare void @foo10(i32, i32
59*f4a2713aSLionel Sambuc 
60*f4a2713aSLionel Sambuc typedef struct __attribute__((aligned(16))) {
61*f4a2713aSLionel Sambuc   int a;
62*f4a2713aSLionel Sambuc } S16;
63*f4a2713aSLionel Sambuc 
64*f4a2713aSLionel Sambuc S16 s16;
65*f4a2713aSLionel Sambuc 
66*f4a2713aSLionel Sambuc void foo10(int, S16);
67*f4a2713aSLionel Sambuc 
68*f4a2713aSLionel Sambuc void foo9(void) {
69*f4a2713aSLionel Sambuc   foo10(1, s16);
70*f4a2713aSLionel Sambuc }
71*f4a2713aSLionel Sambuc 
72