| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1 | //===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===// | 
 | 2 | // | 
 | 3 | //                     The LLVM Compiler Infrastructure | 
 | 4 | // | 
 | 5 | // This file is distributed under the University of Illinois Open Source | 
 | 6 | // License. See LICENSE.TXT for details. | 
 | 7 | // | 
 | 8 | //===----------------------------------------------------------------------===// | 
 | 9 | // | 
 | 10 | /// \file | 
 | 11 | /// \brief Implementation of the TargetInstrInfo class that is common to all | 
 | 12 | /// AMD GPUs. | 
 | 13 | // | 
 | 14 | //===----------------------------------------------------------------------===// | 
 | 15 |  | 
 | 16 | #include "AMDGPUInstrInfo.h" | 
 | 17 | #include "AMDGPURegisterInfo.h" | 
 | 18 | #include "AMDGPUTargetMachine.h" | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineFrameInfo.h" | 
 | 20 | #include "llvm/CodeGen/MachineInstrBuilder.h" | 
 | 21 | #include "llvm/CodeGen/MachineRegisterInfo.h" | 
 | 22 |  | 
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 23 | using namespace llvm; | 
 | 24 |  | 
| Juergen Ributzka | 3543625 | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 25 | #define GET_INSTRINFO_CTOR_DTOR | 
| Tom Stellard | 5e48a0e | 2013-06-25 21:22:18 +0000 | [diff] [blame] | 26 | #define GET_INSTRINFO_NAMED_OPS | 
| Christian Konig | f767018 | 2013-02-26 17:52:42 +0000 | [diff] [blame] | 27 | #define GET_INSTRMAP_INFO | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 28 | #include "AMDGPUGenInstrInfo.inc" | 
 | 29 |  | 
| Juergen Ributzka | 3543625 | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 30 | // Pin the vtable to this file. | 
 | 31 | void AMDGPUInstrInfo::anchor() {} | 
 | 32 |  | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 33 | AMDGPUInstrInfo::AMDGPUInstrInfo(TargetMachine &tm) | 
| Vincent Lejeune | 5b00e83 | 2013-10-01 19:32:38 +0000 | [diff] [blame] | 34 |   : AMDGPUGenInstrInfo(-1,-1), RI(tm), TM(tm) { } | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 35 |  | 
 | 36 | const AMDGPURegisterInfo &AMDGPUInstrInfo::getRegisterInfo() const { | 
 | 37 |   return RI; | 
 | 38 | } | 
 | 39 |  | 
 | 40 | bool AMDGPUInstrInfo::isCoalescableExtInstr(const MachineInstr &MI, | 
 | 41 |                                            unsigned &SrcReg, unsigned &DstReg, | 
 | 42 |                                            unsigned &SubIdx) const { | 
 | 43 | // TODO: Implement this function | 
 | 44 |   return false; | 
 | 45 | } | 
 | 46 |  | 
 | 47 | unsigned AMDGPUInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, | 
 | 48 |                                              int &FrameIndex) const { | 
 | 49 | // TODO: Implement this function | 
 | 50 |   return 0; | 
 | 51 | } | 
 | 52 |  | 
 | 53 | unsigned AMDGPUInstrInfo::isLoadFromStackSlotPostFE(const MachineInstr *MI, | 
 | 54 |                                                    int &FrameIndex) const { | 
 | 55 | // TODO: Implement this function | 
 | 56 |   return 0; | 
 | 57 | } | 
 | 58 |  | 
 | 59 | bool AMDGPUInstrInfo::hasLoadFromStackSlot(const MachineInstr *MI, | 
 | 60 |                                           const MachineMemOperand *&MMO, | 
 | 61 |                                           int &FrameIndex) const { | 
 | 62 | // TODO: Implement this function | 
 | 63 |   return false; | 
 | 64 | } | 
 | 65 | unsigned AMDGPUInstrInfo::isStoreFromStackSlot(const MachineInstr *MI, | 
 | 66 |                                               int &FrameIndex) const { | 
 | 67 | // TODO: Implement this function | 
 | 68 |   return 0; | 
 | 69 | } | 
 | 70 | unsigned AMDGPUInstrInfo::isStoreFromStackSlotPostFE(const MachineInstr *MI, | 
 | 71 |                                                     int &FrameIndex) const { | 
 | 72 | // TODO: Implement this function | 
 | 73 |   return 0; | 
 | 74 | } | 
 | 75 | bool AMDGPUInstrInfo::hasStoreFromStackSlot(const MachineInstr *MI, | 
 | 76 |                                            const MachineMemOperand *&MMO, | 
 | 77 |                                            int &FrameIndex) const { | 
 | 78 | // TODO: Implement this function | 
 | 79 |   return false; | 
 | 80 | } | 
 | 81 |  | 
 | 82 | MachineInstr * | 
 | 83 | AMDGPUInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI, | 
 | 84 |                                       MachineBasicBlock::iterator &MBBI, | 
 | 85 |                                       LiveVariables *LV) const { | 
 | 86 | // TODO: Implement this function | 
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 87 |   return nullptr; | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 88 | } | 
 | 89 | bool AMDGPUInstrInfo::getNextBranchInstr(MachineBasicBlock::iterator &iter, | 
 | 90 |                                         MachineBasicBlock &MBB) const { | 
 | 91 |   while (iter != MBB.end()) { | 
 | 92 |     switch (iter->getOpcode()) { | 
 | 93 |     default: | 
 | 94 |       break; | 
 | 95 |     case AMDGPU::BRANCH_COND_i32: | 
 | 96 |     case AMDGPU::BRANCH_COND_f32: | 
 | 97 |     case AMDGPU::BRANCH: | 
 | 98 |       return true; | 
 | 99 |     }; | 
 | 100 |     ++iter; | 
 | 101 |   } | 
 | 102 |   return false; | 
 | 103 | } | 
 | 104 |  | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 105 | void | 
 | 106 | AMDGPUInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB, | 
 | 107 |                                     MachineBasicBlock::iterator MI, | 
 | 108 |                                     unsigned SrcReg, bool isKill, | 
 | 109 |                                     int FrameIndex, | 
 | 110 |                                     const TargetRegisterClass *RC, | 
 | 111 |                                     const TargetRegisterInfo *TRI) const { | 
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 112 |   llvm_unreachable("Not Implemented"); | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 113 | } | 
 | 114 |  | 
 | 115 | void | 
 | 116 | AMDGPUInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, | 
 | 117 |                                      MachineBasicBlock::iterator MI, | 
 | 118 |                                      unsigned DestReg, int FrameIndex, | 
 | 119 |                                      const TargetRegisterClass *RC, | 
 | 120 |                                      const TargetRegisterInfo *TRI) const { | 
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 121 |   llvm_unreachable("Not Implemented"); | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 122 | } | 
 | 123 |  | 
| Tom Stellard | 04c5595 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 124 | bool AMDGPUInstrInfo::expandPostRAPseudo (MachineBasicBlock::iterator MI) const { | 
 | 125 |   MachineBasicBlock *MBB = MI->getParent(); | 
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 126 |   int OffsetOpIdx = AMDGPU::getNamedOperandIdx(MI->getOpcode(), | 
 | 127 |                                                AMDGPU::OpName::addr); | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 128 |    // addr is a custom operand with multiple MI operands, and only the | 
 | 129 |    // first MI operand is given a name. | 
 | 130 |   int RegOpIdx = OffsetOpIdx + 1; | 
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 131 |   int ChanOpIdx = AMDGPU::getNamedOperandIdx(MI->getOpcode(), | 
 | 132 |                                              AMDGPU::OpName::chan); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 133 |   if (isRegisterLoad(*MI)) { | 
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 134 |     int DstOpIdx = AMDGPU::getNamedOperandIdx(MI->getOpcode(), | 
 | 135 |                                               AMDGPU::OpName::dst); | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 136 |     unsigned RegIndex = MI->getOperand(RegOpIdx).getImm(); | 
 | 137 |     unsigned Channel = MI->getOperand(ChanOpIdx).getImm(); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 138 |     unsigned Address = calculateIndirectAddress(RegIndex, Channel); | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 139 |     unsigned OffsetReg = MI->getOperand(OffsetOpIdx).getReg(); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 140 |     if (OffsetReg == AMDGPU::INDIRECT_BASE_ADDR) { | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 141 |       buildMovInstr(MBB, MI, MI->getOperand(DstOpIdx).getReg(), | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 142 |                     getIndirectAddrRegClass()->getRegister(Address)); | 
| Tom Stellard | 04c5595 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 143 |     } else { | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 144 |       buildIndirectRead(MBB, MI, MI->getOperand(DstOpIdx).getReg(), | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 145 |                         Address, OffsetReg); | 
| Tom Stellard | 04c5595 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 146 |     } | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 147 |   } else if (isRegisterStore(*MI)) { | 
| Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 148 |     int ValOpIdx = AMDGPU::getNamedOperandIdx(MI->getOpcode(), | 
 | 149 |                                               AMDGPU::OpName::val); | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 150 |     AMDGPU::getNamedOperandIdx(MI->getOpcode(), AMDGPU::OpName::dst); | 
 | 151 |     unsigned RegIndex = MI->getOperand(RegOpIdx).getImm(); | 
 | 152 |     unsigned Channel = MI->getOperand(ChanOpIdx).getImm(); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 153 |     unsigned Address = calculateIndirectAddress(RegIndex, Channel); | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 154 |     unsigned OffsetReg = MI->getOperand(OffsetOpIdx).getReg(); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 155 |     if (OffsetReg == AMDGPU::INDIRECT_BASE_ADDR) { | 
 | 156 |       buildMovInstr(MBB, MI, getIndirectAddrRegClass()->getRegister(Address), | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 157 |                     MI->getOperand(ValOpIdx).getReg()); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 158 |     } else { | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 159 |       buildIndirectWrite(MBB, MI, MI->getOperand(ValOpIdx).getReg(), | 
 | 160 |                          calculateIndirectAddress(RegIndex, Channel), | 
 | 161 |                          OffsetReg); | 
| Aaron Ballman | 5203b77 | 2013-10-29 20:40:52 +0000 | [diff] [blame] | 162 |     } | 
 | 163 |   } else { | 
 | 164 |     return false; | 
| Tom Stellard | 04c5595 | 2013-10-22 18:19:10 +0000 | [diff] [blame] | 165 |   } | 
 | 166 |  | 
 | 167 |   MBB->erase(MI); | 
 | 168 |   return true; | 
 | 169 | } | 
 | 170 |  | 
 | 171 |  | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 172 | MachineInstr * | 
 | 173 | AMDGPUInstrInfo::foldMemoryOperandImpl(MachineFunction &MF, | 
 | 174 |                                       MachineInstr *MI, | 
 | 175 |                                       const SmallVectorImpl<unsigned> &Ops, | 
 | 176 |                                       int FrameIndex) const { | 
 | 177 | // TODO: Implement this function | 
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 178 |   return nullptr; | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 179 | } | 
 | 180 | MachineInstr* | 
 | 181 | AMDGPUInstrInfo::foldMemoryOperandImpl(MachineFunction &MF, | 
 | 182 |                                       MachineInstr *MI, | 
 | 183 |                                       const SmallVectorImpl<unsigned> &Ops, | 
 | 184 |                                       MachineInstr *LoadMI) const { | 
 | 185 |   // TODO: Implement this function | 
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 186 |   return nullptr; | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 187 | } | 
 | 188 | bool | 
 | 189 | AMDGPUInstrInfo::canFoldMemoryOperand(const MachineInstr *MI, | 
 | 190 |                                      const SmallVectorImpl<unsigned> &Ops) const { | 
 | 191 |   // TODO: Implement this function | 
 | 192 |   return false; | 
 | 193 | } | 
 | 194 | bool | 
 | 195 | AMDGPUInstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI, | 
 | 196 |                                  unsigned Reg, bool UnfoldLoad, | 
 | 197 |                                  bool UnfoldStore, | 
 | 198 |                                  SmallVectorImpl<MachineInstr*> &NewMIs) const { | 
 | 199 |   // TODO: Implement this function | 
 | 200 |   return false; | 
 | 201 | } | 
 | 202 |  | 
 | 203 | bool | 
 | 204 | AMDGPUInstrInfo::unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N, | 
 | 205 |                                     SmallVectorImpl<SDNode*> &NewNodes) const { | 
 | 206 |   // TODO: Implement this function | 
 | 207 |   return false; | 
 | 208 | } | 
 | 209 |  | 
 | 210 | unsigned | 
 | 211 | AMDGPUInstrInfo::getOpcodeAfterMemoryUnfold(unsigned Opc, | 
 | 212 |                                            bool UnfoldLoad, bool UnfoldStore, | 
 | 213 |                                            unsigned *LoadRegIndex) const { | 
 | 214 |   // TODO: Implement this function | 
 | 215 |   return 0; | 
 | 216 | } | 
 | 217 |  | 
 | 218 | bool AMDGPUInstrInfo::shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2, | 
 | 219 |                                              int64_t Offset1, int64_t Offset2, | 
 | 220 |                                              unsigned NumLoads) const { | 
 | 221 |   assert(Offset2 > Offset1 | 
 | 222 |          && "Second offset should be larger than first offset!"); | 
 | 223 |   // If we have less than 16 loads in a row, and the offsets are within 16, | 
 | 224 |   // then schedule together. | 
 | 225 |   // TODO: Make the loads schedule near if it fits in a cacheline | 
 | 226 |   return (NumLoads < 16 && (Offset2 - Offset1) < 16); | 
 | 227 | } | 
 | 228 |  | 
 | 229 | bool | 
 | 230 | AMDGPUInstrInfo::ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) | 
 | 231 |   const { | 
 | 232 |   // TODO: Implement this function | 
 | 233 |   return true; | 
 | 234 | } | 
 | 235 | void AMDGPUInstrInfo::insertNoop(MachineBasicBlock &MBB, | 
 | 236 |                                 MachineBasicBlock::iterator MI) const { | 
 | 237 |   // TODO: Implement this function | 
 | 238 | } | 
 | 239 |  | 
 | 240 | bool AMDGPUInstrInfo::isPredicated(const MachineInstr *MI) const { | 
 | 241 |   // TODO: Implement this function | 
 | 242 |   return false; | 
 | 243 | } | 
 | 244 | bool | 
 | 245 | AMDGPUInstrInfo::SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1, | 
 | 246 |                                   const SmallVectorImpl<MachineOperand> &Pred2) | 
 | 247 |   const { | 
 | 248 |   // TODO: Implement this function | 
 | 249 |   return false; | 
 | 250 | } | 
 | 251 |  | 
 | 252 | bool AMDGPUInstrInfo::DefinesPredicate(MachineInstr *MI, | 
 | 253 |                                       std::vector<MachineOperand> &Pred) const { | 
 | 254 |   // TODO: Implement this function | 
 | 255 |   return false; | 
 | 256 | } | 
 | 257 |  | 
 | 258 | bool AMDGPUInstrInfo::isPredicable(MachineInstr *MI) const { | 
 | 259 |   // TODO: Implement this function | 
 | 260 |   return MI->getDesc().isPredicable(); | 
 | 261 | } | 
 | 262 |  | 
 | 263 | bool | 
 | 264 | AMDGPUInstrInfo::isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const { | 
 | 265 |   // TODO: Implement this function | 
 | 266 |   return true; | 
 | 267 | } | 
| Tom Stellard | c0b0c67 | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 268 |  | 
 | 269 | bool AMDGPUInstrInfo::isRegisterStore(const MachineInstr &MI) const { | 
 | 270 |   return get(MI.getOpcode()).TSFlags & AMDGPU_FLAG_REGISTER_STORE; | 
 | 271 | } | 
 | 272 |  | 
 | 273 | bool AMDGPUInstrInfo::isRegisterLoad(const MachineInstr &MI) const { | 
 | 274 |   return get(MI.getOpcode()).TSFlags & AMDGPU_FLAG_REGISTER_LOAD; | 
 | 275 | } | 
 | 276 |  | 
| Tom Stellard | a2b4eb6 | 2013-11-13 23:36:50 +0000 | [diff] [blame] | 277 | int AMDGPUInstrInfo::getIndirectIndexBegin(const MachineFunction &MF) const { | 
 | 278 |   const MachineRegisterInfo &MRI = MF.getRegInfo(); | 
 | 279 |   const MachineFrameInfo *MFI = MF.getFrameInfo(); | 
 | 280 |   int Offset = -1; | 
 | 281 |  | 
 | 282 |   if (MFI->getNumObjects() == 0) { | 
 | 283 |     return -1; | 
 | 284 |   } | 
 | 285 |  | 
 | 286 |   if (MRI.livein_empty()) { | 
 | 287 |     return 0; | 
 | 288 |   } | 
 | 289 |  | 
 | 290 |   const TargetRegisterClass *IndirectRC = getIndirectAddrRegClass(); | 
 | 291 |   for (MachineRegisterInfo::livein_iterator LI = MRI.livein_begin(), | 
 | 292 |                                             LE = MRI.livein_end(); | 
 | 293 |                                             LI != LE; ++LI) { | 
 | 294 |     unsigned Reg = LI->first; | 
 | 295 |     if (TargetRegisterInfo::isVirtualRegister(Reg) || | 
 | 296 |         !IndirectRC->contains(Reg)) | 
 | 297 |       continue; | 
 | 298 |  | 
 | 299 |     unsigned RegIndex; | 
 | 300 |     unsigned RegEnd; | 
 | 301 |     for (RegIndex = 0, RegEnd = IndirectRC->getNumRegs(); RegIndex != RegEnd; | 
 | 302 |                                                           ++RegIndex) { | 
 | 303 |       if (IndirectRC->getRegister(RegIndex) == Reg) | 
 | 304 |         break; | 
 | 305 |     } | 
 | 306 |     Offset = std::max(Offset, (int)RegIndex); | 
 | 307 |   } | 
 | 308 |  | 
 | 309 |   return Offset + 1; | 
 | 310 | } | 
 | 311 |  | 
 | 312 | int AMDGPUInstrInfo::getIndirectIndexEnd(const MachineFunction &MF) const { | 
 | 313 |   int Offset = 0; | 
 | 314 |   const MachineFrameInfo *MFI = MF.getFrameInfo(); | 
 | 315 |  | 
 | 316 |   // Variable sized objects are not supported | 
 | 317 |   assert(!MFI->hasVarSizedObjects()); | 
 | 318 |  | 
 | 319 |   if (MFI->getNumObjects() == 0) { | 
 | 320 |     return -1; | 
 | 321 |   } | 
 | 322 |  | 
 | 323 |   Offset = TM.getFrameLowering()->getFrameIndexOffset(MF, -1); | 
 | 324 |  | 
 | 325 |   return getIndirectIndexBegin(MF) + Offset; | 
 | 326 | } | 
 | 327 |  | 
| Tom Stellard | c0b0c67 | 2013-02-06 17:32:29 +0000 | [diff] [blame] | 328 |  | 
| Tom Stellard | f98f2ce | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 329 | void AMDGPUInstrInfo::convertToISA(MachineInstr & MI, MachineFunction &MF, | 
 | 330 |     DebugLoc DL) const { | 
 | 331 |   MachineRegisterInfo &MRI = MF.getRegInfo(); | 
 | 332 |   const AMDGPURegisterInfo & RI = getRegisterInfo(); | 
 | 333 |  | 
 | 334 |   for (unsigned i = 0; i < MI.getNumOperands(); i++) { | 
 | 335 |     MachineOperand &MO = MI.getOperand(i); | 
 | 336 |     // Convert dst regclass to one that is supported by the ISA | 
 | 337 |     if (MO.isReg() && MO.isDef()) { | 
 | 338 |       if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) { | 
 | 339 |         const TargetRegisterClass * oldRegClass = MRI.getRegClass(MO.getReg()); | 
 | 340 |         const TargetRegisterClass * newRegClass = RI.getISARegClass(oldRegClass); | 
 | 341 |  | 
 | 342 |         assert(newRegClass); | 
 | 343 |  | 
 | 344 |         MRI.setRegClass(MO.getReg(), newRegClass); | 
 | 345 |       } | 
 | 346 |     } | 
 | 347 |   } | 
 | 348 | } | 
| Tom Stellard | 0f9eaaa | 2013-10-10 17:11:24 +0000 | [diff] [blame] | 349 |  | 
 | 350 | int AMDGPUInstrInfo::getMaskedMIMGOp(uint16_t Opcode, unsigned Channels) const { | 
 | 351 |   switch (Channels) { | 
 | 352 |   default: return Opcode; | 
 | 353 |   case 1: return AMDGPU::getMaskedMIMGOp(Opcode, AMDGPU::Channels_1); | 
 | 354 |   case 2: return AMDGPU::getMaskedMIMGOp(Opcode, AMDGPU::Channels_2); | 
 | 355 |   case 3: return AMDGPU::getMaskedMIMGOp(Opcode, AMDGPU::Channels_3); | 
 | 356 |   } | 
 | 357 | } | 
| Stephen Hines | dce4a40 | 2014-05-29 02:49:00 -0700 | [diff] [blame] | 358 |  | 
 | 359 | // Wrapper for Tablegen'd function.  enum Subtarget is not defined in any | 
 | 360 | // header files, so we need to wrap it in a function that takes unsigned  | 
 | 361 | // instead. | 
 | 362 | namespace llvm { | 
 | 363 | namespace AMDGPU { | 
 | 364 | int getMCOpcode(uint16_t Opcode, unsigned Gen) { | 
 | 365 |   return getMCOpcode(Opcode); | 
 | 366 | } | 
 | 367 | } | 
 | 368 | } |