-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathlibc.c
55 lines (48 loc) · 1.97 KB
/
libc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir -fwrapv
// RUN: FileCheck --check-prefix=CIR_NO_POISON --input-file=%t.cir %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -fwrapv
// RUN: FileCheck --check-prefix=LLVM_NO_POISON --input-file=%t.ll %s
// Should generate CIR's builtin memcpy op.
void *memcpy(void *, const void *, unsigned long);
void testMemcpy(void *src, const void *dst, unsigned long size) {
memcpy(dst, src, size);
// CHECK: cir.libc.memcpy %{{.+}} bytes from %{{.+}} to %{{.+}} : !u64i, !cir.ptr<!void> -> !cir.ptr<!void>
}
double fabs(double);
double testFabs(double x) {
return fabs(x);
// CHECK: cir.fabs %{{.+}} : !cir.double
}
float fabsf(float);
float testFabsf(float x) {
return fabsf(x);
// CHECK: cir.fabs %{{.+}} : !cir.float
}
int abs(int);
int testAbs(int x) {
return abs(x);
// CHECK: cir.abs %{{.+}} poison : !s32i
// LLVM: %{{.+}} = call i32 @llvm.abs.i32(i32 %{{.+}}, i1 true)
// CIR_NO_POISON: cir.abs %{{.+}} : !s32i
// LLVM_NO_POISON: %{{.+}} = call i32 @llvm.abs.i32(i32 %{{.+}}, i1 false)
}
long labs(long);
long testLabs(long x) {
return labs(x);
// CHECK: cir.abs %{{.+}} poison : !s64i
// LLVM: %{{.+}} = call i64 @llvm.abs.i64(i64 %{{.+}}, i1 true)
// CIR_NO_POISON: cir.abs %{{.+}} : !s64i
// LLVM_NO_POISON: %{{.+}} = call i64 @llvm.abs.i64(i64 %{{.+}}, i1 false)
}
long long llabs(long long);
long long testLlabs(long long x) {
return llabs(x);
// CHECK: cir.abs %{{.+}} poison : !s64i
// LLVM: %{{.+}} = call i64 @llvm.abs.i64(i64 %{{.+}}, i1 true)
// CIR_NO_POISON: cir.abs %{{.+}} : !s64i
// LLVM_NO_POISON: %{{.+}} = call i64 @llvm.abs.i64(i64 %{{.+}}, i1 false)
}