forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Atomics: make use of the "cmpxchg weak" instruction.
This also simplifies the IR we create slightly: instead of working out where success & failure should go manually, it turns out we can just always jump to a success/failure block created for the purpose. Later phases will sort out the mess without much difficulty. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210917 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
6b3ed2b
commit 33fe993
Showing
6 changed files
with
232 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; RUN: llc < %s -mtriple=armv7-apple-ios -verify-machineinstrs | FileCheck %s | ||
|
||
define void @test_cmpxchg_weak(i32 *%addr, i32 %desired, i32 %new) { | ||
; CHECK-LABEL: test_cmpxchg_weak: | ||
|
||
%pair = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic | ||
%oldval = extractvalue { i32, i1 } %pair, 0 | ||
; CHECK: dmb ish | ||
; CHECK: ldrex [[LOADED:r[0-9]+]], [r0] | ||
; CHECK: cmp [[LOADED]], r1 | ||
; CHECK: strexeq [[SUCCESS:r[0-9]+]], r2, [r0] | ||
; CHECK: cmpeq [[SUCCESS]], #0 | ||
; CHECK: bne [[DONE:LBB[0-9]+_[0-9]+]] | ||
; CHECK: dmb ish | ||
; CHECK: [[DONE]]: | ||
; CHECK: str r3, [r0] | ||
; CHECK: bx lr | ||
|
||
store i32 %oldval, i32* %addr | ||
ret void | ||
} | ||
|
||
|
||
define i1 @test_cmpxchg_weak_to_bool(i32, i32 *%addr, i32 %desired, i32 %new) { | ||
; CHECK-LABEL: test_cmpxchg_weak_to_bool: | ||
|
||
%pair = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic | ||
%success = extractvalue { i32, i1 } %pair, 1 | ||
|
||
; CHECK: dmb ish | ||
; CHECK: mov r0, #0 | ||
; CHECK: ldrex [[LOADED:r[0-9]+]], [r1] | ||
; CHECK: cmp [[LOADED]], r2 | ||
; CHECK: strexeq [[STATUS:r[0-9]+]], r3, [r1] | ||
; CHECK: cmpeq [[STATUS]], #0 | ||
; CHECK: bne [[DONE:LBB[0-9]+_[0-9]+]] | ||
; CHECK: dmb ish | ||
; CHECK: mov r0, #1 | ||
; CHECK: [[DONE]]: | ||
; CHECK: bx lr | ||
|
||
ret i1 %success | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.