1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple armv7-unknown-nacl-gnueabi \
2*f4a2713aSLionel Sambuc // RUN:   -ffreestanding -mfloat-abi hard -target-cpu cortex-a8 \
3*f4a2713aSLionel Sambuc // RUN:   -emit-llvm -w -o - %s | FileCheck %s
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc // Test that functions with pnaclcall attribute generate portable bitcode
6*f4a2713aSLionel Sambuc // like the le32 arch target
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc typedef struct {
9*f4a2713aSLionel Sambuc   int a;
10*f4a2713aSLionel Sambuc   int b;
11*f4a2713aSLionel Sambuc } s1;
12*f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @f48(%struct.s1* byval %s)
f48(s1 s)13*f4a2713aSLionel Sambuc int __attribute__((pnaclcall)) f48(s1 s) { return s.a; }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f49(%struct.s1* noalias sret %agg.result)
f49()16*f4a2713aSLionel Sambuc s1 __attribute__((pnaclcall)) f49() { s1 s; s.a = s.b = 1; return s; }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc union simple_union {
19*f4a2713aSLionel Sambuc   int a;
20*f4a2713aSLionel Sambuc   char b;
21*f4a2713aSLionel Sambuc };
22*f4a2713aSLionel Sambuc // Unions should be passed as byval structs
23*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f50(%union.simple_union* byval %s)
f50(union simple_union s)24*f4a2713aSLionel Sambuc void __attribute__((pnaclcall)) f50(union simple_union s) {}
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc typedef struct {
27*f4a2713aSLionel Sambuc   int b4 : 4;
28*f4a2713aSLionel Sambuc   int b3 : 3;
29*f4a2713aSLionel Sambuc   int b8 : 8;
30*f4a2713aSLionel Sambuc } bitfield1;
31*f4a2713aSLionel Sambuc // Bitfields should be passed as byval structs
32*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @f51(%struct.bitfield1* byval %bf1)
f51(bitfield1 bf1)33*f4a2713aSLionel Sambuc void __attribute__((pnaclcall)) f51(bitfield1 bf1) {}
34