23 #define DEBUG_TYPE "systemz-shorten-inst" 32 return "SystemZ Instruction Shortening";
47 bool shortenOn001AddCC(
MachineInstr &MI,
unsigned Opcode);
59 return new SystemZShortenInst(TM);
75 bool SystemZShortenInst::shortenIIF(
MachineInstr &
MI,
unsigned LLIxL,
80 unsigned thisSubRegIdx =
81 (SystemZ::GRH32BitRegClass.contains(Reg) ? SystemZ::subreg_h32
82 : SystemZ::subreg_l32);
83 unsigned otherSubRegIdx =
84 (thisSubRegIdx == SystemZ::subreg_l32 ? SystemZ::subreg_h32
85 : SystemZ::subreg_l32);
87 TRI->getMatchingSuperReg(Reg, thisSubRegIdx, &SystemZ::GR64BitRegClass);
88 Register OtherReg =
TRI->getSubReg(GR64BitReg, otherSubRegIdx);
89 if (LiveRegs.contains(OtherReg))
108 bool SystemZShortenInst::shortenOn0(
MachineInstr &MI,
unsigned Opcode) {
118 bool SystemZShortenInst::shortenOn01(
MachineInstr &MI,
unsigned Opcode) {
130 bool SystemZShortenInst::shortenOn001(
MachineInstr &MI,
unsigned Opcode) {
143 bool SystemZShortenInst::shortenOn001AddCC(
MachineInstr &MI,
unsigned Opcode) {
144 if (!LiveRegs.contains(SystemZ::CC) && shortenOn001(MI, Opcode)) {
156 bool SystemZShortenInst::shortenFPConv(
MachineInstr &MI,
unsigned Opcode) {
180 bool Changed =
false;
184 LiveRegs.addLiveOuts(MBB);
187 for (
auto MBBI = MBB.
rbegin(), MBBE = MBB.
rend(); MBBI != MBBE; ++MBBI) {
191 Changed |= shortenIIF(MI, SystemZ::LLILL, SystemZ::LLILH);
195 Changed |= shortenIIF(MI, SystemZ::LLIHL, SystemZ::LLIHH);
199 Changed |= shortenOn001AddCC(MI, SystemZ::ADBR);
203 Changed |= shortenOn001AddCC(MI, SystemZ::AEBR);
207 Changed |= shortenOn001(MI, SystemZ::DDBR);
211 Changed |= shortenOn001(MI, SystemZ::DEBR);
215 Changed |= shortenFPConv(MI, SystemZ::FIDBRA);
219 Changed |= shortenFPConv(MI, SystemZ::FIEBRA);
223 Changed |= shortenOn01(MI, SystemZ::LDEBR);
227 Changed |= shortenFPConv(MI, SystemZ::LEDBRA);
231 Changed |= shortenOn001(MI, SystemZ::MDBR);
235 Changed |= shortenOn001(MI, SystemZ::MEEBR);
238 case SystemZ::WFLCDB:
239 Changed |= shortenOn01(MI, SystemZ::LCDFR);
242 case SystemZ::WFLCSB:
243 Changed |= shortenOn01(MI, SystemZ::LCDFR_32);
246 case SystemZ::WFLNDB:
247 Changed |= shortenOn01(MI, SystemZ::LNDFR);
250 case SystemZ::WFLNSB:
251 Changed |= shortenOn01(MI, SystemZ::LNDFR_32);
254 case SystemZ::WFLPDB:
255 Changed |= shortenOn01(MI, SystemZ::LPDFR);
258 case SystemZ::WFLPSB:
259 Changed |= shortenOn01(MI, SystemZ::LPDFR_32);
262 case SystemZ::WFSQDB:
263 Changed |= shortenOn01(MI, SystemZ::SQDBR);
266 case SystemZ::WFSQSB:
267 Changed |= shortenOn01(MI, SystemZ::SQEBR);
271 Changed |= shortenOn001AddCC(MI, SystemZ::SDBR);
275 Changed |= shortenOn001AddCC(MI, SystemZ::SEBR);
279 Changed |= shortenOn01(MI, SystemZ::CDBR);
283 Changed |= shortenOn01(MI, SystemZ::CEBR);
287 Changed |= shortenOn01(MI, SystemZ::KDBR);
291 Changed |= shortenOn01(MI, SystemZ::KEBR);
296 Changed |= shortenOn0(MI, SystemZ::LDE32);
300 Changed |= shortenOn0(MI, SystemZ::STE);
308 Changed |= shortenOn0(MI, SystemZ::STD);
313 if (TwoOperandOpcode == -1)
319 !
TII->commuteInstruction(MI,
false, 1, 2)))
324 if (TwoOperandOpcode == SystemZ::SLL ||
325 TwoOperandOpcode == SystemZ::SLA ||
337 LiveRegs.stepBackward(MI);
352 bool Changed =
false;
354 Changed |= processBlock(MBB);
unsigned getFirstReg(unsigned Reg)
This class represents lattice values for constants.
unsigned const TargetRegisterInfo * TRI
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
FunctionPass * createSystemZShortenInstPass(SystemZTargetMachine &TM)
void setReg(Register Reg)
Change the register this operand corresponds to.
int getTwoOperandOpcode(uint16_t Opcode)
reverse_iterator rbegin()
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void setImm(int64_t immVal)
FunctionPass class - This class is used to implement most global optimizations.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
static bool isImmLH(uint64_t Val)
const SystemZInstrInfo * getInstrInfo() const override
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specific constraint if it is set.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
MachineOperand class - Representation of each machine instruction operand.
unsigned getRegAsGR64(unsigned Reg)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
const MachineBasicBlock * getParent() const
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
static void tieOpsIfNeeded(MachineInstr &MI)
static bool isImmLL(uint64_t Val)
StringRef - Represent a constant reference to a string, i.e.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const SystemZRegisterInfo * getRegisterInfo() const override
bool isCommutable(QueryType Type=IgnoreBundle) const
Return true if this may be a 2- or 3-address instruction (of the form "X = op Y, Z, ..."), which produces the same result if Y and Z are exchanged.
Properties which a MachineFunction may have at a given point in time.
Wrapper class representing virtual and physical registers.
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.