25#define DEBUG_TYPE "ppc-atomic-expand"
54 if (Dest0 == Src1 && Dest1 == Src0) {
59 }
else if (Dest0 != Src0 || Dest1 != Src1) {
60 if (Dest0 == Src1 || Dest1 != Src0) {
73 TRI = &
TII->getRegisterInfo();
90 switch (
MI.getOpcode()) {
91 case PPC::ATOMIC_SWAP_I128:
92 case PPC::ATOMIC_LOAD_ADD_I128:
93 case PPC::ATOMIC_LOAD_SUB_I128:
94 case PPC::ATOMIC_LOAD_XOR_I128:
95 case PPC::ATOMIC_LOAD_NAND_I128:
96 case PPC::ATOMIC_LOAD_AND_I128:
97 case PPC::ATOMIC_LOAD_OR_I128:
98 return expandAtomicRMW128(
MBB,
MI, NMBBI);
99 case PPC::ATOMIC_CMP_SWAP_I128:
100 return expandAtomicCmpSwap128(
MBB,
MI, NMBBI);
101 case PPC::BUILD_QUADWORD: {
103 Register DstHi =
TRI->getSubReg(Dst, PPC::sub_gp8_x0);
104 Register DstLo =
TRI->getSubReg(Dst, PPC::sub_gp8_x1);
108 MI.eraseFromParent();
116bool PPCExpandAtomicPseudo::expandAtomicRMW128(
133 MBB.addSuccessor(LoopMBB);
147 Register OldHi =
TRI->getSubReg(Old, PPC::sub_gp8_x0);
148 Register OldLo =
TRI->getSubReg(Old, PPC::sub_gp8_x1);
150 Register ScratchHi =
TRI->getSubReg(Scratch, PPC::sub_gp8_x0);
151 Register ScratchLo =
TRI->getSubReg(Scratch, PPC::sub_gp8_x1);
156 unsigned RMWOpcode =
MI.getOpcode();
162 case PPC::ATOMIC_SWAP_I128:
163 PairedCopy(
TII, *CurrentMBB, CurrentMBB->
end(),
DL, ScratchHi, ScratchLo,
166 case PPC::ATOMIC_LOAD_ADD_I128:
167 BuildMI(CurrentMBB,
DL,
TII->get(PPC::ADDC8), ScratchLo)
170 BuildMI(CurrentMBB,
DL,
TII->get(PPC::ADDE8), ScratchHi)
174 case PPC::ATOMIC_LOAD_SUB_I128:
175 BuildMI(CurrentMBB,
DL,
TII->get(PPC::SUBFC8), ScratchLo)
178 BuildMI(CurrentMBB,
DL,
TII->get(PPC::SUBFE8), ScratchHi)
183#define TRIVIAL_ATOMICRMW(Opcode, Instr) \
185 BuildMI(CurrentMBB, DL, TII->get((Instr)), ScratchLo) \
188 BuildMI(CurrentMBB, DL, TII->get((Instr)), ScratchHi) \
197#undef TRIVIAL_ATOMICRMW
210 MI.eraseFromParent();
214bool PPCExpandAtomicPseudo::expandAtomicCmpSwap128(
223 Register OldHi =
TRI->getSubReg(Old, PPC::sub_gp8_x0);
224 Register OldLo =
TRI->getSubReg(Old, PPC::sub_gp8_x1);
226 Register ScratchHi =
TRI->getSubReg(Scratch, PPC::sub_gp8_x0);
227 Register ScratchLo =
TRI->getSubReg(Scratch, PPC::sub_gp8_x1);
248 MF->
insert(MFI, LoopCmpMBB);
249 MF->
insert(MFI, CmpSuccMBB);
254 MBB.addSuccessor(LoopCmpMBB);
264 BuildMI(CurrentMBB,
DL,
TII->get(PPC::OR8_rec), ScratchLo)
274 CurrentMBB = CmpSuccMBB;
275 PairedCopy(
TII, *CurrentMBB, CurrentMBB->
end(),
DL, ScratchHi, ScratchLo,
287 MI.eraseFromParent();
296char PPCExpandAtomicPseudo::ID = 0;
298 return new PPCExpandAtomicPseudo();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Register const TargetRegisterInfo * TRI
#define TRIVIAL_ATOMICRMW(Opcode, Instr)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
SI optimize exec mask operations pre RA
LLVM Basic Block Representation.
Describe properties that are true of each instruction in the target description file.
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
BasicBlockListType::iterator iterator
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
FunctionPass * createPPCExpandAtomicPseudoPass()
void fullyRecomputeLiveIns(ArrayRef< MachineBasicBlock * > MBBs)
Convenience function for recomputing live-in's for a set of MBBs until the computation converges.