1 // REQUIRES: xcore-registered-target
2 // RUN: %clang_cc1 -triple xcore -verify %s
3 _Static_assert(sizeof(long long) == 8, "sizeof long long is wrong");
4 _Static_assert(_Alignof(long long) == 4, "alignof long long is wrong");
6 _Static_assert(sizeof(double) == 8, "sizeof double is wrong");
7 _Static_assert(_Alignof(double) == 4, "alignof double is wrong");
9 // RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s
11 // CHECK: target triple = "xcore-unknown-unknown"
13 // CHECK: @cgx = external constant i32, section ".cp.rodata"
15 int fcgx() { return cgx
;}
16 // CHECK: @g1 ={{.*}} global i32 0, align 4
18 // CHECK: @cg1 ={{.*}} constant i32 0, section ".cp.rodata", align 4
22 struct x
{ int a
[5]; };
24 void testva (int n
, ...) {
25 // CHECK-LABEL: testva
28 // CHECK: [[AP:%[a-z0-9]+]] = alloca ptr, align 4
29 // CHECK: [[V5:%[a-z0-9]+]] = alloca %struct.x, align 4
30 // CHECK: [[TMP:%[a-z0-9]+]] = alloca [4 x i32], align 4
31 // CHECK: call void @llvm.va_start.p0(ptr [[AP]])
33 char* v1
= va_arg (ap
, char*);
35 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
36 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
37 // CHECK: store ptr [[IN]], ptr [[AP]]
38 // CHECK: [[V1:%[a-z0-9]+]] = load ptr, ptr [[I]]
39 // CHECK: store ptr [[V1]], ptr [[V:%[a-z0-9]+]], align 4
40 // CHECK: [[V2:%[a-z0-9]+]] = load ptr, ptr [[V]], align 4
41 // CHECK: call void @f(ptr noundef [[V2]])
43 char v2
= va_arg (ap
, char); // expected-warning{{second argument to 'va_arg' is of promotable type 'char'}}
45 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
46 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
47 // CHECK: store ptr [[IN]], ptr [[AP]]
48 // CHECK: [[V1:%[a-z0-9]+]] = load i8, ptr [[I]]
49 // CHECK: store i8 [[V1]], ptr [[V:%[a-z0-9]+]], align 1
50 // CHECK: call void @f(ptr noundef [[V]])
52 int v3
= va_arg (ap
, int);
54 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
55 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
56 // CHECK: store ptr [[IN]], ptr [[AP]]
57 // CHECK: [[V1:%[a-z0-9]+]] = load i32, ptr [[I]]
58 // CHECK: store i32 [[V1]], ptr [[V:%[a-z0-9]+]], align 4
59 // CHECK: call void @f(ptr noundef [[V]])
61 long long int v4
= va_arg (ap
, long long int);
63 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
64 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 8
65 // CHECK: store ptr [[IN]], ptr [[AP]]
66 // CHECK: [[V1:%[a-z0-9]+]] = load i64, ptr [[I]]
67 // CHECK: store i64 [[V1]], ptr [[V:%[a-z0-9]+]], align 4
68 // CHECK: call void @f(ptr noundef [[V]])
70 struct x v5
= va_arg (ap
, struct x
); // typical aggregate type
72 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
73 // CHECK: [[P:%[a-z0-9]+]] = load ptr, ptr [[I]]
74 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
75 // CHECK: store ptr [[IN]], ptr [[AP]]
76 // CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[V5]], ptr align 4 [[P]], i32 20, i1 false)
77 // CHECK: call void @f(ptr noundef [[V5]])
79 int* v6
= va_arg (ap
, int[4]); // an unusual aggregate type
81 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
82 // CHECK: [[P:%[a-z0-9]+]] = load ptr, ptr [[I]]
83 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 4
84 // CHECK: store ptr [[IN]], ptr [[AP]]
85 // CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[TMP]], ptr align 4 [[P]], i32 16, i1 false)
86 // CHECK: [[V2:%[a-z0-9]+]] = getelementptr inbounds [4 x i32], ptr [[TMP]], i32 0, i32 0
87 // CHECK: store ptr [[V2]], ptr [[V:%[a-z0-9]+]], align 4
88 // CHECK: [[V3:%[a-z0-9]+]] = load ptr, ptr [[V]], align 4
89 // CHECK: call void @f(ptr noundef [[V3]])
91 double v7
= va_arg (ap
, double);
93 // CHECK: [[I:%[a-z0-9]+]] = load ptr, ptr [[AP]]
94 // CHECK: [[IN:%[a-z0-9]+]] = getelementptr inbounds i8, ptr [[I]], i32 8
95 // CHECK: store ptr [[IN]], ptr [[AP]]
96 // CHECK: [[V1:%[a-z0-9]+]] = load double, ptr [[I]]
97 // CHECK: store double [[V1]], ptr [[V:%[a-z0-9]+]], align 4
98 // CHECK: call void @f(ptr noundef [[V]])
101 void testbuiltin (void) {
102 // CHECK-LABEL: testbuiltin
103 // CHECK: call i32 @llvm.xcore.getid()
104 // CHECK: call i32 @llvm.xcore.getps(i32 {{%[a-z0-9]+}})
105 // CHECK: call i32 @llvm.xcore.bitrev(i32 {{%[a-z0-9]+}})
106 // CHECK: call void @llvm.xcore.setps(i32 {{%[a-z0-9]+}}, i32 {{%[a-z0-9]+}})
107 volatile int i
= __builtin_getid();
108 volatile unsigned int ui
= __builtin_getps(i
);
109 ui
= __builtin_bitrev(ui
);
110 __builtin_setps(i
,ui
);
112 // CHECK: store volatile i32 0, ptr {{%[a-z0-9]+}}, align 4
113 // CHECK: store volatile i32 1, ptr {{%[a-z0-9]+}}, align 4
114 // CHECK: store volatile i32 -1, ptr {{%[a-z0-9]+}}, align 4
116 res
= __builtin_eh_return_data_regno(0);
117 res
= __builtin_eh_return_data_regno(1);
118 res
= __builtin_eh_return_data_regno(2);
121 // CHECK-LABEL: define{{.*}} zeroext i8 @testchar()
123 char testchar (void) {
127 // CHECK-NOT: frame-pointer