xref: /llvm-project/clang/test/CodeGen/link-builtin-bitcode.c (revision 69183f8eb97d3055b2a2617be85e8cb39d877acc)
1d60c4747SJuan Manuel MARTINEZ CAAMAÑO // Build two version of the bitcode library, one with a target-cpu set and one without
28784b6a8SJoseph Huber // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx803 -DBITCODE -emit-llvm-bc -o %t-lib.bc %s
3d60c4747SJuan Manuel MARTINEZ CAAMAÑO // RUN: %clang_cc1 -triple amdgcn-- -DBITCODE -emit-llvm-bc -o %t-lib.no-cpu.bc %s
4d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
58784b6a8SJoseph Huber // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc %s
68784b6a8SJoseph Huber // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
78784b6a8SJoseph Huber // RUN:   -mlink-builtin-bitcode %t-lib.bc -o - %t.bc | FileCheck %s
88784b6a8SJoseph Huber 
9d60c4747SJuan Manuel MARTINEZ CAAMAÑO // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc %s
10d60c4747SJuan Manuel MARTINEZ CAAMAÑO // RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
11d60c4747SJuan Manuel MARTINEZ CAAMAÑO // RUN:   -mlink-builtin-bitcode %t-lib.no-cpu.bc -o - %t.bc | FileCheck %s
12d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
138784b6a8SJoseph Huber #ifdef BITCODE
no_attr(void)14d60c4747SJuan Manuel MARTINEZ CAAMAÑO int no_attr(void) { return 42; }
attr_in_target(void)15d60c4747SJuan Manuel MARTINEZ CAAMAÑO int __attribute__((target("gfx8-insts"))) attr_in_target(void) { return 42; }
attr_not_in_target(void)16d60c4747SJuan Manuel MARTINEZ CAAMAÑO int __attribute__((target("extended-image-insts"))) attr_not_in_target(void) { return 42; }
attr_incompatible(void)17d60c4747SJuan Manuel MARTINEZ CAAMAÑO int __attribute__((target("no-gfx9-insts"))) attr_incompatible(void) { return 42; }
188784b6a8SJoseph Huber int x = 12;
198784b6a8SJoseph Huber #endif
208784b6a8SJoseph Huber 
21d60c4747SJuan Manuel MARTINEZ CAAMAÑO extern int no_attr(void);
22d60c4747SJuan Manuel MARTINEZ CAAMAÑO extern int attr_in_target(void);
23d60c4747SJuan Manuel MARTINEZ CAAMAÑO extern int attr_not_in_target(void);
24d60c4747SJuan Manuel MARTINEZ CAAMAÑO extern int attr_incompatible(void);
258784b6a8SJoseph Huber extern int x;
268784b6a8SJoseph Huber 
bar()27d60c4747SJuan Manuel MARTINEZ CAAMAÑO int bar() { return no_attr() + attr_in_target() + attr_not_in_target() + attr_incompatible() + x; }
28d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
298784b6a8SJoseph Huber // CHECK: @x = internal addrspace(1) global i32 12, align 4
30d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
318784b6a8SJoseph Huber // CHECK-LABEL: define dso_local i32 @bar
32d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-SAME: () #[[ATTR_BAR:[0-9]+]] {
338784b6a8SJoseph Huber //
34d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-LABEL: define internal i32 @no_attr
35d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-SAME: () #[[ATTR_COMPATIBLE:[0-9]+]] {
36d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
37d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-LABEL: define internal i32 @attr_in_target
38d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-SAME: () #[[ATTR_COMPATIBLE:[0-9]+]] {
39d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
40d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-LABEL: define internal i32 @attr_not_in_target
41d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-SAME: () #[[ATTR_EXTEND:[0-9]+]] {
42d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
43d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-LABEL: @attr_incompatible
44d60c4747SJuan Manuel MARTINEZ CAAMAÑO // CHECK-SAME: () #[[ATTR_INCOMPATIBLE:[0-9]+]] {
45d60c4747SJuan Manuel MARTINEZ CAAMAÑO 
46*69183f8eSJuan Manuel Martinez Caamaño // CHECK: attributes #[[ATTR_BAR]] = { {{.*}} "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
47*69183f8eSJuan Manuel Martinez Caamaño // CHECK: attributes #[[ATTR_COMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
48*69183f8eSJuan Manuel Martinez Caamaño // CHECK: attributes #[[ATTR_EXTEND]] = { {{.*}} "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+extended-image-insts,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
49*69183f8eSJuan Manuel Martinez Caamaño // CHECK: attributes #[[ATTR_INCOMPATIBLE]] = { {{.*}} "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx90a-insts,+gws,+image-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64,-gfx9-insts" }
50