Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 1 | //===--- HexagonGenMux.cpp ------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // During instruction selection, MUX instructions are generated for |
| 11 | // conditional assignments. Since such assignments often present an |
| 12 | // opportunity to predicate instructions, HexagonExpandCondsets |
| 13 | // expands MUXes into pairs of conditional transfers, and then proceeds |
| 14 | // with predication of the producers/consumers of the registers involved. |
| 15 | // This happens after exiting from the SSA form, but before the machine |
| 16 | // instruction scheduler. After the scheduler and after the register |
| 17 | // allocation there can be cases of pairs of conditional transfers |
| 18 | // resulting from a MUX where neither of them was further predicated. If |
| 19 | // these transfers are now placed far enough from the instruction defining |
| 20 | // the predicate register, they cannot use the .new form. In such cases it |
| 21 | // is better to collapse them back to a single MUX instruction. |
| 22 | |
| 23 | #define DEBUG_TYPE "hexmux" |
| 24 | |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 25 | #include "HexagonInstrInfo.h" |
| 26 | #include "HexagonRegisterInfo.h" |
| 27 | #include "HexagonSubtarget.h" |
| 28 | #include "llvm/ADT/BitVector.h" |
| 29 | #include "llvm/ADT/SmallVector.h" |
| 30 | #include "llvm/ADT/StringRef.h" |
| 31 | #include "llvm/CodeGen/MachineBasicBlock.h" |
| 32 | #include "llvm/CodeGen/MachineFunction.h" |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 33 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 34 | #include "llvm/CodeGen/MachineInstr.h" |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 35 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 36 | #include "llvm/CodeGen/MachineOperand.h" |
| 37 | #include "llvm/IR/DebugLoc.h" |
| 38 | #include "llvm/MC/MCInstrDesc.h" |
| 39 | #include "llvm/MC/MCRegisterInfo.h" |
| 40 | #include "llvm/Pass.h" |
| 41 | #include "llvm/Support/MathExtras.h" |
| 42 | #include <algorithm> |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 43 | #include <iterator> |
Chandler Carruth | 6bda14b | 2017-06-06 11:49:48 +0000 | [diff] [blame] | 44 | #include <limits> |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 45 | #include <utility> |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 46 | |
| 47 | using namespace llvm; |
| 48 | |
| 49 | namespace llvm { |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 50 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 51 | FunctionPass *createHexagonGenMux(); |
| 52 | void initializeHexagonGenMuxPass(PassRegistry& Registry); |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 53 | |
| 54 | } // end namespace llvm |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 55 | |
| 56 | namespace { |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 57 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 58 | class HexagonGenMux : public MachineFunctionPass { |
| 59 | public: |
| 60 | static char ID; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 61 | |
| 62 | HexagonGenMux() : MachineFunctionPass(ID), HII(nullptr), HRI(nullptr) { |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 63 | initializeHexagonGenMuxPass(*PassRegistry::getPassRegistry()); |
| 64 | } |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 65 | |
Mehdi Amini | 117296c | 2016-10-01 02:56:57 +0000 | [diff] [blame] | 66 | StringRef getPassName() const override { |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 67 | return "Hexagon generate mux instructions"; |
| 68 | } |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 69 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 70 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 71 | MachineFunctionPass::getAnalysisUsage(AU); |
| 72 | } |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 73 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 74 | bool runOnMachineFunction(MachineFunction &MF) override; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 75 | |
Derek Schuff | 1dbf7a5 | 2016-04-04 17:09:25 +0000 | [diff] [blame] | 76 | MachineFunctionProperties getRequiredProperties() const override { |
| 77 | return MachineFunctionProperties().set( |
Matthias Braun | 1eb4736 | 2016-08-25 01:27:13 +0000 | [diff] [blame] | 78 | MachineFunctionProperties::Property::NoVRegs); |
Derek Schuff | 1dbf7a5 | 2016-04-04 17:09:25 +0000 | [diff] [blame] | 79 | } |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 80 | |
| 81 | private: |
| 82 | const HexagonInstrInfo *HII; |
| 83 | const HexagonRegisterInfo *HRI; |
| 84 | |
| 85 | struct CondsetInfo { |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 86 | unsigned PredR = 0; |
| 87 | unsigned TrueX = std::numeric_limits<unsigned>::max(); |
| 88 | unsigned FalseX = std::numeric_limits<unsigned>::max(); |
| 89 | |
| 90 | CondsetInfo() = default; |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 91 | }; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 92 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 93 | struct DefUseInfo { |
| 94 | BitVector Defs, Uses; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 95 | |
| 96 | DefUseInfo() = default; |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 97 | DefUseInfo(const BitVector &D, const BitVector &U) : Defs(D), Uses(U) {} |
| 98 | }; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 99 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 100 | struct MuxInfo { |
| 101 | MachineBasicBlock::iterator At; |
| 102 | unsigned DefR, PredR; |
| 103 | MachineOperand *SrcT, *SrcF; |
| 104 | MachineInstr *Def1, *Def2; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 105 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 106 | MuxInfo(MachineBasicBlock::iterator It, unsigned DR, unsigned PR, |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 107 | MachineOperand *TOp, MachineOperand *FOp, MachineInstr &D1, |
| 108 | MachineInstr &D2) |
| 109 | : At(It), DefR(DR), PredR(PR), SrcT(TOp), SrcF(FOp), Def1(&D1), |
| 110 | Def2(&D2) {} |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 111 | }; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 112 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 113 | typedef DenseMap<MachineInstr*,unsigned> InstrIndexMap; |
| 114 | typedef DenseMap<unsigned,DefUseInfo> DefUseInfoMap; |
| 115 | typedef SmallVector<MuxInfo,4> MuxInfoList; |
| 116 | |
| 117 | bool isRegPair(unsigned Reg) const { |
| 118 | return Hexagon::DoubleRegsRegClass.contains(Reg); |
| 119 | } |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 120 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 121 | void getSubRegs(unsigned Reg, BitVector &SRs) const; |
| 122 | void expandReg(unsigned Reg, BitVector &Set) const; |
| 123 | void getDefsUses(const MachineInstr *MI, BitVector &Defs, |
| 124 | BitVector &Uses) const; |
| 125 | void buildMaps(MachineBasicBlock &B, InstrIndexMap &I2X, |
| 126 | DefUseInfoMap &DUM); |
| 127 | bool isCondTransfer(unsigned Opc) const; |
| 128 | unsigned getMuxOpcode(const MachineOperand &Src1, |
| 129 | const MachineOperand &Src2) const; |
| 130 | bool genMuxInBlock(MachineBasicBlock &B); |
| 131 | }; |
| 132 | |
| 133 | char HexagonGenMux::ID = 0; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 134 | |
| 135 | } // end anonymous namespace |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 136 | |
| 137 | INITIALIZE_PASS(HexagonGenMux, "hexagon-mux", |
| 138 | "Hexagon generate mux instructions", false, false) |
| 139 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 140 | void HexagonGenMux::getSubRegs(unsigned Reg, BitVector &SRs) const { |
| 141 | for (MCSubRegIterator I(Reg, HRI); I.isValid(); ++I) |
| 142 | SRs[*I] = true; |
| 143 | } |
| 144 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 145 | void HexagonGenMux::expandReg(unsigned Reg, BitVector &Set) const { |
| 146 | if (isRegPair(Reg)) |
| 147 | getSubRegs(Reg, Set); |
| 148 | else |
| 149 | Set[Reg] = true; |
| 150 | } |
| 151 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 152 | void HexagonGenMux::getDefsUses(const MachineInstr *MI, BitVector &Defs, |
| 153 | BitVector &Uses) const { |
| 154 | // First, get the implicit defs and uses for this instruction. |
| 155 | unsigned Opc = MI->getOpcode(); |
| 156 | const MCInstrDesc &D = HII->get(Opc); |
Craig Topper | e5e035a3 | 2015-12-05 07:13:35 +0000 | [diff] [blame] | 157 | if (const MCPhysReg *R = D.ImplicitDefs) |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 158 | while (*R) |
| 159 | expandReg(*R++, Defs); |
Craig Topper | e5e035a3 | 2015-12-05 07:13:35 +0000 | [diff] [blame] | 160 | if (const MCPhysReg *R = D.ImplicitUses) |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 161 | while (*R) |
| 162 | expandReg(*R++, Uses); |
| 163 | |
| 164 | // Look over all operands, and collect explicit defs and uses. |
Matthias Braun | fc37155 | 2016-10-24 21:36:43 +0000 | [diff] [blame] | 165 | for (const MachineOperand &MO : MI->operands()) { |
| 166 | if (!MO.isReg() || MO.isImplicit()) |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 167 | continue; |
Matthias Braun | fc37155 | 2016-10-24 21:36:43 +0000 | [diff] [blame] | 168 | unsigned R = MO.getReg(); |
| 169 | BitVector &Set = MO.isDef() ? Defs : Uses; |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 170 | expandReg(R, Set); |
| 171 | } |
| 172 | } |
| 173 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 174 | void HexagonGenMux::buildMaps(MachineBasicBlock &B, InstrIndexMap &I2X, |
| 175 | DefUseInfoMap &DUM) { |
| 176 | unsigned Index = 0; |
| 177 | unsigned NR = HRI->getNumRegs(); |
| 178 | BitVector Defs(NR), Uses(NR); |
| 179 | |
| 180 | for (MachineBasicBlock::iterator I = B.begin(), E = B.end(); I != E; ++I) { |
| 181 | MachineInstr *MI = &*I; |
| 182 | I2X.insert(std::make_pair(MI, Index)); |
| 183 | Defs.reset(); |
| 184 | Uses.reset(); |
| 185 | getDefsUses(MI, Defs, Uses); |
| 186 | DUM.insert(std::make_pair(Index, DefUseInfo(Defs, Uses))); |
| 187 | Index++; |
| 188 | } |
| 189 | } |
| 190 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 191 | bool HexagonGenMux::isCondTransfer(unsigned Opc) const { |
| 192 | switch (Opc) { |
| 193 | case Hexagon::A2_tfrt: |
| 194 | case Hexagon::A2_tfrf: |
| 195 | case Hexagon::C2_cmoveit: |
| 196 | case Hexagon::C2_cmoveif: |
| 197 | return true; |
| 198 | } |
| 199 | return false; |
| 200 | } |
| 201 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 202 | unsigned HexagonGenMux::getMuxOpcode(const MachineOperand &Src1, |
| 203 | const MachineOperand &Src2) const { |
| 204 | bool IsReg1 = Src1.isReg(), IsReg2 = Src2.isReg(); |
| 205 | if (IsReg1) |
| 206 | return IsReg2 ? Hexagon::C2_mux : Hexagon::C2_muxir; |
| 207 | if (IsReg2) |
| 208 | return Hexagon::C2_muxri; |
| 209 | |
| 210 | // Neither is a register. The first source is extendable, but the second |
| 211 | // is not (s8). |
| 212 | if (Src2.isImm() && isInt<8>(Src2.getImm())) |
| 213 | return Hexagon::C2_muxii; |
| 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 218 | bool HexagonGenMux::genMuxInBlock(MachineBasicBlock &B) { |
| 219 | bool Changed = false; |
| 220 | InstrIndexMap I2X; |
| 221 | DefUseInfoMap DUM; |
| 222 | buildMaps(B, I2X, DUM); |
| 223 | |
| 224 | typedef DenseMap<unsigned,CondsetInfo> CondsetMap; |
| 225 | CondsetMap CM; |
| 226 | MuxInfoList ML; |
| 227 | |
| 228 | MachineBasicBlock::iterator NextI, End = B.end(); |
| 229 | for (MachineBasicBlock::iterator I = B.begin(); I != End; I = NextI) { |
| 230 | MachineInstr *MI = &*I; |
| 231 | NextI = std::next(I); |
| 232 | unsigned Opc = MI->getOpcode(); |
| 233 | if (!isCondTransfer(Opc)) |
| 234 | continue; |
| 235 | unsigned DR = MI->getOperand(0).getReg(); |
| 236 | if (isRegPair(DR)) |
| 237 | continue; |
Krzysztof Parzyszek | 8a7fb0f | 2017-06-08 20:56:36 +0000 | [diff] [blame^] | 238 | MachineOperand &PredOp = MI->getOperand(1); |
| 239 | if (PredOp.isUndef()) |
| 240 | continue; |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 241 | |
Krzysztof Parzyszek | 8a7fb0f | 2017-06-08 20:56:36 +0000 | [diff] [blame^] | 242 | unsigned PR = PredOp.getReg(); |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 243 | unsigned Idx = I2X.lookup(MI); |
| 244 | CondsetMap::iterator F = CM.find(DR); |
| 245 | bool IfTrue = HII->isPredicatedTrue(Opc); |
| 246 | |
| 247 | // If there is no record of a conditional transfer for this register, |
| 248 | // or the predicate register differs, create a new record for it. |
| 249 | if (F != CM.end() && F->second.PredR != PR) { |
| 250 | CM.erase(F); |
| 251 | F = CM.end(); |
| 252 | } |
| 253 | if (F == CM.end()) { |
| 254 | auto It = CM.insert(std::make_pair(DR, CondsetInfo())); |
| 255 | F = It.first; |
| 256 | F->second.PredR = PR; |
| 257 | } |
| 258 | CondsetInfo &CI = F->second; |
| 259 | if (IfTrue) |
| 260 | CI.TrueX = Idx; |
| 261 | else |
| 262 | CI.FalseX = Idx; |
Eugene Zelenko | 26e8c7d | 2016-12-16 01:00:40 +0000 | [diff] [blame] | 263 | if (CI.TrueX == std::numeric_limits<unsigned>::max() || |
| 264 | CI.FalseX == std::numeric_limits<unsigned>::max()) |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 265 | continue; |
| 266 | |
| 267 | // There is now a complete definition of DR, i.e. we have the predicate |
| 268 | // register, the definition if-true, and definition if-false. |
| 269 | |
| 270 | // First, check if both definitions are far enough from the definition |
| 271 | // of the predicate register. |
| 272 | unsigned MinX = std::min(CI.TrueX, CI.FalseX); |
| 273 | unsigned MaxX = std::max(CI.TrueX, CI.FalseX); |
| 274 | unsigned SearchX = (MaxX > 4) ? MaxX-4 : 0; |
| 275 | bool NearDef = false; |
| 276 | for (unsigned X = SearchX; X < MaxX; ++X) { |
| 277 | const DefUseInfo &DU = DUM.lookup(X); |
| 278 | if (!DU.Defs[PR]) |
| 279 | continue; |
| 280 | NearDef = true; |
| 281 | break; |
| 282 | } |
| 283 | if (NearDef) |
| 284 | continue; |
| 285 | |
| 286 | // The predicate register is not defined in the last few instructions. |
| 287 | // Check if the conversion to MUX is possible (either "up", i.e. at the |
| 288 | // place of the earlier partial definition, or "down", where the later |
| 289 | // definition is located). Examine all defs and uses between these two |
| 290 | // definitions. |
| 291 | // SR1, SR2 - source registers from the first and the second definition. |
| 292 | MachineBasicBlock::iterator It1 = B.begin(), It2 = B.begin(); |
| 293 | std::advance(It1, MinX); |
| 294 | std::advance(It2, MaxX); |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 295 | MachineInstr &Def1 = *It1, &Def2 = *It2; |
| 296 | MachineOperand *Src1 = &Def1.getOperand(2), *Src2 = &Def2.getOperand(2); |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 297 | unsigned SR1 = Src1->isReg() ? Src1->getReg() : 0; |
| 298 | unsigned SR2 = Src2->isReg() ? Src2->getReg() : 0; |
| 299 | bool Failure = false, CanUp = true, CanDown = true; |
| 300 | for (unsigned X = MinX+1; X < MaxX; X++) { |
| 301 | const DefUseInfo &DU = DUM.lookup(X); |
| 302 | if (DU.Defs[PR] || DU.Defs[DR] || DU.Uses[DR]) { |
| 303 | Failure = true; |
| 304 | break; |
| 305 | } |
| 306 | if (CanDown && DU.Defs[SR1]) |
| 307 | CanDown = false; |
| 308 | if (CanUp && DU.Defs[SR2]) |
| 309 | CanUp = false; |
| 310 | } |
| 311 | if (Failure || (!CanUp && !CanDown)) |
| 312 | continue; |
| 313 | |
| 314 | MachineOperand *SrcT = (MinX == CI.TrueX) ? Src1 : Src2; |
| 315 | MachineOperand *SrcF = (MinX == CI.FalseX) ? Src1 : Src2; |
| 316 | // Prefer "down", since this will move the MUX farther away from the |
| 317 | // predicate definition. |
| 318 | MachineBasicBlock::iterator At = CanDown ? Def2 : Def1; |
| 319 | ML.push_back(MuxInfo(At, DR, PR, SrcT, SrcF, Def1, Def2)); |
| 320 | } |
| 321 | |
| 322 | for (unsigned I = 0, N = ML.size(); I < N; ++I) { |
| 323 | MuxInfo &MX = ML[I]; |
| 324 | MachineBasicBlock &B = *MX.At->getParent(); |
| 325 | DebugLoc DL = MX.At->getDebugLoc(); |
| 326 | unsigned MxOpc = getMuxOpcode(*MX.SrcT, *MX.SrcF); |
| 327 | if (!MxOpc) |
| 328 | continue; |
| 329 | BuildMI(B, MX.At, DL, HII->get(MxOpc), MX.DefR) |
Diana Picus | 116bbab | 2017-01-13 09:58:52 +0000 | [diff] [blame] | 330 | .addReg(MX.PredR) |
| 331 | .add(*MX.SrcT) |
| 332 | .add(*MX.SrcF); |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 333 | B.erase(MX.Def1); |
| 334 | B.erase(MX.Def2); |
| 335 | Changed = true; |
| 336 | } |
| 337 | |
| 338 | return Changed; |
| 339 | } |
| 340 | |
| 341 | bool HexagonGenMux::runOnMachineFunction(MachineFunction &MF) { |
Andrew Kaylor | 5b444a2 | 2016-04-26 19:46:28 +0000 | [diff] [blame] | 342 | if (skipFunction(*MF.getFunction())) |
| 343 | return false; |
Krzysztof Parzyszek | 9217220 | 2015-07-20 21:23:25 +0000 | [diff] [blame] | 344 | HII = MF.getSubtarget<HexagonSubtarget>().getInstrInfo(); |
| 345 | HRI = MF.getSubtarget<HexagonSubtarget>().getRegisterInfo(); |
| 346 | bool Changed = false; |
| 347 | for (auto &I : MF) |
| 348 | Changed |= genMuxInBlock(I); |
| 349 | return Changed; |
| 350 | } |
| 351 | |
| 352 | FunctionPass *llvm::createHexagonGenMux() { |
| 353 | return new HexagonGenMux(); |
| 354 | } |