25#define DEBUG_TYPE "systemz-postrewrite"
26STATISTIC(MemFoldCopies,
"Number of copies inserted before folded mem ops.");
27STATISTIC(LOCRMuxJumps,
"Number of LOCRMux jump-sequences (lower is better)");
61char SystemZPostRewrite::ID = 0;
66 "SystemZ Post Rewrite pass",
false,
false)
70 return new SystemZPostRewrite();
81 unsigned HighOpcode) {
87 if (!DestIsHigh && !SrcIsHigh)
88 MBBI->setDesc(
TII->get(LowOpcode));
89 else if (DestIsHigh && SrcIsHigh)
90 MBBI->setDesc(
TII->get(HighOpcode));
92 expandCondMove(
MBB,
MBBI, NextMBBI);
102 unsigned HighOpcode) {
113 if (DestReg != Src1Reg && DestReg != Src2Reg) {
114 if (DestIsHigh != Src1IsHigh) {
116 TII->get(SystemZ::COPY), DestReg)
118 MBBI->getOperand(1).setReg(DestReg);
120 Src1IsHigh = DestIsHigh;
121 }
else if (DestIsHigh != Src2IsHigh) {
123 TII->get(SystemZ::COPY), DestReg)
125 MBBI->getOperand(2).setReg(DestReg);
127 Src2IsHigh = DestIsHigh;
132 if (DestReg != Src1Reg && DestReg == Src2Reg) {
133 TII->commuteInstruction(*
MBBI,
false, 1, 2);
138 if (!DestIsHigh && !Src1IsHigh && !Src2IsHigh)
139 MBBI->setDesc(
TII->get(LowOpcode));
140 else if (DestIsHigh && Src1IsHigh && Src2IsHigh)
141 MBBI->setDesc(
TII->get(HighOpcode));
144 expandCondMove(
MBB,
MBBI, NextMBBI);
159 unsigned CCValid =
MI.getOperand(3).getImm();
160 unsigned CCMask =
MI.getOperand(4).getImm();
161 assert(DestReg ==
MI.getOperand(1).getReg() &&
162 "Expected destination and first source operand to be the same.");
165 LiveRegs.addLiveOuts(
MBB);
167 LiveRegs.stepBackward(*
I);
193 BuildMI(*MoveMBB, MoveMBB->
end(),
DL,
TII->get(SystemZ::COPY), DestReg)
198 MI.eraseFromParent();
209 unsigned Opcode =
MI.getOpcode();
215 if (TargetMemOpcode != -1) {
216 MI.setDesc(
TII->get(TargetMemOpcode));
217 MI.tieOperands(0, 1);
220 if (DstReg != SrcMO.
getReg()) {
230 case SystemZ::LOCRMux:
231 selectLOCRMux(
MBB,
MBBI, NextMBBI, SystemZ::LOCR, SystemZ::LOCFHR);
233 case SystemZ::SELRMux:
234 selectSELRMux(
MBB,
MBBI, NextMBBI, SystemZ::SELR, SystemZ::SELFHR);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
LLVM Basic Block Representation.
FunctionPass class - This class is used to implement most global optimizations.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
void transferSuccessors(MachineBasicBlock *FromMBB)
Transfers all the successors from MBB to this machine basic block (i.e., copies all the successors Fr...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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 '...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
void setReg(Register Reg)
Change the register this operand corresponds to.
Register getReg() const
getReg - Returns the register number.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Wrapper class representing virtual and physical registers.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
int getTargetMemOpcode(uint16_t Opcode)
bool isHighReg(unsigned int Reg)
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.
void initializeSystemZPostRewritePass(PassRegistry &)
unsigned getRegState(const MachineOperand &RegOp)
Get all register state flags from machine operand RegOp.
FunctionPass * createSystemZPostRewritePass(SystemZTargetMachine &TM)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.