#include "RISCV.h"
#include "RISCVInstrInfo.h"
#include "RISCVTargetMachine.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
usingnamespacellvm;
#define RISCV_EXPAND_ATOMIC_PSEUDO_NAME …
namespace {
class RISCVExpandAtomicPseudo : public MachineFunctionPass { … };
char RISCVExpandAtomicPseudo::ID = …;
bool RISCVExpandAtomicPseudo::runOnMachineFunction(MachineFunction &MF) { … }
bool RISCVExpandAtomicPseudo::expandMBB(MachineBasicBlock &MBB) { … }
bool RISCVExpandAtomicPseudo::expandMI(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MBBI,
MachineBasicBlock::iterator &NextMBBI) { … }
static unsigned getLRForRMW32(AtomicOrdering Ordering,
const RISCVSubtarget *Subtarget) { … }
static unsigned getSCForRMW32(AtomicOrdering Ordering,
const RISCVSubtarget *Subtarget) { … }
static unsigned getLRForRMW64(AtomicOrdering Ordering,
const RISCVSubtarget *Subtarget) { … }
static unsigned getSCForRMW64(AtomicOrdering Ordering,
const RISCVSubtarget *Subtarget) { … }
static unsigned getLRForRMW(AtomicOrdering Ordering, int Width,
const RISCVSubtarget *Subtarget) { … }
static unsigned getSCForRMW(AtomicOrdering Ordering, int Width,
const RISCVSubtarget *Subtarget) { … }
static void doAtomicBinOpExpansion(const RISCVInstrInfo *TII, MachineInstr &MI,
DebugLoc DL, MachineBasicBlock *ThisMBB,
MachineBasicBlock *LoopMBB,
MachineBasicBlock *DoneMBB,
AtomicRMWInst::BinOp BinOp, int Width,
const RISCVSubtarget *STI) { … }
static void insertMaskedMerge(const RISCVInstrInfo *TII, DebugLoc DL,
MachineBasicBlock *MBB, Register DestReg,
Register OldValReg, Register NewValReg,
Register MaskReg, Register ScratchReg) { … }
static void doMaskedAtomicBinOpExpansion(const RISCVInstrInfo *TII,
MachineInstr &MI, DebugLoc DL,
MachineBasicBlock *ThisMBB,
MachineBasicBlock *LoopMBB,
MachineBasicBlock *DoneMBB,
AtomicRMWInst::BinOp BinOp, int Width,
const RISCVSubtarget *STI) { … }
bool RISCVExpandAtomicPseudo::expandAtomicBinOp(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
AtomicRMWInst::BinOp BinOp, bool IsMasked, int Width,
MachineBasicBlock::iterator &NextMBBI) { … }
static void insertSext(const RISCVInstrInfo *TII, DebugLoc DL,
MachineBasicBlock *MBB, Register ValReg,
Register ShamtReg) { … }
bool RISCVExpandAtomicPseudo::expandAtomicMinMaxOp(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
AtomicRMWInst::BinOp BinOp, bool IsMasked, int Width,
MachineBasicBlock::iterator &NextMBBI) { … }
bool tryToFoldBNEOnCmpXchgResult(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MBBI,
Register DestReg, Register CmpValReg,
Register MaskReg,
MachineBasicBlock *&LoopHeadBNETarget) { … }
bool RISCVExpandAtomicPseudo::expandAtomicCmpXchg(
MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, bool IsMasked,
int Width, MachineBasicBlock::iterator &NextMBBI) { … }
}
INITIALIZE_PASS(…)
namespace llvm {
FunctionPass *createRISCVExpandAtomicPseudoPass() { … }
}