1; RUN: rs2spirv_lit_driver.sh %s | FileCheck %s
2
3; rs_allocation g;
4; extern uint32_t __rsov_rsAllocationGetDimX(uint32_t ga);
5; int32_t RS_KERNEL getDim(int32_t dummy) {
6;    // lowered accessor by an earlier LLVM pass
7;    return __rsov_rsAllocationGetDimX(0);
8;}
9target datalayout = "e-p:32:32-i64:64-v128:64:128-n32-S64"
10target triple = "armv7-none-linux-gnueabi"
11
12%struct.rs_allocation = type { i32* }
13; CHECK-NOT OpCapability Kernel
14; CHECK-NOT OpDecorate %{{[a-zA-Z_0-9]*}} Alignment {{[0-9]*}}
15; CHECK: OpMemberDecorate [[MetadataS:%[a-zA-Z_0-9]*]] 0 Offset 4
16; CHECK: OpMemberDecorate [[MetadataS]] 1 Offset 8
17; CHECK: OpMemberDecorate [[MetadataS]] 2 Offset 12
18; CHECK: OpMemberDecorate [[MetadataS]] 3 Offset 16
19; CHECK: OpDecorate [[RuntimeArrS:%[a-zA-Z_0-9]*]] ArrayStride {{[0-9]*}}
20; CHECK: OpDecorate [[MetadataSSBO:%[a-zA-Z_0-9]*]] BufferBlock
21; CHECK: OpDecorate [[Metadata:%[a-zA-Z_0-9]*]] DescriptorSet 0
22; CHECK: OpDecorate [[Metadata]] Binding 1
23
24
25; CHECK: [[MetadataSSBO]] = OpTypeStruct [[RuntimeArrS]]
26; CHECK: [[MetadataPtr:%[a-zA-Z_0-9]*]] = OpTypePointer Uniform [[MetadataSSBO]]
27; CHECK: [[Metadata]] = OpVariable [[MetadataPtr]]
28
29@g = common global %struct.rs_allocation zeroinitializer, align 4
30
31
32; CHECK-NOT OpFunctionCall %uint %__rsov_rsAllocationGetDimX %{{[a-zA-Z_0-9]*}}
33; CHECK: [[DimX:%[a-zA-Z_0-9]*]] = OpAccessChain %_ptr_Uniform_uint [[Metadata]]
34; CHECK: [[Res:%[a-zA-Z_0-9]*]] = OpLoad %uint [[DimX]]
35; CHECK: OpReturnValue [[Res]]
36
37; Function Attrs: nounwind
38define i32 @getDim(i32 %dummy) local_unnamed_addr #0 {
39entry:
40  %call = tail call i32 @__rsov_rsAllocationGetDimX(i32 0) #2
41  ret i32 %call
42}
43
44declare i32 @__rsov_rsAllocationGetDimX(i32) local_unnamed_addr #1
45
46; Function Attrs: nounwind
47define void @.rs.dtor() local_unnamed_addr #0 {
48entry:
49  tail call void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation* nonnull @g) #2
50  ret void
51}
52
53declare void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation*) local_unnamed_addr #1
54
55attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="0" "stackrealign" "unsafe-fp-math"="false" "use-soft-float"="false" }
56attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="0" "stackrealign" "unsafe-fp-math"="false" "use-soft-float"="false" }
57attributes #2 = { nounwind }
58
59!llvm.module.flags = !{!0, !1}
60!llvm.ident = !{!2}
61!\23pragma = !{!3, !4}
62!\23rs_export_var = !{!5}
63!\23rs_object_slots = !{!6}
64!\23rs_export_foreach_name = !{!7, !8}
65!\23rs_export_foreach = !{!6, !9}
66
67!0 = !{i32 1, !"wchar_size", i32 4}
68!1 = !{i32 1, !"min_enum_size", i32 4}
69!2 = !{!"Android clang version 3.8.275480  (based on LLVM 3.8.275480)"}
70!3 = !{!"version", !"1"}
71!4 = !{!"java_package_name", !"com.android.rs.rsov.test"}
72!5 = !{!"g", !"20"}
73!6 = !{!"0"}
74!7 = !{!"root"}
75!8 = !{!"getDim"}
76!9 = !{!"35"}
77