Skip to content

Commit 2da30f8

Browse files
authored
[NVPTX] Add Volta Load/Store Atomics (.relaxed, .acquire, .release) and Volatile (.mmio/.volatile) support (#98022)
This PR adds initial support for some of Volta's (sm_70) load/store atomic and volatile/MMIO operations, hopefully without breaking any preexisting code. Only relaxed, acquire, and release operations w/ volatile are handled. This PR does not aim to add support for any of the following: - syncscope support - read atomic ops to const, param, grid param - local memory atomics - sequentially consistent atomics - atomicrmw - ...
1 parent 8659c91 commit 2da30f8

File tree

7 files changed

+1848
-157
lines changed

7 files changed

+1848
-157
lines changed

llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,33 @@ void NVPTXInstPrinter::printLdStCode(const MCInst *MI, int OpNum,
227227
if (Modifier) {
228228
const MCOperand &MO = MI->getOperand(OpNum);
229229
int Imm = (int) MO.getImm();
230-
if (!strcmp(Modifier, "volatile")) {
231-
if (Imm)
230+
if (!strcmp(Modifier, "sem")) {
231+
switch (Imm) {
232+
case NVPTX::PTXLdStInstCode::NotAtomic:
233+
break;
234+
case NVPTX::PTXLdStInstCode::Volatile:
232235
O << ".volatile";
236+
break;
237+
case NVPTX::PTXLdStInstCode::Relaxed:
238+
O << ".relaxed.sys";
239+
break;
240+
case NVPTX::PTXLdStInstCode::Acquire:
241+
O << ".acquire.sys";
242+
break;
243+
case NVPTX::PTXLdStInstCode::Release:
244+
O << ".release.sys";
245+
break;
246+
case NVPTX::PTXLdStInstCode::RelaxedMMIO:
247+
O << ".mmio.relaxed.sys";
248+
break;
249+
default:
250+
SmallString<256> Msg;
251+
raw_svector_ostream OS(Msg);
252+
OS << "NVPTX LdStCode Printer does not support \"" << Imm
253+
<< "\" sem modifier.";
254+
report_fatal_error(OS.str());
255+
break;
256+
}
233257
} else if (!strcmp(Modifier, "addsp")) {
234258
switch (Imm) {
235259
case NVPTX::PTXLdStInstCode::GLOBAL:

llvm/lib/Target/NVPTX/NVPTX.h

+8
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ enum LoadStore {
107107
};
108108

109109
namespace PTXLdStInstCode {
110+
enum MemorySemantic {
111+
NotAtomic = 0, // PTX calls these: "Weak"
112+
Volatile = 1,
113+
Relaxed = 2,
114+
Acquire = 3,
115+
Release = 4,
116+
RelaxedMMIO = 5
117+
};
110118
enum AddressSpace {
111119
GENERIC = 0,
112120
GLOBAL = 1,

0 commit comments

Comments
 (0)