1; RUN: not llc -march=r600 < %s 2>&1 | FileCheck -check-prefix=ERROR %s
2; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=GCN %s
3
4declare hidden i32 @memcmp(i8 addrspace(1)* readonly nocapture, i8 addrspace(1)* readonly nocapture, i64) #0
5declare hidden i8 addrspace(1)* @memchr(i8 addrspace(1)* readonly nocapture, i32, i64) #1
6declare hidden i8* @strcpy(i8* nocapture, i8* readonly nocapture) #0
7declare hidden i32 @strlen(i8* nocapture) #1
8declare hidden i32 @strnlen(i8* nocapture, i32) #1
9declare hidden i32 @strcmp(i8* nocapture, i8* nocapture) #1
10
11
12; ERROR: error: <unknown>:0:0: in function test_memcmp void (i8 addrspace(1)*, i8 addrspace(1)*, i32*): unsupported call to function memcmp
13
14; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, memcmp@rel32@lo+4
15; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, memcmp@rel32@hi+12
16define amdgpu_kernel void @test_memcmp(i8 addrspace(1)* %x, i8 addrspace(1)* %y, i32* nocapture %p) #0 {
17entry:
18  %cmp = tail call i32 @memcmp(i8 addrspace(1)* %x, i8 addrspace(1)* %y, i64 2)
19  store volatile i32 %cmp, i32 addrspace(1)* undef
20  ret void
21}
22
23; ERROR: error: <unknown>:0:0: in function test_memchr void (i8 addrspace(1)*, i32, i64): unsupported call to function memchr
24
25; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, memchr@rel32@lo+4
26; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, memchr@rel32@hi+12
27define amdgpu_kernel void @test_memchr(i8 addrspace(1)* %src, i32 %char, i64 %len) #0 {
28  %res = call i8 addrspace(1)* @memchr(i8 addrspace(1)* %src, i32 %char, i64 %len)
29  store volatile i8 addrspace(1)* %res, i8 addrspace(1)* addrspace(1)* undef
30  ret void
31}
32
33; ERROR: error: <unknown>:0:0: in function test_strcpy void (i8*, i8*): unsupported call to function strcpy
34
35; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, strcpy@rel32@lo+4
36; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, strcpy@rel32@hi+12
37define amdgpu_kernel void @test_strcpy(i8* %dst, i8* %src) #0 {
38  %res = call i8* @strcpy(i8* %dst, i8* %src)
39  store volatile i8* %res, i8* addrspace(1)* undef
40  ret void
41}
42
43; ERROR: error: <unknown>:0:0: in function test_strcmp void (i8*, i8*): unsupported call to function strcmp
44
45; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, strcmp@rel32@lo+4
46; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, strcmp@rel32@hi+12
47define amdgpu_kernel void @test_strcmp(i8* %src0, i8* %src1) #0 {
48  %res = call i32 @strcmp(i8* %src0, i8* %src1)
49  store volatile i32 %res, i32 addrspace(1)* undef
50  ret void
51}
52
53; ERROR: error: <unknown>:0:0: in function test_strlen void (i8*): unsupported call to function strlen
54
55; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, strlen@rel32@lo+4
56; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, strlen@rel32@hi+12
57define amdgpu_kernel void @test_strlen(i8* %src) #0 {
58  %res = call i32 @strlen(i8* %src)
59  store volatile i32 %res, i32 addrspace(1)* undef
60  ret void
61}
62
63; ERROR: error: <unknown>:0:0: in function test_strnlen void (i8*, i32): unsupported call to function strnlen
64
65; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, strnlen@rel32@lo+4
66; GCN: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, strnlen@rel32@hi+12
67define amdgpu_kernel void @test_strnlen(i8* %src, i32 %size) #0 {
68  %res = call i32 @strnlen(i8* %src, i32 %size)
69  store volatile i32 %res, i32 addrspace(1)* undef
70  ret void
71}
72
73attributes #0 = { nounwind }
74