24 #define DEBUG_TYPE "systemz-shorten-inst" 33 return "SystemZ Instruction Shortening";
48 bool shortenOn001AddCC(
MachineInstr &MI,
unsigned Opcode);
60 return new SystemZShortenInst(TM);
76 bool SystemZShortenInst::shortenIIF(
MachineInstr &
MI,
unsigned LLIxL,
81 unsigned thisSubRegIdx =
82 (SystemZ::GRH32BitRegClass.contains(Reg) ? SystemZ::subreg_h32
83 : SystemZ::subreg_l32);
84 unsigned otherSubRegIdx =
85 (thisSubRegIdx == SystemZ::subreg_l32 ? SystemZ::subreg_h32
86 : SystemZ::subreg_l32);
88 TRI->getMatchingSuperReg(Reg, thisSubRegIdx, &SystemZ::GR64BitRegClass);
89 unsigned OtherReg =
TRI->getSubReg(GR64BitReg, otherSubRegIdx);
90 if (LiveRegs.contains(OtherReg))
109 bool SystemZShortenInst::shortenOn0(
MachineInstr &MI,
unsigned Opcode) {
119 bool SystemZShortenInst::shortenOn01(
MachineInstr &MI,
unsigned Opcode) {
131 bool SystemZShortenInst::shortenOn001(
MachineInstr &MI,
unsigned Opcode) {
144 bool SystemZShortenInst::shortenOn001AddCC(
MachineInstr &MI,
unsigned Opcode) {
145 if (!LiveRegs.contains(SystemZ::CC) && shortenOn001(MI, Opcode)) {
157 bool SystemZShortenInst::shortenFPConv(
MachineInstr &MI,
unsigned Opcode) {
181 bool Changed =
false;
185 LiveRegs.addLiveOuts(MBB);
188 for (
auto MBBI = MBB.
rbegin(), MBBE = MBB.
rend(); MBBI != MBBE; ++MBBI) {
192 Changed |= shortenIIF(MI, SystemZ::LLILL, SystemZ::LLILH);
196 Changed |= shortenIIF(MI, SystemZ::LLIHL, SystemZ::LLIHH);
200 Changed |= shortenOn001AddCC(MI, SystemZ::ADBR);
204 Changed |= shortenOn001AddCC(MI, SystemZ::AEBR);
208 Changed |= shortenOn001(MI, SystemZ::DDBR);
212 Changed |= shortenOn001(MI, SystemZ::DEBR);
216 Changed |= shortenFPConv(MI, SystemZ::FIDBRA);
220 Changed |= shortenFPConv(MI, SystemZ::FIEBRA);
224 Changed |= shortenOn01(MI, SystemZ::LDEBR);
228 Changed |= shortenFPConv(MI, SystemZ::LEDBRA);
232 Changed |= shortenOn001(MI, SystemZ::MDBR);
236 Changed |= shortenOn001(MI, SystemZ::MEEBR);
239 case SystemZ::WFLCDB:
240 Changed |= shortenOn01(MI, SystemZ::LCDFR);
243 case SystemZ::WFLCSB:
244 Changed |= shortenOn01(MI, SystemZ::LCDFR_32);
247 case SystemZ::WFLNDB:
248 Changed |= shortenOn01(MI, SystemZ::LNDFR);
251 case SystemZ::WFLNSB:
252 Changed |= shortenOn01(MI, SystemZ::LNDFR_32);
255 case SystemZ::WFLPDB:
256 Changed |= shortenOn01(MI, SystemZ::LPDFR);
259 case SystemZ::WFLPSB:
260 Changed |= shortenOn01(MI, SystemZ::LPDFR_32);
263 case SystemZ::WFSQDB:
264 Changed |= shortenOn01(MI, SystemZ::SQDBR);
267 case SystemZ::WFSQSB:
268 Changed |= shortenOn01(MI, SystemZ::SQEBR);
272 Changed |= shortenOn001AddCC(MI, SystemZ::SDBR);
276 Changed |= shortenOn001AddCC(MI, SystemZ::SEBR);
280 Changed |= shortenOn01(MI, SystemZ::CDBR);
284 Changed |= shortenOn01(MI, SystemZ::CEBR);
289 Changed |= shortenOn0(MI, SystemZ::LDE32);
293 Changed |= shortenOn0(MI, SystemZ::STE);
301 Changed |= shortenOn0(MI, SystemZ::STD);
305 LiveRegs.stepBackward(MI);
320 bool Changed =
false;
322 Changed |= processBlock(MBB);
unsigned getFirstReg(unsigned Reg)
This class represents lattice values for constants.
unsigned getReg() const
getReg - Returns the register number.
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)
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...
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...
void setReg(unsigned Reg)
Change the register this operand corresponds to.
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...
const MachineOperand & getOperand(unsigned i) const
const SystemZRegisterInfo * getRegisterInfo() const override
Properties which a MachineFunction may have at a given point in time.
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.