xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/le32-arguments.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple le32-unknown-nacl %s -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // Basic argument/attribute tests for le32/PNaCl
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f0(i32 %i, i32 %j, double %k)
f0(int i,long j,double k)6*f4a2713aSLionel Sambuc void f0(int i, long j, double k) {}
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc typedef struct {
9*f4a2713aSLionel Sambuc   int aa;
10*f4a2713aSLionel Sambuc   int bb;
11*f4a2713aSLionel Sambuc } s1;
12*f4a2713aSLionel Sambuc // Structs should be passed byval and not split up
13*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f1(%struct.s1* byval %i)
f1(s1 i)14*f4a2713aSLionel Sambuc void f1(s1 i) {}
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc typedef struct {
17*f4a2713aSLionel Sambuc   int cc;
18*f4a2713aSLionel Sambuc } s2;
19*f4a2713aSLionel Sambuc // Structs should be returned sret and not simplified by the frontend
20*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f2(%struct.s2* noalias sret %agg.result)
f2()21*f4a2713aSLionel Sambuc s2 f2() {
22*f4a2713aSLionel Sambuc   s2 foo;
23*f4a2713aSLionel Sambuc   return foo;
24*f4a2713aSLionel Sambuc }
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f3(i64 %i)
f3(long long i)27*f4a2713aSLionel Sambuc void f3(long long i) {}
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc // i8/i16 should be signext, i32 and higher should not
30*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f4(i8 signext %a, i16 signext %b)
f4(char a,short b)31*f4a2713aSLionel Sambuc void f4(char a, short b) {}
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f5(i8 zeroext %a, i16 zeroext %b)
f5(unsigned char a,unsigned short b)34*f4a2713aSLionel Sambuc void f5(unsigned char a, unsigned short b) {}
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc enum my_enum {
38*f4a2713aSLionel Sambuc   ENUM1,
39*f4a2713aSLionel Sambuc   ENUM2,
40*f4a2713aSLionel Sambuc   ENUM3,
41*f4a2713aSLionel Sambuc };
42*f4a2713aSLionel Sambuc // Enums should be treated as the underlying i32
43*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f6(i32 %a)
f6(enum my_enum a)44*f4a2713aSLionel Sambuc void f6(enum my_enum a) {}
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc union simple_union {
47*f4a2713aSLionel Sambuc   int a;
48*f4a2713aSLionel Sambuc   char b;
49*f4a2713aSLionel Sambuc };
50*f4a2713aSLionel Sambuc // Unions should be passed as byval structs
51*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f7(%union.simple_union* byval %s)
f7(union simple_union s)52*f4a2713aSLionel Sambuc void f7(union simple_union s) {}
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc typedef struct {
55*f4a2713aSLionel Sambuc   int b4 : 4;
56*f4a2713aSLionel Sambuc   int b3 : 3;
57*f4a2713aSLionel Sambuc   int b8 : 8;
58*f4a2713aSLionel Sambuc } bitfield1;
59*f4a2713aSLionel Sambuc // Bitfields should be passed as byval structs
60*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f8(%struct.bitfield1* byval %bf1)
f8(bitfield1 bf1)61*f4a2713aSLionel Sambuc void f8(bitfield1 bf1) {}
62