2012-09-07 01:37:28 +08:00
|
|
|
// RUN: %clang_cc1 -triple le32-unknown-nacl %s -emit-llvm -o - | FileCheck %s
|
|
|
|
|
|
|
|
// Basic argument/attribute tests for le32/PNaCl
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f0(i32 %i, i32 %j, double %k)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f0(int i, long j, double k) {}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int aa;
|
|
|
|
int bb;
|
|
|
|
} s1;
|
|
|
|
// Structs should be passed byval and not split up
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f1(%struct.s1* byval %i)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f1(s1 i) {}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int cc;
|
|
|
|
} s2;
|
|
|
|
// Structs should be returned sret and not simplified by the frontend
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f2(%struct.s2* noalias sret %agg.result)
|
2012-09-07 01:37:28 +08:00
|
|
|
s2 f2() {
|
|
|
|
s2 foo;
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f3(i64 %i)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f3(long long i) {}
|
|
|
|
|
|
|
|
// i8/i16 should be signext, i32 and higher should not
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f4(i8 signext %a, i16 signext %b)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f4(char a, short b) {}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f5(i8 zeroext %a, i16 zeroext %b)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f5(unsigned char a, unsigned short b) {}
|
|
|
|
|
|
|
|
|
|
|
|
enum my_enum {
|
|
|
|
ENUM1,
|
|
|
|
ENUM2,
|
|
|
|
ENUM3,
|
|
|
|
};
|
|
|
|
// Enums should be treated as the underlying i32
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f6(i32 %a)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f6(enum my_enum a) {}
|
|
|
|
|
|
|
|
union simple_union {
|
|
|
|
int a;
|
|
|
|
char b;
|
|
|
|
};
|
|
|
|
// Unions should be passed as byval structs
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f7(%union.simple_union* byval %s)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f7(union simple_union s) {}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int b4 : 4;
|
|
|
|
int b3 : 3;
|
|
|
|
int b8 : 8;
|
|
|
|
} bitfield1;
|
|
|
|
// Bitfields should be passed as byval structs
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @f8(%struct.bitfield1* byval %bf1)
|
2012-09-07 01:37:28 +08:00
|
|
|
void f8(bitfield1 bf1) {}
|