16 #define DEBUG_TYPE "systemz-shorten-inst"
29 virtual const char *getPassName()
const {
30 return "SystemZ Instruction Shortening";
37 bool shortenIIF(
MachineInstr &
MI,
unsigned *GPRMap,
unsigned LiveOther,
38 unsigned LLIxL,
unsigned LLIxH);
44 unsigned LowGPRs[SystemZ::NUM_TARGET_REGS];
45 unsigned HighGPRs[SystemZ::NUM_TARGET_REGS];
52 return new SystemZShortenInst(TM);
58 for (
unsigned I = 0;
I < 16; ++
I) {
64 LowGPRs[GR128] |= 3 <<
I;
65 HighGPRs[GR128] |= 3 <<
I;
75 bool SystemZShortenInst::shortenIIF(
MachineInstr &
MI,
unsigned *GPRMap,
76 unsigned LiveOther,
unsigned LLIxL,
79 assert(Reg < SystemZ::NUM_TARGET_REGS &&
"Invalid register number");
80 unsigned GPRs = GPRMap[
Reg];
81 assert(GPRs != 0 &&
"Register must be a GPR");
102 bool Changed =
false;
105 unsigned LiveLow = 0;
106 unsigned LiveHigh = 0;
108 SE = MBB->
succ_end(); SI != SE; ++SI) {
110 LE = (*SI)->livein_end();
LI !=
LE; ++
LI) {
112 assert(Reg < SystemZ::NUM_TARGET_REGS &&
"Invalid register number");
113 LiveLow |= LowGPRs[
Reg];
114 LiveHigh |= HighGPRs[
Reg];
120 MBBE = MBB->
rend(); MBBI != MBBE; ++MBBI) {
123 if (Opcode == SystemZ::IILF)
124 Changed |= shortenIIF(MI, LowGPRs, LiveHigh, SystemZ::LLILL,
126 else if (Opcode == SystemZ::IIHF)
127 Changed |= shortenIIF(MI, HighGPRs, LiveLow, SystemZ::LLIHL,
129 unsigned UsedLow = 0;
130 unsigned UsedHigh = 0;
135 if (
unsigned Reg = MO.
getReg()) {
136 assert(Reg < SystemZ::NUM_TARGET_REGS &&
"Invalid register number");
138 LiveLow &= ~LowGPRs[
Reg];
139 LiveHigh &= ~HighGPRs[
Reg];
141 UsedLow |= LowGPRs[
Reg];
142 UsedHigh |= HighGPRs[
Reg];
148 LiveHigh |= UsedHigh;
157 bool Changed =
false;
160 Changed |= processBlock(MFI);
mop_iterator operands_end()
const unsigned GR32Regs[16]
std::vector< unsigned >::const_iterator livein_iterator
LoopInfoBase< BlockT, LoopT > * LI
const HexagonInstrInfo * TII
bool isReg() const
isReg - Tests if this is a MO_Register operand.
std::vector< MachineBasicBlock * >::iterator succ_iterator
const unsigned GRH32Regs[16]
ID
LLVM Calling Convention Representation.
FunctionPass * createSystemZShortenInstPass(SystemZTargetMachine &TM)
reverse_iterator rbegin()
const MachineOperand & getOperand(unsigned i) const
void setImm(int64_t immVal)
succ_iterator succ_begin()
static bool isImmLH(uint64_t Val)
virtual const TargetInstrInfo * getInstrInfo() const
void setDesc(const MCInstrDesc &tid)
const unsigned GR128Regs[16]
unsigned getRegAsGR64(unsigned Reg)
const unsigned GR64Regs[16]
void setReg(unsigned Reg)
const TargetMachine & getTarget() const
unsigned getReg() const
getReg - Returns the register number.
std::reverse_iterator< iterator > reverse_iterator
mop_iterator operands_begin()
BasicBlockListType::iterator iterator
static bool isImmLL(uint64_t Val)