File: ms-inline-asm-fields.cpp

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 (56 lines) | stat: -rw-r--r-- 1,767 bytes parent folder | download | duplicates (3)
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
56
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s

struct A {
  int a1;
  int a2;
  struct B {
    int b1;
    int b2;
  } a3;
};

namespace asdf {
A a_global;
}

extern "C" int test_param_field(A p) {
// CHECK: define{{.*}} i32 @test_param_field(ptr noundef byval(%struct.A) align 4 %p)
// CHECK: getelementptr inbounds %struct.A, ptr %p, i32 0, i32 0
// CHECK: call i32 asm sideeffect inteldialect "mov eax, $1"
// CHECK: ret i32
  __asm mov eax, p.a1
}

extern "C" int test_namespace_global() {
// CHECK: define{{.*}} i32 @test_namespace_global()
// CHECK: call i32 asm sideeffect inteldialect "mov eax, $1", "{{.*}}"(ptr elementtype(i32) getelementptr inbounds (%"struct.A::B", ptr getelementptr inbounds (%struct.A, ptr @_ZN4asdf8a_globalE, i32 0, i32 2), i32 0, i32 1))
// CHECK: ret i32
  __asm mov eax, asdf::a_global.a3.b2
}

template <bool Signed>
struct make_storage_type {
  struct type {
    struct B {
      int a;
      int x;
    } b;
  };
};

template <bool Signed>
struct msvc_dcas_x86 {
  typedef typename make_storage_type<Signed>::type storage_type;
  void store() __asm("PR26001") {
    storage_type p;
    __asm mov edx, p.b.x;
  }
};

template void msvc_dcas_x86<false>::store();
// CHECK: define weak_odr void @"\01PR26001"(
// CHECK: %[[P:.*]] = alloca %"struct.make_storage_type<false>::type", align 4
// CHECK: %[[B:.*]] = getelementptr inbounds %"struct.make_storage_type<false>::type", ptr %[[P]], i32 0, i32 0
// CHECK: %[[X:.*]] = getelementptr inbounds %"struct.make_storage_type<false>::type::B", ptr %[[B]], i32 0, i32 1
// CHECK: call void asm sideeffect inteldialect "mov edx, $0", "*m,~{edx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) %[[X]])