#include "LoongArch.h"
#include "LoongArchInstrInfo.h"
#include "LoongArchTargetMachine.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
usingnamespacellvm;
#define LoongArch_EXPAND_ATOMIC_PSEUDO_NAME …
namespace {
class LoongArchExpandAtomicPseudo : public MachineFunctionPass { … };
char LoongArchExpandAtomicPseudo::ID = …;
bool LoongArchExpandAtomicPseudo::runOnMachineFunction(MachineFunction &MF) { … }
bool LoongArchExpandAtomicPseudo::expandMBB(MachineBasicBlock &MBB) { … }
bool LoongArchExpandAtomicPseudo::expandMI(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
MachineBasicBlock::iterator &NextMBBI) { … }
static void doAtomicBinOpExpansion(const LoongArchInstrInfo *TII,
MachineInstr &MI, DebugLoc DL,
MachineBasicBlock *ThisMBB,
MachineBasicBlock *LoopMBB,
MachineBasicBlock *DoneMBB,
AtomicRMWInst::BinOp BinOp, int Width) { … }
static void insertMaskedMerge(const LoongArchInstrInfo *TII, DebugLoc DL,
MachineBasicBlock *MBB, Register DestReg,
Register OldValReg, Register NewValReg,
Register MaskReg, Register ScratchReg) { … }
static void doMaskedAtomicBinOpExpansion(
const LoongArchInstrInfo *TII, MachineInstr &MI, DebugLoc DL,
MachineBasicBlock *ThisMBB, MachineBasicBlock *LoopMBB,
MachineBasicBlock *DoneMBB, AtomicRMWInst::BinOp BinOp, int Width) { … }
bool LoongArchExpandAtomicPseudo::expandAtomicBinOp(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
AtomicRMWInst::BinOp BinOp, bool IsMasked, int Width,
MachineBasicBlock::iterator &NextMBBI) { … }
static void insertSext(const LoongArchInstrInfo *TII, DebugLoc DL,
MachineBasicBlock *MBB, Register ValReg,
Register ShamtReg) { … }
bool LoongArchExpandAtomicPseudo::expandAtomicMinMaxOp(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
AtomicRMWInst::BinOp BinOp, bool IsMasked, int Width,
MachineBasicBlock::iterator &NextMBBI) { … }
bool LoongArchExpandAtomicPseudo::expandAtomicCmpXchg(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, bool IsMasked,
int Width, MachineBasicBlock::iterator &NextMBBI) { … }
}
INITIALIZE_PASS(…)
namespace llvm {
FunctionPass *createLoongArchExpandAtomicPseudoPass() { … }
}