mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-25 14:32:53 +00:00
5c8b83eb7a
The logic for expanding atomics that aren't natively supported in terms of cmpxchg loops is much simpler to express at the IR level. It also allows the normal optimisations and CodeGen improvements to help out with atomics, instead of using a limited set of possible instructions.. rdar://problem/13496295 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212119 91177308-0d34-0410-b5e6-96231b3b80d8
60 lines
1.5 KiB
LLVM
60 lines
1.5 KiB
LLVM
; RUN: llc -march=x86 -mattr=+cmov,cx16 -mtriple=i386-pc-linux -verify-machineinstrs < %s | FileCheck %s -check-prefix=LINUX
|
|
; RUN: llc -march=x86 -mattr=cx16 -mtriple=i386-macosx -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s -check-prefix=PIC
|
|
|
|
@sc64 = external global i64
|
|
|
|
define void @atomic_maxmin_i6432() {
|
|
; LINUX: atomic_maxmin_i6432
|
|
%1 = atomicrmw max i64* @sc64, i64 5 acquire
|
|
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
|
|
; LINUX: cmpl
|
|
; LINUX: seta
|
|
; LINUX: cmovne
|
|
; LINUX: cmovne
|
|
; LINUX: lock
|
|
; LINUX-NEXT: cmpxchg8b
|
|
; LINUX: jne [[LABEL]]
|
|
%2 = atomicrmw min i64* @sc64, i64 6 acquire
|
|
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
|
|
; LINUX: cmpl
|
|
; LINUX: setb
|
|
; LINUX: cmovne
|
|
; LINUX: cmovne
|
|
; LINUX: lock
|
|
; LINUX-NEXT: cmpxchg8b
|
|
; LINUX: jne [[LABEL]]
|
|
%3 = atomicrmw umax i64* @sc64, i64 7 acquire
|
|
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
|
|
; LINUX: cmpl
|
|
; LINUX: seta
|
|
; LINUX: cmovne
|
|
; LINUX: cmovne
|
|
; LINUX: lock
|
|
; LINUX-NEXT: cmpxchg8b
|
|
; LINUX: jne [[LABEL]]
|
|
%4 = atomicrmw umin i64* @sc64, i64 8 acquire
|
|
; LINUX: [[LABEL:.LBB[0-9]+_[0-9]+]]
|
|
; LINUX: cmpl
|
|
; LINUX: setb
|
|
; LINUX: cmovne
|
|
; LINUX: cmovne
|
|
; LINUX: lock
|
|
; LINUX-NEXT: cmpxchg8b
|
|
; LINUX: jne [[LABEL]]
|
|
ret void
|
|
}
|
|
|
|
; rdar://12453106
|
|
@id = internal global i64 0, align 8
|
|
|
|
define void @tf_bug(i8* %ptr) nounwind {
|
|
; PIC-LABEL: tf_bug:
|
|
; PIC-DAG: movl _id-L1$pb(
|
|
; PIC-DAG: movl (_id-L1$pb)+4(
|
|
%tmp1 = atomicrmw add i64* @id, i64 1 seq_cst
|
|
%tmp2 = add i64 %tmp1, 1
|
|
%tmp3 = bitcast i8* %ptr to i64*
|
|
store i64 %tmp2, i64* %tmp3, align 4
|
|
ret void
|
|
}
|