Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -mtriple=armv7-apple-ios -verify-machineinstrs | FileCheck %s
      2 
      3 define void @test_cmpxchg_weak(i32 *%addr, i32 %desired, i32 %new) {
      4 ; CHECK-LABEL: test_cmpxchg_weak:
      5 
      6   %pair = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic
      7   %oldval = extractvalue { i32, i1 } %pair, 0
      8 ; CHECK:     dmb ish
      9 ; CHECK:     ldrex   [[LOADED:r[0-9]+]], [r0]
     10 ; CHECK:     cmp     [[LOADED]], r1
     11 ; CHECK:     strexeq [[SUCCESS:r[0-9]+]], r2, [r0]
     12 ; CHECK:     cmpeq   [[SUCCESS]], #0
     13 ; CHECK:     bne     [[DONE:LBB[0-9]+_[0-9]+]]
     14 ; CHECK:     dmb     ish
     15 ; CHECK: [[DONE]]:
     16 ; CHECK:     str     r3, [r0]
     17 ; CHECK:     bx      lr
     18 
     19   store i32 %oldval, i32* %addr
     20   ret void
     21 }
     22 
     23 
     24 define i1 @test_cmpxchg_weak_to_bool(i32, i32 *%addr, i32 %desired, i32 %new) {
     25 ; CHECK-LABEL: test_cmpxchg_weak_to_bool:
     26 
     27   %pair = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic
     28   %success = extractvalue { i32, i1 } %pair, 1
     29 
     30 ; CHECK:      dmb     ish
     31 ; CHECK:      mov     r0, #0
     32 ; CHECK:      ldrex   [[LOADED:r[0-9]+]], [r1]
     33 ; CHECK:      cmp     [[LOADED]], r2
     34 ; CHECK:      strexeq [[STATUS:r[0-9]+]], r3, [r1]
     35 ; CHECK:      cmpeq   [[STATUS]], #0
     36 ; CHECK:      bne     [[DONE:LBB[0-9]+_[0-9]+]]
     37 ; CHECK:      dmb     ish
     38 ; CHECK:      mov     r0, #1
     39 ; CHECK: [[DONE]]:
     40 ; CHECK:      bx      lr
     41 
     42   ret i1 %success
     43 }
     44