mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
8f2a85e099
This commit adds a weak variant of the cmpxchg operation, as described in C++11. A cmpxchg instruction with this modifier is permitted to fail to store, even if the comparison indicated it should. As a result, cmpxchg instructions must return a flag indicating success in addition to their original iN value loaded. Thus, for uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The second flag is 1 when the store succeeded. At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been added as the natural representation for the new cmpxchg instructions. It is a strong cmpxchg. By default this gets Expanded to the existing ATOMIC_CMP_SWAP during Legalization, so existing backends should see no change in behaviour. If they wish to deal with the enhanced node instead, they can call setOperationAction on it. Beware: as a node with 2 results, it cannot be selected from TableGen. Currently, no use is made of the extra information provided in this patch. Test updates are almost entirely adapting the input IR to the new scheme. Summary for out of tree users: ------------------------------ + Legacy Bitcode files are upgraded during read. + Legacy assembly IR files will be invalid. + Front-ends must adapt to different type for "cmpxchg". + Backends should be unaffected by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210903 91177308-0d34-0410-b5e6-96231b3b80d8
90 lines
4.3 KiB
LLVM
90 lines
4.3 KiB
LLVM
; RUN: llc -march=cpp -o - %s | FileCheck %s
|
|
|
|
define void @test_atomicrmw(i32* %addr, i32 %inc) {
|
|
%inst0 = atomicrmw xchg i32* %addr, i32 %inc seq_cst
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Xchg, {{.*}}, SequentiallyConsistent, CrossThread
|
|
; CHECK: [[INST]]->setName("inst0");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
%inst1 = atomicrmw add i32* %addr, i32 %inc seq_cst
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Add, {{.*}}, SequentiallyConsistent, CrossThread
|
|
; CHECK: [[INST]]->setName("inst1");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
%inst2 = atomicrmw volatile sub i32* %addr, i32 %inc singlethread monotonic
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Sub, {{.*}}, Monotonic, SingleThread
|
|
; CHECK: [[INST]]->setName("inst2");
|
|
; CHECK: [[INST]]->setVolatile(true);
|
|
|
|
%inst3 = atomicrmw and i32* %addr, i32 %inc acq_rel
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::And, {{.*}}, AcquireRelease, CrossThread
|
|
; CHECK: [[INST]]->setName("inst3");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
%inst4 = atomicrmw nand i32* %addr, i32 %inc release
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Nand, {{.*}}, Release, CrossThread
|
|
; CHECK: [[INST]]->setName("inst4");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
%inst5 = atomicrmw volatile or i32* %addr, i32 %inc singlethread seq_cst
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Or, {{.*}}, SequentiallyConsistent, SingleThread
|
|
; CHECK: [[INST]]->setName("inst5");
|
|
; CHECK: [[INST]]->setVolatile(true);
|
|
|
|
%inst6 = atomicrmw xor i32* %addr, i32 %inc release
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Xor, {{.*}}, Release, CrossThread
|
|
; CHECK: [[INST]]->setName("inst6");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
%inst7 = atomicrmw volatile max i32* %addr, i32 %inc singlethread monotonic
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Max, {{.*}}, Monotonic, SingleThread
|
|
; CHECK: [[INST]]->setName("inst7");
|
|
; CHECK: [[INST]]->setVolatile(true);
|
|
|
|
%inst8 = atomicrmw min i32* %addr, i32 %inc acquire
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::Min, {{.*}}, Acquire, CrossThread
|
|
; CHECK: [[INST]]->setName("inst8");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
%inst9 = atomicrmw volatile umax i32* %addr, i32 %inc monotonic
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::UMax, {{.*}}, Monotonic, CrossThread
|
|
; CHECK: [[INST]]->setName("inst9");
|
|
; CHECK: [[INST]]->setVolatile(true);
|
|
|
|
%inst10 = atomicrmw umin i32* %addr, i32 %inc singlethread release
|
|
; CHECK: AtomicRMWInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicRMWInst(AtomicRMWInst::UMin, {{.*}}, Release, SingleThread
|
|
; CHECK: [[INST]]->setName("inst10");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
|
|
|
|
ret void
|
|
}
|
|
|
|
define void @test_cmpxchg(i32* %addr, i32 %desired, i32 %new) {
|
|
%inst0 = cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst monotonic
|
|
; CHECK: AtomicCmpXchgInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicCmpXchgInst({{.*}}, SequentiallyConsistent, Monotonic, CrossThread
|
|
; CHECK: [[INST]]->setName("inst0");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
; CHECK: [[INST]]->setWeak(false);
|
|
|
|
%inst1 = cmpxchg volatile i32* %addr, i32 %desired, i32 %new singlethread acq_rel acquire
|
|
; CHECK: AtomicCmpXchgInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicCmpXchgInst({{.*}}, AcquireRelease, Acquire, SingleThread
|
|
; CHECK: [[INST]]->setName("inst1");
|
|
; CHECK: [[INST]]->setVolatile(true);
|
|
; CHECK: [[INST]]->setWeak(false);
|
|
|
|
%inst2 = cmpxchg weak i32* %addr, i32 %desired, i32 %new seq_cst monotonic
|
|
; CHECK: AtomicCmpXchgInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicCmpXchgInst({{.*}}, SequentiallyConsistent, Monotonic, CrossThread
|
|
; CHECK: [[INST]]->setName("inst2");
|
|
; CHECK: [[INST]]->setVolatile(false);
|
|
; CHECK: [[INST]]->setWeak(true);
|
|
|
|
%inst3 = cmpxchg weak volatile i32* %addr, i32 %desired, i32 %new singlethread acq_rel acquire
|
|
; CHECK: AtomicCmpXchgInst* [[INST:[a-zA-Z0-9_]+]] = new AtomicCmpXchgInst({{.*}}, AcquireRelease, Acquire, SingleThread
|
|
; CHECK: [[INST]]->setName("inst3");
|
|
; CHECK: [[INST]]->setVolatile(true);
|
|
; CHECK: [[INST]]->setWeak(true);
|
|
|
|
ret void
|
|
}
|