1 // RUN: %clang_cc1 -triple lanai-unknown-unknown %s -emit-llvm -o - \
2 // RUN: | FileCheck %s
3
4 // Basic argument/attribute tests for Lanai.
5
6 // CHECK: define void @f0(i32 inreg %i, i32 inreg %j, i64 inreg %k)
f0(int i,long j,long long k)7 void f0(int i, long j, long long k) {}
8
9 typedef struct {
10 int aa;
11 int bb;
12 } s1;
13 // CHECK: define void @f1(i32 inreg %i.coerce0, i32 inreg %i.coerce1)
f1(s1 i)14 void f1(s1 i) {}
15
16 typedef struct {
17 int cc;
18 } s2;
19 // CHECK: define void @f2(%struct.s2* noalias sret(%struct.s2) align 4 %agg.result)
f2()20 s2 f2() {
21 s2 foo;
22 return foo;
23 }
24
25 typedef struct {
26 int cc;
27 int dd;
28 } s3;
29 // CHECK: define void @f3(%struct.s3* noalias sret(%struct.s3) align 4 %agg.result)
f3()30 s3 f3() {
31 s3 foo;
32 return foo;
33 }
34
35 // CHECK: define void @f4(i64 inreg %i)
f4(long long i)36 void f4(long long i) {}
37
38 // CHECK: define void @f5(i8 inreg %a, i16 inreg %b)
f5(char a,short b)39 void f5(char a, short b) {}
40
41 // CHECK: define void @f6(i8 inreg %a, i16 inreg %b)
f6(unsigned char a,unsigned short b)42 void f6(unsigned char a, unsigned short b) {}
43
44 enum my_enum {
45 ENUM1,
46 ENUM2,
47 ENUM3,
48 };
49 // Enums should be treated as the underlying i32.
50 // CHECK: define void @f7(i32 inreg %a)
f7(enum my_enum a)51 void f7(enum my_enum a) {}
52
53 enum my_big_enum {
54 ENUM4 = 0xFFFFFFFFFFFFFFFF,
55 };
56 // Big enums should be treated as the underlying i64.
57 // CHECK: define void @f8(i64 inreg %a)
f8(enum my_big_enum a)58 void f8(enum my_big_enum a) {}
59
60 union simple_union {
61 int a;
62 char b;
63 };
64 // Unions should be passed inreg.
65 // CHECK: define void @f9(i32 inreg %s.coerce)
f9(union simple_union s)66 void f9(union simple_union s) {}
67
68 typedef struct {
69 int b4 : 4;
70 int b3 : 3;
71 int b8 : 8;
72 } bitfield1;
73 // Bitfields should be passed inreg.
74 // CHECK: define void @f10(i32 inreg %bf1.coerce)
f10(bitfield1 bf1)75 void f10(bitfield1 bf1) {}
76