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