Skip to content

Commit

Permalink
[SOL] Expand atomic load and store
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Aug 16, 2024
1 parent 19a1195 commit 2e039cf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/SBF/SBFISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ SBFTargetLowering::SBFTargetLowering(const TargetMachine &TM,
setOperationAction(ISD::ATOMIC_LOAD_UMAX, VT, Custom);
setOperationAction(ISD::ATOMIC_LOAD_UMIN, VT, Custom);
setOperationAction(ISD::ATOMIC_LOAD_XOR, VT, Custom);
setOperationAction(ISD::ATOMIC_LOAD, VT, Expand);
setOperationAction(ISD::ATOMIC_STORE, VT, Expand);
continue;
}

Expand Down
42 changes: 42 additions & 0 deletions llvm/test/CodeGen/SBF/atomics_sbf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,45 @@ entry:
%0 = atomicrmw umax i64* %ptr, i64 %v release, align 1
ret i64 %0
}

; CHECK-LABEL: test_load_64
; CHECK: ldxdw r0, [r1 + 0]
; CHECK: mov64 r2, 0
; CHECK: jeq r0, 0, LBB24_2
; CHECK: mov64 r2, r0
; CHECK: LBB24_2:
; CHECK: stxdw [r1 + 0], r2
define dso_local i64 @test_load_64(ptr nocapture %p) local_unnamed_addr {
entry:
%0 = load atomic i64, ptr %p seq_cst, align 8
ret i64 %0
}

; CHECK-LABEL: test_load_32
; CHECK: ldxw w0, [r1 + 0]
; CHECK: mov32 w2, 0
; CHECK: jeq r0, 0, LBB25_2
; CHECK: mov32 w2, w0
; CHECK: LBB25_2:
; CHECK: stxw [r1 + 0], w2
define dso_local i32 @test_load_32(ptr nocapture %p) local_unnamed_addr {
entry:
%0 = load atomic i32, ptr %p seq_cst, align 8
ret i32 %0
}

; CHECK-LABEL: test_store_64
; CHECK: stxdw [r1 + 0], r2
define dso_local void @test_store_64(ptr nocapture %p, i64 %val) local_unnamed_addr {
entry:
store atomic i64 %val, ptr %p seq_cst, align 8
ret void
}

; CHECK-LABEL: test_store_32
; CHECK: stxw [r1 + 0], w2
define dso_local void @test_store_32(ptr nocapture %p, i32 %val) local_unnamed_addr {
entry:
store atomic i32 %val, ptr %p seq_cst, align 8
ret void
}

0 comments on commit 2e039cf

Please sign in to comment.