File: cmpxchg.d

package info (click to toggle)
ldc 1%3A1.41.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 64,576 kB
  • sloc: cpp: 91,105; ansic: 23,829; makefile: 1,518; sh: 1,056; asm: 724; objc: 135; exp: 50; python: 12
file content (28 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (2)
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;
}