Skip to content

Commit 3c7a0e6

Browse files
authored
[NVPTX] Cleanup and refactor atomic lowering (#133781)
Cleanup lowering of atomic instructions and intrninsics. The TableGen changes are primarily a refactor, though sub variants are now lowered via operation legalization, potentially allowing for more DAG optimization.
1 parent 9f3d8e8 commit 3c7a0e6

File tree

4 files changed

+184
-643
lines changed

4 files changed

+184
-643
lines changed

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
994994

995995
setOperationAction(ISD::ADDRSPACECAST, {MVT::i32, MVT::i64}, Custom);
996996

997+
setOperationAction(ISD::ATOMIC_LOAD_SUB, {MVT::i32, MVT::i64}, Expand);
997998
// No FPOW or FREM in PTX.
998999

9991000
// Now deduce the information based on the above mentioned

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

+13-4
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,25 @@ class fpimm_pos_inf<ValueType vt>
216216

217217
// Utility class to wrap up information about a register and DAG type for more
218218
// convenient iteration and parameterization
219-
class RegTyInfo<ValueType ty, NVPTXRegClass rc, Operand imm> {
219+
class RegTyInfo<ValueType ty, NVPTXRegClass rc, Operand imm, SDNode imm_node,
220+
bit supports_imm = 1> {
220221
ValueType Ty = ty;
221222
NVPTXRegClass RC = rc;
222223
Operand Imm = imm;
224+
SDNode ImmNode = imm_node;
225+
bit SupportsImm = supports_imm;
223226
int Size = ty.Size;
224227
}
225228

226-
def I16RT : RegTyInfo<i16, Int16Regs, i16imm>;
227-
def I32RT : RegTyInfo<i32, Int32Regs, i32imm>;
228-
def I64RT : RegTyInfo<i64, Int64Regs, i64imm>;
229+
def I16RT : RegTyInfo<i16, Int16Regs, i16imm, imm>;
230+
def I32RT : RegTyInfo<i32, Int32Regs, i32imm, imm>;
231+
def I64RT : RegTyInfo<i64, Int64Regs, i64imm, imm>;
232+
233+
def F32RT : RegTyInfo<f32, Float32Regs, f32imm, fpimm>;
234+
def F64RT : RegTyInfo<f64, Float64Regs, f64imm, fpimm>;
235+
def F16RT : RegTyInfo<f16, Int16Regs, f16imm, fpimm, supports_imm = 0>;
236+
def BF16RT : RegTyInfo<bf16, Int16Regs, bf16imm, fpimm, supports_imm = 0>;
237+
229238

230239
// Template for instructions which take three int64, int32, or int16 args.
231240
// The instructions are named "<OpcStr><Width>" (e.g. "add.s64").

0 commit comments

Comments
 (0)