28#define DEBUG_TYPE "systemz-shorten-inst"
34 SystemZShortenInstLegacy();
46char SystemZShortenInstLegacy::ID = 0;
50 "SystemZ Instruction Shortening",
false,
false)
54 return new SystemZShortenInstLegacy();
57SystemZShortenInstLegacy::SystemZShortenInstLegacy()
63 !
MI.getOperand(0).isTied())
76 unsigned thisSubRegIdx =
77 (SystemZ::GRH32BitRegClass.contains(
Reg) ? SystemZ::subreg_h32
78 : SystemZ::subreg_l32);
79 unsigned otherSubRegIdx =
80 (thisSubRegIdx == SystemZ::subreg_l32 ? SystemZ::subreg_h32
81 : SystemZ::subreg_l32);
83 TRI->getMatchingSuperReg(
Reg, thisSubRegIdx, &SystemZ::GR64BitRegClass);
84 Register OtherReg =
TRI->getSubReg(GR64BitReg, otherSubRegIdx);
90 MI.setDesc(
TII->get(LLIxL));
95 MI.setDesc(
TII->get(LLIxH));
97 MI.getOperand(1).setImm(
Imm >> 16);
107 MI.setDesc(
TII->get(Opcode));
119 MI.setDesc(
TII->get(Opcode));
131 MI.getOperand(1).getReg() ==
MI.getOperand(0).getReg() &&
133 MI.setDesc(
TII->get(Opcode));
169 MI.setDesc(
TII->get(Opcode));
197 MI.setDesc(
TII->get(Opcode));
219 switch (
MI.getOpcode()) {
270 case SystemZ::WFMADB:
274 case SystemZ::WFMASB:
278 case SystemZ::WFMSDB:
282 case SystemZ::WFMSSB:
286 case SystemZ::WFLCDB:
290 case SystemZ::WFLCSB:
294 case SystemZ::WFLNDB:
298 case SystemZ::WFLNSB:
302 case SystemZ::WFLPDB:
306 case SystemZ::WFLPSB:
310 case SystemZ::WFSQDB:
314 case SystemZ::WFSQSB:
361 if (TwoOperandOpcode == -1)
364 if ((
MI.getOperand(0).getReg() !=
MI.getOperand(1).getReg()) &&
365 (!
MI.isCommutable() ||
366 MI.getOperand(0).getReg() !=
MI.getOperand(2).getReg() ||
367 !
TII->commuteInstruction(
MI,
false, 1, 2)))
370 MI.setDesc(
TII->get(TwoOperandOpcode));
371 MI.tieOperands(0, 1);
372 if (TwoOperandOpcode == SystemZ::SLL ||
373 TwoOperandOpcode == SystemZ::SLA ||
374 TwoOperandOpcode == SystemZ::SRL ||
375 TwoOperandOpcode == SystemZ::SRA) {
384 if (!
MI.isDebugInstr())
405bool SystemZShortenInstLegacy::runOnMachineFunction(
MachineFunction &MF) {
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static bool shortenFPConv(MachineInstr &MI, unsigned Opcode, const SystemZInstrInfo *TII)
static bool processBlock(MachineBasicBlock &MBB, LiveRegUnits &LiveRegs, const SystemZInstrInfo *TII, const TargetRegisterInfo *TRI)
static bool shortenOn01(MachineInstr &MI, unsigned Opcode, const SystemZInstrInfo *TII)
static bool shortenIIF(MachineInstr &MI, unsigned LLIxL, unsigned LLIxH, const SystemZInstrInfo *TII, const TargetRegisterInfo *TRI, LiveRegUnits &LiveRegs)
static void tieOpsIfNeeded(MachineInstr &MI)
static bool shortenFusedFPOp(MachineInstr &MI, unsigned Opcode, const SystemZInstrInfo *TII)
static bool shortenOn001(MachineInstr &MI, unsigned Opcode, const SystemZInstrInfo *TII)
static bool shortenOn0(MachineInstr &MI, unsigned Opcode, const SystemZInstrInfo *TII)
static bool shortenOn001AddCC(MachineInstr &MI, unsigned Opcode, const SystemZInstrInfo *TII, LiveRegUnits &LiveRegs)
static bool shortenInstructionsInMF(MachineFunction &F)
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
A set of register units used to track register liveness.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
void setImm(int64_t immVal)
Register getReg() const
getReg - Returns the register number.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Wrapper class representing virtual and physical registers.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Pass manager infrastructure for declaring and invalidating analyses.
unsigned getFirstReg(unsigned Reg)
unsigned getRegAsGR64(unsigned Reg)
static bool isImmLL(uint64_t Val)
static bool isImmLH(uint64_t Val)
int32_t getTwoOperandOpcode(uint32_t Opcode)
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
auto reverse(ContainerTy &&C)
FunctionPass * createSystemZShortenInstLegacyPass(SystemZTargetMachine &TM)