28#define DEBUG_TYPE "systemz-shorten-inst"
34 SystemZShortenInstLegacy();
47char SystemZShortenInstLegacy::ID = 0;
51 "SystemZ Instruction Shortening",
false,
false)
55 return new SystemZShortenInstLegacy();
58SystemZShortenInstLegacy::SystemZShortenInstLegacy()
64 !
MI.getOperand(0).isTied())
77 unsigned thisSubRegIdx =
78 (SystemZ::GRH32BitRegClass.contains(
Reg) ? SystemZ::subreg_h32
79 : SystemZ::subreg_l32);
80 unsigned otherSubRegIdx =
81 (thisSubRegIdx == SystemZ::subreg_l32 ? SystemZ::subreg_h32
82 : SystemZ::subreg_l32);
84 TRI->getMatchingSuperReg(
Reg, thisSubRegIdx, &SystemZ::GR64BitRegClass);
85 Register OtherReg =
TRI->getSubReg(GR64BitReg, otherSubRegIdx);
91 MI.setDesc(
TII->get(LLIxL));
96 MI.setDesc(
TII->get(LLIxH));
98 MI.getOperand(1).setImm(
Imm >> 16);
108 MI.setDesc(
TII->get(Opcode));
120 MI.setDesc(
TII->get(Opcode));
132 MI.getOperand(1).getReg() ==
MI.getOperand(0).getReg() &&
134 MI.setDesc(
TII->get(Opcode));
170 MI.setDesc(
TII->get(Opcode));
198 MI.setDesc(
TII->get(Opcode));
220 switch (
MI.getOpcode()) {
271 case SystemZ::WFMADB:
275 case SystemZ::WFMASB:
279 case SystemZ::WFMSDB:
283 case SystemZ::WFMSSB:
287 case SystemZ::WFLCDB:
291 case SystemZ::WFLCSB:
295 case SystemZ::WFLNDB:
299 case SystemZ::WFLNSB:
303 case SystemZ::WFLPDB:
307 case SystemZ::WFLPSB:
311 case SystemZ::WFSQDB:
315 case SystemZ::WFSQSB:
362 if (TwoOperandOpcode == -1)
365 if ((
MI.getOperand(0).getReg() !=
MI.getOperand(1).getReg()) &&
366 (!
MI.isCommutable() ||
367 MI.getOperand(0).getReg() !=
MI.getOperand(2).getReg() ||
368 !
TII->commuteInstruction(
MI,
false, 1, 2)))
371 MI.setDesc(
TII->get(TwoOperandOpcode));
372 MI.tieOperands(0, 1);
373 if (TwoOperandOpcode == SystemZ::SLL ||
374 TwoOperandOpcode == SystemZ::SLA ||
375 TwoOperandOpcode == SystemZ::SRL ||
376 TwoOperandOpcode == SystemZ::SRA) {
385 if (!
MI.isDebugInstr())
406bool 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)