File: addrspace-references.clcpp

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (33 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (12)
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
//RUN: %clang_cc1 %s -triple spir -emit-llvm -o - -O0 | FileCheck %s

typedef short short2 __attribute__((ext_vector_type(2)));

int bar(const unsigned int &i);

class C {
public:
  void bar(const short2 &);
};

// CHECK-LABEL: define{{.*}} spir_func void @_Z6scalarv()
void scalar() {
  // The generic addr space reference parameter object will be bound
  // to a temporary value allocated in private addr space. We need an
  // addrspacecast before passing the value to the function.
  // CHECK: [[REF:%.*]] = alloca i32
  // CHECK: store i32 1, ptr [[REF]]
  // CHECK: [[REG:%[.a-z0-9]+]] ={{.*}} addrspacecast ptr [[REF]] to ptr addrspace(4)
  // CHECK: call spir_func noundef i32 @_Z3barRU3AS4Kj(ptr addrspace(4) noundef align 4 dereferenceable(4) [[REG]])
  bar(1);
}

// Test list initialization
// CHECK-LABEL: define{{.*}} spir_func void @_Z4listv()
void list() {
  C c1;
// CHECK: [[REF:%.*]] = alloca <2 x i16>
// CHECK: store <2 x i16> <i16 1, i16 2>, ptr [[REF]]
// CHECK: [[REG:%[.a-z0-9]+]] = addrspacecast ptr [[REF]] to ptr addrspace(4)
// CHECK: call {{.*}}void @_ZNU3AS41C3barERU3AS4KDv2_s(ptr addrspace(4) {{.*}}, ptr addrspace(4){{.*}} [[REG]])
  c1.bar({1, 2});
}