File: cmpxchg.d

package info (click to toggle)
ldc 1%3A1.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 63,308 kB
  • sloc: cpp: 85,368; ansic: 21,877; makefile: 1,705; sh: 1,018; asm: 584; objc: 135; exp: 48; python: 12
file content (28 lines) | stat: -rw-r--r-- 854 bytes parent folder | download
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
// RUN: %ldc -O -output-ll -of=%t.ll %s && FileCheck %s < %t.ll

import core.atomic;

// CHECK: define {{.*}}_D7cmpxchg3fooFiZb
bool foo(int cmp)
{
    static shared int g;
    // CHECK-NOT: ret
    // CHECK:      [[FOO1:%[0-9]]] = cmpxchg ptr
    // CHECK-NEXT: [[FOO2:%[0-9]]] = extractvalue { i32, i1 } [[FOO1]], 1
    // CHECK-NEXT: ret i1 [[FOO2]]
    return cas(&g, cmp, 456);
}

// CHECK: define {{.*}}_D7cmpxchg3barFdZd
double bar(double cmp)
{
    static shared double g;
    // CHECK-NOT: ret
    // CHECK:      [[BAR1:%[0-9]]] = bitcast double %cmp_arg to i64
    // CHECK-NEXT: [[BAR2:%[0-9]]] = cmpxchg weak ptr
    casWeak(&g, &cmp, 456.0);
    // CHECK-NEXT: [[BAR3:%[0-9]]] = extractvalue { i64, i1 } [[BAR2]], 0
    // CHECK-NEXT: [[BAR4:%[0-9]]] = bitcast i64 [[BAR3]] to double
    // CHECK-NEXT: ret double [[BAR4]]
    return cmp;
}