Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang -target mipsel-unknown-linux -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32
      2 // RUN: %clang -target mips64el-unknown-linux -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64
      3 
      4 typedef struct {
      5   double d;
      6   long double ld;
      7 } S0;
      8 
      9 // Insert padding to ensure arguments of type S0 are aligned to 16-byte boundaries.
     10 
     11 // N64: 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)
     12 // 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)
     13 // N64: declare void @foo2(i32, i32, i32, i64, double, i64, i64, i64, double, i64, i64, i64, i32, i64, double, i64, i64, i64)
     14 
     15 extern void foo2(int, int, int, S0, S0, int, S0);
     16 
     17 void foo1(int a0, S0 a1, S0 a2, int b, S0 a3) {
     18   foo2(1, 2, a0, a1, a2, 3, a3);
     19 }
     20 
     21 // Insert padding before long double argument.
     22 //
     23 // N64: define void @foo3(i32 %a0, i64, fp128 %a1)
     24 // N64: tail call void @foo4(i32 1, i32 2, i32 %a0, i64 undef, fp128 %a1)
     25 // N64: declare void @foo4(i32, i32, i32, i64, fp128)
     26 
     27 extern void foo4(int, int, int, long double);
     28 
     29 void foo3(int a0, long double a1) {
     30   foo4(1, 2, a0, a1);
     31 }
     32 
     33 // Insert padding after hidden argument.
     34 //
     35 // N64: define void @foo5(%struct.S0* noalias sret %agg.result, i64, fp128 %a0)
     36 // N64: call void @foo6(%struct.S0* sret %agg.result, i32 1, i32 2, i64 undef, fp128 %a0)
     37 // N64: declare void @foo6(%struct.S0* sret, i32, i32, i64, fp128)
     38 
     39 extern S0 foo6(int, int, long double);
     40 
     41 S0 foo5(long double a0) {
     42   return foo6(1, 2, a0);
     43 }
     44 
     45 // Do not insert padding if ABI is O32.
     46 //
     47 // O32: define void @foo7(float %a0, double %a1)
     48 // O32: declare void @foo8(float, double)
     49 
     50 extern void foo8(float, double);
     51 
     52 void foo7(float a0, double a1) {
     53   foo8(a0 + 1.0f, a1 + 2.0);
     54 }
     55 
     56