Tony Linthicum | b4b5415 | 2011-12-12 21:14:40 +0000 | [diff] [blame^] | 1 | //=- HexagonInstrInfo.cpp - Hexagon Instruction Information -------*- 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 | // |
| 10 | // This file contains the Hexagon implementation of the TargetInstrInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "HexagonRegisterInfo.h" |
| 15 | #include "HexagonInstrInfo.h" |
| 16 | #include "HexagonSubtarget.h" |
| 17 | #include "Hexagon.h" |
| 18 | #include "llvm/Support/MathExtras.h" |
| 19 | #include "llvm/ADT/STLExtras.h" |
| 20 | #include "llvm/ADT/SmallVector.h" |
| 21 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 22 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
| 23 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 24 | #include "llvm/CodeGen/MachineMemOperand.h" |
| 25 | #include "llvm/CodeGen/PseudoSourceValue.h" |
| 26 | #define GET_INSTRINFO_MC_DESC |
| 27 | #define GET_INSTRINFO_CTOR |
| 28 | #include "HexagonGenInstrInfo.inc" |
| 29 | |
| 30 | #include <iostream> |
| 31 | |
| 32 | |
| 33 | using namespace llvm; |
| 34 | |
| 35 | /// |
| 36 | /// Constants for Hexagon instructions. |
| 37 | /// |
| 38 | const int Hexagon_MEMW_OFFSET_MAX = 4095; |
| 39 | const int Hexagon_MEMW_OFFSET_MIN = 4096; |
| 40 | const int Hexagon_MEMD_OFFSET_MAX = 8191; |
| 41 | const int Hexagon_MEMD_OFFSET_MIN = 8192; |
| 42 | const int Hexagon_MEMH_OFFSET_MAX = 2047; |
| 43 | const int Hexagon_MEMH_OFFSET_MIN = 2048; |
| 44 | const int Hexagon_MEMB_OFFSET_MAX = 1023; |
| 45 | const int Hexagon_MEMB_OFFSET_MIN = 1024; |
| 46 | const int Hexagon_ADDI_OFFSET_MAX = 32767; |
| 47 | const int Hexagon_ADDI_OFFSET_MIN = 32768; |
| 48 | const int Hexagon_MEMD_AUTOINC_MAX = 56; |
| 49 | const int Hexagon_MEMD_AUTOINC_MIN = 64; |
| 50 | const int Hexagon_MEMW_AUTOINC_MAX = 28; |
| 51 | const int Hexagon_MEMW_AUTOINC_MIN = 32; |
| 52 | const int Hexagon_MEMH_AUTOINC_MAX = 14; |
| 53 | const int Hexagon_MEMH_AUTOINC_MIN = 16; |
| 54 | const int Hexagon_MEMB_AUTOINC_MAX = 7; |
| 55 | const int Hexagon_MEMB_AUTOINC_MIN = 8; |
| 56 | |
| 57 | |
| 58 | |
| 59 | HexagonInstrInfo::HexagonInstrInfo(HexagonSubtarget &ST) |
| 60 | : HexagonGenInstrInfo(Hexagon::ADJCALLSTACKDOWN, Hexagon::ADJCALLSTACKUP), |
| 61 | RI(ST, *this), Subtarget(ST) { |
| 62 | } |
| 63 | |
| 64 | |
| 65 | /// isLoadFromStackSlot - If the specified machine instruction is a direct |
| 66 | /// load from a stack slot, return the virtual or physical register number of |
| 67 | /// the destination along with the FrameIndex of the loaded stack slot. If |
| 68 | /// not, return 0. This predicate must return 0 if the instruction has |
| 69 | /// any side effects other than loading from the stack slot. |
| 70 | unsigned HexagonInstrInfo::isLoadFromStackSlot(const MachineInstr *MI, |
| 71 | int &FrameIndex) const { |
| 72 | |
| 73 | |
| 74 | switch (MI->getOpcode()) { |
| 75 | case Hexagon::LDriw: |
| 76 | case Hexagon::LDrid: |
| 77 | case Hexagon::LDrih: |
| 78 | case Hexagon::LDrib: |
| 79 | case Hexagon::LDriub: |
| 80 | if (MI->getOperand(2).isFI() && |
| 81 | MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) { |
| 82 | FrameIndex = MI->getOperand(2).getIndex(); |
| 83 | return MI->getOperand(0).getReg(); |
| 84 | } |
| 85 | break; |
| 86 | |
| 87 | default: |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | |
| 95 | /// isStoreToStackSlot - If the specified machine instruction is a direct |
| 96 | /// store to a stack slot, return the virtual or physical register number of |
| 97 | /// the source reg along with the FrameIndex of the loaded stack slot. If |
| 98 | /// not, return 0. This predicate must return 0 if the instruction has |
| 99 | /// any side effects other than storing to the stack slot. |
| 100 | unsigned HexagonInstrInfo::isStoreToStackSlot(const MachineInstr *MI, |
| 101 | int &FrameIndex) const { |
| 102 | switch (MI->getOpcode()) { |
| 103 | case Hexagon::STriw: |
| 104 | case Hexagon::STrid: |
| 105 | case Hexagon::STrih: |
| 106 | case Hexagon::STrib: |
| 107 | if (MI->getOperand(2).isFI() && |
| 108 | MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) { |
| 109 | FrameIndex = MI->getOperand(2).getIndex(); |
| 110 | return MI->getOperand(0).getReg(); |
| 111 | } |
| 112 | break; |
| 113 | |
| 114 | default: |
| 115 | break; |
| 116 | } |
| 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | |
| 122 | unsigned |
| 123 | HexagonInstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB, |
| 124 | MachineBasicBlock *FBB, |
| 125 | const SmallVectorImpl<MachineOperand> &Cond, |
| 126 | DebugLoc DL) const{ |
| 127 | |
| 128 | int BOpc = Hexagon::JMP; |
| 129 | int BccOpc = Hexagon::JMP_Pred; |
| 130 | |
| 131 | assert(TBB && "InsertBranch must not be told to insert a fallthrough"); |
| 132 | |
| 133 | int regPos = 0; |
| 134 | // Check if ReverseBranchCondition has asked to reverse this branch |
| 135 | // If we want to reverse the branch an odd number of times, we want |
| 136 | // JMP_PredNot. |
| 137 | if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) { |
| 138 | BccOpc = Hexagon::JMP_PredNot; |
| 139 | regPos = 1; |
| 140 | } |
| 141 | |
| 142 | if (FBB == 0) { |
| 143 | if (Cond.empty()) { |
| 144 | // Due to a bug in TailMerging/CFG Optimization, we need to add a |
| 145 | // special case handling of a predicated jump followed by an |
| 146 | // unconditional jump. If not, Tail Merging and CFG Optimization go |
| 147 | // into an infinite loop. |
| 148 | MachineBasicBlock *NewTBB, *NewFBB; |
| 149 | SmallVector<MachineOperand, 4> Cond; |
| 150 | MachineInstr *Term = MBB.getFirstTerminator(); |
| 151 | if (isPredicated(Term) && !AnalyzeBranch(MBB, NewTBB, NewFBB, Cond, |
| 152 | false)) { |
| 153 | MachineBasicBlock *NextBB = |
| 154 | llvm::next(MachineFunction::iterator(&MBB)); |
| 155 | if (NewTBB == NextBB) { |
| 156 | ReverseBranchCondition(Cond); |
| 157 | RemoveBranch(MBB); |
| 158 | return InsertBranch(MBB, TBB, 0, Cond, DL); |
| 159 | } |
| 160 | } |
| 161 | BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB); |
| 162 | } else { |
| 163 | BuildMI(&MBB, DL, |
| 164 | get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB); |
| 165 | } |
| 166 | return 1; |
| 167 | } |
| 168 | |
| 169 | BuildMI(&MBB, DL, get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB); |
| 170 | BuildMI(&MBB, DL, get(BOpc)).addMBB(FBB); |
| 171 | |
| 172 | return 2; |
| 173 | } |
| 174 | |
| 175 | |
| 176 | bool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, |
| 177 | MachineBasicBlock *&TBB, |
| 178 | MachineBasicBlock *&FBB, |
| 179 | SmallVectorImpl<MachineOperand> &Cond, |
| 180 | bool AllowModify) const { |
| 181 | FBB = NULL; |
| 182 | |
| 183 | // If the block has no terminators, it just falls into the block after it. |
| 184 | MachineBasicBlock::iterator I = MBB.end(); |
| 185 | if (I == MBB.begin()) |
| 186 | return false; |
| 187 | |
| 188 | // A basic block may looks like this: |
| 189 | // |
| 190 | // [ insn |
| 191 | // EH_LABEL |
| 192 | // insn |
| 193 | // insn |
| 194 | // insn |
| 195 | // EH_LABEL |
| 196 | // insn ] |
| 197 | // |
| 198 | // It has two succs but does not have a terminator |
| 199 | // Don't know how to handle it. |
| 200 | do { |
| 201 | --I; |
| 202 | if (I->isEHLabel()) |
| 203 | return true; |
| 204 | } while (I != MBB.begin()); |
| 205 | |
| 206 | I = MBB.end(); |
| 207 | --I; |
| 208 | |
| 209 | while (I->isDebugValue()) { |
| 210 | if (I == MBB.begin()) |
| 211 | return false; |
| 212 | --I; |
| 213 | } |
| 214 | if (!isUnpredicatedTerminator(I)) |
| 215 | return false; |
| 216 | |
| 217 | // Get the last instruction in the block. |
| 218 | MachineInstr *LastInst = I; |
| 219 | |
| 220 | // If there is only one terminator instruction, process it. |
| 221 | if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) { |
| 222 | if (LastInst->getOpcode() == Hexagon::JMP) { |
| 223 | TBB = LastInst->getOperand(0).getMBB(); |
| 224 | return false; |
| 225 | } |
| 226 | if (LastInst->getOpcode() == Hexagon::JMP_Pred) { |
| 227 | // Block ends with fall-through true condbranch. |
| 228 | TBB = LastInst->getOperand(1).getMBB(); |
| 229 | Cond.push_back(LastInst->getOperand(0)); |
| 230 | return false; |
| 231 | } |
| 232 | if (LastInst->getOpcode() == Hexagon::JMP_PredNot) { |
| 233 | // Block ends with fall-through false condbranch. |
| 234 | TBB = LastInst->getOperand(1).getMBB(); |
| 235 | Cond.push_back(MachineOperand::CreateImm(0)); |
| 236 | Cond.push_back(LastInst->getOperand(0)); |
| 237 | return false; |
| 238 | } |
| 239 | // Otherwise, don't know what this is. |
| 240 | return true; |
| 241 | } |
| 242 | |
| 243 | // Get the instruction before it if it's a terminator. |
| 244 | MachineInstr *SecondLastInst = I; |
| 245 | |
| 246 | // If there are three terminators, we don't know what sort of block this is. |
| 247 | if (SecondLastInst && I != MBB.begin() && |
| 248 | isUnpredicatedTerminator(--I)) |
| 249 | return true; |
| 250 | |
| 251 | // If the block ends with Hexagon::BRCOND and Hexagon:JMP, handle it. |
| 252 | if (((SecondLastInst->getOpcode() == Hexagon::BRCOND) || |
| 253 | (SecondLastInst->getOpcode() == Hexagon::JMP_Pred)) && |
| 254 | LastInst->getOpcode() == Hexagon::JMP) { |
| 255 | TBB = SecondLastInst->getOperand(1).getMBB(); |
| 256 | Cond.push_back(SecondLastInst->getOperand(0)); |
| 257 | FBB = LastInst->getOperand(0).getMBB(); |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | // If the block ends with Hexagon::JMP_PredNot and Hexagon:JMP, handle it. |
| 262 | if ((SecondLastInst->getOpcode() == Hexagon::JMP_PredNot) && |
| 263 | LastInst->getOpcode() == Hexagon::JMP) { |
| 264 | TBB = SecondLastInst->getOperand(1).getMBB(); |
| 265 | Cond.push_back(MachineOperand::CreateImm(0)); |
| 266 | Cond.push_back(SecondLastInst->getOperand(0)); |
| 267 | FBB = LastInst->getOperand(0).getMBB(); |
| 268 | return false; |
| 269 | } |
| 270 | |
| 271 | // If the block ends with two Hexagon:JMPs, handle it. The second one is not |
| 272 | // executed, so remove it. |
| 273 | if (SecondLastInst->getOpcode() == Hexagon::JMP && |
| 274 | LastInst->getOpcode() == Hexagon::JMP) { |
| 275 | TBB = SecondLastInst->getOperand(0).getMBB(); |
| 276 | I = LastInst; |
| 277 | if (AllowModify) |
| 278 | I->eraseFromParent(); |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | // Otherwise, can't handle this. |
| 283 | return true; |
| 284 | } |
| 285 | |
| 286 | |
| 287 | unsigned HexagonInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { |
| 288 | int BOpc = Hexagon::JMP; |
| 289 | int BccOpc = Hexagon::JMP_Pred; |
| 290 | int BccOpcNot = Hexagon::JMP_PredNot; |
| 291 | |
| 292 | MachineBasicBlock::iterator I = MBB.end(); |
| 293 | if (I == MBB.begin()) return 0; |
| 294 | --I; |
| 295 | if (I->getOpcode() != BOpc && I->getOpcode() != BccOpc && |
| 296 | I->getOpcode() != BccOpcNot) |
| 297 | return 0; |
| 298 | |
| 299 | // Remove the branch. |
| 300 | I->eraseFromParent(); |
| 301 | |
| 302 | I = MBB.end(); |
| 303 | |
| 304 | if (I == MBB.begin()) return 1; |
| 305 | --I; |
| 306 | if (I->getOpcode() != BccOpc && I->getOpcode() != BccOpcNot) |
| 307 | return 1; |
| 308 | |
| 309 | // Remove the branch. |
| 310 | I->eraseFromParent(); |
| 311 | return 2; |
| 312 | } |
| 313 | |
| 314 | |
| 315 | void HexagonInstrInfo::copyPhysReg(MachineBasicBlock &MBB, |
| 316 | MachineBasicBlock::iterator I, DebugLoc DL, |
| 317 | unsigned DestReg, unsigned SrcReg, |
| 318 | bool KillSrc) const { |
| 319 | if (Hexagon::IntRegsRegClass.contains(SrcReg, DestReg)) { |
| 320 | BuildMI(MBB, I, DL, get(Hexagon::TFR), DestReg).addReg(SrcReg); |
| 321 | return; |
| 322 | } |
| 323 | if (Hexagon::DoubleRegsRegClass.contains(SrcReg, DestReg)) { |
| 324 | BuildMI(MBB, I, DL, get(Hexagon::TFR_64), DestReg).addReg(SrcReg); |
| 325 | return; |
| 326 | } |
| 327 | if (Hexagon::PredRegsRegClass.contains(SrcReg, DestReg)) { |
| 328 | // Map Pd = Ps to Pd = or(Ps, Ps). |
| 329 | BuildMI(MBB, I, DL, get(Hexagon::OR_pp), |
| 330 | DestReg).addReg(SrcReg).addReg(SrcReg); |
| 331 | return; |
| 332 | } |
| 333 | if (Hexagon::DoubleRegsRegClass.contains(DestReg, SrcReg)) { |
| 334 | // We can have an overlap between single and double reg: r1:0 = r0. |
| 335 | if(SrcReg == RI.getSubReg(DestReg, Hexagon::subreg_loreg)) { |
| 336 | // r1:0 = r0 |
| 337 | BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg, |
| 338 | Hexagon::subreg_hireg))).addImm(0); |
| 339 | } else { |
| 340 | // r1:0 = r1 or no overlap. |
| 341 | BuildMI(MBB, I, DL, get(Hexagon::TFR), (RI.getSubReg(DestReg, |
| 342 | Hexagon::subreg_loreg))).addReg(SrcReg); |
| 343 | BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg, |
| 344 | Hexagon::subreg_hireg))).addImm(0); |
| 345 | } |
| 346 | return; |
| 347 | } |
| 348 | if (Hexagon::CRRegsRegClass.contains(DestReg, SrcReg)) { |
| 349 | BuildMI(MBB, I, DL, get(Hexagon::TFCR), DestReg).addReg(SrcReg); |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | assert (0 && "Unimplemented"); |
| 354 | } |
| 355 | |
| 356 | |
| 357 | void HexagonInstrInfo:: |
| 358 | storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, |
| 359 | unsigned SrcReg, bool isKill, int FI, |
| 360 | const TargetRegisterClass *RC, |
| 361 | const TargetRegisterInfo *TRI) const { |
| 362 | |
| 363 | DebugLoc DL = MBB.findDebugLoc(I); |
| 364 | MachineFunction &MF = *MBB.getParent(); |
| 365 | MachineFrameInfo &MFI = *MF.getFrameInfo(); |
| 366 | unsigned Align = MFI.getObjectAlignment(FI); |
| 367 | |
| 368 | MachineMemOperand *MMO = |
| 369 | MF.getMachineMemOperand( |
| 370 | MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)), |
| 371 | MachineMemOperand::MOStore, |
| 372 | MFI.getObjectSize(FI), |
| 373 | Align); |
| 374 | |
| 375 | if (Hexagon::IntRegsRegisterClass->hasSubClassEq(RC)) { |
| 376 | BuildMI(MBB, I, DL, get(Hexagon::STriw)) |
| 377 | .addFrameIndex(FI).addImm(0) |
| 378 | .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO); |
| 379 | } else if (Hexagon::DoubleRegsRegisterClass->hasSubClassEq(RC)) { |
| 380 | BuildMI(MBB, I, DL, get(Hexagon::STrid)) |
| 381 | .addFrameIndex(FI).addImm(0) |
| 382 | .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO); |
| 383 | } else if (Hexagon::PredRegsRegisterClass->hasSubClassEq(RC)) { |
| 384 | BuildMI(MBB, I, DL, get(Hexagon::STriw_pred)) |
| 385 | .addFrameIndex(FI).addImm(0) |
| 386 | .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO); |
| 387 | } else { |
| 388 | assert(0 && "Unimplemented"); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | |
| 393 | void HexagonInstrInfo::storeRegToAddr( |
| 394 | MachineFunction &MF, unsigned SrcReg, |
| 395 | bool isKill, |
| 396 | SmallVectorImpl<MachineOperand> &Addr, |
| 397 | const TargetRegisterClass *RC, |
| 398 | SmallVectorImpl<MachineInstr*> &NewMIs) const |
| 399 | { |
| 400 | assert(0 && "Unimplemented"); |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | |
| 405 | void HexagonInstrInfo:: |
| 406 | loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, |
| 407 | unsigned DestReg, int FI, |
| 408 | const TargetRegisterClass *RC, |
| 409 | const TargetRegisterInfo *TRI) const { |
| 410 | DebugLoc DL = MBB.findDebugLoc(I); |
| 411 | MachineFunction &MF = *MBB.getParent(); |
| 412 | MachineFrameInfo &MFI = *MF.getFrameInfo(); |
| 413 | unsigned Align = MFI.getObjectAlignment(FI); |
| 414 | |
| 415 | MachineMemOperand *MMO = |
| 416 | MF.getMachineMemOperand( |
| 417 | MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)), |
| 418 | MachineMemOperand::MOLoad, |
| 419 | MFI.getObjectSize(FI), |
| 420 | Align); |
| 421 | |
| 422 | if (RC == Hexagon::IntRegsRegisterClass) { |
| 423 | BuildMI(MBB, I, DL, get(Hexagon::LDriw), DestReg) |
| 424 | .addFrameIndex(FI).addImm(0).addMemOperand(MMO); |
| 425 | } else if (RC == Hexagon::DoubleRegsRegisterClass) { |
| 426 | BuildMI(MBB, I, DL, get(Hexagon::LDrid), DestReg) |
| 427 | .addFrameIndex(FI).addImm(0).addMemOperand(MMO); |
| 428 | } else if (RC == Hexagon::PredRegsRegisterClass) { |
| 429 | BuildMI(MBB, I, DL, get(Hexagon::LDriw_pred), DestReg) |
| 430 | .addFrameIndex(FI).addImm(0).addMemOperand(MMO); |
| 431 | } else { |
| 432 | assert(0 && "Can't store this register to stack slot"); |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | |
| 437 | void HexagonInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg, |
| 438 | SmallVectorImpl<MachineOperand> &Addr, |
| 439 | const TargetRegisterClass *RC, |
| 440 | SmallVectorImpl<MachineInstr*> &NewMIs) const { |
| 441 | assert(0 && "Unimplemented"); |
| 442 | } |
| 443 | |
| 444 | |
| 445 | MachineInstr *HexagonInstrInfo::foldMemoryOperandImpl(MachineFunction &MF, |
| 446 | MachineInstr* MI, |
| 447 | const SmallVectorImpl<unsigned> &Ops, |
| 448 | int FI) const { |
| 449 | // Hexagon_TODO: Implement. |
| 450 | return(0); |
| 451 | } |
| 452 | |
| 453 | |
| 454 | unsigned HexagonInstrInfo::createVR(MachineFunction* MF, MVT VT) const { |
| 455 | |
| 456 | MachineRegisterInfo &RegInfo = MF->getRegInfo(); |
| 457 | const TargetRegisterClass *TRC; |
| 458 | if (VT == MVT::i1) { |
| 459 | TRC = Hexagon::PredRegsRegisterClass; |
| 460 | } else if (VT == MVT::i32) { |
| 461 | TRC = Hexagon::IntRegsRegisterClass; |
| 462 | } else if (VT == MVT::i64) { |
| 463 | TRC = Hexagon::DoubleRegsRegisterClass; |
| 464 | } else { |
| 465 | assert(0 && "Cannot handle this register class"); |
| 466 | } |
| 467 | |
| 468 | unsigned NewReg = RegInfo.createVirtualRegister(TRC); |
| 469 | return NewReg; |
| 470 | } |
| 471 | |
| 472 | |
| 473 | bool HexagonInstrInfo::isPredicable(MachineInstr *MI) const { |
| 474 | bool isPred = MI->getDesc().isPredicable(); |
| 475 | |
| 476 | if (!isPred) |
| 477 | return false; |
| 478 | |
| 479 | const int Opc = MI->getOpcode(); |
| 480 | |
| 481 | switch(Opc) { |
| 482 | case Hexagon::TFRI: |
| 483 | return isInt<12>(MI->getOperand(1).getImm()); |
| 484 | |
| 485 | case Hexagon::STrid: |
| 486 | case Hexagon::STrid_indexed: |
| 487 | return isShiftedUInt<6,3>(MI->getOperand(1).getImm()); |
| 488 | |
| 489 | case Hexagon::STriw: |
| 490 | case Hexagon::STriw_indexed: |
| 491 | case Hexagon::STriw_nv_V4: |
| 492 | return isShiftedUInt<6,2>(MI->getOperand(1).getImm()); |
| 493 | |
| 494 | case Hexagon::STrih: |
| 495 | case Hexagon::STrih_indexed: |
| 496 | case Hexagon::STrih_nv_V4: |
| 497 | return isShiftedUInt<6,1>(MI->getOperand(1).getImm()); |
| 498 | |
| 499 | case Hexagon::STrib: |
| 500 | case Hexagon::STrib_indexed: |
| 501 | case Hexagon::STrib_nv_V4: |
| 502 | return isUInt<6>(MI->getOperand(1).getImm()); |
| 503 | |
| 504 | case Hexagon::LDrid: |
| 505 | case Hexagon::LDrid_indexed: |
| 506 | return isShiftedUInt<6,3>(MI->getOperand(2).getImm()); |
| 507 | |
| 508 | case Hexagon::LDriw: |
| 509 | case Hexagon::LDriw_indexed: |
| 510 | return isShiftedUInt<6,2>(MI->getOperand(2).getImm()); |
| 511 | |
| 512 | case Hexagon::LDrih: |
| 513 | case Hexagon::LDriuh: |
| 514 | case Hexagon::LDrih_indexed: |
| 515 | case Hexagon::LDriuh_indexed: |
| 516 | return isShiftedUInt<6,1>(MI->getOperand(2).getImm()); |
| 517 | |
| 518 | case Hexagon::LDrib: |
| 519 | case Hexagon::LDriub: |
| 520 | case Hexagon::LDrib_indexed: |
| 521 | case Hexagon::LDriub_indexed: |
| 522 | return isUInt<6>(MI->getOperand(2).getImm()); |
| 523 | |
| 524 | case Hexagon::POST_LDrid: |
| 525 | return isShiftedInt<4,3>(MI->getOperand(3).getImm()); |
| 526 | |
| 527 | case Hexagon::POST_LDriw: |
| 528 | return isShiftedInt<4,2>(MI->getOperand(3).getImm()); |
| 529 | |
| 530 | case Hexagon::POST_LDrih: |
| 531 | case Hexagon::POST_LDriuh: |
| 532 | return isShiftedInt<4,1>(MI->getOperand(3).getImm()); |
| 533 | |
| 534 | case Hexagon::POST_LDrib: |
| 535 | case Hexagon::POST_LDriub: |
| 536 | return isInt<4>(MI->getOperand(3).getImm()); |
| 537 | |
| 538 | case Hexagon::STrib_imm_V4: |
| 539 | case Hexagon::STrih_imm_V4: |
| 540 | case Hexagon::STriw_imm_V4: |
| 541 | return (isUInt<6>(MI->getOperand(1).getImm()) && |
| 542 | isInt<6>(MI->getOperand(2).getImm())); |
| 543 | |
| 544 | case Hexagon::ADD_ri: |
| 545 | return isInt<8>(MI->getOperand(2).getImm()); |
| 546 | |
| 547 | case Hexagon::ASLH: |
| 548 | case Hexagon::ASRH: |
| 549 | case Hexagon::SXTB: |
| 550 | case Hexagon::SXTH: |
| 551 | case Hexagon::ZXTB: |
| 552 | case Hexagon::ZXTH: |
| 553 | return Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4; |
| 554 | |
| 555 | case Hexagon::JMPR: |
| 556 | return false; |
| 557 | return true; |
| 558 | |
| 559 | default: |
| 560 | return true; |
| 561 | } |
| 562 | |
| 563 | return true; |
| 564 | } |
| 565 | |
| 566 | |
| 567 | int HexagonInstrInfo:: |
| 568 | getMatchingCondBranchOpcode(int Opc, bool invertPredicate) const { |
| 569 | switch(Opc) { |
| 570 | case Hexagon::TFR: |
| 571 | return !invertPredicate ? Hexagon::TFR_cPt : |
| 572 | Hexagon::TFR_cNotPt; |
| 573 | case Hexagon::TFRI: |
| 574 | return !invertPredicate ? Hexagon::TFRI_cPt : |
| 575 | Hexagon::TFRI_cNotPt; |
| 576 | case Hexagon::JMP: |
| 577 | return !invertPredicate ? Hexagon::JMP_Pred : |
| 578 | Hexagon::JMP_PredNot; |
| 579 | case Hexagon::ADD_ri: |
| 580 | return !invertPredicate ? Hexagon::ADD_ri_cPt : |
| 581 | Hexagon::ADD_ri_cNotPt; |
| 582 | case Hexagon::ADD_rr: |
| 583 | return !invertPredicate ? Hexagon::ADD_rr_cPt : |
| 584 | Hexagon::ADD_rr_cNotPt; |
| 585 | case Hexagon::XOR_rr: |
| 586 | return !invertPredicate ? Hexagon::XOR_rr_cPt : |
| 587 | Hexagon::XOR_rr_cNotPt; |
| 588 | case Hexagon::AND_rr: |
| 589 | return !invertPredicate ? Hexagon::AND_rr_cPt : |
| 590 | Hexagon::AND_rr_cNotPt; |
| 591 | case Hexagon::OR_rr: |
| 592 | return !invertPredicate ? Hexagon::OR_rr_cPt : |
| 593 | Hexagon::OR_rr_cNotPt; |
| 594 | case Hexagon::SUB_rr: |
| 595 | return !invertPredicate ? Hexagon::SUB_rr_cPt : |
| 596 | Hexagon::SUB_rr_cNotPt; |
| 597 | case Hexagon::COMBINE_rr: |
| 598 | return !invertPredicate ? Hexagon::COMBINE_rr_cPt : |
| 599 | Hexagon::COMBINE_rr_cNotPt; |
| 600 | case Hexagon::ASLH: |
| 601 | return !invertPredicate ? Hexagon::ASLH_cPt_V4 : |
| 602 | Hexagon::ASLH_cNotPt_V4; |
| 603 | case Hexagon::ASRH: |
| 604 | return !invertPredicate ? Hexagon::ASRH_cPt_V4 : |
| 605 | Hexagon::ASRH_cNotPt_V4; |
| 606 | case Hexagon::SXTB: |
| 607 | return !invertPredicate ? Hexagon::SXTB_cPt_V4 : |
| 608 | Hexagon::SXTB_cNotPt_V4; |
| 609 | case Hexagon::SXTH: |
| 610 | return !invertPredicate ? Hexagon::SXTH_cPt_V4 : |
| 611 | Hexagon::SXTH_cNotPt_V4; |
| 612 | case Hexagon::ZXTB: |
| 613 | return !invertPredicate ? Hexagon::ZXTB_cPt_V4 : |
| 614 | Hexagon::ZXTB_cNotPt_V4; |
| 615 | case Hexagon::ZXTH: |
| 616 | return !invertPredicate ? Hexagon::ZXTH_cPt_V4 : |
| 617 | Hexagon::ZXTH_cNotPt_V4; |
| 618 | |
| 619 | case Hexagon::JMPR: |
| 620 | return !invertPredicate ? Hexagon::JMPR_cPt : |
| 621 | Hexagon::JMPR_cNotPt; |
| 622 | |
| 623 | // V4 indexed+scaled load. |
| 624 | case Hexagon::LDrid_indexed_V4: |
| 625 | return !invertPredicate ? Hexagon::LDrid_indexed_cPt_V4 : |
| 626 | Hexagon::LDrid_indexed_cNotPt_V4; |
| 627 | case Hexagon::LDrid_indexed_shl_V4: |
| 628 | return !invertPredicate ? Hexagon::LDrid_indexed_shl_cPt_V4 : |
| 629 | Hexagon::LDrid_indexed_shl_cNotPt_V4; |
| 630 | case Hexagon::LDrib_indexed_V4: |
| 631 | return !invertPredicate ? Hexagon::LDrib_indexed_cPt_V4 : |
| 632 | Hexagon::LDrib_indexed_cNotPt_V4; |
| 633 | case Hexagon::LDriub_indexed_V4: |
| 634 | return !invertPredicate ? Hexagon::LDriub_indexed_cPt_V4 : |
| 635 | Hexagon::LDriub_indexed_cNotPt_V4; |
| 636 | case Hexagon::LDriub_ae_indexed_V4: |
| 637 | return !invertPredicate ? Hexagon::LDriub_indexed_cPt_V4 : |
| 638 | Hexagon::LDriub_indexed_cNotPt_V4; |
| 639 | case Hexagon::LDrib_indexed_shl_V4: |
| 640 | return !invertPredicate ? Hexagon::LDrib_indexed_shl_cPt_V4 : |
| 641 | Hexagon::LDrib_indexed_shl_cNotPt_V4; |
| 642 | case Hexagon::LDriub_indexed_shl_V4: |
| 643 | return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 : |
| 644 | Hexagon::LDriub_indexed_shl_cNotPt_V4; |
| 645 | case Hexagon::LDriub_ae_indexed_shl_V4: |
| 646 | return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 : |
| 647 | Hexagon::LDriub_indexed_shl_cNotPt_V4; |
| 648 | case Hexagon::LDrih_indexed_V4: |
| 649 | return !invertPredicate ? Hexagon::LDrih_indexed_cPt_V4 : |
| 650 | Hexagon::LDrih_indexed_cNotPt_V4; |
| 651 | case Hexagon::LDriuh_indexed_V4: |
| 652 | return !invertPredicate ? Hexagon::LDriuh_indexed_cPt_V4 : |
| 653 | Hexagon::LDriuh_indexed_cNotPt_V4; |
| 654 | case Hexagon::LDriuh_ae_indexed_V4: |
| 655 | return !invertPredicate ? Hexagon::LDriuh_indexed_cPt_V4 : |
| 656 | Hexagon::LDriuh_indexed_cNotPt_V4; |
| 657 | case Hexagon::LDrih_indexed_shl_V4: |
| 658 | return !invertPredicate ? Hexagon::LDrih_indexed_shl_cPt_V4 : |
| 659 | Hexagon::LDrih_indexed_shl_cNotPt_V4; |
| 660 | case Hexagon::LDriuh_indexed_shl_V4: |
| 661 | return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 : |
| 662 | Hexagon::LDriuh_indexed_shl_cNotPt_V4; |
| 663 | case Hexagon::LDriuh_ae_indexed_shl_V4: |
| 664 | return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 : |
| 665 | Hexagon::LDriuh_indexed_shl_cNotPt_V4; |
| 666 | case Hexagon::LDriw_indexed_V4: |
| 667 | return !invertPredicate ? Hexagon::LDriw_indexed_cPt_V4 : |
| 668 | Hexagon::LDriw_indexed_cNotPt_V4; |
| 669 | case Hexagon::LDriw_indexed_shl_V4: |
| 670 | return !invertPredicate ? Hexagon::LDriw_indexed_shl_cPt_V4 : |
| 671 | Hexagon::LDriw_indexed_shl_cNotPt_V4; |
| 672 | // Byte. |
| 673 | case Hexagon::POST_STbri: |
| 674 | return !invertPredicate ? Hexagon::POST_STbri_cPt : |
| 675 | Hexagon::POST_STbri_cNotPt; |
| 676 | case Hexagon::STrib: |
| 677 | return !invertPredicate ? Hexagon::STrib_cPt : |
| 678 | Hexagon::STrib_cNotPt; |
| 679 | case Hexagon::STrib_indexed: |
| 680 | return !invertPredicate ? Hexagon::STrib_indexed_cPt : |
| 681 | Hexagon::STrib_indexed_cNotPt; |
| 682 | case Hexagon::STrib_imm_V4: |
| 683 | return !invertPredicate ? Hexagon::STrib_imm_cPt_V4 : |
| 684 | Hexagon::STrib_imm_cNotPt_V4; |
| 685 | case Hexagon::STrib_indexed_shl_V4: |
| 686 | return !invertPredicate ? Hexagon::STrib_indexed_shl_cPt_V4 : |
| 687 | Hexagon::STrib_indexed_shl_cNotPt_V4; |
| 688 | // Halfword. |
| 689 | case Hexagon::POST_SThri: |
| 690 | return !invertPredicate ? Hexagon::POST_SThri_cPt : |
| 691 | Hexagon::POST_SThri_cNotPt; |
| 692 | case Hexagon::STrih: |
| 693 | return !invertPredicate ? Hexagon::STrih_cPt : |
| 694 | Hexagon::STrih_cNotPt; |
| 695 | case Hexagon::STrih_indexed: |
| 696 | return !invertPredicate ? Hexagon::STrih_indexed_cPt : |
| 697 | Hexagon::STrih_indexed_cNotPt; |
| 698 | case Hexagon::STrih_imm_V4: |
| 699 | return !invertPredicate ? Hexagon::STrih_imm_cPt_V4 : |
| 700 | Hexagon::STrih_imm_cNotPt_V4; |
| 701 | case Hexagon::STrih_indexed_shl_V4: |
| 702 | return !invertPredicate ? Hexagon::STrih_indexed_shl_cPt_V4 : |
| 703 | Hexagon::STrih_indexed_shl_cNotPt_V4; |
| 704 | // Word. |
| 705 | case Hexagon::POST_STwri: |
| 706 | return !invertPredicate ? Hexagon::POST_STwri_cPt : |
| 707 | Hexagon::POST_STwri_cNotPt; |
| 708 | case Hexagon::STriw: |
| 709 | return !invertPredicate ? Hexagon::STriw_cPt : |
| 710 | Hexagon::STriw_cNotPt; |
| 711 | case Hexagon::STriw_indexed: |
| 712 | return !invertPredicate ? Hexagon::STriw_indexed_cPt : |
| 713 | Hexagon::STriw_indexed_cNotPt; |
| 714 | case Hexagon::STriw_indexed_shl_V4: |
| 715 | return !invertPredicate ? Hexagon::STriw_indexed_shl_cPt_V4 : |
| 716 | Hexagon::STriw_indexed_shl_cNotPt_V4; |
| 717 | case Hexagon::STriw_imm_V4: |
| 718 | return !invertPredicate ? Hexagon::STriw_imm_cPt_V4 : |
| 719 | Hexagon::STriw_imm_cNotPt_V4; |
| 720 | // Double word. |
| 721 | case Hexagon::POST_STdri: |
| 722 | return !invertPredicate ? Hexagon::POST_STdri_cPt : |
| 723 | Hexagon::POST_STdri_cNotPt; |
| 724 | case Hexagon::STrid: |
| 725 | return !invertPredicate ? Hexagon::STrid_cPt : |
| 726 | Hexagon::STrid_cNotPt; |
| 727 | case Hexagon::STrid_indexed: |
| 728 | return !invertPredicate ? Hexagon::STrid_indexed_cPt : |
| 729 | Hexagon::STrid_indexed_cNotPt; |
| 730 | case Hexagon::STrid_indexed_shl_V4: |
| 731 | return !invertPredicate ? Hexagon::STrid_indexed_shl_cPt_V4 : |
| 732 | Hexagon::STrid_indexed_shl_cNotPt_V4; |
| 733 | // Load. |
| 734 | case Hexagon::LDrid: |
| 735 | return !invertPredicate ? Hexagon::LDrid_cPt : |
| 736 | Hexagon::LDrid_cNotPt; |
| 737 | case Hexagon::LDriw: |
| 738 | return !invertPredicate ? Hexagon::LDriw_cPt : |
| 739 | Hexagon::LDriw_cNotPt; |
| 740 | case Hexagon::LDrih: |
| 741 | return !invertPredicate ? Hexagon::LDrih_cPt : |
| 742 | Hexagon::LDrih_cNotPt; |
| 743 | case Hexagon::LDriuh: |
| 744 | return !invertPredicate ? Hexagon::LDriuh_cPt : |
| 745 | Hexagon::LDriuh_cNotPt; |
| 746 | case Hexagon::LDrib: |
| 747 | return !invertPredicate ? Hexagon::LDrib_cPt : |
| 748 | Hexagon::LDrib_cNotPt; |
| 749 | case Hexagon::LDriub: |
| 750 | return !invertPredicate ? Hexagon::LDriub_cPt : |
| 751 | Hexagon::LDriub_cNotPt; |
| 752 | case Hexagon::LDriubit: |
| 753 | return !invertPredicate ? Hexagon::LDriub_cPt : |
| 754 | Hexagon::LDriub_cNotPt; |
| 755 | // Load Indexed. |
| 756 | case Hexagon::LDrid_indexed: |
| 757 | return !invertPredicate ? Hexagon::LDrid_indexed_cPt : |
| 758 | Hexagon::LDrid_indexed_cNotPt; |
| 759 | case Hexagon::LDriw_indexed: |
| 760 | return !invertPredicate ? Hexagon::LDriw_indexed_cPt : |
| 761 | Hexagon::LDriw_indexed_cNotPt; |
| 762 | case Hexagon::LDrih_indexed: |
| 763 | return !invertPredicate ? Hexagon::LDrih_indexed_cPt : |
| 764 | Hexagon::LDrih_indexed_cNotPt; |
| 765 | case Hexagon::LDriuh_indexed: |
| 766 | return !invertPredicate ? Hexagon::LDriuh_indexed_cPt : |
| 767 | Hexagon::LDriuh_indexed_cNotPt; |
| 768 | case Hexagon::LDrib_indexed: |
| 769 | return !invertPredicate ? Hexagon::LDrib_indexed_cPt : |
| 770 | Hexagon::LDrib_indexed_cNotPt; |
| 771 | case Hexagon::LDriub_indexed: |
| 772 | return !invertPredicate ? Hexagon::LDriub_indexed_cPt : |
| 773 | Hexagon::LDriub_indexed_cNotPt; |
| 774 | // Post Increment Load. |
| 775 | case Hexagon::POST_LDrid: |
| 776 | return !invertPredicate ? Hexagon::POST_LDrid_cPt : |
| 777 | Hexagon::POST_LDrid_cNotPt; |
| 778 | case Hexagon::POST_LDriw: |
| 779 | return !invertPredicate ? Hexagon::POST_LDriw_cPt : |
| 780 | Hexagon::POST_LDriw_cNotPt; |
| 781 | case Hexagon::POST_LDrih: |
| 782 | return !invertPredicate ? Hexagon::POST_LDrih_cPt : |
| 783 | Hexagon::POST_LDrih_cNotPt; |
| 784 | case Hexagon::POST_LDriuh: |
| 785 | return !invertPredicate ? Hexagon::POST_LDriuh_cPt : |
| 786 | Hexagon::POST_LDriuh_cNotPt; |
| 787 | case Hexagon::POST_LDrib: |
| 788 | return !invertPredicate ? Hexagon::POST_LDrib_cPt : |
| 789 | Hexagon::POST_LDrib_cNotPt; |
| 790 | case Hexagon::POST_LDriub: |
| 791 | return !invertPredicate ? Hexagon::POST_LDriub_cPt : |
| 792 | Hexagon::POST_LDriub_cNotPt; |
| 793 | // DEALLOC_RETURN. |
| 794 | case Hexagon::DEALLOC_RET_V4: |
| 795 | return !invertPredicate ? Hexagon::DEALLOC_RET_cPt_V4 : |
| 796 | Hexagon::DEALLOC_RET_cNotPt_V4; |
| 797 | default: |
| 798 | assert(false && "Unexpected predicable instruction"); |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | |
| 803 | bool HexagonInstrInfo:: |
| 804 | PredicateInstruction(MachineInstr *MI, |
| 805 | const SmallVectorImpl<MachineOperand> &Cond) const { |
| 806 | int Opc = MI->getOpcode(); |
| 807 | assert (isPredicable(MI) && "Expected predicable instruction"); |
| 808 | bool invertJump = (!Cond.empty() && Cond[0].isImm() && |
| 809 | (Cond[0].getImm() == 0)); |
| 810 | MI->setDesc(get(getMatchingCondBranchOpcode(Opc, invertJump))); |
| 811 | // |
| 812 | // This assumes that the predicate is always the first operand |
| 813 | // in the set of inputs. |
| 814 | // |
| 815 | MI->addOperand(MI->getOperand(MI->getNumOperands()-1)); |
| 816 | int oper; |
| 817 | for (oper = MI->getNumOperands() - 3; oper >= 0; --oper) { |
| 818 | MachineOperand MO = MI->getOperand(oper); |
| 819 | if ((MO.isReg() && !MO.isUse() && !MO.isImplicit())) { |
| 820 | break; |
| 821 | } |
| 822 | |
| 823 | if (MO.isReg()) { |
| 824 | MI->getOperand(oper+1).ChangeToRegister(MO.getReg(), MO.isDef(), |
| 825 | MO.isImplicit(), MO.isKill(), |
| 826 | MO.isDead(), MO.isUndef(), |
| 827 | MO.isDebug()); |
| 828 | } else if (MO.isImm()) { |
| 829 | MI->getOperand(oper+1).ChangeToImmediate(MO.getImm()); |
| 830 | } else { |
| 831 | assert(false && "Unexpected operand type"); |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | int regPos = invertJump ? 1 : 0; |
| 836 | MachineOperand PredMO = Cond[regPos]; |
| 837 | MI->getOperand(oper+1).ChangeToRegister(PredMO.getReg(), PredMO.isDef(), |
| 838 | PredMO.isImplicit(), PredMO.isKill(), |
| 839 | PredMO.isDead(), PredMO.isUndef(), |
| 840 | PredMO.isDebug()); |
| 841 | |
| 842 | return true; |
| 843 | } |
| 844 | |
| 845 | |
| 846 | bool |
| 847 | HexagonInstrInfo:: |
| 848 | isProfitableToIfCvt(MachineBasicBlock &MBB, |
| 849 | unsigned NumCyles, |
| 850 | unsigned ExtraPredCycles, |
| 851 | const BranchProbability &Probability) const { |
| 852 | return true; |
| 853 | } |
| 854 | |
| 855 | |
| 856 | bool |
| 857 | HexagonInstrInfo:: |
| 858 | isProfitableToIfCvt(MachineBasicBlock &TMBB, |
| 859 | unsigned NumTCycles, |
| 860 | unsigned ExtraTCycles, |
| 861 | MachineBasicBlock &FMBB, |
| 862 | unsigned NumFCycles, |
| 863 | unsigned ExtraFCycles, |
| 864 | const BranchProbability &Probability) const { |
| 865 | return true; |
| 866 | } |
| 867 | |
| 868 | |
| 869 | bool HexagonInstrInfo::isPredicated(const MachineInstr *MI) const { |
| 870 | switch (MI->getOpcode()) { |
| 871 | case Hexagon::TFR_cPt: |
| 872 | case Hexagon::TFR_cNotPt: |
| 873 | case Hexagon::TFRI_cPt: |
| 874 | case Hexagon::TFRI_cNotPt: |
| 875 | case Hexagon::TFR_cdnPt: |
| 876 | case Hexagon::TFR_cdnNotPt: |
| 877 | case Hexagon::TFRI_cdnPt: |
| 878 | case Hexagon::TFRI_cdnNotPt: |
| 879 | return true; |
| 880 | |
| 881 | case Hexagon::JMP_Pred: |
| 882 | case Hexagon::JMP_PredNot: |
| 883 | case Hexagon::BRCOND: |
| 884 | case Hexagon::JMP_PredPt: |
| 885 | case Hexagon::JMP_PredNotPt: |
| 886 | case Hexagon::JMP_PredPnt: |
| 887 | case Hexagon::JMP_PredNotPnt: |
| 888 | return true; |
| 889 | |
| 890 | case Hexagon::LDrid_indexed_cPt_V4 : |
| 891 | case Hexagon::LDrid_indexed_cdnPt_V4 : |
| 892 | case Hexagon::LDrid_indexed_cNotPt_V4 : |
| 893 | case Hexagon::LDrid_indexed_cdnNotPt_V4 : |
| 894 | case Hexagon::LDrid_indexed_shl_cPt_V4 : |
| 895 | case Hexagon::LDrid_indexed_shl_cdnPt_V4 : |
| 896 | case Hexagon::LDrid_indexed_shl_cNotPt_V4 : |
| 897 | case Hexagon::LDrid_indexed_shl_cdnNotPt_V4 : |
| 898 | case Hexagon::LDrib_indexed_cPt_V4 : |
| 899 | case Hexagon::LDrib_indexed_cdnPt_V4 : |
| 900 | case Hexagon::LDrib_indexed_cNotPt_V4 : |
| 901 | case Hexagon::LDrib_indexed_cdnNotPt_V4 : |
| 902 | case Hexagon::LDrib_indexed_shl_cPt_V4 : |
| 903 | case Hexagon::LDrib_indexed_shl_cdnPt_V4 : |
| 904 | case Hexagon::LDrib_indexed_shl_cNotPt_V4 : |
| 905 | case Hexagon::LDrib_indexed_shl_cdnNotPt_V4 : |
| 906 | case Hexagon::LDriub_indexed_cPt_V4 : |
| 907 | case Hexagon::LDriub_indexed_cdnPt_V4 : |
| 908 | case Hexagon::LDriub_indexed_cNotPt_V4 : |
| 909 | case Hexagon::LDriub_indexed_cdnNotPt_V4 : |
| 910 | case Hexagon::LDriub_indexed_shl_cPt_V4 : |
| 911 | case Hexagon::LDriub_indexed_shl_cdnPt_V4 : |
| 912 | case Hexagon::LDriub_indexed_shl_cNotPt_V4 : |
| 913 | case Hexagon::LDriub_indexed_shl_cdnNotPt_V4 : |
| 914 | case Hexagon::LDrih_indexed_cPt_V4 : |
| 915 | case Hexagon::LDrih_indexed_cdnPt_V4 : |
| 916 | case Hexagon::LDrih_indexed_cNotPt_V4 : |
| 917 | case Hexagon::LDrih_indexed_cdnNotPt_V4 : |
| 918 | case Hexagon::LDrih_indexed_shl_cPt_V4 : |
| 919 | case Hexagon::LDrih_indexed_shl_cdnPt_V4 : |
| 920 | case Hexagon::LDrih_indexed_shl_cNotPt_V4 : |
| 921 | case Hexagon::LDrih_indexed_shl_cdnNotPt_V4 : |
| 922 | case Hexagon::LDriuh_indexed_cPt_V4 : |
| 923 | case Hexagon::LDriuh_indexed_cdnPt_V4 : |
| 924 | case Hexagon::LDriuh_indexed_cNotPt_V4 : |
| 925 | case Hexagon::LDriuh_indexed_cdnNotPt_V4 : |
| 926 | case Hexagon::LDriuh_indexed_shl_cPt_V4 : |
| 927 | case Hexagon::LDriuh_indexed_shl_cdnPt_V4 : |
| 928 | case Hexagon::LDriuh_indexed_shl_cNotPt_V4 : |
| 929 | case Hexagon::LDriuh_indexed_shl_cdnNotPt_V4 : |
| 930 | case Hexagon::LDriw_indexed_cPt_V4 : |
| 931 | case Hexagon::LDriw_indexed_cdnPt_V4 : |
| 932 | case Hexagon::LDriw_indexed_cNotPt_V4 : |
| 933 | case Hexagon::LDriw_indexed_cdnNotPt_V4 : |
| 934 | case Hexagon::LDriw_indexed_shl_cPt_V4 : |
| 935 | case Hexagon::LDriw_indexed_shl_cdnPt_V4 : |
| 936 | case Hexagon::LDriw_indexed_shl_cNotPt_V4 : |
| 937 | case Hexagon::LDriw_indexed_shl_cdnNotPt_V4 : |
| 938 | return true; |
| 939 | |
| 940 | case Hexagon::LDrid_cPt : |
| 941 | case Hexagon::LDrid_cNotPt : |
| 942 | case Hexagon::LDrid_indexed_cPt : |
| 943 | case Hexagon::LDrid_indexed_cNotPt : |
| 944 | case Hexagon::POST_LDrid_cPt : |
| 945 | case Hexagon::POST_LDrid_cNotPt : |
| 946 | case Hexagon::LDriw_cPt : |
| 947 | case Hexagon::LDriw_cNotPt : |
| 948 | case Hexagon::LDriw_indexed_cPt : |
| 949 | case Hexagon::LDriw_indexed_cNotPt : |
| 950 | case Hexagon::POST_LDriw_cPt : |
| 951 | case Hexagon::POST_LDriw_cNotPt : |
| 952 | case Hexagon::LDrih_cPt : |
| 953 | case Hexagon::LDrih_cNotPt : |
| 954 | case Hexagon::LDrih_indexed_cPt : |
| 955 | case Hexagon::LDrih_indexed_cNotPt : |
| 956 | case Hexagon::POST_LDrih_cPt : |
| 957 | case Hexagon::POST_LDrih_cNotPt : |
| 958 | case Hexagon::LDrib_cPt : |
| 959 | case Hexagon::LDrib_cNotPt : |
| 960 | case Hexagon::LDrib_indexed_cPt : |
| 961 | case Hexagon::LDrib_indexed_cNotPt : |
| 962 | case Hexagon::POST_LDrib_cPt : |
| 963 | case Hexagon::POST_LDrib_cNotPt : |
| 964 | case Hexagon::LDriuh_cPt : |
| 965 | case Hexagon::LDriuh_cNotPt : |
| 966 | case Hexagon::LDriuh_indexed_cPt : |
| 967 | case Hexagon::LDriuh_indexed_cNotPt : |
| 968 | case Hexagon::POST_LDriuh_cPt : |
| 969 | case Hexagon::POST_LDriuh_cNotPt : |
| 970 | case Hexagon::LDriub_cPt : |
| 971 | case Hexagon::LDriub_cNotPt : |
| 972 | case Hexagon::LDriub_indexed_cPt : |
| 973 | case Hexagon::LDriub_indexed_cNotPt : |
| 974 | case Hexagon::POST_LDriub_cPt : |
| 975 | case Hexagon::POST_LDriub_cNotPt : |
| 976 | return true; |
| 977 | |
| 978 | case Hexagon::LDrid_cdnPt : |
| 979 | case Hexagon::LDrid_cdnNotPt : |
| 980 | case Hexagon::LDrid_indexed_cdnPt : |
| 981 | case Hexagon::LDrid_indexed_cdnNotPt : |
| 982 | case Hexagon::POST_LDrid_cdnPt_V4 : |
| 983 | case Hexagon::POST_LDrid_cdnNotPt_V4 : |
| 984 | case Hexagon::LDriw_cdnPt : |
| 985 | case Hexagon::LDriw_cdnNotPt : |
| 986 | case Hexagon::LDriw_indexed_cdnPt : |
| 987 | case Hexagon::LDriw_indexed_cdnNotPt : |
| 988 | case Hexagon::POST_LDriw_cdnPt_V4 : |
| 989 | case Hexagon::POST_LDriw_cdnNotPt_V4 : |
| 990 | case Hexagon::LDrih_cdnPt : |
| 991 | case Hexagon::LDrih_cdnNotPt : |
| 992 | case Hexagon::LDrih_indexed_cdnPt : |
| 993 | case Hexagon::LDrih_indexed_cdnNotPt : |
| 994 | case Hexagon::POST_LDrih_cdnPt_V4 : |
| 995 | case Hexagon::POST_LDrih_cdnNotPt_V4 : |
| 996 | case Hexagon::LDrib_cdnPt : |
| 997 | case Hexagon::LDrib_cdnNotPt : |
| 998 | case Hexagon::LDrib_indexed_cdnPt : |
| 999 | case Hexagon::LDrib_indexed_cdnNotPt : |
| 1000 | case Hexagon::POST_LDrib_cdnPt_V4 : |
| 1001 | case Hexagon::POST_LDrib_cdnNotPt_V4 : |
| 1002 | case Hexagon::LDriuh_cdnPt : |
| 1003 | case Hexagon::LDriuh_cdnNotPt : |
| 1004 | case Hexagon::LDriuh_indexed_cdnPt : |
| 1005 | case Hexagon::LDriuh_indexed_cdnNotPt : |
| 1006 | case Hexagon::POST_LDriuh_cdnPt_V4 : |
| 1007 | case Hexagon::POST_LDriuh_cdnNotPt_V4 : |
| 1008 | case Hexagon::LDriub_cdnPt : |
| 1009 | case Hexagon::LDriub_cdnNotPt : |
| 1010 | case Hexagon::LDriub_indexed_cdnPt : |
| 1011 | case Hexagon::LDriub_indexed_cdnNotPt : |
| 1012 | case Hexagon::POST_LDriub_cdnPt_V4 : |
| 1013 | case Hexagon::POST_LDriub_cdnNotPt_V4 : |
| 1014 | return true; |
| 1015 | |
| 1016 | case Hexagon::ADD_ri_cPt: |
| 1017 | case Hexagon::ADD_ri_cNotPt: |
| 1018 | case Hexagon::ADD_ri_cdnPt: |
| 1019 | case Hexagon::ADD_ri_cdnNotPt: |
| 1020 | case Hexagon::ADD_rr_cPt: |
| 1021 | case Hexagon::ADD_rr_cNotPt: |
| 1022 | case Hexagon::ADD_rr_cdnPt: |
| 1023 | case Hexagon::ADD_rr_cdnNotPt: |
| 1024 | case Hexagon::XOR_rr_cPt: |
| 1025 | case Hexagon::XOR_rr_cNotPt: |
| 1026 | case Hexagon::XOR_rr_cdnPt: |
| 1027 | case Hexagon::XOR_rr_cdnNotPt: |
| 1028 | case Hexagon::AND_rr_cPt: |
| 1029 | case Hexagon::AND_rr_cNotPt: |
| 1030 | case Hexagon::AND_rr_cdnPt: |
| 1031 | case Hexagon::AND_rr_cdnNotPt: |
| 1032 | case Hexagon::OR_rr_cPt: |
| 1033 | case Hexagon::OR_rr_cNotPt: |
| 1034 | case Hexagon::OR_rr_cdnPt: |
| 1035 | case Hexagon::OR_rr_cdnNotPt: |
| 1036 | case Hexagon::SUB_rr_cPt: |
| 1037 | case Hexagon::SUB_rr_cNotPt: |
| 1038 | case Hexagon::SUB_rr_cdnPt: |
| 1039 | case Hexagon::SUB_rr_cdnNotPt: |
| 1040 | case Hexagon::COMBINE_rr_cPt: |
| 1041 | case Hexagon::COMBINE_rr_cNotPt: |
| 1042 | case Hexagon::COMBINE_rr_cdnPt: |
| 1043 | case Hexagon::COMBINE_rr_cdnNotPt: |
| 1044 | return true; |
| 1045 | |
| 1046 | case Hexagon::ASLH_cPt_V4: |
| 1047 | case Hexagon::ASLH_cNotPt_V4: |
| 1048 | case Hexagon::ASRH_cPt_V4: |
| 1049 | case Hexagon::ASRH_cNotPt_V4: |
| 1050 | case Hexagon::SXTB_cPt_V4: |
| 1051 | case Hexagon::SXTB_cNotPt_V4: |
| 1052 | case Hexagon::SXTH_cPt_V4: |
| 1053 | case Hexagon::SXTH_cNotPt_V4: |
| 1054 | case Hexagon::ZXTB_cPt_V4: |
| 1055 | case Hexagon::ZXTB_cNotPt_V4: |
| 1056 | case Hexagon::ZXTH_cPt_V4: |
| 1057 | case Hexagon::ZXTH_cNotPt_V4: |
| 1058 | return true; |
| 1059 | |
| 1060 | case Hexagon::ASLH_cdnPt_V4: |
| 1061 | case Hexagon::ASLH_cdnNotPt_V4: |
| 1062 | case Hexagon::ASRH_cdnPt_V4: |
| 1063 | case Hexagon::ASRH_cdnNotPt_V4: |
| 1064 | case Hexagon::SXTB_cdnPt_V4: |
| 1065 | case Hexagon::SXTB_cdnNotPt_V4: |
| 1066 | case Hexagon::SXTH_cdnPt_V4: |
| 1067 | case Hexagon::SXTH_cdnNotPt_V4: |
| 1068 | case Hexagon::ZXTB_cdnPt_V4: |
| 1069 | case Hexagon::ZXTB_cdnNotPt_V4: |
| 1070 | case Hexagon::ZXTH_cdnPt_V4: |
| 1071 | case Hexagon::ZXTH_cdnNotPt_V4: |
| 1072 | return true; |
| 1073 | |
| 1074 | default: |
| 1075 | return false; |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | |
| 1080 | bool |
| 1081 | HexagonInstrInfo::DefinesPredicate(MachineInstr *MI, |
| 1082 | std::vector<MachineOperand> &Pred) const { |
| 1083 | for (unsigned oper = 0; oper < MI->getNumOperands(); ++oper) { |
| 1084 | MachineOperand MO = MI->getOperand(oper); |
| 1085 | if (MO.isReg() && MO.isDef()) { |
| 1086 | const TargetRegisterClass* RC = RI.getMinimalPhysRegClass(MO.getReg()); |
| 1087 | if (RC == Hexagon::PredRegsRegisterClass) { |
| 1088 | Pred.push_back(MO); |
| 1089 | return true; |
| 1090 | } |
| 1091 | } |
| 1092 | } |
| 1093 | return false; |
| 1094 | } |
| 1095 | |
| 1096 | |
| 1097 | bool |
| 1098 | HexagonInstrInfo:: |
| 1099 | SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1, |
| 1100 | const SmallVectorImpl<MachineOperand> &Pred2) const { |
| 1101 | // TODO: Fix this |
| 1102 | return false; |
| 1103 | } |
| 1104 | |
| 1105 | |
| 1106 | // |
| 1107 | // We indicate that we want to reverse the branch by |
| 1108 | // inserting a 0 at the beginning of the Cond vector. |
| 1109 | // |
| 1110 | bool HexagonInstrInfo:: |
| 1111 | ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const { |
| 1112 | if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) { |
| 1113 | Cond.erase(Cond.begin()); |
| 1114 | } else { |
| 1115 | Cond.insert(Cond.begin(), MachineOperand::CreateImm(0)); |
| 1116 | } |
| 1117 | return false; |
| 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | bool HexagonInstrInfo:: |
| 1122 | isProfitableToDupForIfCvt(MachineBasicBlock &MBB,unsigned NumInstrs, |
| 1123 | const BranchProbability &Probability) const { |
| 1124 | return (NumInstrs <= 4); |
| 1125 | } |
| 1126 | |
| 1127 | bool HexagonInstrInfo::isDeallocRet(const MachineInstr *MI) const { |
| 1128 | switch (MI->getOpcode()) { |
| 1129 | case Hexagon::DEALLOC_RET_V4 : |
| 1130 | case Hexagon::DEALLOC_RET_cPt_V4 : |
| 1131 | case Hexagon::DEALLOC_RET_cNotPt_V4 : |
| 1132 | case Hexagon::DEALLOC_RET_cdnPnt_V4 : |
| 1133 | case Hexagon::DEALLOC_RET_cNotdnPnt_V4 : |
| 1134 | case Hexagon::DEALLOC_RET_cdnPt_V4 : |
| 1135 | case Hexagon::DEALLOC_RET_cNotdnPt_V4 : |
| 1136 | return true; |
| 1137 | } |
| 1138 | return false; |
| 1139 | } |
| 1140 | |
| 1141 | |
| 1142 | bool HexagonInstrInfo:: |
| 1143 | isValidOffset(const int Opcode, const int Offset) const { |
| 1144 | // This function is to check whether the "Offset" is in the correct range of |
| 1145 | // the given "Opcode". If "Offset" is not in the correct range, "ADD_ri" is |
| 1146 | // inserted to calculate the final address. Due to this reason, the function |
| 1147 | // assumes that the "Offset" has correct alignment. |
| 1148 | |
| 1149 | switch(Opcode) { |
| 1150 | |
| 1151 | case Hexagon::LDriw: |
| 1152 | case Hexagon::STriw: |
| 1153 | case Hexagon::STriwt: |
| 1154 | assert((Offset % 4 == 0) && "Offset has incorrect alignment"); |
| 1155 | return (Offset >= Hexagon_MEMW_OFFSET_MIN) && |
| 1156 | (Offset <= Hexagon_MEMW_OFFSET_MAX); |
| 1157 | |
| 1158 | case Hexagon::LDrid: |
| 1159 | case Hexagon::STrid: |
| 1160 | assert((Offset % 8 == 0) && "Offset has incorrect alignment"); |
| 1161 | return (Offset >= Hexagon_MEMD_OFFSET_MIN) && |
| 1162 | (Offset <= Hexagon_MEMD_OFFSET_MAX); |
| 1163 | |
| 1164 | case Hexagon::LDrih: |
| 1165 | case Hexagon::LDriuh: |
| 1166 | case Hexagon::STrih: |
| 1167 | case Hexagon::LDrih_ae: |
| 1168 | assert((Offset % 2 == 0) && "Offset has incorrect alignment"); |
| 1169 | return (Offset >= Hexagon_MEMH_OFFSET_MIN) && |
| 1170 | (Offset <= Hexagon_MEMH_OFFSET_MAX); |
| 1171 | |
| 1172 | case Hexagon::LDrib: |
| 1173 | case Hexagon::STrib: |
| 1174 | case Hexagon::LDriub: |
| 1175 | case Hexagon::LDriubit: |
| 1176 | case Hexagon::LDrib_ae: |
| 1177 | case Hexagon::LDriub_ae: |
| 1178 | return (Offset >= Hexagon_MEMB_OFFSET_MIN) && |
| 1179 | (Offset <= Hexagon_MEMB_OFFSET_MAX); |
| 1180 | |
| 1181 | case Hexagon::ADD_ri: |
| 1182 | case Hexagon::TFR_FI: |
| 1183 | return (Offset >= Hexagon_ADDI_OFFSET_MIN) && |
| 1184 | (Offset <= Hexagon_ADDI_OFFSET_MAX); |
| 1185 | |
| 1186 | case Hexagon::MEMw_ADDSUBi_indexed_MEM_V4 : |
| 1187 | case Hexagon::MEMw_ADDi_indexed_MEM_V4 : |
| 1188 | case Hexagon::MEMw_SUBi_indexed_MEM_V4 : |
| 1189 | case Hexagon::MEMw_ADDr_indexed_MEM_V4 : |
| 1190 | case Hexagon::MEMw_SUBr_indexed_MEM_V4 : |
| 1191 | case Hexagon::MEMw_ANDr_indexed_MEM_V4 : |
| 1192 | case Hexagon::MEMw_ORr_indexed_MEM_V4 : |
| 1193 | case Hexagon::MEMw_ADDSUBi_MEM_V4 : |
| 1194 | case Hexagon::MEMw_ADDi_MEM_V4 : |
| 1195 | case Hexagon::MEMw_SUBi_MEM_V4 : |
| 1196 | case Hexagon::MEMw_ADDr_MEM_V4 : |
| 1197 | case Hexagon::MEMw_SUBr_MEM_V4 : |
| 1198 | case Hexagon::MEMw_ANDr_MEM_V4 : |
| 1199 | case Hexagon::MEMw_ORr_MEM_V4 : |
| 1200 | assert ((Offset % 4) == 0 && "MEMOPw offset is not aligned correctly." ); |
| 1201 | return (0 <= Offset && Offset <= 255); |
| 1202 | |
| 1203 | case Hexagon::MEMh_ADDSUBi_indexed_MEM_V4 : |
| 1204 | case Hexagon::MEMh_ADDi_indexed_MEM_V4 : |
| 1205 | case Hexagon::MEMh_SUBi_indexed_MEM_V4 : |
| 1206 | case Hexagon::MEMh_ADDr_indexed_MEM_V4 : |
| 1207 | case Hexagon::MEMh_SUBr_indexed_MEM_V4 : |
| 1208 | case Hexagon::MEMh_ANDr_indexed_MEM_V4 : |
| 1209 | case Hexagon::MEMh_ORr_indexed_MEM_V4 : |
| 1210 | case Hexagon::MEMh_ADDSUBi_MEM_V4 : |
| 1211 | case Hexagon::MEMh_ADDi_MEM_V4 : |
| 1212 | case Hexagon::MEMh_SUBi_MEM_V4 : |
| 1213 | case Hexagon::MEMh_ADDr_MEM_V4 : |
| 1214 | case Hexagon::MEMh_SUBr_MEM_V4 : |
| 1215 | case Hexagon::MEMh_ANDr_MEM_V4 : |
| 1216 | case Hexagon::MEMh_ORr_MEM_V4 : |
| 1217 | assert ((Offset % 2) == 0 && "MEMOPh offset is not aligned correctly." ); |
| 1218 | return (0 <= Offset && Offset <= 127); |
| 1219 | |
| 1220 | case Hexagon::MEMb_ADDSUBi_indexed_MEM_V4 : |
| 1221 | case Hexagon::MEMb_ADDi_indexed_MEM_V4 : |
| 1222 | case Hexagon::MEMb_SUBi_indexed_MEM_V4 : |
| 1223 | case Hexagon::MEMb_ADDr_indexed_MEM_V4 : |
| 1224 | case Hexagon::MEMb_SUBr_indexed_MEM_V4 : |
| 1225 | case Hexagon::MEMb_ANDr_indexed_MEM_V4 : |
| 1226 | case Hexagon::MEMb_ORr_indexed_MEM_V4 : |
| 1227 | case Hexagon::MEMb_ADDSUBi_MEM_V4 : |
| 1228 | case Hexagon::MEMb_ADDi_MEM_V4 : |
| 1229 | case Hexagon::MEMb_SUBi_MEM_V4 : |
| 1230 | case Hexagon::MEMb_ADDr_MEM_V4 : |
| 1231 | case Hexagon::MEMb_SUBr_MEM_V4 : |
| 1232 | case Hexagon::MEMb_ANDr_MEM_V4 : |
| 1233 | case Hexagon::MEMb_ORr_MEM_V4 : |
| 1234 | return (0 <= Offset && Offset <= 63); |
| 1235 | |
| 1236 | // LDri_pred and STriw_pred are pseudo operations, so it has to take offset of |
| 1237 | // any size. Later pass knows how to handle it. |
| 1238 | case Hexagon::STriw_pred: |
| 1239 | case Hexagon::LDriw_pred: |
| 1240 | return true; |
| 1241 | |
| 1242 | // INLINEASM is very special. |
| 1243 | case Hexagon::INLINEASM: |
| 1244 | return true; |
| 1245 | } |
| 1246 | |
| 1247 | assert(0 && "No offset range is defined for this opcode. Please define it in \ |
| 1248 | the above switch statement!"); |
| 1249 | } |
| 1250 | |
| 1251 | |
| 1252 | // |
| 1253 | // Check if the Offset is a valid auto-inc imm by Load/Store Type. |
| 1254 | // |
| 1255 | bool HexagonInstrInfo:: |
| 1256 | isValidAutoIncImm(const EVT VT, const int Offset) const { |
| 1257 | |
| 1258 | if (VT == MVT::i64) { |
| 1259 | return (Offset >= Hexagon_MEMD_AUTOINC_MIN && |
| 1260 | Offset <= Hexagon_MEMD_AUTOINC_MAX && |
| 1261 | (Offset & 0x7) == 0); |
| 1262 | } |
| 1263 | if (VT == MVT::i32) { |
| 1264 | return (Offset >= Hexagon_MEMW_AUTOINC_MIN && |
| 1265 | Offset <= Hexagon_MEMW_AUTOINC_MAX && |
| 1266 | (Offset & 0x3) == 0); |
| 1267 | } |
| 1268 | if (VT == MVT::i16) { |
| 1269 | return (Offset >= Hexagon_MEMH_AUTOINC_MIN && |
| 1270 | Offset <= Hexagon_MEMH_AUTOINC_MAX && |
| 1271 | (Offset & 0x1) == 0); |
| 1272 | } |
| 1273 | if (VT == MVT::i8) { |
| 1274 | return (Offset >= Hexagon_MEMB_AUTOINC_MIN && |
| 1275 | Offset <= Hexagon_MEMB_AUTOINC_MAX); |
| 1276 | } |
| 1277 | |
| 1278 | assert(0 && "Not an auto-inc opc!"); |
| 1279 | |
| 1280 | return false; |
| 1281 | } |
| 1282 | |
| 1283 | |
| 1284 | bool HexagonInstrInfo:: |
| 1285 | isMemOp(const MachineInstr *MI) const { |
| 1286 | switch (MI->getOpcode()) |
| 1287 | { |
| 1288 | case Hexagon::MEMw_ADDSUBi_indexed_MEM_V4 : |
| 1289 | case Hexagon::MEMw_ADDi_indexed_MEM_V4 : |
| 1290 | case Hexagon::MEMw_SUBi_indexed_MEM_V4 : |
| 1291 | case Hexagon::MEMw_ADDr_indexed_MEM_V4 : |
| 1292 | case Hexagon::MEMw_SUBr_indexed_MEM_V4 : |
| 1293 | case Hexagon::MEMw_ANDr_indexed_MEM_V4 : |
| 1294 | case Hexagon::MEMw_ORr_indexed_MEM_V4 : |
| 1295 | case Hexagon::MEMw_ADDSUBi_MEM_V4 : |
| 1296 | case Hexagon::MEMw_ADDi_MEM_V4 : |
| 1297 | case Hexagon::MEMw_SUBi_MEM_V4 : |
| 1298 | case Hexagon::MEMw_ADDr_MEM_V4 : |
| 1299 | case Hexagon::MEMw_SUBr_MEM_V4 : |
| 1300 | case Hexagon::MEMw_ANDr_MEM_V4 : |
| 1301 | case Hexagon::MEMw_ORr_MEM_V4 : |
| 1302 | case Hexagon::MEMh_ADDSUBi_indexed_MEM_V4 : |
| 1303 | case Hexagon::MEMh_ADDi_indexed_MEM_V4 : |
| 1304 | case Hexagon::MEMh_SUBi_indexed_MEM_V4 : |
| 1305 | case Hexagon::MEMh_ADDr_indexed_MEM_V4 : |
| 1306 | case Hexagon::MEMh_SUBr_indexed_MEM_V4 : |
| 1307 | case Hexagon::MEMh_ANDr_indexed_MEM_V4 : |
| 1308 | case Hexagon::MEMh_ORr_indexed_MEM_V4 : |
| 1309 | case Hexagon::MEMh_ADDSUBi_MEM_V4 : |
| 1310 | case Hexagon::MEMh_ADDi_MEM_V4 : |
| 1311 | case Hexagon::MEMh_SUBi_MEM_V4 : |
| 1312 | case Hexagon::MEMh_ADDr_MEM_V4 : |
| 1313 | case Hexagon::MEMh_SUBr_MEM_V4 : |
| 1314 | case Hexagon::MEMh_ANDr_MEM_V4 : |
| 1315 | case Hexagon::MEMh_ORr_MEM_V4 : |
| 1316 | case Hexagon::MEMb_ADDSUBi_indexed_MEM_V4 : |
| 1317 | case Hexagon::MEMb_ADDi_indexed_MEM_V4 : |
| 1318 | case Hexagon::MEMb_SUBi_indexed_MEM_V4 : |
| 1319 | case Hexagon::MEMb_ADDr_indexed_MEM_V4 : |
| 1320 | case Hexagon::MEMb_SUBr_indexed_MEM_V4 : |
| 1321 | case Hexagon::MEMb_ANDr_indexed_MEM_V4 : |
| 1322 | case Hexagon::MEMb_ORr_indexed_MEM_V4 : |
| 1323 | case Hexagon::MEMb_ADDSUBi_MEM_V4 : |
| 1324 | case Hexagon::MEMb_ADDi_MEM_V4 : |
| 1325 | case Hexagon::MEMb_SUBi_MEM_V4 : |
| 1326 | case Hexagon::MEMb_ADDr_MEM_V4 : |
| 1327 | case Hexagon::MEMb_SUBr_MEM_V4 : |
| 1328 | case Hexagon::MEMb_ANDr_MEM_V4 : |
| 1329 | case Hexagon::MEMb_ORr_MEM_V4 : |
| 1330 | return true; |
| 1331 | } |
| 1332 | return false; |
| 1333 | } |
| 1334 | |
| 1335 | |
| 1336 | bool HexagonInstrInfo:: |
| 1337 | isSpillPredRegOp(const MachineInstr *MI) const { |
| 1338 | switch (MI->getOpcode()) |
| 1339 | { |
| 1340 | case Hexagon::STriw_pred : |
| 1341 | case Hexagon::LDriw_pred : |
| 1342 | return true; |
| 1343 | } |
| 1344 | return false; |
| 1345 | } |
| 1346 | |
| 1347 | |
| 1348 | bool HexagonInstrInfo::isConditionalALU32 (const MachineInstr* MI) const { |
| 1349 | const HexagonRegisterInfo& QRI = getRegisterInfo(); |
| 1350 | switch (MI->getOpcode()) |
| 1351 | { |
| 1352 | case Hexagon::ADD_ri_cPt: |
| 1353 | case Hexagon::ADD_ri_cNotPt: |
| 1354 | case Hexagon::ADD_rr_cPt: |
| 1355 | case Hexagon::ADD_rr_cNotPt: |
| 1356 | case Hexagon::XOR_rr_cPt: |
| 1357 | case Hexagon::XOR_rr_cNotPt: |
| 1358 | case Hexagon::AND_rr_cPt: |
| 1359 | case Hexagon::AND_rr_cNotPt: |
| 1360 | case Hexagon::OR_rr_cPt: |
| 1361 | case Hexagon::OR_rr_cNotPt: |
| 1362 | case Hexagon::SUB_rr_cPt: |
| 1363 | case Hexagon::SUB_rr_cNotPt: |
| 1364 | case Hexagon::COMBINE_rr_cPt: |
| 1365 | case Hexagon::COMBINE_rr_cNotPt: |
| 1366 | return true; |
| 1367 | case Hexagon::ASLH_cPt_V4: |
| 1368 | case Hexagon::ASLH_cNotPt_V4: |
| 1369 | case Hexagon::ASRH_cPt_V4: |
| 1370 | case Hexagon::ASRH_cNotPt_V4: |
| 1371 | case Hexagon::SXTB_cPt_V4: |
| 1372 | case Hexagon::SXTB_cNotPt_V4: |
| 1373 | case Hexagon::SXTH_cPt_V4: |
| 1374 | case Hexagon::SXTH_cNotPt_V4: |
| 1375 | case Hexagon::ZXTB_cPt_V4: |
| 1376 | case Hexagon::ZXTB_cNotPt_V4: |
| 1377 | case Hexagon::ZXTH_cPt_V4: |
| 1378 | case Hexagon::ZXTH_cNotPt_V4: |
| 1379 | return QRI.Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4; |
| 1380 | |
| 1381 | default: |
| 1382 | return false; |
| 1383 | } |
| 1384 | return false; |
| 1385 | } |
| 1386 | |
| 1387 | |
| 1388 | bool HexagonInstrInfo:: |
| 1389 | isConditionalLoad (const MachineInstr* MI) const { |
| 1390 | const HexagonRegisterInfo& QRI = getRegisterInfo(); |
| 1391 | switch (MI->getOpcode()) |
| 1392 | { |
| 1393 | case Hexagon::LDrid_cPt : |
| 1394 | case Hexagon::LDrid_cNotPt : |
| 1395 | case Hexagon::LDrid_indexed_cPt : |
| 1396 | case Hexagon::LDrid_indexed_cNotPt : |
| 1397 | case Hexagon::LDriw_cPt : |
| 1398 | case Hexagon::LDriw_cNotPt : |
| 1399 | case Hexagon::LDriw_indexed_cPt : |
| 1400 | case Hexagon::LDriw_indexed_cNotPt : |
| 1401 | case Hexagon::LDrih_cPt : |
| 1402 | case Hexagon::LDrih_cNotPt : |
| 1403 | case Hexagon::LDrih_indexed_cPt : |
| 1404 | case Hexagon::LDrih_indexed_cNotPt : |
| 1405 | case Hexagon::LDrib_cPt : |
| 1406 | case Hexagon::LDrib_cNotPt : |
| 1407 | case Hexagon::LDrib_indexed_cPt : |
| 1408 | case Hexagon::LDrib_indexed_cNotPt : |
| 1409 | case Hexagon::LDriuh_cPt : |
| 1410 | case Hexagon::LDriuh_cNotPt : |
| 1411 | case Hexagon::LDriuh_indexed_cPt : |
| 1412 | case Hexagon::LDriuh_indexed_cNotPt : |
| 1413 | case Hexagon::LDriub_cPt : |
| 1414 | case Hexagon::LDriub_cNotPt : |
| 1415 | case Hexagon::LDriub_indexed_cPt : |
| 1416 | case Hexagon::LDriub_indexed_cNotPt : |
| 1417 | return true; |
| 1418 | case Hexagon::POST_LDrid_cPt : |
| 1419 | case Hexagon::POST_LDrid_cNotPt : |
| 1420 | case Hexagon::POST_LDriw_cPt : |
| 1421 | case Hexagon::POST_LDriw_cNotPt : |
| 1422 | case Hexagon::POST_LDrih_cPt : |
| 1423 | case Hexagon::POST_LDrih_cNotPt : |
| 1424 | case Hexagon::POST_LDrib_cPt : |
| 1425 | case Hexagon::POST_LDrib_cNotPt : |
| 1426 | case Hexagon::POST_LDriuh_cPt : |
| 1427 | case Hexagon::POST_LDriuh_cNotPt : |
| 1428 | case Hexagon::POST_LDriub_cPt : |
| 1429 | case Hexagon::POST_LDriub_cNotPt : |
| 1430 | return QRI.Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4; |
| 1431 | case Hexagon::LDrid_indexed_cPt_V4 : |
| 1432 | case Hexagon::LDrid_indexed_cNotPt_V4 : |
| 1433 | case Hexagon::LDrid_indexed_shl_cPt_V4 : |
| 1434 | case Hexagon::LDrid_indexed_shl_cNotPt_V4 : |
| 1435 | case Hexagon::LDrib_indexed_cPt_V4 : |
| 1436 | case Hexagon::LDrib_indexed_cNotPt_V4 : |
| 1437 | case Hexagon::LDrib_indexed_shl_cPt_V4 : |
| 1438 | case Hexagon::LDrib_indexed_shl_cNotPt_V4 : |
| 1439 | case Hexagon::LDriub_indexed_cPt_V4 : |
| 1440 | case Hexagon::LDriub_indexed_cNotPt_V4 : |
| 1441 | case Hexagon::LDriub_indexed_shl_cPt_V4 : |
| 1442 | case Hexagon::LDriub_indexed_shl_cNotPt_V4 : |
| 1443 | case Hexagon::LDrih_indexed_cPt_V4 : |
| 1444 | case Hexagon::LDrih_indexed_cNotPt_V4 : |
| 1445 | case Hexagon::LDrih_indexed_shl_cPt_V4 : |
| 1446 | case Hexagon::LDrih_indexed_shl_cNotPt_V4 : |
| 1447 | case Hexagon::LDriuh_indexed_cPt_V4 : |
| 1448 | case Hexagon::LDriuh_indexed_cNotPt_V4 : |
| 1449 | case Hexagon::LDriuh_indexed_shl_cPt_V4 : |
| 1450 | case Hexagon::LDriuh_indexed_shl_cNotPt_V4 : |
| 1451 | case Hexagon::LDriw_indexed_cPt_V4 : |
| 1452 | case Hexagon::LDriw_indexed_cNotPt_V4 : |
| 1453 | case Hexagon::LDriw_indexed_shl_cPt_V4 : |
| 1454 | case Hexagon::LDriw_indexed_shl_cNotPt_V4 : |
| 1455 | return QRI.Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4; |
| 1456 | default: |
| 1457 | return false; |
| 1458 | } |
| 1459 | return false; |
| 1460 | } |