Skip to content

Commit cbb14ca

Browse files
committed
[NVPTX] Support Unordered Atomics with same lowering as Monotonic
1 parent c1f31fe commit cbb14ca

File tree

3 files changed

+665
-5
lines changed

3 files changed

+665
-5
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,9 @@ static unsigned int getCodeMemorySemantic(MemSDNode *N,
736736
// | No | Yes | Generic,Shared, | .volatile | .volatile |
737737
// | | | Global [0] | | |
738738
// | No | Yes | Local,Const,Param | plain [1] | .weak [1] |
739-
// | Relaxed | No | Generic,Shared, | | |
740-
// | | | Global [0] | .volatile | <atomic sem> |
739+
// | Unorder | Yes/No | All | == Relaxed | == Relaxed |
740+
// | Relaxed | No | Generic,Shared, | .volatile | <atomic sem> |
741+
// | | | Global [0] | | |
741742
// | Other | No | Generic,Shared, | Error [2] | <atomic sem> |
742743
// | | | Global [0] | | |
743744
// | Yes | No | Local,Const,Param | plain [1] | .weak [1] |
@@ -794,9 +795,10 @@ static unsigned int getCodeMemorySemantic(MemSDNode *N,
794795
return NVPTX::PTXLdStInstCode::NotAtomic;
795796
}
796797

797-
// [2]: Atomics with Ordering different than Relaxed are not supported on
798-
// sm_60 and older; this includes volatile atomics.
798+
// [2]: Atomics with Ordering different than Unordered or Relaxed are not
799+
// supported on sm_60 and older; this includes volatile atomics.
799800
if (!(Ordering == AtomicOrdering::NotAtomic ||
801+
Ordering == AtomicOrdering::Unordered ||
800802
Ordering == AtomicOrdering::Monotonic) &&
801803
!HasMemoryOrdering) {
802804
SmallString<256> Msg;
@@ -826,6 +828,9 @@ static unsigned int getCodeMemorySemantic(MemSDNode *N,
826828
return N->isVolatile() && AddrGenericOrGlobalOrShared
827829
? NVPTX::PTXLdStInstCode::Volatile
828830
: NVPTX::PTXLdStInstCode::NotAtomic;
831+
case AtomicOrdering::Unordered:
832+
// We lower unordered in the exact same way as 'monotonic' to respect
833+
// LLVM IR atomicity requirements.
829834
case AtomicOrdering::Monotonic:
830835
if (N->isVolatile())
831836
return UseRelaxedMMIO ? NVPTX::PTXLdStInstCode::RelaxedMMIO
@@ -866,7 +871,6 @@ static unsigned int getCodeMemorySemantic(MemSDNode *N,
866871
report_fatal_error(OS.str());
867872
}
868873
case AtomicOrdering::SequentiallyConsistent:
869-
case AtomicOrdering::Unordered:
870874
// TODO: support AcquireRelease and SequentiallyConsistent
871875
SmallString<256> Msg;
872876
raw_svector_ostream OS(Msg);

0 commit comments

Comments
 (0)