[llvm] a8b90c0 - [GlobalISel] Update `MachineIRBuilder::buildAtomicRMW` interface (#86851)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 14:41:32 PDT 2024
Author: Shilei Tian
Date: 2024-03-27T17:41:30-04:00
New Revision: a8b90c047d5bb47702eebd4ceeb763e8537981a1
URL: https://github.com/llvm/llvm-project/commit/a8b90c047d5bb47702eebd4ceeb763e8537981a1
DIFF: https://github.com/llvm/llvm-project/commit/a8b90c047d5bb47702eebd4ceeb763e8537981a1.diff
LOG: [GlobalISel] Update `MachineIRBuilder::buildAtomicRMW` interface (#86851)
Added:
Modified:
llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h b/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
index 16a7fc446fbe1d..4c9d85fd9f5140 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
@@ -1333,9 +1333,9 @@ class MachineIRBuilder {
///
/// \return a MachineInstrBuilder for the newly created instruction.
MachineInstrBuilder
- buildAtomicCmpXchgWithSuccess(Register OldValRes, Register SuccessRes,
- Register Addr, Register CmpVal, Register NewVal,
- MachineMemOperand &MMO);
+ buildAtomicCmpXchgWithSuccess(const DstOp &OldValRes, const DstOp &SuccessRes,
+ const SrcOp &Addr, const SrcOp &CmpVal,
+ const SrcOp &NewVal, MachineMemOperand &MMO);
/// Build and insert `OldValRes<def> = G_ATOMIC_CMPXCHG Addr, CmpVal, NewVal,
/// MMO`.
@@ -1351,8 +1351,9 @@ class MachineIRBuilder {
/// registers of the same type.
///
/// \return a MachineInstrBuilder for the newly created instruction.
- MachineInstrBuilder buildAtomicCmpXchg(Register OldValRes, Register Addr,
- Register CmpVal, Register NewVal,
+ MachineInstrBuilder buildAtomicCmpXchg(const DstOp &OldValRes,
+ const SrcOp &Addr, const SrcOp &CmpVal,
+ const SrcOp &NewVal,
MachineMemOperand &MMO);
/// Build and insert `OldValRes<def> = G_ATOMICRMW_<Opcode> Addr, Val, MMO`.
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index 07d4cb5eaa23c8..b8ba782254c370 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -930,14 +930,14 @@ MachineIRBuilder::buildExtractVectorElement(const DstOp &Res, const SrcOp &Val,
}
MachineInstrBuilder MachineIRBuilder::buildAtomicCmpXchgWithSuccess(
- Register OldValRes, Register SuccessRes, Register Addr, Register CmpVal,
- Register NewVal, MachineMemOperand &MMO) {
+ const DstOp &OldValRes, const DstOp &SuccessRes, const SrcOp &Addr,
+ const SrcOp &CmpVal, const SrcOp &NewVal, MachineMemOperand &MMO) {
#ifndef NDEBUG
- LLT OldValResTy = getMRI()->getType(OldValRes);
- LLT SuccessResTy = getMRI()->getType(SuccessRes);
- LLT AddrTy = getMRI()->getType(Addr);
- LLT CmpValTy = getMRI()->getType(CmpVal);
- LLT NewValTy = getMRI()->getType(NewVal);
+ LLT OldValResTy = OldValRes.getLLTTy(*getMRI());
+ LLT SuccessResTy = SuccessRes.getLLTTy(*getMRI());
+ LLT AddrTy = Addr.getLLTTy(*getMRI());
+ LLT CmpValTy = CmpVal.getLLTTy(*getMRI());
+ LLT NewValTy = NewVal.getLLTTy(*getMRI());
assert(OldValResTy.isScalar() && "invalid operand type");
assert(SuccessResTy.isScalar() && "invalid operand type");
assert(AddrTy.isPointer() && "invalid operand type");
@@ -947,24 +947,25 @@ MachineInstrBuilder MachineIRBuilder::buildAtomicCmpXchgWithSuccess(
assert(OldValResTy == NewValTy && "type mismatch");
#endif
- return buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG_WITH_SUCCESS)
- .addDef(OldValRes)
- .addDef(SuccessRes)
- .addUse(Addr)
- .addUse(CmpVal)
- .addUse(NewVal)
- .addMemOperand(&MMO);
+ auto MIB = buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG_WITH_SUCCESS);
+ OldValRes.addDefToMIB(*getMRI(), MIB);
+ SuccessRes.addDefToMIB(*getMRI(), MIB);
+ Addr.addSrcToMIB(MIB);
+ CmpVal.addSrcToMIB(MIB);
+ NewVal.addSrcToMIB(MIB);
+ MIB.addMemOperand(&MMO);
+ return MIB;
}
MachineInstrBuilder
-MachineIRBuilder::buildAtomicCmpXchg(Register OldValRes, Register Addr,
- Register CmpVal, Register NewVal,
+MachineIRBuilder::buildAtomicCmpXchg(const DstOp &OldValRes, const SrcOp &Addr,
+ const SrcOp &CmpVal, const SrcOp &NewVal,
MachineMemOperand &MMO) {
#ifndef NDEBUG
- LLT OldValResTy = getMRI()->getType(OldValRes);
- LLT AddrTy = getMRI()->getType(Addr);
- LLT CmpValTy = getMRI()->getType(CmpVal);
- LLT NewValTy = getMRI()->getType(NewVal);
+ LLT OldValResTy = OldValRes.getLLTTy(*getMRI());
+ LLT AddrTy = Addr.getLLTTy(*getMRI());
+ LLT CmpValTy = CmpVal.getLLTTy(*getMRI());
+ LLT NewValTy = NewVal.getLLTTy(*getMRI());
assert(OldValResTy.isScalar() && "invalid operand type");
assert(AddrTy.isPointer() && "invalid operand type");
assert(CmpValTy.isValid() && "invalid operand type");
@@ -973,12 +974,13 @@ MachineIRBuilder::buildAtomicCmpXchg(Register OldValRes, Register Addr,
assert(OldValResTy == NewValTy && "type mismatch");
#endif
- return buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG)
- .addDef(OldValRes)
- .addUse(Addr)
- .addUse(CmpVal)
- .addUse(NewVal)
- .addMemOperand(&MMO);
+ auto MIB = buildInstr(TargetOpcode::G_ATOMIC_CMPXCHG);
+ OldValRes.addDefToMIB(*getMRI(), MIB);
+ Addr.addSrcToMIB(MIB);
+ CmpVal.addSrcToMIB(MIB);
+ NewVal.addSrcToMIB(MIB);
+ MIB.addMemOperand(&MMO);
+ return MIB;
}
MachineInstrBuilder MachineIRBuilder::buildAtomicRMW(
More information about the llvm-commits
mailing list