Skip to content

Commit a2352f9

Browse files
committed
address comments
1 parent 905b1ce commit a2352f9

File tree

7 files changed

+172
-166
lines changed

7 files changed

+172
-166
lines changed

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void NVPTXDAGToDAGISel::Select(SDNode *N) {
172172
}
173173
case NVPTXISD::ATOMIC_CMP_SWAP_B128:
174174
case NVPTXISD::ATOMIC_SWAP_B128:
175-
selectAtomic128(N);
175+
selectAtomicSwap128(N);
176176
return;
177177
case ISD::FADD:
178178
case ISD::FMUL:
@@ -2342,7 +2342,7 @@ bool NVPTXDAGToDAGISel::tryIntrinsicVoid(SDNode *N) {
23422342
}
23432343
}
23442344

2345-
void NVPTXDAGToDAGISel::selectAtomic128(SDNode *N) {
2345+
void NVPTXDAGToDAGISel::selectAtomicSwap128(SDNode *N) {
23462346
MemSDNode *AN = cast<MemSDNode>(N);
23472347
SDLoc dl(N);
23482348

llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel {
9090
bool IsIm2Col = false);
9191
void SelectTcgen05Ld(SDNode *N, bool hasOffset = false);
9292
void SelectTcgen05St(SDNode *N, bool hasOffset = false);
93-
void selectAtomic128(SDNode *N);
93+
void selectAtomicSwap128(SDNode *N);
9494

9595
inline SDValue getI32Imm(unsigned Imm, const SDLoc &DL) {
9696
return CurDAG->getTargetConstant(Imm, DL, MVT::i32);

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6242,7 +6242,7 @@ static void replaceProxyReg(SDNode *N, SelectionDAG &DAG,
62426242
Results.push_back(Res);
62436243
}
62446244

6245-
static void replaceAtomic128(SDNode *N, SelectionDAG &DAG,
6245+
static void replaceAtomicSwap128(SDNode *N, SelectionDAG &DAG,
62466246
const NVPTXSubtarget &STI,
62476247
SmallVectorImpl<SDValue> &Results) {
62486248
assert(N->getValueType(0) == MVT::i128 &&
@@ -6251,7 +6251,7 @@ static void replaceAtomic128(SDNode *N, SelectionDAG &DAG,
62516251
AtomicSDNode *AN = cast<AtomicSDNode>(N);
62526252
SDLoc dl(N);
62536253

6254-
if (STI.getSmVersion() < 90 || STI.getPTXVersion() < 83) {
6254+
if (!STI.hasAtomSwap128()) {
62556255
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
62566256
DAG.getMachineFunction().getFunction(),
62576257
"Support for b128 atomics introduced in PTX ISA version 8.3 and "
@@ -6307,7 +6307,7 @@ void NVPTXTargetLowering::ReplaceNodeResults(
63076307
return;
63086308
case ISD::ATOMIC_CMP_SWAP:
63096309
case ISD::ATOMIC_SWAP:
6310-
replaceAtomic128(N, DAG, STI, Results);
6310+
replaceAtomicSwap128(N, DAG, STI, Results);
63116311
return;
63126312
}
63136313
}

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def hasAtomAddF64 : Predicate<"Subtarget->hasAtomAddF64()">;
104104
def hasAtomScope : Predicate<"Subtarget->hasAtomScope()">;
105105
def hasAtomBitwise64 : Predicate<"Subtarget->hasAtomBitwise64()">;
106106
def hasAtomMinMax64 : Predicate<"Subtarget->hasAtomMinMax64()">;
107+
def hasAtomSwap128 : Predicate<"Subtarget->hasAtomSwap128()">;
107108
def hasClusters : Predicate<"Subtarget->hasClusters()">;
108109
def hasPTXASUnreachableBug : Predicate<"Subtarget->hasPTXASUnreachableBug()">;
109110
def noPTXASUnreachableBug : Predicate<"!Subtarget->hasPTXASUnreachableBug()">;

llvm/lib/Target/NVPTX/NVPTXIntrinsics.td

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,17 +2206,18 @@ defm INT_PTX_SATOM_XOR : ATOM2_bitwise_impl<"xor">;
22062206

22072207
// atom.*.b128
22082208

2209-
let mayLoad = 1, mayStore = 1, hasSideEffects = 1 in {
2209+
let mayLoad = true, mayStore = true, hasSideEffects = true,
2210+
Predicates = [hasAtomSwap128] in {
22102211
def ATOM_CAS_B128 :
22112212
NVPTXInst<
22122213
(outs B64:$dst0, B64:$dst1),
22132214
(ins ADDR:$addr, B64:$cmp0, B64:$cmp1, B64:$swap0, B64:$swap1,
22142215
AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
22152216
"{{\n\t"
2216-
".reg .b128 src1, src2, dst;\n\t"
2217-
"mov.b128 src1, {$cmp0, $cmp1};\n\t"
2218-
"mov.b128 src2, {$swap0, $swap1};\n\t"
2219-
"atom${sem:sem}${scope:scope}${addsp:addsp}.cas.b128 dst, $addr, src1, src2;\n\t"
2217+
".reg .b128 cmp, swap, dst;\n\t"
2218+
"mov.b128 cmp, {$cmp0, $cmp1};\n\t"
2219+
"mov.b128 swap, {$swap0, $swap1};\n\t"
2220+
"atom${sem:sem}${scope:scope}${addsp:addsp}.cas.b128 dst, [$addr], cmp, swap;\n\t"
22202221
"mov.b128 {$dst0, $dst1}, dst;\n\t"
22212222
"}}">;
22222223

@@ -2226,9 +2227,9 @@ let mayLoad = 1, mayStore = 1, hasSideEffects = 1 in {
22262227
(ins ADDR:$addr, B64:$amt0, B64:$amt1,
22272228
AtomicCode:$sem, AtomicCode:$scope, AtomicCode:$addsp),
22282229
"{{\n\t"
2229-
".reg .b128 src1, dst;\n\t"
2230-
"mov.b128 src1, {$amt0, $amt1};\n\t"
2231-
"atom${sem:sem}${scope:scope}${addsp:addsp}.exch.b128 dst, $addr, src1;\n\t"
2230+
".reg .b128 amt, dst;\n\t"
2231+
"mov.b128 amt, {$amt0, $amt1};\n\t"
2232+
"atom${sem:sem}${scope:scope}${addsp:addsp}.exch.b128 dst, [$addr], amt;\n\t"
22322233
"mov.b128 {$dst0, $dst1}, dst;\n\t"
22332234
"}}">;
22342235
}

llvm/lib/Target/NVPTX/NVPTXSubtarget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
8282
bool hasAtomBitwise64() const { return SmVersion >= 32; }
8383
bool hasAtomMinMax64() const { return SmVersion >= 32; }
8484
bool hasAtomCas16() const { return SmVersion >= 70 && PTXVersion >= 63; }
85+
bool hasAtomSwap128() const { return SmVersion >= 90 && PTXVersion >= 83; }
8586
bool hasClusters() const { return SmVersion >= 90 && PTXVersion >= 78; }
8687
bool hasLDG() const { return SmVersion >= 32; }
8788
bool hasHWROT32() const { return SmVersion >= 32; }

0 commit comments

Comments
 (0)