Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 1 | //===------- HexagonCopyToCombine.cpp - Hexagon Copy-To-Combine Pass ------===// |
| 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 | // This pass replaces transfer instructions by combine instructions. |
| 10 | // We walk along a basic block and look for two combinable instructions and try |
| 11 | // to move them together. If we can move them next to each other we do so and |
| 12 | // replace them with a combine instruction. |
| 13 | //===----------------------------------------------------------------------===// |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 14 | #include "HexagonInstrInfo.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 15 | #include "HexagonSubtarget.h" |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 16 | #include "llvm/PassSupport.h" |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/DenseMap.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/DenseSet.h" |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineBasicBlock.h" |
| 20 | #include "llvm/CodeGen/MachineFunction.h" |
| 21 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 22 | #include "llvm/CodeGen/MachineInstr.h" |
| 23 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/Passes.h" |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 25 | #include "llvm/Support/CodeGen.h" |
| 26 | #include "llvm/Support/CommandLine.h" |
| 27 | #include "llvm/Support/Debug.h" |
| 28 | #include "llvm/Support/raw_ostream.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 29 | #include "llvm/Target/TargetRegisterInfo.h" |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 30 | |
| 31 | using namespace llvm; |
| 32 | |
Chandler Carruth | 84e68b2 | 2014-04-22 02:41:26 +0000 | [diff] [blame] | 33 | #define DEBUG_TYPE "hexagon-copy-combine" |
| 34 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 35 | static |
| 36 | cl::opt<bool> IsCombinesDisabled("disable-merge-into-combines", |
| 37 | cl::Hidden, cl::ZeroOrMore, |
| 38 | cl::init(false), |
| 39 | cl::desc("Disable merging into combines")); |
| 40 | static |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 41 | cl::opt<bool> IsConst64Disabled("disable-const64", |
| 42 | cl::Hidden, cl::ZeroOrMore, |
| 43 | cl::init(false), |
| 44 | cl::desc("Disable generation of const64")); |
| 45 | static |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 46 | cl::opt<unsigned> |
| 47 | MaxNumOfInstsBetweenNewValueStoreAndTFR("max-num-inst-between-tfr-and-nv-store", |
| 48 | cl::Hidden, cl::init(4), |
| 49 | cl::desc("Maximum distance between a tfr feeding a store we " |
| 50 | "consider the store still to be newifiable")); |
| 51 | |
| 52 | namespace llvm { |
Colin LeMahieu | 56efafc | 2015-06-15 19:05:35 +0000 | [diff] [blame] | 53 | FunctionPass *createHexagonCopyToCombine(); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 54 | void initializeHexagonCopyToCombinePass(PassRegistry&); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | namespace { |
| 59 | |
| 60 | class HexagonCopyToCombine : public MachineFunctionPass { |
| 61 | const HexagonInstrInfo *TII; |
| 62 | const TargetRegisterInfo *TRI; |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 63 | const HexagonSubtarget *ST; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 64 | bool ShouldCombineAggressively; |
| 65 | |
| 66 | DenseSet<MachineInstr *> PotentiallyNewifiableTFR; |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 67 | SmallVector<MachineInstr *, 8> DbgMItoMove; |
| 68 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 69 | public: |
| 70 | static char ID; |
| 71 | |
| 72 | HexagonCopyToCombine() : MachineFunctionPass(ID) { |
| 73 | initializeHexagonCopyToCombinePass(*PassRegistry::getPassRegistry()); |
| 74 | } |
| 75 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 76 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 77 | MachineFunctionPass::getAnalysisUsage(AU); |
| 78 | } |
| 79 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 80 | const char *getPassName() const override { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 81 | return "Hexagon Copy-To-Combine Pass"; |
| 82 | } |
| 83 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 84 | bool runOnMachineFunction(MachineFunction &Fn) override; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 85 | |
Derek Schuff | 1dbf7a5 | 2016-04-04 17:09:25 +0000 | [diff] [blame] | 86 | MachineFunctionProperties getRequiredProperties() const override { |
| 87 | return MachineFunctionProperties().set( |
Matthias Braun | 1eb4736 | 2016-08-25 01:27:13 +0000 | [diff] [blame] | 88 | MachineFunctionProperties::Property::NoVRegs); |
Derek Schuff | 1dbf7a5 | 2016-04-04 17:09:25 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 91 | private: |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 92 | MachineInstr *findPairable(MachineInstr &I1, bool &DoInsertAtI1, |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 93 | bool AllowC64); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 94 | |
| 95 | void findPotentialNewifiableTFRs(MachineBasicBlock &); |
| 96 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 97 | void combine(MachineInstr &I1, MachineInstr &I2, |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 98 | MachineBasicBlock::iterator &MI, bool DoInsertAtI1, |
| 99 | bool OptForSize); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 100 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 101 | bool isSafeToMoveTogether(MachineInstr &I1, MachineInstr &I2, |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 102 | unsigned I1DestReg, unsigned I2DestReg, |
| 103 | bool &DoInsertAtI1); |
| 104 | |
| 105 | void emitCombineRR(MachineBasicBlock::iterator &Before, unsigned DestReg, |
| 106 | MachineOperand &HiOperand, MachineOperand &LoOperand); |
| 107 | |
| 108 | void emitCombineRI(MachineBasicBlock::iterator &Before, unsigned DestReg, |
| 109 | MachineOperand &HiOperand, MachineOperand &LoOperand); |
| 110 | |
| 111 | void emitCombineIR(MachineBasicBlock::iterator &Before, unsigned DestReg, |
| 112 | MachineOperand &HiOperand, MachineOperand &LoOperand); |
| 113 | |
| 114 | void emitCombineII(MachineBasicBlock::iterator &Before, unsigned DestReg, |
| 115 | MachineOperand &HiOperand, MachineOperand &LoOperand); |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 116 | |
| 117 | void emitConst64(MachineBasicBlock::iterator &Before, unsigned DestReg, |
| 118 | MachineOperand &HiOperand, MachineOperand &LoOperand); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | } // End anonymous namespace. |
| 122 | |
| 123 | char HexagonCopyToCombine::ID = 0; |
| 124 | |
| 125 | INITIALIZE_PASS(HexagonCopyToCombine, "hexagon-copy-combine", |
| 126 | "Hexagon Copy-To-Combine Pass", false, false) |
| 127 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 128 | static bool isCombinableInstType(MachineInstr &MI, const HexagonInstrInfo *TII, |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 129 | bool ShouldCombineAggressively) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 130 | switch (MI.getOpcode()) { |
Colin LeMahieu | 4af437f | 2014-12-09 20:23:30 +0000 | [diff] [blame] | 131 | case Hexagon::A2_tfr: { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 132 | // A COPY instruction can be combined if its arguments are IntRegs (32bit). |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 133 | const MachineOperand &Op0 = MI.getOperand(0); |
| 134 | const MachineOperand &Op1 = MI.getOperand(1); |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 135 | assert(Op0.isReg() && Op1.isReg()); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 136 | |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 137 | unsigned DestReg = Op0.getReg(); |
| 138 | unsigned SrcReg = Op1.getReg(); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 139 | return Hexagon::IntRegsRegClass.contains(DestReg) && |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 140 | Hexagon::IntRegsRegClass.contains(SrcReg); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Colin LeMahieu | 4af437f | 2014-12-09 20:23:30 +0000 | [diff] [blame] | 143 | case Hexagon::A2_tfrsi: { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 144 | // A transfer-immediate can be combined if its argument is a signed 8bit |
| 145 | // value. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 146 | const MachineOperand &Op0 = MI.getOperand(0); |
| 147 | const MachineOperand &Op1 = MI.getOperand(1); |
Colin LeMahieu | 2efa2d0 | 2015-03-09 21:48:13 +0000 | [diff] [blame] | 148 | assert(Op0.isReg()); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 149 | |
Colin LeMahieu | 2efa2d0 | 2015-03-09 21:48:13 +0000 | [diff] [blame] | 150 | unsigned DestReg = Op0.getReg(); |
| 151 | // Ensure that TargetFlags are MO_NO_FLAG for a global. This is a |
| 152 | // workaround for an ABI bug that prevents GOT relocations on combine |
| 153 | // instructions |
| 154 | if (!Op1.isImm() && Op1.getTargetFlags() != HexagonII::MO_NO_FLAG) |
| 155 | return false; |
| 156 | |
| 157 | // Only combine constant extended A2_tfrsi if we are in aggressive mode. |
| 158 | bool NotExt = Op1.isImm() && isInt<8>(Op1.getImm()); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 159 | return Hexagon::IntRegsRegClass.contains(DestReg) && |
Colin LeMahieu | 2efa2d0 | 2015-03-09 21:48:13 +0000 | [diff] [blame] | 160 | (ShouldCombineAggressively || NotExt); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 161 | } |
| 162 | |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 163 | case Hexagon::V6_vassign: |
| 164 | case Hexagon::V6_vassign_128B: |
| 165 | return true; |
| 166 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 167 | default: |
| 168 | break; |
| 169 | } |
| 170 | |
| 171 | return false; |
| 172 | } |
| 173 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 174 | template <unsigned N> static bool isGreaterThanNBitTFRI(const MachineInstr &I) { |
| 175 | if (I.getOpcode() == Hexagon::TFRI64_V4 || |
| 176 | I.getOpcode() == Hexagon::A2_tfrsi) { |
| 177 | const MachineOperand &Op = I.getOperand(1); |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 178 | return !Op.isImm() || !isInt<N>(Op.getImm()); |
| 179 | } |
| 180 | return false; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /// areCombinableOperations - Returns true if the two instruction can be merge |
| 184 | /// into a combine (ignoring register constraints). |
| 185 | static bool areCombinableOperations(const TargetRegisterInfo *TRI, |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 186 | MachineInstr &HighRegInst, |
| 187 | MachineInstr &LowRegInst, bool AllowC64) { |
| 188 | unsigned HiOpc = HighRegInst.getOpcode(); |
| 189 | unsigned LoOpc = LowRegInst.getOpcode(); |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 190 | |
| 191 | auto verifyOpc = [](unsigned Opc) -> void { |
| 192 | switch (Opc) { |
| 193 | case Hexagon::A2_tfr: |
| 194 | case Hexagon::A2_tfrsi: |
| 195 | case Hexagon::V6_vassign: |
| 196 | break; |
| 197 | default: |
| 198 | llvm_unreachable("Unexpected opcode"); |
| 199 | } |
| 200 | }; |
| 201 | verifyOpc(HiOpc); |
| 202 | verifyOpc(LoOpc); |
| 203 | |
| 204 | if (HiOpc == Hexagon::V6_vassign || LoOpc == Hexagon::V6_vassign) |
| 205 | return HiOpc == LoOpc; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 206 | |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 207 | if (!AllowC64) { |
| 208 | // There is no combine of two constant extended values. |
| 209 | if (isGreaterThanNBitTFRI<8>(HighRegInst) && |
| 210 | isGreaterThanNBitTFRI<6>(LowRegInst)) |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | // There is a combine of two constant extended values into CONST64, |
| 215 | // provided both constants are true immediates. |
| 216 | if (isGreaterThanNBitTFRI<16>(HighRegInst) && |
| 217 | isGreaterThanNBitTFRI<16>(LowRegInst)) |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 218 | return (HighRegInst.getOperand(1).isImm() && |
| 219 | LowRegInst.getOperand(1).isImm()); |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 220 | |
| 221 | // There is no combine of two constant extended values, unless handled above |
| 222 | // Make both 8-bit size checks to allow both combine (#,##) and combine(##,#) |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 223 | if (isGreaterThanNBitTFRI<8>(HighRegInst) && |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 224 | isGreaterThanNBitTFRI<8>(LowRegInst)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 225 | return false; |
| 226 | |
| 227 | return true; |
| 228 | } |
| 229 | |
| 230 | static bool isEvenReg(unsigned Reg) { |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 231 | assert(TargetRegisterInfo::isPhysicalRegister(Reg)); |
| 232 | if (Hexagon::IntRegsRegClass.contains(Reg)) |
| 233 | return (Reg - Hexagon::R0) % 2 == 0; |
| 234 | if (Hexagon::VectorRegsRegClass.contains(Reg) || |
| 235 | Hexagon::VectorRegs128BRegClass.contains(Reg)) |
| 236 | return (Reg - Hexagon::V0) % 2 == 0; |
| 237 | llvm_unreachable("Invalid register"); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 240 | static void removeKillInfo(MachineInstr &MI, unsigned RegNotKilled) { |
| 241 | for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I) { |
| 242 | MachineOperand &Op = MI.getOperand(I); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 243 | if (!Op.isReg() || Op.getReg() != RegNotKilled || !Op.isKill()) |
| 244 | continue; |
| 245 | Op.setIsKill(false); |
| 246 | } |
| 247 | } |
| 248 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 249 | /// Returns true if it is unsafe to move a copy instruction from \p UseReg to |
| 250 | /// \p DestReg over the instruction \p MI. |
| 251 | static bool isUnsafeToMoveAcross(MachineInstr &MI, unsigned UseReg, |
| 252 | unsigned DestReg, |
| 253 | const TargetRegisterInfo *TRI) { |
| 254 | return (UseReg && (MI.modifiesRegister(UseReg, TRI))) || |
| 255 | MI.modifiesRegister(DestReg, TRI) || MI.readsRegister(DestReg, TRI) || |
| 256 | MI.hasUnmodeledSideEffects() || MI.isInlineAsm() || MI.isDebugValue(); |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | static unsigned UseReg(const MachineOperand& MO) { |
| 260 | return MO.isReg() ? MO.getReg() : 0; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | /// isSafeToMoveTogether - Returns true if it is safe to move I1 next to I2 such |
| 264 | /// that the two instructions can be paired in a combine. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 265 | bool HexagonCopyToCombine::isSafeToMoveTogether(MachineInstr &I1, |
| 266 | MachineInstr &I2, |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 267 | unsigned I1DestReg, |
| 268 | unsigned I2DestReg, |
| 269 | bool &DoInsertAtI1) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 270 | unsigned I2UseReg = UseReg(I2.getOperand(1)); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 271 | |
| 272 | // It is not safe to move I1 and I2 into one combine if I2 has a true |
| 273 | // dependence on I1. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 274 | if (I2UseReg && I1.modifiesRegister(I2UseReg, TRI)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 275 | return false; |
| 276 | |
| 277 | bool isSafe = true; |
| 278 | |
| 279 | // First try to move I2 towards I1. |
| 280 | { |
| 281 | // A reverse_iterator instantiated like below starts before I2, and I1 |
| 282 | // respectively. |
| 283 | // Look at instructions I in between I2 and (excluding) I1. |
| 284 | MachineBasicBlock::reverse_iterator I(I2), |
| 285 | End = --(MachineBasicBlock::reverse_iterator(I1)); |
| 286 | // At 03 we got better results (dhrystone!) by being more conservative. |
| 287 | if (!ShouldCombineAggressively) |
| 288 | End = MachineBasicBlock::reverse_iterator(I1); |
| 289 | // If I2 kills its operand and we move I2 over an instruction that also |
| 290 | // uses I2's use reg we need to modify that (first) instruction to now kill |
| 291 | // this reg. |
| 292 | unsigned KilledOperand = 0; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 293 | if (I2.killsRegister(I2UseReg)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 294 | KilledOperand = I2UseReg; |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 295 | MachineInstr *KillingInstr = nullptr; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 296 | |
| 297 | for (; I != End; ++I) { |
| 298 | // If the intervening instruction I: |
| 299 | // * modifies I2's use reg |
| 300 | // * modifies I2's def reg |
| 301 | // * reads I2's def reg |
| 302 | // * or has unmodelled side effects |
| 303 | // we can't move I2 across it. |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 304 | if (I->isDebugValue()) |
| 305 | continue; |
| 306 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 307 | if (isUnsafeToMoveAcross(*I, I2UseReg, I2DestReg, TRI)) { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 308 | isSafe = false; |
| 309 | break; |
| 310 | } |
| 311 | |
| 312 | // Update first use of the killed operand. |
| 313 | if (!KillingInstr && KilledOperand && |
| 314 | I->readsRegister(KilledOperand, TRI)) |
| 315 | KillingInstr = &*I; |
| 316 | } |
| 317 | if (isSafe) { |
| 318 | // Update the intermediate instruction to with the kill flag. |
| 319 | if (KillingInstr) { |
| 320 | bool Added = KillingInstr->addRegisterKilled(KilledOperand, TRI, true); |
Alp Toker | cb40291 | 2014-01-24 17:20:08 +0000 | [diff] [blame] | 321 | (void)Added; // suppress compiler warning |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 322 | assert(Added && "Must successfully update kill flag"); |
| 323 | removeKillInfo(I2, KilledOperand); |
| 324 | } |
| 325 | DoInsertAtI1 = true; |
| 326 | return true; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | // Try to move I1 towards I2. |
| 331 | { |
| 332 | // Look at instructions I in between I1 and (excluding) I2. |
| 333 | MachineBasicBlock::iterator I(I1), End(I2); |
| 334 | // At O3 we got better results (dhrystone) by being more conservative here. |
| 335 | if (!ShouldCombineAggressively) |
Benjamin Kramer | b6d0bd4 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 336 | End = std::next(MachineBasicBlock::iterator(I2)); |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 337 | unsigned I1UseReg = UseReg(I1.getOperand(1)); |
Jyotsna Verma | cceafb2 | 2013-05-28 19:01:45 +0000 | [diff] [blame] | 338 | // Track killed operands. If we move across an instruction that kills our |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 339 | // operand, we need to update the kill information on the moved I1. It kills |
| 340 | // the operand now. |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 341 | MachineInstr *KillingInstr = nullptr; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 342 | unsigned KilledOperand = 0; |
| 343 | |
| 344 | while(++I != End) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 345 | MachineInstr &MI = *I; |
| 346 | // If the intervening instruction MI: |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 347 | // * modifies I1's use reg |
| 348 | // * modifies I1's def reg |
| 349 | // * reads I1's def reg |
| 350 | // * or has unmodelled side effects |
| 351 | // We introduce this special case because llvm has no api to remove a |
| 352 | // kill flag for a register (a removeRegisterKilled() analogous to |
| 353 | // addRegisterKilled) that handles aliased register correctly. |
| 354 | // * or has a killed aliased register use of I1's use reg |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 355 | // %D4<def> = A2_tfrpi 16 |
| 356 | // %R6<def> = A2_tfr %R9 |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 357 | // %R8<def> = KILL %R8, %D4<imp-use,kill> |
| 358 | // If we want to move R6 = across the KILL instruction we would have |
| 359 | // to remove the %D4<imp-use,kill> operand. For now, we are |
| 360 | // conservative and disallow the move. |
| 361 | // we can't move I1 across it. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 362 | if (MI.isDebugValue()) { |
| 363 | if (MI.readsRegister(I1DestReg, TRI)) // Move this instruction after I2. |
| 364 | DbgMItoMove.push_back(&MI); |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 365 | continue; |
| 366 | } |
| 367 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 368 | if (isUnsafeToMoveAcross(MI, I1UseReg, I1DestReg, TRI) || |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 369 | // Check for an aliased register kill. Bail out if we see one. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 370 | (!MI.killsRegister(I1UseReg) && MI.killsRegister(I1UseReg, TRI))) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 371 | return false; |
| 372 | |
| 373 | // Check for an exact kill (registers match). |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 374 | if (I1UseReg && MI.killsRegister(I1UseReg)) { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 375 | assert(!KillingInstr && "Should only see one killing instruction"); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 376 | KilledOperand = I1UseReg; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 377 | KillingInstr = &MI; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 378 | } |
| 379 | } |
| 380 | if (KillingInstr) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 381 | removeKillInfo(*KillingInstr, KilledOperand); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 382 | // Update I1 to set the kill flag. This flag will later be picked up by |
| 383 | // the new COMBINE instruction. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 384 | bool Added = I1.addRegisterKilled(KilledOperand, TRI); |
Alp Toker | cb40291 | 2014-01-24 17:20:08 +0000 | [diff] [blame] | 385 | (void)Added; // suppress compiler warning |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 386 | assert(Added && "Must successfully update kill flag"); |
| 387 | } |
| 388 | DoInsertAtI1 = false; |
| 389 | } |
| 390 | |
| 391 | return true; |
| 392 | } |
| 393 | |
| 394 | /// findPotentialNewifiableTFRs - Finds tranfers that feed stores that could be |
| 395 | /// newified. (A use of a 64 bit register define can not be newified) |
| 396 | void |
| 397 | HexagonCopyToCombine::findPotentialNewifiableTFRs(MachineBasicBlock &BB) { |
| 398 | DenseMap<unsigned, MachineInstr *> LastDef; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 399 | for (MachineInstr &MI : BB) { |
| 400 | if (MI.isDebugValue()) |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 401 | continue; |
| 402 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 403 | // Mark TFRs that feed a potential new value store as such. |
Krzysztof Parzyszek | f0b34a5 | 2016-07-29 21:49:42 +0000 | [diff] [blame] | 404 | if (TII->mayBeNewStore(MI)) { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 405 | // Look for uses of TFR instructions. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 406 | for (unsigned OpdIdx = 0, OpdE = MI.getNumOperands(); OpdIdx != OpdE; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 407 | ++OpdIdx) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 408 | MachineOperand &Op = MI.getOperand(OpdIdx); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 409 | |
| 410 | // Skip over anything except register uses. |
| 411 | if (!Op.isReg() || !Op.isUse() || !Op.getReg()) |
| 412 | continue; |
| 413 | |
| 414 | // Look for the defining instruction. |
| 415 | unsigned Reg = Op.getReg(); |
| 416 | MachineInstr *DefInst = LastDef[Reg]; |
| 417 | if (!DefInst) |
| 418 | continue; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 419 | if (!isCombinableInstType(*DefInst, TII, ShouldCombineAggressively)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 420 | continue; |
| 421 | |
| 422 | // Only close newifiable stores should influence the decision. |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 423 | // Ignore the debug instructions in between. |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 424 | MachineBasicBlock::iterator It(DefInst); |
| 425 | unsigned NumInstsToDef = 0; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 426 | while (&*It != &MI) { |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 427 | if (!It->isDebugValue()) |
| 428 | ++NumInstsToDef; |
Krzysztof Parzyszek | 14f9535e | 2016-01-21 12:45:17 +0000 | [diff] [blame] | 429 | ++It; |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 430 | } |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 431 | |
| 432 | if (NumInstsToDef > MaxNumOfInstsBetweenNewValueStoreAndTFR) |
| 433 | continue; |
| 434 | |
| 435 | PotentiallyNewifiableTFR.insert(DefInst); |
| 436 | } |
| 437 | // Skip to next instruction. |
| 438 | continue; |
| 439 | } |
| 440 | |
| 441 | // Put instructions that last defined integer or double registers into the |
| 442 | // map. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 443 | for (unsigned I = 0, E = MI.getNumOperands(); I != E; ++I) { |
| 444 | MachineOperand &Op = MI.getOperand(I); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 445 | if (!Op.isReg() || !Op.isDef() || !Op.getReg()) |
| 446 | continue; |
| 447 | unsigned Reg = Op.getReg(); |
| 448 | if (Hexagon::DoubleRegsRegClass.contains(Reg)) { |
| 449 | for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 450 | LastDef[*SubRegs] = &MI; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 451 | } |
| 452 | } else if (Hexagon::IntRegsRegClass.contains(Reg)) |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 453 | LastDef[Reg] = &MI; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | bool HexagonCopyToCombine::runOnMachineFunction(MachineFunction &MF) { |
| 459 | |
| 460 | if (IsCombinesDisabled) return false; |
| 461 | |
| 462 | bool HasChanged = false; |
| 463 | |
| 464 | // Get target info. |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 465 | ST = &MF.getSubtarget<HexagonSubtarget>(); |
| 466 | TRI = ST->getRegisterInfo(); |
| 467 | TII = ST->getInstrInfo(); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 468 | |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 469 | const Function *F = MF.getFunction(); |
| 470 | bool OptForSize = F->hasFnAttribute(Attribute::OptimizeForSize); |
| 471 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 472 | // Combine aggressively (for code size) |
| 473 | ShouldCombineAggressively = |
| 474 | MF.getTarget().getOptLevel() <= CodeGenOpt::Default; |
| 475 | |
| 476 | // Traverse basic blocks. |
| 477 | for (MachineFunction::iterator BI = MF.begin(), BE = MF.end(); BI != BE; |
| 478 | ++BI) { |
| 479 | PotentiallyNewifiableTFR.clear(); |
| 480 | findPotentialNewifiableTFRs(*BI); |
| 481 | |
| 482 | // Traverse instructions in basic block. |
| 483 | for(MachineBasicBlock::iterator MI = BI->begin(), End = BI->end(); |
| 484 | MI != End;) { |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 485 | MachineInstr &I1 = *MI++; |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 486 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 487 | if (I1.isDebugValue()) |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 488 | continue; |
| 489 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 490 | // Don't combine a TFR whose user could be newified (instructions that |
| 491 | // define double registers can not be newified - Programmer's Ref Manual |
| 492 | // 5.4.2 New-value stores). |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 493 | if (ShouldCombineAggressively && PotentiallyNewifiableTFR.count(&I1)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 494 | continue; |
| 495 | |
| 496 | // Ignore instructions that are not combinable. |
| 497 | if (!isCombinableInstType(I1, TII, ShouldCombineAggressively)) |
| 498 | continue; |
| 499 | |
| 500 | // Find a second instruction that can be merged into a combine |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 501 | // instruction. In addition, also find all the debug instructions that |
| 502 | // need to be moved along with it. |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 503 | bool DoInsertAtI1 = false; |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 504 | DbgMItoMove.clear(); |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 505 | MachineInstr *I2 = findPairable(I1, DoInsertAtI1, OptForSize); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 506 | if (I2) { |
| 507 | HasChanged = true; |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 508 | combine(I1, *I2, MI, DoInsertAtI1, OptForSize); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | return HasChanged; |
| 514 | } |
| 515 | |
| 516 | /// findPairable - Returns an instruction that can be merged with \p I1 into a |
| 517 | /// COMBINE instruction or 0 if no such instruction can be found. Returns true |
| 518 | /// in \p DoInsertAtI1 if the combine must be inserted at instruction \p I1 |
| 519 | /// false if the combine must be inserted at the returned instruction. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 520 | MachineInstr *HexagonCopyToCombine::findPairable(MachineInstr &I1, |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 521 | bool &DoInsertAtI1, |
| 522 | bool AllowC64) { |
Benjamin Kramer | b6d0bd4 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 523 | MachineBasicBlock::iterator I2 = std::next(MachineBasicBlock::iterator(I1)); |
Krzysztof Parzyszek | 6dff336 | 2016-08-24 22:36:35 +0000 | [diff] [blame] | 524 | while (I2 != I1.getParent()->end() && I2->isDebugValue()) |
| 525 | ++I2; |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 526 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 527 | unsigned I1DestReg = I1.getOperand(0).getReg(); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 528 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 529 | for (MachineBasicBlock::iterator End = I1.getParent()->end(); I2 != End; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 530 | ++I2) { |
| 531 | // Bail out early if we see a second definition of I1DestReg. |
| 532 | if (I2->modifiesRegister(I1DestReg, TRI)) |
| 533 | break; |
| 534 | |
| 535 | // Ignore non-combinable instructions. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 536 | if (!isCombinableInstType(*I2, TII, ShouldCombineAggressively)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 537 | continue; |
| 538 | |
| 539 | // Don't combine a TFR whose user could be newified. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 540 | if (ShouldCombineAggressively && PotentiallyNewifiableTFR.count(&*I2)) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 541 | continue; |
| 542 | |
| 543 | unsigned I2DestReg = I2->getOperand(0).getReg(); |
| 544 | |
| 545 | // Check that registers are adjacent and that the first destination register |
| 546 | // is even. |
| 547 | bool IsI1LowReg = (I2DestReg - I1DestReg) == 1; |
| 548 | bool IsI2LowReg = (I1DestReg - I2DestReg) == 1; |
| 549 | unsigned FirstRegIndex = IsI1LowReg ? I1DestReg : I2DestReg; |
| 550 | if ((!IsI1LowReg && !IsI2LowReg) || !isEvenReg(FirstRegIndex)) |
| 551 | continue; |
| 552 | |
| 553 | // Check that the two instructions are combinable. V4 allows more |
| 554 | // instructions to be merged into a combine. |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 555 | // The order matters because in a A2_tfrsi we might can encode a int8 as |
| 556 | // the hi reg operand but only a uint6 as the low reg operand. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 557 | if ((IsI2LowReg && !areCombinableOperations(TRI, I1, *I2, AllowC64)) || |
| 558 | (IsI1LowReg && !areCombinableOperations(TRI, *I2, I1, AllowC64))) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 559 | break; |
| 560 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 561 | if (isSafeToMoveTogether(I1, *I2, I1DestReg, I2DestReg, DoInsertAtI1)) |
| 562 | return &*I2; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 563 | |
| 564 | // Not safe. Stop searching. |
| 565 | break; |
| 566 | } |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 567 | return nullptr; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 568 | } |
| 569 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 570 | void HexagonCopyToCombine::combine(MachineInstr &I1, MachineInstr &I2, |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 571 | MachineBasicBlock::iterator &MI, |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 572 | bool DoInsertAtI1, bool OptForSize) { |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 573 | // We are going to delete I2. If MI points to I2 advance it to the next |
| 574 | // instruction. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 575 | if (MI == I2.getIterator()) |
| 576 | ++MI; |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 577 | |
| 578 | // Figure out whether I1 or I2 goes into the lowreg part. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 579 | unsigned I1DestReg = I1.getOperand(0).getReg(); |
| 580 | unsigned I2DestReg = I2.getOperand(0).getReg(); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 581 | bool IsI1Loreg = (I2DestReg - I1DestReg) == 1; |
| 582 | unsigned LoRegDef = IsI1Loreg ? I1DestReg : I2DestReg; |
| 583 | |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 584 | const TargetRegisterClass *SuperRC = nullptr; |
| 585 | if (Hexagon::IntRegsRegClass.contains(LoRegDef)) { |
| 586 | SuperRC = &Hexagon::DoubleRegsRegClass; |
| 587 | } else if (Hexagon::VectorRegsRegClass.contains(LoRegDef)) { |
| 588 | assert(ST->useHVXOps()); |
| 589 | if (ST->useHVXSglOps()) |
| 590 | SuperRC = &Hexagon::VecDblRegsRegClass; |
| 591 | else |
| 592 | SuperRC = &Hexagon::VecDblRegs128BRegClass; |
| 593 | } |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 594 | // Get the double word register. |
| 595 | unsigned DoubleRegDest = |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 596 | TRI->getMatchingSuperReg(LoRegDef, Hexagon::subreg_loreg, SuperRC); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 597 | assert(DoubleRegDest != 0 && "Expect a valid register"); |
| 598 | |
| 599 | |
| 600 | // Setup source operands. |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 601 | MachineOperand &LoOperand = IsI1Loreg ? I1.getOperand(1) : I2.getOperand(1); |
| 602 | MachineOperand &HiOperand = IsI1Loreg ? I2.getOperand(1) : I1.getOperand(1); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 603 | |
| 604 | // Figure out which source is a register and which a constant. |
| 605 | bool IsHiReg = HiOperand.isReg(); |
| 606 | bool IsLoReg = LoOperand.isReg(); |
| 607 | |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 608 | // There is a combine of two constant extended values into CONST64. |
| 609 | bool IsC64 = OptForSize && LoOperand.isImm() && HiOperand.isImm() && |
| 610 | isGreaterThanNBitTFRI<16>(I1) && isGreaterThanNBitTFRI<16>(I2); |
| 611 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 612 | MachineBasicBlock::iterator InsertPt(DoInsertAtI1 ? I1 : I2); |
| 613 | // Emit combine. |
| 614 | if (IsHiReg && IsLoReg) |
| 615 | emitCombineRR(InsertPt, DoubleRegDest, HiOperand, LoOperand); |
| 616 | else if (IsHiReg) |
| 617 | emitCombineRI(InsertPt, DoubleRegDest, HiOperand, LoOperand); |
| 618 | else if (IsLoReg) |
| 619 | emitCombineIR(InsertPt, DoubleRegDest, HiOperand, LoOperand); |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 620 | else if (IsC64 && !IsConst64Disabled) |
| 621 | emitConst64(InsertPt, DoubleRegDest, HiOperand, LoOperand); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 622 | else |
| 623 | emitCombineII(InsertPt, DoubleRegDest, HiOperand, LoOperand); |
| 624 | |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 625 | // Move debug instructions along with I1 if it's being |
| 626 | // moved towards I2. |
| 627 | if (!DoInsertAtI1 && DbgMItoMove.size() != 0) { |
| 628 | // Insert debug instructions at the new location before I2. |
| 629 | MachineBasicBlock *BB = InsertPt->getParent(); |
| 630 | for (auto NewMI : DbgMItoMove) { |
| 631 | // If iterator MI is pointing to DEBUG_VAL, make sure |
| 632 | // MI now points to next relevant instruction. |
Duncan P. N. Exon Smith | f197b1f | 2016-08-12 05:05:36 +0000 | [diff] [blame] | 633 | if (NewMI == MI) |
Krzysztof Parzyszek | 9b7320e | 2016-01-15 13:55:57 +0000 | [diff] [blame] | 634 | ++MI; |
| 635 | BB->splice(InsertPt, BB, NewMI); |
| 636 | } |
| 637 | } |
| 638 | |
Duncan P. N. Exon Smith | 98226e3 | 2016-07-12 01:55:32 +0000 | [diff] [blame] | 639 | I1.eraseFromParent(); |
| 640 | I2.eraseFromParent(); |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 641 | } |
| 642 | |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 643 | void HexagonCopyToCombine::emitConst64(MachineBasicBlock::iterator &InsertPt, |
| 644 | unsigned DoubleDestReg, |
| 645 | MachineOperand &HiOperand, |
| 646 | MachineOperand &LoOperand) { |
| 647 | DEBUG(dbgs() << "Found a CONST64\n"); |
| 648 | |
| 649 | DebugLoc DL = InsertPt->getDebugLoc(); |
| 650 | MachineBasicBlock *BB = InsertPt->getParent(); |
| 651 | assert(LoOperand.isImm() && HiOperand.isImm() && |
| 652 | "Both operands must be immediate"); |
| 653 | |
| 654 | int64_t V = HiOperand.getImm(); |
| 655 | V = (V << 32) | (0x0ffffffffLL & LoOperand.getImm()); |
Krzysztof Parzyszek | a338650 | 2016-08-10 16:46:36 +0000 | [diff] [blame] | 656 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::CONST64), DoubleDestReg) |
Krzysztof Parzyszek | 2a3b2f9 | 2016-01-15 14:08:31 +0000 | [diff] [blame] | 657 | .addImm(V); |
| 658 | } |
| 659 | |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 660 | void HexagonCopyToCombine::emitCombineII(MachineBasicBlock::iterator &InsertPt, |
| 661 | unsigned DoubleDestReg, |
| 662 | MachineOperand &HiOperand, |
| 663 | MachineOperand &LoOperand) { |
| 664 | DebugLoc DL = InsertPt->getDebugLoc(); |
| 665 | MachineBasicBlock *BB = InsertPt->getParent(); |
| 666 | |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 667 | // Handle globals. |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 668 | if (HiOperand.isGlobal()) { |
Colin LeMahieu | b580d7d | 2014-12-09 19:23:45 +0000 | [diff] [blame] | 669 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A2_combineii), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 670 | .addGlobalAddress(HiOperand.getGlobal(), HiOperand.getOffset(), |
| 671 | HiOperand.getTargetFlags()) |
| 672 | .addImm(LoOperand.getImm()); |
| 673 | return; |
| 674 | } |
| 675 | if (LoOperand.isGlobal()) { |
Colin LeMahieu | 82fb8cb | 2014-12-30 17:53:54 +0000 | [diff] [blame] | 676 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineii), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 677 | .addImm(HiOperand.getImm()) |
| 678 | .addGlobalAddress(LoOperand.getGlobal(), LoOperand.getOffset(), |
| 679 | LoOperand.getTargetFlags()); |
| 680 | return; |
| 681 | } |
| 682 | |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 683 | // Handle block addresses. |
| 684 | if (HiOperand.isBlockAddress()) { |
Colin LeMahieu | b580d7d | 2014-12-09 19:23:45 +0000 | [diff] [blame] | 685 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A2_combineii), DoubleDestReg) |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 686 | .addBlockAddress(HiOperand.getBlockAddress(), HiOperand.getOffset(), |
| 687 | HiOperand.getTargetFlags()) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 688 | .addImm(LoOperand.getImm()); |
| 689 | return; |
| 690 | } |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 691 | if (LoOperand.isBlockAddress()) { |
| 692 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineii), DoubleDestReg) |
| 693 | .addImm(HiOperand.getImm()) |
| 694 | .addBlockAddress(LoOperand.getBlockAddress(), LoOperand.getOffset(), |
| 695 | LoOperand.getTargetFlags()); |
| 696 | return; |
| 697 | } |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 698 | |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 699 | // Handle jump tables. |
| 700 | if (HiOperand.isJTI()) { |
| 701 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A2_combineii), DoubleDestReg) |
| 702 | .addJumpTableIndex(HiOperand.getIndex(), HiOperand.getTargetFlags()) |
| 703 | .addImm(LoOperand.getImm()); |
| 704 | return; |
| 705 | } |
| 706 | if (LoOperand.isJTI()) { |
| 707 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineii), DoubleDestReg) |
| 708 | .addImm(HiOperand.getImm()) |
| 709 | .addJumpTableIndex(LoOperand.getIndex(), LoOperand.getTargetFlags()); |
| 710 | return; |
| 711 | } |
| 712 | |
| 713 | // Handle constant pools. |
| 714 | if (HiOperand.isCPI()) { |
| 715 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A2_combineii), DoubleDestReg) |
| 716 | .addConstantPoolIndex(HiOperand.getIndex(), HiOperand.getOffset(), |
| 717 | HiOperand.getTargetFlags()) |
| 718 | .addImm(LoOperand.getImm()); |
| 719 | return; |
| 720 | } |
| 721 | if (LoOperand.isCPI()) { |
| 722 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineii), DoubleDestReg) |
| 723 | .addImm(HiOperand.getImm()) |
| 724 | .addConstantPoolIndex(LoOperand.getIndex(), LoOperand.getOffset(), |
| 725 | LoOperand.getTargetFlags()); |
| 726 | return; |
| 727 | } |
| 728 | |
| 729 | // First preference should be given to Hexagon::A2_combineii instruction |
| 730 | // as it can include U6 (in Hexagon::A4_combineii) as well. |
| 731 | // In this instruction, HiOperand is const extended, if required. |
| 732 | if (isInt<8>(LoOperand.getImm())) { |
| 733 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A2_combineii), DoubleDestReg) |
| 734 | .addImm(HiOperand.getImm()) |
| 735 | .addImm(LoOperand.getImm()); |
| 736 | return; |
| 737 | } |
| 738 | |
| 739 | // In this instruction, LoOperand is const extended, if required. |
| 740 | if (isInt<8>(HiOperand.getImm())) { |
Colin LeMahieu | 82fb8cb | 2014-12-30 17:53:54 +0000 | [diff] [blame] | 741 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineii), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 742 | .addImm(HiOperand.getImm()) |
| 743 | .addImm(LoOperand.getImm()); |
| 744 | return; |
| 745 | } |
| 746 | |
| 747 | // Insert new combine instruction. |
| 748 | // DoubleRegDest = combine #HiImm, #LoImm |
Colin LeMahieu | b580d7d | 2014-12-09 19:23:45 +0000 | [diff] [blame] | 749 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A2_combineii), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 750 | .addImm(HiOperand.getImm()) |
| 751 | .addImm(LoOperand.getImm()); |
| 752 | } |
| 753 | |
| 754 | void HexagonCopyToCombine::emitCombineIR(MachineBasicBlock::iterator &InsertPt, |
| 755 | unsigned DoubleDestReg, |
| 756 | MachineOperand &HiOperand, |
| 757 | MachineOperand &LoOperand) { |
| 758 | unsigned LoReg = LoOperand.getReg(); |
| 759 | unsigned LoRegKillFlag = getKillRegState(LoOperand.isKill()); |
| 760 | |
| 761 | DebugLoc DL = InsertPt->getDebugLoc(); |
| 762 | MachineBasicBlock *BB = InsertPt->getParent(); |
| 763 | |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 764 | // Handle globals. |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 765 | if (HiOperand.isGlobal()) { |
Colin LeMahieu | 82fb8cb | 2014-12-30 17:53:54 +0000 | [diff] [blame] | 766 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineir), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 767 | .addGlobalAddress(HiOperand.getGlobal(), HiOperand.getOffset(), |
| 768 | HiOperand.getTargetFlags()) |
| 769 | .addReg(LoReg, LoRegKillFlag); |
| 770 | return; |
| 771 | } |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 772 | // Handle block addresses. |
| 773 | if (HiOperand.isBlockAddress()) { |
| 774 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineir), DoubleDestReg) |
| 775 | .addBlockAddress(HiOperand.getBlockAddress(), HiOperand.getOffset(), |
| 776 | HiOperand.getTargetFlags()) |
| 777 | .addReg(LoReg, LoRegKillFlag); |
| 778 | return; |
| 779 | } |
| 780 | // Handle jump tables. |
| 781 | if (HiOperand.isJTI()) { |
| 782 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineir), DoubleDestReg) |
| 783 | .addJumpTableIndex(HiOperand.getIndex(), HiOperand.getTargetFlags()) |
| 784 | .addReg(LoReg, LoRegKillFlag); |
| 785 | return; |
| 786 | } |
| 787 | // Handle constant pools. |
| 788 | if (HiOperand.isCPI()) { |
| 789 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineir), DoubleDestReg) |
| 790 | .addConstantPoolIndex(HiOperand.getIndex(), HiOperand.getOffset(), |
| 791 | HiOperand.getTargetFlags()) |
| 792 | .addReg(LoReg, LoRegKillFlag); |
| 793 | return; |
| 794 | } |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 795 | // Insert new combine instruction. |
| 796 | // DoubleRegDest = combine #HiImm, LoReg |
Colin LeMahieu | 82fb8cb | 2014-12-30 17:53:54 +0000 | [diff] [blame] | 797 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineir), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 798 | .addImm(HiOperand.getImm()) |
| 799 | .addReg(LoReg, LoRegKillFlag); |
| 800 | } |
| 801 | |
| 802 | void HexagonCopyToCombine::emitCombineRI(MachineBasicBlock::iterator &InsertPt, |
| 803 | unsigned DoubleDestReg, |
| 804 | MachineOperand &HiOperand, |
| 805 | MachineOperand &LoOperand) { |
| 806 | unsigned HiRegKillFlag = getKillRegState(HiOperand.isKill()); |
| 807 | unsigned HiReg = HiOperand.getReg(); |
| 808 | |
| 809 | DebugLoc DL = InsertPt->getDebugLoc(); |
| 810 | MachineBasicBlock *BB = InsertPt->getParent(); |
| 811 | |
| 812 | // Handle global. |
| 813 | if (LoOperand.isGlobal()) { |
Colin LeMahieu | 82fb8cb | 2014-12-30 17:53:54 +0000 | [diff] [blame] | 814 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineri), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 815 | .addReg(HiReg, HiRegKillFlag) |
| 816 | .addGlobalAddress(LoOperand.getGlobal(), LoOperand.getOffset(), |
| 817 | LoOperand.getTargetFlags()); |
| 818 | return; |
| 819 | } |
Krzysztof Parzyszek | cd97c98 | 2015-04-22 18:25:53 +0000 | [diff] [blame] | 820 | // Handle block addresses. |
| 821 | if (LoOperand.isBlockAddress()) { |
| 822 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineri), DoubleDestReg) |
| 823 | .addReg(HiReg, HiRegKillFlag) |
| 824 | .addBlockAddress(LoOperand.getBlockAddress(), LoOperand.getOffset(), |
| 825 | LoOperand.getTargetFlags()); |
| 826 | return; |
| 827 | } |
| 828 | // Handle jump tables. |
| 829 | if (LoOperand.isJTI()) { |
| 830 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineri), DoubleDestReg) |
| 831 | .addReg(HiOperand.getReg(), HiRegKillFlag) |
| 832 | .addJumpTableIndex(LoOperand.getIndex(), LoOperand.getTargetFlags()); |
| 833 | return; |
| 834 | } |
| 835 | // Handle constant pools. |
| 836 | if (LoOperand.isCPI()) { |
| 837 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineri), DoubleDestReg) |
| 838 | .addReg(HiOperand.getReg(), HiRegKillFlag) |
| 839 | .addConstantPoolIndex(LoOperand.getIndex(), LoOperand.getOffset(), |
| 840 | LoOperand.getTargetFlags()); |
| 841 | return; |
| 842 | } |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 843 | |
| 844 | // Insert new combine instruction. |
| 845 | // DoubleRegDest = combine HiReg, #LoImm |
Colin LeMahieu | 82fb8cb | 2014-12-30 17:53:54 +0000 | [diff] [blame] | 846 | BuildMI(*BB, InsertPt, DL, TII->get(Hexagon::A4_combineri), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 847 | .addReg(HiReg, HiRegKillFlag) |
| 848 | .addImm(LoOperand.getImm()); |
| 849 | } |
| 850 | |
| 851 | void HexagonCopyToCombine::emitCombineRR(MachineBasicBlock::iterator &InsertPt, |
| 852 | unsigned DoubleDestReg, |
| 853 | MachineOperand &HiOperand, |
| 854 | MachineOperand &LoOperand) { |
| 855 | unsigned LoRegKillFlag = getKillRegState(LoOperand.isKill()); |
| 856 | unsigned HiRegKillFlag = getKillRegState(HiOperand.isKill()); |
| 857 | unsigned LoReg = LoOperand.getReg(); |
| 858 | unsigned HiReg = HiOperand.getReg(); |
| 859 | |
| 860 | DebugLoc DL = InsertPt->getDebugLoc(); |
| 861 | MachineBasicBlock *BB = InsertPt->getParent(); |
| 862 | |
| 863 | // Insert new combine instruction. |
| 864 | // DoubleRegDest = combine HiReg, LoReg |
Krzysztof Parzyszek | b1b0372 | 2016-08-18 14:12:34 +0000 | [diff] [blame] | 865 | unsigned NewOpc; |
| 866 | if (Hexagon::DoubleRegsRegClass.contains(DoubleDestReg)) { |
| 867 | NewOpc = Hexagon::A2_combinew; |
| 868 | } else if (Hexagon::VecDblRegsRegClass.contains(DoubleDestReg)) { |
| 869 | assert(ST->useHVXOps()); |
| 870 | if (ST->useHVXSglOps()) |
| 871 | NewOpc = Hexagon::V6_vcombine; |
| 872 | else |
| 873 | NewOpc = Hexagon::V6_vcombine_128B; |
| 874 | } else |
| 875 | llvm_unreachable("Unexpected register"); |
| 876 | |
| 877 | BuildMI(*BB, InsertPt, DL, TII->get(NewOpc), DoubleDestReg) |
Jyotsna Verma | 803e506 | 2013-05-14 18:54:06 +0000 | [diff] [blame] | 878 | .addReg(HiReg, HiRegKillFlag) |
| 879 | .addReg(LoReg, LoRegKillFlag); |
| 880 | } |
| 881 | |
| 882 | FunctionPass *llvm::createHexagonCopyToCombine() { |
| 883 | return new HexagonCopyToCombine(); |
| 884 | } |