Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 1 | //===-- ARMExpandPseudoInsts.cpp - Expand pseudo instructions -----*- C++ -*-=// |
| 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 | // |
Bob Wilson | 656edcf | 2010-09-08 23:39:54 +0000 | [diff] [blame] | 10 | // This file contains a pass that expands pseudo instructions into target |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 11 | // instructions to allow proper scheduling, if-conversion, and other late |
| 12 | // optimizations. This pass should be run after register allocation but before |
Bob Wilson | 656edcf | 2010-09-08 23:39:54 +0000 | [diff] [blame] | 13 | // the post-regalloc scheduling pass. |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #define DEBUG_TYPE "arm-pseudo" |
| 18 | #include "ARM.h" |
| 19 | #include "ARMBaseInstrInfo.h" |
Jim Grosbach | 65dc303 | 2010-10-06 21:16:16 +0000 | [diff] [blame^] | 20 | #include "ARMRegisterInfo.h" |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 22 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
Chris Lattner | 4dbbe34 | 2010-07-20 21:17:29 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetRegisterInfo.h" |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 24 | using namespace llvm; |
| 25 | |
| 26 | namespace { |
| 27 | class ARMExpandPseudo : public MachineFunctionPass { |
| 28 | public: |
| 29 | static char ID; |
Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 30 | ARMExpandPseudo() : MachineFunctionPass(ID) {} |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 31 | |
| 32 | const TargetInstrInfo *TII; |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 33 | const TargetRegisterInfo *TRI; |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 34 | |
| 35 | virtual bool runOnMachineFunction(MachineFunction &Fn); |
| 36 | |
| 37 | virtual const char *getPassName() const { |
| 38 | return "ARM pseudo instruction expansion pass"; |
| 39 | } |
| 40 | |
| 41 | private: |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 42 | void TransferImpOps(MachineInstr &OldMI, |
| 43 | MachineInstrBuilder &UseMI, MachineInstrBuilder &DefMI); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 44 | bool ExpandMBB(MachineBasicBlock &MBB); |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 45 | void ExpandVLD(MachineBasicBlock::iterator &MBBI); |
| 46 | void ExpandVST(MachineBasicBlock::iterator &MBBI); |
| 47 | void ExpandLaneOp(MachineBasicBlock::iterator &MBBI); |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 48 | void ExpandVTBL(MachineBasicBlock::iterator &MBBI, |
| 49 | unsigned Opc, bool IsExt, unsigned NumRegs); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 50 | }; |
| 51 | char ARMExpandPseudo::ID = 0; |
| 52 | } |
| 53 | |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 54 | /// TransferImpOps - Transfer implicit operands on the pseudo instruction to |
| 55 | /// the instructions created from the expansion. |
| 56 | void ARMExpandPseudo::TransferImpOps(MachineInstr &OldMI, |
| 57 | MachineInstrBuilder &UseMI, |
| 58 | MachineInstrBuilder &DefMI) { |
| 59 | const TargetInstrDesc &Desc = OldMI.getDesc(); |
| 60 | for (unsigned i = Desc.getNumOperands(), e = OldMI.getNumOperands(); |
| 61 | i != e; ++i) { |
| 62 | const MachineOperand &MO = OldMI.getOperand(i); |
| 63 | assert(MO.isReg() && MO.getReg()); |
| 64 | if (MO.isUse()) |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 65 | UseMI.addOperand(MO); |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 66 | else |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 67 | DefMI.addOperand(MO); |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 71 | namespace { |
| 72 | // Constants for register spacing in NEON load/store instructions. |
| 73 | // For quad-register load-lane and store-lane pseudo instructors, the |
| 74 | // spacing is initially assumed to be EvenDblSpc, and that is changed to |
| 75 | // OddDblSpc depending on the lane number operand. |
| 76 | enum NEONRegSpacing { |
| 77 | SingleSpc, |
| 78 | EvenDblSpc, |
| 79 | OddDblSpc |
| 80 | }; |
| 81 | |
| 82 | // Entries for NEON load/store information table. The table is sorted by |
| 83 | // PseudoOpc for fast binary-search lookups. |
| 84 | struct NEONLdStTableEntry { |
| 85 | unsigned PseudoOpc; |
| 86 | unsigned RealOpc; |
| 87 | bool IsLoad; |
| 88 | bool HasWriteBack; |
| 89 | NEONRegSpacing RegSpacing; |
| 90 | unsigned char NumRegs; // D registers loaded or stored |
| 91 | unsigned char RegElts; // elements per D register; used for lane ops |
| 92 | |
| 93 | // Comparison methods for binary search of the table. |
| 94 | bool operator<(const NEONLdStTableEntry &TE) const { |
| 95 | return PseudoOpc < TE.PseudoOpc; |
| 96 | } |
| 97 | friend bool operator<(const NEONLdStTableEntry &TE, unsigned PseudoOpc) { |
| 98 | return TE.PseudoOpc < PseudoOpc; |
| 99 | } |
| 100 | friend bool ATTRIBUTE_UNUSED operator<(unsigned PseudoOpc, |
| 101 | const NEONLdStTableEntry &TE) { |
| 102 | return PseudoOpc < TE.PseudoOpc; |
| 103 | } |
| 104 | }; |
| 105 | } |
| 106 | |
| 107 | static const NEONLdStTableEntry NEONLdStTable[] = { |
| 108 | { ARM::VLD1d64QPseudo, ARM::VLD1d64Q, true, false, SingleSpc, 4, 1 }, |
| 109 | { ARM::VLD1d64QPseudo_UPD, ARM::VLD1d64Q_UPD, true, true, SingleSpc, 4, 1 }, |
| 110 | { ARM::VLD1d64TPseudo, ARM::VLD1d64T, true, false, SingleSpc, 3, 1 }, |
| 111 | { ARM::VLD1d64TPseudo_UPD, ARM::VLD1d64T_UPD, true, true, SingleSpc, 3, 1 }, |
| 112 | |
| 113 | { ARM::VLD1q16Pseudo, ARM::VLD1q16, true, false, SingleSpc, 2, 4 }, |
| 114 | { ARM::VLD1q16Pseudo_UPD, ARM::VLD1q16_UPD, true, true, SingleSpc, 2, 4 }, |
| 115 | { ARM::VLD1q32Pseudo, ARM::VLD1q32, true, false, SingleSpc, 2, 2 }, |
| 116 | { ARM::VLD1q32Pseudo_UPD, ARM::VLD1q32_UPD, true, true, SingleSpc, 2, 2 }, |
| 117 | { ARM::VLD1q64Pseudo, ARM::VLD1q64, true, false, SingleSpc, 2, 1 }, |
| 118 | { ARM::VLD1q64Pseudo_UPD, ARM::VLD1q64_UPD, true, true, SingleSpc, 2, 1 }, |
| 119 | { ARM::VLD1q8Pseudo, ARM::VLD1q8, true, false, SingleSpc, 2, 8 }, |
| 120 | { ARM::VLD1q8Pseudo_UPD, ARM::VLD1q8_UPD, true, true, SingleSpc, 2, 8 }, |
| 121 | |
| 122 | { ARM::VLD2LNd16Pseudo, ARM::VLD2LNd16, true, false, SingleSpc, 2, 4 }, |
| 123 | { ARM::VLD2LNd16Pseudo_UPD, ARM::VLD2LNd16_UPD, true, true, SingleSpc, 2, 4 }, |
| 124 | { ARM::VLD2LNd32Pseudo, ARM::VLD2LNd32, true, false, SingleSpc, 2, 2 }, |
| 125 | { ARM::VLD2LNd32Pseudo_UPD, ARM::VLD2LNd32_UPD, true, true, SingleSpc, 2, 2 }, |
| 126 | { ARM::VLD2LNd8Pseudo, ARM::VLD2LNd8, true, false, SingleSpc, 2, 8 }, |
| 127 | { ARM::VLD2LNd8Pseudo_UPD, ARM::VLD2LNd8_UPD, true, true, SingleSpc, 2, 8 }, |
| 128 | { ARM::VLD2LNq16Pseudo, ARM::VLD2LNq16, true, false, EvenDblSpc, 2, 4 }, |
| 129 | { ARM::VLD2LNq16Pseudo_UPD, ARM::VLD2LNq16_UPD, true, true, EvenDblSpc, 2, 4 }, |
| 130 | { ARM::VLD2LNq32Pseudo, ARM::VLD2LNq32, true, false, EvenDblSpc, 2, 2 }, |
| 131 | { ARM::VLD2LNq32Pseudo_UPD, ARM::VLD2LNq32_UPD, true, true, EvenDblSpc, 2, 2 }, |
| 132 | |
| 133 | { ARM::VLD2d16Pseudo, ARM::VLD2d16, true, false, SingleSpc, 2, 4 }, |
| 134 | { ARM::VLD2d16Pseudo_UPD, ARM::VLD2d16_UPD, true, true, SingleSpc, 2, 4 }, |
| 135 | { ARM::VLD2d32Pseudo, ARM::VLD2d32, true, false, SingleSpc, 2, 2 }, |
| 136 | { ARM::VLD2d32Pseudo_UPD, ARM::VLD2d32_UPD, true, true, SingleSpc, 2, 2 }, |
| 137 | { ARM::VLD2d8Pseudo, ARM::VLD2d8, true, false, SingleSpc, 2, 8 }, |
| 138 | { ARM::VLD2d8Pseudo_UPD, ARM::VLD2d8_UPD, true, true, SingleSpc, 2, 8 }, |
| 139 | |
| 140 | { ARM::VLD2q16Pseudo, ARM::VLD2q16, true, false, SingleSpc, 4, 4 }, |
| 141 | { ARM::VLD2q16Pseudo_UPD, ARM::VLD2q16_UPD, true, true, SingleSpc, 4, 4 }, |
| 142 | { ARM::VLD2q32Pseudo, ARM::VLD2q32, true, false, SingleSpc, 4, 2 }, |
| 143 | { ARM::VLD2q32Pseudo_UPD, ARM::VLD2q32_UPD, true, true, SingleSpc, 4, 2 }, |
| 144 | { ARM::VLD2q8Pseudo, ARM::VLD2q8, true, false, SingleSpc, 4, 8 }, |
| 145 | { ARM::VLD2q8Pseudo_UPD, ARM::VLD2q8_UPD, true, true, SingleSpc, 4, 8 }, |
| 146 | |
| 147 | { ARM::VLD3LNd16Pseudo, ARM::VLD3LNd16, true, false, SingleSpc, 3, 4 }, |
| 148 | { ARM::VLD3LNd16Pseudo_UPD, ARM::VLD3LNd16_UPD, true, true, SingleSpc, 3, 4 }, |
| 149 | { ARM::VLD3LNd32Pseudo, ARM::VLD3LNd32, true, false, SingleSpc, 3, 2 }, |
| 150 | { ARM::VLD3LNd32Pseudo_UPD, ARM::VLD3LNd32_UPD, true, true, SingleSpc, 3, 2 }, |
| 151 | { ARM::VLD3LNd8Pseudo, ARM::VLD3LNd8, true, false, SingleSpc, 3, 8 }, |
| 152 | { ARM::VLD3LNd8Pseudo_UPD, ARM::VLD3LNd8_UPD, true, true, SingleSpc, 3, 8 }, |
| 153 | { ARM::VLD3LNq16Pseudo, ARM::VLD3LNq16, true, false, EvenDblSpc, 3, 4 }, |
| 154 | { ARM::VLD3LNq16Pseudo_UPD, ARM::VLD3LNq16_UPD, true, true, EvenDblSpc, 3, 4 }, |
| 155 | { ARM::VLD3LNq32Pseudo, ARM::VLD3LNq32, true, false, EvenDblSpc, 3, 2 }, |
| 156 | { ARM::VLD3LNq32Pseudo_UPD, ARM::VLD3LNq32_UPD, true, true, EvenDblSpc, 3, 2 }, |
| 157 | |
| 158 | { ARM::VLD3d16Pseudo, ARM::VLD3d16, true, false, SingleSpc, 3, 4 }, |
| 159 | { ARM::VLD3d16Pseudo_UPD, ARM::VLD3d16_UPD, true, true, SingleSpc, 3, 4 }, |
| 160 | { ARM::VLD3d32Pseudo, ARM::VLD3d32, true, false, SingleSpc, 3, 2 }, |
| 161 | { ARM::VLD3d32Pseudo_UPD, ARM::VLD3d32_UPD, true, true, SingleSpc, 3, 2 }, |
| 162 | { ARM::VLD3d8Pseudo, ARM::VLD3d8, true, false, SingleSpc, 3, 8 }, |
| 163 | { ARM::VLD3d8Pseudo_UPD, ARM::VLD3d8_UPD, true, true, SingleSpc, 3, 8 }, |
| 164 | |
| 165 | { ARM::VLD3q16Pseudo_UPD, ARM::VLD3q16_UPD, true, true, EvenDblSpc, 3, 4 }, |
| 166 | { ARM::VLD3q16oddPseudo_UPD, ARM::VLD3q16_UPD, true, true, OddDblSpc, 3, 4 }, |
| 167 | { ARM::VLD3q32Pseudo_UPD, ARM::VLD3q32_UPD, true, true, EvenDblSpc, 3, 2 }, |
| 168 | { ARM::VLD3q32oddPseudo_UPD, ARM::VLD3q32_UPD, true, true, OddDblSpc, 3, 2 }, |
| 169 | { ARM::VLD3q8Pseudo_UPD, ARM::VLD3q8_UPD, true, true, EvenDblSpc, 3, 8 }, |
| 170 | { ARM::VLD3q8oddPseudo_UPD, ARM::VLD3q8_UPD, true, true, OddDblSpc, 3, 8 }, |
| 171 | |
| 172 | { ARM::VLD4LNd16Pseudo, ARM::VLD4LNd16, true, false, SingleSpc, 4, 4 }, |
| 173 | { ARM::VLD4LNd16Pseudo_UPD, ARM::VLD4LNd16_UPD, true, true, SingleSpc, 4, 4 }, |
| 174 | { ARM::VLD4LNd32Pseudo, ARM::VLD4LNd32, true, false, SingleSpc, 4, 2 }, |
| 175 | { ARM::VLD4LNd32Pseudo_UPD, ARM::VLD4LNd32_UPD, true, true, SingleSpc, 4, 2 }, |
| 176 | { ARM::VLD4LNd8Pseudo, ARM::VLD4LNd8, true, false, SingleSpc, 4, 8 }, |
| 177 | { ARM::VLD4LNd8Pseudo_UPD, ARM::VLD4LNd8_UPD, true, true, SingleSpc, 4, 8 }, |
| 178 | { ARM::VLD4LNq16Pseudo, ARM::VLD4LNq16, true, false, EvenDblSpc, 4, 4 }, |
| 179 | { ARM::VLD4LNq16Pseudo_UPD, ARM::VLD4LNq16_UPD, true, true, EvenDblSpc, 4, 4 }, |
| 180 | { ARM::VLD4LNq32Pseudo, ARM::VLD4LNq32, true, false, EvenDblSpc, 4, 2 }, |
| 181 | { ARM::VLD4LNq32Pseudo_UPD, ARM::VLD4LNq32_UPD, true, true, EvenDblSpc, 4, 2 }, |
| 182 | |
| 183 | { ARM::VLD4d16Pseudo, ARM::VLD4d16, true, false, SingleSpc, 4, 4 }, |
| 184 | { ARM::VLD4d16Pseudo_UPD, ARM::VLD4d16_UPD, true, true, SingleSpc, 4, 4 }, |
| 185 | { ARM::VLD4d32Pseudo, ARM::VLD4d32, true, false, SingleSpc, 4, 2 }, |
| 186 | { ARM::VLD4d32Pseudo_UPD, ARM::VLD4d32_UPD, true, true, SingleSpc, 4, 2 }, |
| 187 | { ARM::VLD4d8Pseudo, ARM::VLD4d8, true, false, SingleSpc, 4, 8 }, |
| 188 | { ARM::VLD4d8Pseudo_UPD, ARM::VLD4d8_UPD, true, true, SingleSpc, 4, 8 }, |
| 189 | |
| 190 | { ARM::VLD4q16Pseudo_UPD, ARM::VLD4q16_UPD, true, true, EvenDblSpc, 4, 4 }, |
| 191 | { ARM::VLD4q16oddPseudo_UPD, ARM::VLD4q16_UPD, true, true, OddDblSpc, 4, 4 }, |
| 192 | { ARM::VLD4q32Pseudo_UPD, ARM::VLD4q32_UPD, true, true, EvenDblSpc, 4, 2 }, |
| 193 | { ARM::VLD4q32oddPseudo_UPD, ARM::VLD4q32_UPD, true, true, OddDblSpc, 4, 2 }, |
| 194 | { ARM::VLD4q8Pseudo_UPD, ARM::VLD4q8_UPD, true, true, EvenDblSpc, 4, 8 }, |
| 195 | { ARM::VLD4q8oddPseudo_UPD, ARM::VLD4q8_UPD, true, true, OddDblSpc, 4, 8 }, |
| 196 | |
| 197 | { ARM::VST1d64QPseudo, ARM::VST1d64Q, false, false, SingleSpc, 4, 1 }, |
| 198 | { ARM::VST1d64QPseudo_UPD, ARM::VST1d64Q_UPD, false, true, SingleSpc, 4, 1 }, |
| 199 | { ARM::VST1d64TPseudo, ARM::VST1d64T, false, false, SingleSpc, 3, 1 }, |
| 200 | { ARM::VST1d64TPseudo_UPD, ARM::VST1d64T_UPD, false, true, SingleSpc, 3, 1 }, |
| 201 | |
| 202 | { ARM::VST1q16Pseudo, ARM::VST1q16, false, false, SingleSpc, 2, 4 }, |
| 203 | { ARM::VST1q16Pseudo_UPD, ARM::VST1q16_UPD, false, true, SingleSpc, 2, 4 }, |
| 204 | { ARM::VST1q32Pseudo, ARM::VST1q32, false, false, SingleSpc, 2, 2 }, |
| 205 | { ARM::VST1q32Pseudo_UPD, ARM::VST1q32_UPD, false, true, SingleSpc, 2, 2 }, |
| 206 | { ARM::VST1q64Pseudo, ARM::VST1q64, false, false, SingleSpc, 2, 1 }, |
| 207 | { ARM::VST1q64Pseudo_UPD, ARM::VST1q64_UPD, false, true, SingleSpc, 2, 1 }, |
| 208 | { ARM::VST1q8Pseudo, ARM::VST1q8, false, false, SingleSpc, 2, 8 }, |
| 209 | { ARM::VST1q8Pseudo_UPD, ARM::VST1q8_UPD, false, true, SingleSpc, 2, 8 }, |
| 210 | |
| 211 | { ARM::VST2LNd16Pseudo, ARM::VST2LNd16, false, false, SingleSpc, 2, 4 }, |
| 212 | { ARM::VST2LNd16Pseudo_UPD, ARM::VST2LNd16_UPD, false, true, SingleSpc, 2, 4 }, |
| 213 | { ARM::VST2LNd32Pseudo, ARM::VST2LNd32, false, false, SingleSpc, 2, 2 }, |
| 214 | { ARM::VST2LNd32Pseudo_UPD, ARM::VST2LNd32_UPD, false, true, SingleSpc, 2, 2 }, |
| 215 | { ARM::VST2LNd8Pseudo, ARM::VST2LNd8, false, false, SingleSpc, 2, 8 }, |
| 216 | { ARM::VST2LNd8Pseudo_UPD, ARM::VST2LNd8_UPD, false, true, SingleSpc, 2, 8 }, |
| 217 | { ARM::VST2LNq16Pseudo, ARM::VST2LNq16, false, false, EvenDblSpc, 2, 4}, |
| 218 | { ARM::VST2LNq16Pseudo_UPD, ARM::VST2LNq16_UPD, false, true, EvenDblSpc, 2, 4}, |
| 219 | { ARM::VST2LNq32Pseudo, ARM::VST2LNq32, false, false, EvenDblSpc, 2, 2}, |
| 220 | { ARM::VST2LNq32Pseudo_UPD, ARM::VST2LNq32_UPD, false, true, EvenDblSpc, 2, 2}, |
| 221 | |
| 222 | { ARM::VST2d16Pseudo, ARM::VST2d16, false, false, SingleSpc, 2, 4 }, |
| 223 | { ARM::VST2d16Pseudo_UPD, ARM::VST2d16_UPD, false, true, SingleSpc, 2, 4 }, |
| 224 | { ARM::VST2d32Pseudo, ARM::VST2d32, false, false, SingleSpc, 2, 2 }, |
| 225 | { ARM::VST2d32Pseudo_UPD, ARM::VST2d32_UPD, false, true, SingleSpc, 2, 2 }, |
| 226 | { ARM::VST2d8Pseudo, ARM::VST2d8, false, false, SingleSpc, 2, 8 }, |
| 227 | { ARM::VST2d8Pseudo_UPD, ARM::VST2d8_UPD, false, true, SingleSpc, 2, 8 }, |
| 228 | |
| 229 | { ARM::VST2q16Pseudo, ARM::VST2q16, false, false, SingleSpc, 4, 4 }, |
| 230 | { ARM::VST2q16Pseudo_UPD, ARM::VST2q16_UPD, false, true, SingleSpc, 4, 4 }, |
| 231 | { ARM::VST2q32Pseudo, ARM::VST2q32, false, false, SingleSpc, 4, 2 }, |
| 232 | { ARM::VST2q32Pseudo_UPD, ARM::VST2q32_UPD, false, true, SingleSpc, 4, 2 }, |
| 233 | { ARM::VST2q8Pseudo, ARM::VST2q8, false, false, SingleSpc, 4, 8 }, |
| 234 | { ARM::VST2q8Pseudo_UPD, ARM::VST2q8_UPD, false, true, SingleSpc, 4, 8 }, |
| 235 | |
| 236 | { ARM::VST3LNd16Pseudo, ARM::VST3LNd16, false, false, SingleSpc, 3, 4 }, |
| 237 | { ARM::VST3LNd16Pseudo_UPD, ARM::VST3LNd16_UPD, false, true, SingleSpc, 3, 4 }, |
| 238 | { ARM::VST3LNd32Pseudo, ARM::VST3LNd32, false, false, SingleSpc, 3, 2 }, |
| 239 | { ARM::VST3LNd32Pseudo_UPD, ARM::VST3LNd32_UPD, false, true, SingleSpc, 3, 2 }, |
| 240 | { ARM::VST3LNd8Pseudo, ARM::VST3LNd8, false, false, SingleSpc, 3, 8 }, |
| 241 | { ARM::VST3LNd8Pseudo_UPD, ARM::VST3LNd8_UPD, false, true, SingleSpc, 3, 8 }, |
| 242 | { ARM::VST3LNq16Pseudo, ARM::VST3LNq16, false, false, EvenDblSpc, 3, 4}, |
| 243 | { ARM::VST3LNq16Pseudo_UPD, ARM::VST3LNq16_UPD, false, true, EvenDblSpc, 3, 4}, |
| 244 | { ARM::VST3LNq32Pseudo, ARM::VST3LNq32, false, false, EvenDblSpc, 3, 2}, |
| 245 | { ARM::VST3LNq32Pseudo_UPD, ARM::VST3LNq32_UPD, false, true, EvenDblSpc, 3, 2}, |
| 246 | |
| 247 | { ARM::VST3d16Pseudo, ARM::VST3d16, false, false, SingleSpc, 3, 4 }, |
| 248 | { ARM::VST3d16Pseudo_UPD, ARM::VST3d16_UPD, false, true, SingleSpc, 3, 4 }, |
| 249 | { ARM::VST3d32Pseudo, ARM::VST3d32, false, false, SingleSpc, 3, 2 }, |
| 250 | { ARM::VST3d32Pseudo_UPD, ARM::VST3d32_UPD, false, true, SingleSpc, 3, 2 }, |
| 251 | { ARM::VST3d8Pseudo, ARM::VST3d8, false, false, SingleSpc, 3, 8 }, |
| 252 | { ARM::VST3d8Pseudo_UPD, ARM::VST3d8_UPD, false, true, SingleSpc, 3, 8 }, |
| 253 | |
| 254 | { ARM::VST3q16Pseudo_UPD, ARM::VST3q16_UPD, false, true, EvenDblSpc, 3, 4 }, |
| 255 | { ARM::VST3q16oddPseudo_UPD, ARM::VST3q16_UPD, false, true, OddDblSpc, 3, 4 }, |
| 256 | { ARM::VST3q32Pseudo_UPD, ARM::VST3q32_UPD, false, true, EvenDblSpc, 3, 2 }, |
| 257 | { ARM::VST3q32oddPseudo_UPD, ARM::VST3q32_UPD, false, true, OddDblSpc, 3, 2 }, |
| 258 | { ARM::VST3q8Pseudo_UPD, ARM::VST3q8_UPD, false, true, EvenDblSpc, 3, 8 }, |
| 259 | { ARM::VST3q8oddPseudo_UPD, ARM::VST3q8_UPD, false, true, OddDblSpc, 3, 8 }, |
| 260 | |
| 261 | { ARM::VST4LNd16Pseudo, ARM::VST4LNd16, false, false, SingleSpc, 4, 4 }, |
| 262 | { ARM::VST4LNd16Pseudo_UPD, ARM::VST4LNd16_UPD, false, true, SingleSpc, 4, 4 }, |
| 263 | { ARM::VST4LNd32Pseudo, ARM::VST4LNd32, false, false, SingleSpc, 4, 2 }, |
| 264 | { ARM::VST4LNd32Pseudo_UPD, ARM::VST4LNd32_UPD, false, true, SingleSpc, 4, 2 }, |
| 265 | { ARM::VST4LNd8Pseudo, ARM::VST4LNd8, false, false, SingleSpc, 4, 8 }, |
| 266 | { ARM::VST4LNd8Pseudo_UPD, ARM::VST4LNd8_UPD, false, true, SingleSpc, 4, 8 }, |
| 267 | { ARM::VST4LNq16Pseudo, ARM::VST4LNq16, false, false, EvenDblSpc, 4, 4}, |
| 268 | { ARM::VST4LNq16Pseudo_UPD, ARM::VST4LNq16_UPD, false, true, EvenDblSpc, 4, 4}, |
| 269 | { ARM::VST4LNq32Pseudo, ARM::VST4LNq32, false, false, EvenDblSpc, 4, 2}, |
| 270 | { ARM::VST4LNq32Pseudo_UPD, ARM::VST4LNq32_UPD, false, true, EvenDblSpc, 4, 2}, |
| 271 | |
| 272 | { ARM::VST4d16Pseudo, ARM::VST4d16, false, false, SingleSpc, 4, 4 }, |
| 273 | { ARM::VST4d16Pseudo_UPD, ARM::VST4d16_UPD, false, true, SingleSpc, 4, 4 }, |
| 274 | { ARM::VST4d32Pseudo, ARM::VST4d32, false, false, SingleSpc, 4, 2 }, |
| 275 | { ARM::VST4d32Pseudo_UPD, ARM::VST4d32_UPD, false, true, SingleSpc, 4, 2 }, |
| 276 | { ARM::VST4d8Pseudo, ARM::VST4d8, false, false, SingleSpc, 4, 8 }, |
| 277 | { ARM::VST4d8Pseudo_UPD, ARM::VST4d8_UPD, false, true, SingleSpc, 4, 8 }, |
| 278 | |
| 279 | { ARM::VST4q16Pseudo_UPD, ARM::VST4q16_UPD, false, true, EvenDblSpc, 4, 4 }, |
| 280 | { ARM::VST4q16oddPseudo_UPD, ARM::VST4q16_UPD, false, true, OddDblSpc, 4, 4 }, |
| 281 | { ARM::VST4q32Pseudo_UPD, ARM::VST4q32_UPD, false, true, EvenDblSpc, 4, 2 }, |
| 282 | { ARM::VST4q32oddPseudo_UPD, ARM::VST4q32_UPD, false, true, OddDblSpc, 4, 2 }, |
| 283 | { ARM::VST4q8Pseudo_UPD, ARM::VST4q8_UPD, false, true, EvenDblSpc, 4, 8 }, |
| 284 | { ARM::VST4q8oddPseudo_UPD , ARM::VST4q8_UPD, false, true, OddDblSpc, 4, 8 } |
| 285 | }; |
| 286 | |
| 287 | /// LookupNEONLdSt - Search the NEONLdStTable for information about a NEON |
| 288 | /// load or store pseudo instruction. |
| 289 | static const NEONLdStTableEntry *LookupNEONLdSt(unsigned Opcode) { |
| 290 | unsigned NumEntries = array_lengthof(NEONLdStTable); |
| 291 | |
| 292 | #ifndef NDEBUG |
| 293 | // Make sure the table is sorted. |
| 294 | static bool TableChecked = false; |
| 295 | if (!TableChecked) { |
| 296 | for (unsigned i = 0; i != NumEntries-1; ++i) |
| 297 | assert(NEONLdStTable[i] < NEONLdStTable[i+1] && |
| 298 | "NEONLdStTable is not sorted!"); |
| 299 | TableChecked = true; |
| 300 | } |
| 301 | #endif |
| 302 | |
| 303 | const NEONLdStTableEntry *I = |
| 304 | std::lower_bound(NEONLdStTable, NEONLdStTable + NumEntries, Opcode); |
| 305 | if (I != NEONLdStTable + NumEntries && I->PseudoOpc == Opcode) |
| 306 | return I; |
| 307 | return NULL; |
| 308 | } |
| 309 | |
| 310 | /// GetDSubRegs - Get 4 D subregisters of a Q, QQ, or QQQQ register, |
| 311 | /// corresponding to the specified register spacing. Not all of the results |
| 312 | /// are necessarily valid, e.g., a Q register only has 2 D subregisters. |
| 313 | static void GetDSubRegs(unsigned Reg, NEONRegSpacing RegSpc, |
| 314 | const TargetRegisterInfo *TRI, unsigned &D0, |
| 315 | unsigned &D1, unsigned &D2, unsigned &D3) { |
| 316 | if (RegSpc == SingleSpc) { |
| 317 | D0 = TRI->getSubReg(Reg, ARM::dsub_0); |
| 318 | D1 = TRI->getSubReg(Reg, ARM::dsub_1); |
| 319 | D2 = TRI->getSubReg(Reg, ARM::dsub_2); |
| 320 | D3 = TRI->getSubReg(Reg, ARM::dsub_3); |
| 321 | } else if (RegSpc == EvenDblSpc) { |
| 322 | D0 = TRI->getSubReg(Reg, ARM::dsub_0); |
| 323 | D1 = TRI->getSubReg(Reg, ARM::dsub_2); |
| 324 | D2 = TRI->getSubReg(Reg, ARM::dsub_4); |
| 325 | D3 = TRI->getSubReg(Reg, ARM::dsub_6); |
| 326 | } else { |
| 327 | assert(RegSpc == OddDblSpc && "unknown register spacing"); |
| 328 | D0 = TRI->getSubReg(Reg, ARM::dsub_1); |
| 329 | D1 = TRI->getSubReg(Reg, ARM::dsub_3); |
| 330 | D2 = TRI->getSubReg(Reg, ARM::dsub_5); |
| 331 | D3 = TRI->getSubReg(Reg, ARM::dsub_7); |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 332 | } |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Bob Wilson | 82a9c84 | 2010-09-02 16:17:29 +0000 | [diff] [blame] | 335 | /// ExpandVLD - Translate VLD pseudo instructions with Q, QQ or QQQQ register |
| 336 | /// operands to real VLD instructions with D register operands. |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 337 | void ARMExpandPseudo::ExpandVLD(MachineBasicBlock::iterator &MBBI) { |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 338 | MachineInstr &MI = *MBBI; |
| 339 | MachineBasicBlock &MBB = *MI.getParent(); |
| 340 | |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 341 | const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode()); |
| 342 | assert(TableEntry && TableEntry->IsLoad && "NEONLdStTable lookup failed"); |
| 343 | NEONRegSpacing RegSpc = TableEntry->RegSpacing; |
| 344 | unsigned NumRegs = TableEntry->NumRegs; |
| 345 | |
| 346 | MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 347 | TII->get(TableEntry->RealOpc)); |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 348 | unsigned OpIdx = 0; |
| 349 | |
| 350 | bool DstIsDead = MI.getOperand(OpIdx).isDead(); |
| 351 | unsigned DstReg = MI.getOperand(OpIdx++).getReg(); |
| 352 | unsigned D0, D1, D2, D3; |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 353 | GetDSubRegs(DstReg, RegSpc, TRI, D0, D1, D2, D3); |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 354 | MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead)) |
| 355 | .addReg(D1, RegState::Define | getDeadRegState(DstIsDead)); |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 356 | if (NumRegs > 2) |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 357 | MIB.addReg(D2, RegState::Define | getDeadRegState(DstIsDead)); |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 358 | if (NumRegs > 3) |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 359 | MIB.addReg(D3, RegState::Define | getDeadRegState(DstIsDead)); |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 360 | |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 361 | if (TableEntry->HasWriteBack) |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 362 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 363 | |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 364 | // Copy the addrmode6 operands. |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 365 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 366 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 367 | // Copy the am6offset operand. |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 368 | if (TableEntry->HasWriteBack) |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 369 | MIB.addOperand(MI.getOperand(OpIdx++)); |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 370 | |
Bob Wilson | 19d644d | 2010-09-09 00:38:32 +0000 | [diff] [blame] | 371 | // For an instruction writing double-spaced subregs, the pseudo instruction |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 372 | // has an extra operand that is a use of the super-register. Record the |
| 373 | // operand index and skip over it. |
| 374 | unsigned SrcOpIdx = 0; |
| 375 | if (RegSpc == EvenDblSpc || RegSpc == OddDblSpc) |
| 376 | SrcOpIdx = OpIdx++; |
| 377 | |
| 378 | // Copy the predicate operands. |
| 379 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 380 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 381 | |
| 382 | // Copy the super-register source operand used for double-spaced subregs over |
Bob Wilson | 19d644d | 2010-09-09 00:38:32 +0000 | [diff] [blame] | 383 | // to the new instruction as an implicit operand. |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 384 | if (SrcOpIdx != 0) { |
| 385 | MachineOperand MO = MI.getOperand(SrcOpIdx); |
Bob Wilson | 19d644d | 2010-09-09 00:38:32 +0000 | [diff] [blame] | 386 | MO.setImplicit(true); |
| 387 | MIB.addOperand(MO); |
| 388 | } |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 389 | // Add an implicit def for the super-register. |
| 390 | MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead)); |
Bob Wilson | 19d644d | 2010-09-09 00:38:32 +0000 | [diff] [blame] | 391 | TransferImpOps(MI, MIB, MIB); |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 392 | MI.eraseFromParent(); |
| 393 | } |
| 394 | |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 395 | /// ExpandVST - Translate VST pseudo instructions with Q, QQ or QQQQ register |
| 396 | /// operands to real VST instructions with D register operands. |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 397 | void ARMExpandPseudo::ExpandVST(MachineBasicBlock::iterator &MBBI) { |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 398 | MachineInstr &MI = *MBBI; |
| 399 | MachineBasicBlock &MBB = *MI.getParent(); |
| 400 | |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 401 | const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode()); |
| 402 | assert(TableEntry && !TableEntry->IsLoad && "NEONLdStTable lookup failed"); |
| 403 | NEONRegSpacing RegSpc = TableEntry->RegSpacing; |
| 404 | unsigned NumRegs = TableEntry->NumRegs; |
| 405 | |
| 406 | MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 407 | TII->get(TableEntry->RealOpc)); |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 408 | unsigned OpIdx = 0; |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 409 | if (TableEntry->HasWriteBack) |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 410 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 411 | |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 412 | // Copy the addrmode6 operands. |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 413 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 414 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 415 | // Copy the am6offset operand. |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 416 | if (TableEntry->HasWriteBack) |
Bob Wilson | 63569c9 | 2010-09-09 00:15:32 +0000 | [diff] [blame] | 417 | MIB.addOperand(MI.getOperand(OpIdx++)); |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 418 | |
| 419 | bool SrcIsKill = MI.getOperand(OpIdx).isKill(); |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 420 | unsigned SrcReg = MI.getOperand(OpIdx++).getReg(); |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 421 | unsigned D0, D1, D2, D3; |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 422 | GetDSubRegs(SrcReg, RegSpc, TRI, D0, D1, D2, D3); |
Bob Wilson | 7e70197 | 2010-08-30 18:10:48 +0000 | [diff] [blame] | 423 | MIB.addReg(D0).addReg(D1); |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 424 | if (NumRegs > 2) |
Bob Wilson | 7e70197 | 2010-08-30 18:10:48 +0000 | [diff] [blame] | 425 | MIB.addReg(D2); |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 426 | if (NumRegs > 3) |
Bob Wilson | 7e70197 | 2010-08-30 18:10:48 +0000 | [diff] [blame] | 427 | MIB.addReg(D3); |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 428 | |
| 429 | // Copy the predicate operands. |
| 430 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 431 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 432 | |
Bob Wilson | 7e70197 | 2010-08-30 18:10:48 +0000 | [diff] [blame] | 433 | if (SrcIsKill) |
| 434 | // Add an implicit kill for the super-reg. |
| 435 | (*MIB).addRegisterKilled(SrcReg, TRI, true); |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 436 | TransferImpOps(MI, MIB, MIB); |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 437 | MI.eraseFromParent(); |
| 438 | } |
| 439 | |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 440 | /// ExpandLaneOp - Translate VLD*LN and VST*LN instructions with Q, QQ or QQQQ |
| 441 | /// register operands to real instructions with D register operands. |
| 442 | void ARMExpandPseudo::ExpandLaneOp(MachineBasicBlock::iterator &MBBI) { |
| 443 | MachineInstr &MI = *MBBI; |
| 444 | MachineBasicBlock &MBB = *MI.getParent(); |
| 445 | |
| 446 | const NEONLdStTableEntry *TableEntry = LookupNEONLdSt(MI.getOpcode()); |
| 447 | assert(TableEntry && "NEONLdStTable lookup failed"); |
| 448 | NEONRegSpacing RegSpc = TableEntry->RegSpacing; |
| 449 | unsigned NumRegs = TableEntry->NumRegs; |
| 450 | unsigned RegElts = TableEntry->RegElts; |
| 451 | |
| 452 | MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 453 | TII->get(TableEntry->RealOpc)); |
| 454 | unsigned OpIdx = 0; |
| 455 | // The lane operand is always the 3rd from last operand, before the 2 |
| 456 | // predicate operands. |
| 457 | unsigned Lane = MI.getOperand(MI.getDesc().getNumOperands() - 3).getImm(); |
| 458 | |
| 459 | // Adjust the lane and spacing as needed for Q registers. |
| 460 | assert(RegSpc != OddDblSpc && "unexpected register spacing for VLD/VST-lane"); |
| 461 | if (RegSpc == EvenDblSpc && Lane >= RegElts) { |
| 462 | RegSpc = OddDblSpc; |
| 463 | Lane -= RegElts; |
| 464 | } |
| 465 | assert(Lane < RegElts && "out of range lane for VLD/VST-lane"); |
| 466 | |
Bob Wilson | fe3ac08 | 2010-09-14 21:12:05 +0000 | [diff] [blame] | 467 | unsigned D0, D1, D2, D3; |
| 468 | unsigned DstReg = 0; |
| 469 | bool DstIsDead = false; |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 470 | if (TableEntry->IsLoad) { |
| 471 | DstIsDead = MI.getOperand(OpIdx).isDead(); |
| 472 | DstReg = MI.getOperand(OpIdx++).getReg(); |
| 473 | GetDSubRegs(DstReg, RegSpc, TRI, D0, D1, D2, D3); |
| 474 | MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead)) |
| 475 | .addReg(D1, RegState::Define | getDeadRegState(DstIsDead)); |
| 476 | if (NumRegs > 2) |
| 477 | MIB.addReg(D2, RegState::Define | getDeadRegState(DstIsDead)); |
| 478 | if (NumRegs > 3) |
| 479 | MIB.addReg(D3, RegState::Define | getDeadRegState(DstIsDead)); |
| 480 | } |
| 481 | |
| 482 | if (TableEntry->HasWriteBack) |
| 483 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 484 | |
| 485 | // Copy the addrmode6 operands. |
| 486 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 487 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 488 | // Copy the am6offset operand. |
| 489 | if (TableEntry->HasWriteBack) |
| 490 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 491 | |
| 492 | // Grab the super-register source. |
| 493 | MachineOperand MO = MI.getOperand(OpIdx++); |
| 494 | if (!TableEntry->IsLoad) |
| 495 | GetDSubRegs(MO.getReg(), RegSpc, TRI, D0, D1, D2, D3); |
| 496 | |
| 497 | // Add the subregs as sources of the new instruction. |
| 498 | unsigned SrcFlags = (getUndefRegState(MO.isUndef()) | |
| 499 | getKillRegState(MO.isKill())); |
| 500 | MIB.addReg(D0, SrcFlags).addReg(D1, SrcFlags); |
| 501 | if (NumRegs > 2) |
| 502 | MIB.addReg(D2, SrcFlags); |
| 503 | if (NumRegs > 3) |
| 504 | MIB.addReg(D3, SrcFlags); |
| 505 | |
| 506 | // Add the lane number operand. |
| 507 | MIB.addImm(Lane); |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 508 | OpIdx += 1; |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 509 | |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 510 | // Copy the predicate operands. |
| 511 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 512 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 513 | |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 514 | // Copy the super-register source to be an implicit source. |
| 515 | MO.setImplicit(true); |
| 516 | MIB.addOperand(MO); |
| 517 | if (TableEntry->IsLoad) |
| 518 | // Add an implicit def for the super-register. |
| 519 | MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead)); |
| 520 | TransferImpOps(MI, MIB, MIB); |
| 521 | MI.eraseFromParent(); |
| 522 | } |
| 523 | |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 524 | /// ExpandVTBL - Translate VTBL and VTBX pseudo instructions with Q or QQ |
| 525 | /// register operands to real instructions with D register operands. |
| 526 | void ARMExpandPseudo::ExpandVTBL(MachineBasicBlock::iterator &MBBI, |
| 527 | unsigned Opc, bool IsExt, unsigned NumRegs) { |
| 528 | MachineInstr &MI = *MBBI; |
| 529 | MachineBasicBlock &MBB = *MI.getParent(); |
| 530 | |
| 531 | MachineInstrBuilder MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(Opc)); |
| 532 | unsigned OpIdx = 0; |
| 533 | |
| 534 | // Transfer the destination register operand. |
| 535 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 536 | if (IsExt) |
| 537 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 538 | |
| 539 | bool SrcIsKill = MI.getOperand(OpIdx).isKill(); |
| 540 | unsigned SrcReg = MI.getOperand(OpIdx++).getReg(); |
| 541 | unsigned D0, D1, D2, D3; |
| 542 | GetDSubRegs(SrcReg, SingleSpc, TRI, D0, D1, D2, D3); |
| 543 | MIB.addReg(D0).addReg(D1); |
| 544 | if (NumRegs > 2) |
| 545 | MIB.addReg(D2); |
| 546 | if (NumRegs > 3) |
| 547 | MIB.addReg(D3); |
| 548 | |
| 549 | // Copy the other source register operand. |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 550 | MIB.addOperand(MI.getOperand(OpIdx++)); |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 551 | |
Bob Wilson | 823611b | 2010-09-16 04:25:37 +0000 | [diff] [blame] | 552 | // Copy the predicate operands. |
| 553 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 554 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 555 | |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 556 | if (SrcIsKill) |
| 557 | // Add an implicit kill for the super-reg. |
| 558 | (*MIB).addRegisterKilled(SrcReg, TRI, true); |
| 559 | TransferImpOps(MI, MIB, MIB); |
| 560 | MI.eraseFromParent(); |
| 561 | } |
| 562 | |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 563 | bool ARMExpandPseudo::ExpandMBB(MachineBasicBlock &MBB) { |
| 564 | bool Modified = false; |
| 565 | |
| 566 | MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end(); |
| 567 | while (MBBI != E) { |
| 568 | MachineInstr &MI = *MBBI; |
Chris Lattner | 7896c9f | 2009-12-03 00:50:42 +0000 | [diff] [blame] | 569 | MachineBasicBlock::iterator NMBBI = llvm::next(MBBI); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 570 | |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 571 | bool ModifiedOp = true; |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 572 | unsigned Opcode = MI.getOpcode(); |
| 573 | switch (Opcode) { |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 574 | default: |
| 575 | ModifiedOp = false; |
| 576 | break; |
| 577 | |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 578 | case ARM::tLDRpci_pic: |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 579 | case ARM::t2LDRpci_pic: { |
| 580 | unsigned NewLdOpc = (Opcode == ARM::tLDRpci_pic) |
| 581 | ? ARM::tLDRpci : ARM::t2LDRpci; |
| 582 | unsigned DstReg = MI.getOperand(0).getReg(); |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 583 | bool DstIsDead = MI.getOperand(0).isDead(); |
| 584 | MachineInstrBuilder MIB1 = |
| 585 | AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 586 | TII->get(NewLdOpc), DstReg) |
| 587 | .addOperand(MI.getOperand(1))); |
| 588 | (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); |
| 589 | MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 590 | TII->get(ARM::tPICADD)) |
| 591 | .addReg(DstReg, getDefRegState(true) | getDeadRegState(DstIsDead)) |
| 592 | .addReg(DstReg) |
| 593 | .addOperand(MI.getOperand(2)); |
| 594 | TransferImpOps(MI, MIB1, MIB2); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 595 | MI.eraseFromParent(); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 596 | break; |
| 597 | } |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 598 | |
Anton Korobeynikov | 6d1e29d | 2010-08-30 22:50:36 +0000 | [diff] [blame] | 599 | case ARM::MOVi32imm: |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 600 | case ARM::t2MOVi32imm: { |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 601 | unsigned PredReg = 0; |
| 602 | ARMCC::CondCodes Pred = llvm::getInstrPredicate(&MI, PredReg); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 603 | unsigned DstReg = MI.getOperand(0).getReg(); |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 604 | bool DstIsDead = MI.getOperand(0).isDead(); |
| 605 | const MachineOperand &MO = MI.getOperand(1); |
| 606 | MachineInstrBuilder LO16, HI16; |
Anton Korobeynikov | 5cdc3a9 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 607 | |
Anton Korobeynikov | 6d1e29d | 2010-08-30 22:50:36 +0000 | [diff] [blame] | 608 | LO16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 609 | TII->get(Opcode == ARM::MOVi32imm ? |
| 610 | ARM::MOVi16 : ARM::t2MOVi16), |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 611 | DstReg); |
Anton Korobeynikov | 6d1e29d | 2010-08-30 22:50:36 +0000 | [diff] [blame] | 612 | HI16 = BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 613 | TII->get(Opcode == ARM::MOVi32imm ? |
| 614 | ARM::MOVTi16 : ARM::t2MOVTi16)) |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 615 | .addReg(DstReg, getDefRegState(true) | getDeadRegState(DstIsDead)) |
| 616 | .addReg(DstReg); |
Anton Korobeynikov | 5cdc3a9 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 617 | |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 618 | if (MO.isImm()) { |
| 619 | unsigned Imm = MO.getImm(); |
| 620 | unsigned Lo16 = Imm & 0xffff; |
| 621 | unsigned Hi16 = (Imm >> 16) & 0xffff; |
| 622 | LO16 = LO16.addImm(Lo16); |
| 623 | HI16 = HI16.addImm(Hi16); |
| 624 | } else { |
| 625 | const GlobalValue *GV = MO.getGlobal(); |
| 626 | unsigned TF = MO.getTargetFlags(); |
| 627 | LO16 = LO16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_LO16); |
| 628 | HI16 = HI16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_HI16); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 629 | } |
Evan Cheng | 4313007 | 2010-05-12 23:13:12 +0000 | [diff] [blame] | 630 | (*LO16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); |
| 631 | (*HI16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); |
| 632 | LO16.addImm(Pred).addReg(PredReg); |
| 633 | HI16.addImm(Pred).addReg(PredReg); |
| 634 | TransferImpOps(MI, LO16, HI16); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 635 | MI.eraseFromParent(); |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 636 | break; |
| 637 | } |
| 638 | |
| 639 | case ARM::VMOVQQ: { |
| 640 | unsigned DstReg = MI.getOperand(0).getReg(); |
| 641 | bool DstIsDead = MI.getOperand(0).isDead(); |
Jakob Stoklund Olesen | 558661d | 2010-05-24 16:54:32 +0000 | [diff] [blame] | 642 | unsigned EvenDst = TRI->getSubReg(DstReg, ARM::qsub_0); |
| 643 | unsigned OddDst = TRI->getSubReg(DstReg, ARM::qsub_1); |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 644 | unsigned SrcReg = MI.getOperand(1).getReg(); |
| 645 | bool SrcIsKill = MI.getOperand(1).isKill(); |
Jakob Stoklund Olesen | 558661d | 2010-05-24 16:54:32 +0000 | [diff] [blame] | 646 | unsigned EvenSrc = TRI->getSubReg(SrcReg, ARM::qsub_0); |
| 647 | unsigned OddSrc = TRI->getSubReg(SrcReg, ARM::qsub_1); |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 648 | MachineInstrBuilder Even = |
| 649 | AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 650 | TII->get(ARM::VMOVQ)) |
Jim Grosbach | 18f30e6 | 2010-06-02 21:53:11 +0000 | [diff] [blame] | 651 | .addReg(EvenDst, |
| 652 | getDefRegState(true) | getDeadRegState(DstIsDead)) |
| 653 | .addReg(EvenSrc, getKillRegState(SrcIsKill))); |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 654 | MachineInstrBuilder Odd = |
| 655 | AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), |
| 656 | TII->get(ARM::VMOVQ)) |
Jim Grosbach | 18f30e6 | 2010-06-02 21:53:11 +0000 | [diff] [blame] | 657 | .addReg(OddDst, |
| 658 | getDefRegState(true) | getDeadRegState(DstIsDead)) |
| 659 | .addReg(OddSrc, getKillRegState(SrcIsKill))); |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 660 | TransferImpOps(MI, Even, Odd); |
| 661 | MI.eraseFromParent(); |
Bob Wilson | ea606bb | 2010-09-16 00:31:32 +0000 | [diff] [blame] | 662 | break; |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 663 | } |
| 664 | |
Bob Wilson | 9d4ebc0 | 2010-09-16 00:31:02 +0000 | [diff] [blame] | 665 | case ARM::VLDMQ: { |
| 666 | MachineInstrBuilder MIB = |
| 667 | BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::VLDMD)); |
| 668 | unsigned OpIdx = 0; |
| 669 | // Grab the Q register destination. |
| 670 | bool DstIsDead = MI.getOperand(OpIdx).isDead(); |
| 671 | unsigned DstReg = MI.getOperand(OpIdx++).getReg(); |
| 672 | // Copy the addrmode4 operands. |
| 673 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 674 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 675 | // Copy the predicate operands. |
| 676 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 677 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 678 | // Add the destination operands (D subregs). |
| 679 | unsigned D0 = TRI->getSubReg(DstReg, ARM::dsub_0); |
| 680 | unsigned D1 = TRI->getSubReg(DstReg, ARM::dsub_1); |
| 681 | MIB.addReg(D0, RegState::Define | getDeadRegState(DstIsDead)) |
| 682 | .addReg(D1, RegState::Define | getDeadRegState(DstIsDead)); |
| 683 | // Add an implicit def for the super-register. |
| 684 | MIB.addReg(DstReg, RegState::ImplicitDefine | getDeadRegState(DstIsDead)); |
| 685 | TransferImpOps(MI, MIB, MIB); |
| 686 | MI.eraseFromParent(); |
| 687 | break; |
| 688 | } |
| 689 | |
| 690 | case ARM::VSTMQ: { |
| 691 | MachineInstrBuilder MIB = |
| 692 | BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::VSTMD)); |
| 693 | unsigned OpIdx = 0; |
| 694 | // Grab the Q register source. |
| 695 | bool SrcIsKill = MI.getOperand(OpIdx).isKill(); |
| 696 | unsigned SrcReg = MI.getOperand(OpIdx++).getReg(); |
| 697 | // Copy the addrmode4 operands. |
| 698 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 699 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 700 | // Copy the predicate operands. |
| 701 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 702 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 703 | // Add the source operands (D subregs). |
| 704 | unsigned D0 = TRI->getSubReg(SrcReg, ARM::dsub_0); |
| 705 | unsigned D1 = TRI->getSubReg(SrcReg, ARM::dsub_1); |
| 706 | MIB.addReg(D0).addReg(D1); |
| 707 | if (SrcIsKill) |
| 708 | // Add an implicit kill for the Q register. |
| 709 | (*MIB).addRegisterKilled(SrcReg, TRI, true); |
| 710 | TransferImpOps(MI, MIB, MIB); |
| 711 | MI.eraseFromParent(); |
| 712 | break; |
| 713 | } |
Jim Grosbach | 65dc303 | 2010-10-06 21:16:16 +0000 | [diff] [blame^] | 714 | case ARM::VDUPfqf: |
| 715 | case ARM::VDUPfdf:{ |
| 716 | unsigned NewOpc = Opcode == ARM::VDUPfqf ? ARM::VDUPLNfq : ARM::VDUPLNfd; |
| 717 | MachineInstrBuilder MIB = |
| 718 | BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewOpc)); |
| 719 | unsigned OpIdx = 0; |
| 720 | unsigned SrcReg = MI.getOperand(1).getReg(); |
| 721 | unsigned Lane = getARMRegisterNumbering(SrcReg) & 1; |
| 722 | unsigned DReg = TRI->getMatchingSuperReg(SrcReg, |
| 723 | Lane & 1 ? ARM::ssub_1 : ARM::ssub_0, &ARM::DPR_VFP2RegClass); |
| 724 | // The lane is [0,1] for the containing DReg superregister. |
| 725 | // Copy the dst/src register operands. |
| 726 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 727 | MIB.addReg(DReg); |
| 728 | ++OpIdx; |
| 729 | // Add the lane select operand. |
| 730 | MIB.addImm(Lane); |
| 731 | // Add the predicate operands. |
| 732 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 733 | MIB.addOperand(MI.getOperand(OpIdx++)); |
| 734 | |
| 735 | TransferImpOps(MI, MIB, MIB); |
| 736 | MI.eraseFromParent(); |
| 737 | break; |
| 738 | } |
Bob Wilson | 9d4ebc0 | 2010-09-16 00:31:02 +0000 | [diff] [blame] | 739 | |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 740 | case ARM::VLD1q8Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 741 | case ARM::VLD1q16Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 742 | case ARM::VLD1q32Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 743 | case ARM::VLD1q64Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 744 | case ARM::VLD1q8Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 745 | case ARM::VLD1q16Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 746 | case ARM::VLD1q32Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 747 | case ARM::VLD1q64Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 748 | case ARM::VLD2d8Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 749 | case ARM::VLD2d16Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 750 | case ARM::VLD2d32Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 751 | case ARM::VLD2q8Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 752 | case ARM::VLD2q16Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 753 | case ARM::VLD2q32Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 754 | case ARM::VLD2d8Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 755 | case ARM::VLD2d16Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 756 | case ARM::VLD2d32Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 757 | case ARM::VLD2q8Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 758 | case ARM::VLD2q16Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 759 | case ARM::VLD2q32Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 760 | case ARM::VLD3d8Pseudo: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 761 | case ARM::VLD3d16Pseudo: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 762 | case ARM::VLD3d32Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 763 | case ARM::VLD1d64TPseudo: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 764 | case ARM::VLD3d8Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 765 | case ARM::VLD3d16Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 766 | case ARM::VLD3d32Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 767 | case ARM::VLD1d64TPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 768 | case ARM::VLD3q8Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 769 | case ARM::VLD3q16Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 770 | case ARM::VLD3q32Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 771 | case ARM::VLD3q8oddPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 772 | case ARM::VLD3q16oddPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 773 | case ARM::VLD3q32oddPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 774 | case ARM::VLD4d8Pseudo: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 775 | case ARM::VLD4d16Pseudo: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 776 | case ARM::VLD4d32Pseudo: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 777 | case ARM::VLD1d64QPseudo: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 778 | case ARM::VLD4d8Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 779 | case ARM::VLD4d16Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 780 | case ARM::VLD4d32Pseudo_UPD: |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 781 | case ARM::VLD1d64QPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 782 | case ARM::VLD4q8Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 783 | case ARM::VLD4q16Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 784 | case ARM::VLD4q32Pseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 785 | case ARM::VLD4q8oddPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 786 | case ARM::VLD4q16oddPseudo_UPD: |
Bob Wilson | f572191 | 2010-09-03 18:16:02 +0000 | [diff] [blame] | 787 | case ARM::VLD4q32oddPseudo_UPD: |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 788 | ExpandVLD(MBBI); |
| 789 | break; |
Bob Wilson | ffde080 | 2010-09-02 16:00:54 +0000 | [diff] [blame] | 790 | |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 791 | case ARM::VST1q8Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 792 | case ARM::VST1q16Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 793 | case ARM::VST1q32Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 794 | case ARM::VST1q64Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 795 | case ARM::VST1q8Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 796 | case ARM::VST1q16Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 797 | case ARM::VST1q32Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 798 | case ARM::VST1q64Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 799 | case ARM::VST2d8Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 800 | case ARM::VST2d16Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 801 | case ARM::VST2d32Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 802 | case ARM::VST2q8Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 803 | case ARM::VST2q16Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 804 | case ARM::VST2q32Pseudo: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 805 | case ARM::VST2d8Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 806 | case ARM::VST2d16Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 807 | case ARM::VST2d32Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 808 | case ARM::VST2q8Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 809 | case ARM::VST2q16Pseudo_UPD: |
Bob Wilson | e5ce4f6 | 2010-08-28 05:12:57 +0000 | [diff] [blame] | 810 | case ARM::VST2q32Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 811 | case ARM::VST3d8Pseudo: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 812 | case ARM::VST3d16Pseudo: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 813 | case ARM::VST3d32Pseudo: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 814 | case ARM::VST1d64TPseudo: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 815 | case ARM::VST3d8Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 816 | case ARM::VST3d16Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 817 | case ARM::VST3d32Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 818 | case ARM::VST1d64TPseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 819 | case ARM::VST3q8Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 820 | case ARM::VST3q16Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 821 | case ARM::VST3q32Pseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 822 | case ARM::VST3q8oddPseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 823 | case ARM::VST3q16oddPseudo_UPD: |
Bob Wilson | 01ba461 | 2010-08-26 18:51:29 +0000 | [diff] [blame] | 824 | case ARM::VST3q32oddPseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 825 | case ARM::VST4d8Pseudo: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 826 | case ARM::VST4d16Pseudo: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 827 | case ARM::VST4d32Pseudo: |
Bob Wilson | 70e48b2 | 2010-08-26 05:33:30 +0000 | [diff] [blame] | 828 | case ARM::VST1d64QPseudo: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 829 | case ARM::VST4d8Pseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 830 | case ARM::VST4d16Pseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 831 | case ARM::VST4d32Pseudo_UPD: |
Bob Wilson | 70e48b2 | 2010-08-26 05:33:30 +0000 | [diff] [blame] | 832 | case ARM::VST1d64QPseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 833 | case ARM::VST4q8Pseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 834 | case ARM::VST4q16Pseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 835 | case ARM::VST4q32Pseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 836 | case ARM::VST4q8oddPseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 837 | case ARM::VST4q16oddPseudo_UPD: |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 838 | case ARM::VST4q32oddPseudo_UPD: |
Bob Wilson | 8466fa1 | 2010-09-13 23:01:35 +0000 | [diff] [blame] | 839 | ExpandVST(MBBI); |
| 840 | break; |
| 841 | |
| 842 | case ARM::VLD2LNd8Pseudo: |
| 843 | case ARM::VLD2LNd16Pseudo: |
| 844 | case ARM::VLD2LNd32Pseudo: |
| 845 | case ARM::VLD2LNq16Pseudo: |
| 846 | case ARM::VLD2LNq32Pseudo: |
| 847 | case ARM::VLD2LNd8Pseudo_UPD: |
| 848 | case ARM::VLD2LNd16Pseudo_UPD: |
| 849 | case ARM::VLD2LNd32Pseudo_UPD: |
| 850 | case ARM::VLD2LNq16Pseudo_UPD: |
| 851 | case ARM::VLD2LNq32Pseudo_UPD: |
| 852 | case ARM::VLD3LNd8Pseudo: |
| 853 | case ARM::VLD3LNd16Pseudo: |
| 854 | case ARM::VLD3LNd32Pseudo: |
| 855 | case ARM::VLD3LNq16Pseudo: |
| 856 | case ARM::VLD3LNq32Pseudo: |
| 857 | case ARM::VLD3LNd8Pseudo_UPD: |
| 858 | case ARM::VLD3LNd16Pseudo_UPD: |
| 859 | case ARM::VLD3LNd32Pseudo_UPD: |
| 860 | case ARM::VLD3LNq16Pseudo_UPD: |
| 861 | case ARM::VLD3LNq32Pseudo_UPD: |
| 862 | case ARM::VLD4LNd8Pseudo: |
| 863 | case ARM::VLD4LNd16Pseudo: |
| 864 | case ARM::VLD4LNd32Pseudo: |
| 865 | case ARM::VLD4LNq16Pseudo: |
| 866 | case ARM::VLD4LNq32Pseudo: |
| 867 | case ARM::VLD4LNd8Pseudo_UPD: |
| 868 | case ARM::VLD4LNd16Pseudo_UPD: |
| 869 | case ARM::VLD4LNd32Pseudo_UPD: |
| 870 | case ARM::VLD4LNq16Pseudo_UPD: |
| 871 | case ARM::VLD4LNq32Pseudo_UPD: |
| 872 | case ARM::VST2LNd8Pseudo: |
| 873 | case ARM::VST2LNd16Pseudo: |
| 874 | case ARM::VST2LNd32Pseudo: |
| 875 | case ARM::VST2LNq16Pseudo: |
| 876 | case ARM::VST2LNq32Pseudo: |
| 877 | case ARM::VST2LNd8Pseudo_UPD: |
| 878 | case ARM::VST2LNd16Pseudo_UPD: |
| 879 | case ARM::VST2LNd32Pseudo_UPD: |
| 880 | case ARM::VST2LNq16Pseudo_UPD: |
| 881 | case ARM::VST2LNq32Pseudo_UPD: |
| 882 | case ARM::VST3LNd8Pseudo: |
| 883 | case ARM::VST3LNd16Pseudo: |
| 884 | case ARM::VST3LNd32Pseudo: |
| 885 | case ARM::VST3LNq16Pseudo: |
| 886 | case ARM::VST3LNq32Pseudo: |
| 887 | case ARM::VST3LNd8Pseudo_UPD: |
| 888 | case ARM::VST3LNd16Pseudo_UPD: |
| 889 | case ARM::VST3LNd32Pseudo_UPD: |
| 890 | case ARM::VST3LNq16Pseudo_UPD: |
| 891 | case ARM::VST3LNq32Pseudo_UPD: |
| 892 | case ARM::VST4LNd8Pseudo: |
| 893 | case ARM::VST4LNd16Pseudo: |
| 894 | case ARM::VST4LNd32Pseudo: |
| 895 | case ARM::VST4LNq16Pseudo: |
| 896 | case ARM::VST4LNq32Pseudo: |
| 897 | case ARM::VST4LNd8Pseudo_UPD: |
| 898 | case ARM::VST4LNd16Pseudo_UPD: |
| 899 | case ARM::VST4LNd32Pseudo_UPD: |
| 900 | case ARM::VST4LNq16Pseudo_UPD: |
| 901 | case ARM::VST4LNq32Pseudo_UPD: |
| 902 | ExpandLaneOp(MBBI); |
| 903 | break; |
Bob Wilson | bd916c5 | 2010-09-13 23:55:10 +0000 | [diff] [blame] | 904 | |
| 905 | case ARM::VTBL2Pseudo: |
| 906 | ExpandVTBL(MBBI, ARM::VTBL2, false, 2); break; |
| 907 | case ARM::VTBL3Pseudo: |
| 908 | ExpandVTBL(MBBI, ARM::VTBL3, false, 3); break; |
| 909 | case ARM::VTBL4Pseudo: |
| 910 | ExpandVTBL(MBBI, ARM::VTBL4, false, 4); break; |
| 911 | case ARM::VTBX2Pseudo: |
| 912 | ExpandVTBL(MBBI, ARM::VTBX2, true, 2); break; |
| 913 | case ARM::VTBX3Pseudo: |
| 914 | ExpandVTBL(MBBI, ARM::VTBX3, true, 3); break; |
| 915 | case ARM::VTBX4Pseudo: |
| 916 | ExpandVTBL(MBBI, ARM::VTBX4, true, 4); break; |
Bob Wilson | 709d592 | 2010-08-25 23:27:42 +0000 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | if (ModifiedOp) |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 920 | Modified = true; |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 921 | MBBI = NMBBI; |
| 922 | } |
| 923 | |
| 924 | return Modified; |
| 925 | } |
| 926 | |
| 927 | bool ARMExpandPseudo::runOnMachineFunction(MachineFunction &MF) { |
| 928 | TII = MF.getTarget().getInstrInfo(); |
Evan Cheng | d929f77 | 2010-05-13 00:17:02 +0000 | [diff] [blame] | 929 | TRI = MF.getTarget().getRegisterInfo(); |
Evan Cheng | b9803a8 | 2009-11-06 23:52:48 +0000 | [diff] [blame] | 930 | |
| 931 | bool Modified = false; |
| 932 | for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); MFI != E; |
| 933 | ++MFI) |
| 934 | Modified |= ExpandMBB(*MFI); |
| 935 | return Modified; |
| 936 | } |
| 937 | |
| 938 | /// createARMExpandPseudoPass - returns an instance of the pseudo instruction |
| 939 | /// expansion pass. |
| 940 | FunctionPass *llvm::createARMExpandPseudoPass() { |
| 941 | return new ARMExpandPseudo(); |
| 942 | } |