1 //===-- HexagonInstrInfo.cpp - Hexagon Instruction Information ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the Hexagon implementation of the TargetInstrInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "HexagonInstrInfo.h"
16 #include "HexagonRegisterInfo.h"
17 #include "HexagonSubtarget.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/CodeGen/DFAPacketizer.h"
21 #include "llvm/CodeGen/MachineFrameInfo.h"
22 #include "llvm/CodeGen/MachineInstrBuilder.h"
23 #include "llvm/CodeGen/MachineMemOperand.h"
24 #include "llvm/CodeGen/MachineRegisterInfo.h"
25 #include "llvm/CodeGen/PseudoSourceValue.h"
26 #include "llvm/Support/MathExtras.h"
27 #define GET_INSTRINFO_CTOR
28 #define GET_INSTRMAP_INFO
29 #include "HexagonGenInstrInfo.inc"
30 #include "HexagonGenDFAPacketizer.inc"
35 /// Constants for Hexagon instructions.
37 const int Hexagon_MEMW_OFFSET_MAX = 4095;
38 const int Hexagon_MEMW_OFFSET_MIN = -4096;
39 const int Hexagon_MEMD_OFFSET_MAX = 8191;
40 const int Hexagon_MEMD_OFFSET_MIN = -8192;
41 const int Hexagon_MEMH_OFFSET_MAX = 2047;
42 const int Hexagon_MEMH_OFFSET_MIN = -2048;
43 const int Hexagon_MEMB_OFFSET_MAX = 1023;
44 const int Hexagon_MEMB_OFFSET_MIN = -1024;
45 const int Hexagon_ADDI_OFFSET_MAX = 32767;
46 const int Hexagon_ADDI_OFFSET_MIN = -32768;
47 const int Hexagon_MEMD_AUTOINC_MAX = 56;
48 const int Hexagon_MEMD_AUTOINC_MIN = -64;
49 const int Hexagon_MEMW_AUTOINC_MAX = 28;
50 const int Hexagon_MEMW_AUTOINC_MIN = -32;
51 const int Hexagon_MEMH_AUTOINC_MAX = 14;
52 const int Hexagon_MEMH_AUTOINC_MIN = -16;
53 const int Hexagon_MEMB_AUTOINC_MAX = 7;
54 const int Hexagon_MEMB_AUTOINC_MIN = -8;
57 HexagonInstrInfo::HexagonInstrInfo(HexagonSubtarget &ST)
58 : HexagonGenInstrInfo(Hexagon::ADJCALLSTACKDOWN, Hexagon::ADJCALLSTACKUP),
59 RI(ST, *this), Subtarget(ST) {
63 /// isLoadFromStackSlot - If the specified machine instruction is a direct
64 /// load from a stack slot, return the virtual or physical register number of
65 /// the destination along with the FrameIndex of the loaded stack slot. If
66 /// not, return 0. This predicate must return 0 if the instruction has
67 /// any side effects other than loading from the stack slot.
68 unsigned HexagonInstrInfo::isLoadFromStackSlot(const MachineInstr *MI,
69 int &FrameIndex) const {
72 switch (MI->getOpcode()) {
79 if (MI->getOperand(2).isFI() &&
80 MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) {
81 FrameIndex = MI->getOperand(2).getIndex();
82 return MI->getOperand(0).getReg();
90 /// isStoreToStackSlot - If the specified machine instruction is a direct
91 /// store to a stack slot, return the virtual or physical register number of
92 /// the source reg along with the FrameIndex of the loaded stack slot. If
93 /// not, return 0. This predicate must return 0 if the instruction has
94 /// any side effects other than storing to the stack slot.
95 unsigned HexagonInstrInfo::isStoreToStackSlot(const MachineInstr *MI,
96 int &FrameIndex) const {
97 switch (MI->getOpcode()) {
103 if (MI->getOperand(2).isFI() &&
104 MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) {
105 FrameIndex = MI->getOperand(0).getIndex();
106 return MI->getOperand(2).getReg();
115 HexagonInstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB,
116 MachineBasicBlock *FBB,
117 const SmallVectorImpl<MachineOperand> &Cond,
120 int BOpc = Hexagon::JMP;
121 int BccOpc = Hexagon::JMP_c;
123 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
126 // Check if ReverseBranchCondition has asked to reverse this branch
127 // If we want to reverse the branch an odd number of times, we want
129 if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) {
130 BccOpc = Hexagon::JMP_cNot;
136 // Due to a bug in TailMerging/CFG Optimization, we need to add a
137 // special case handling of a predicated jump followed by an
138 // unconditional jump. If not, Tail Merging and CFG Optimization go
139 // into an infinite loop.
140 MachineBasicBlock *NewTBB, *NewFBB;
141 SmallVector<MachineOperand, 4> Cond;
142 MachineInstr *Term = MBB.getFirstTerminator();
143 if (isPredicated(Term) && !AnalyzeBranch(MBB, NewTBB, NewFBB, Cond,
145 MachineBasicBlock *NextBB =
146 llvm::next(MachineFunction::iterator(&MBB));
147 if (NewTBB == NextBB) {
148 ReverseBranchCondition(Cond);
150 return InsertBranch(MBB, TBB, 0, Cond, DL);
153 BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB);
156 get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB);
161 BuildMI(&MBB, DL, get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB);
162 BuildMI(&MBB, DL, get(BOpc)).addMBB(FBB);
168 bool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
169 MachineBasicBlock *&TBB,
170 MachineBasicBlock *&FBB,
171 SmallVectorImpl<MachineOperand> &Cond,
172 bool AllowModify) const {
176 // If the block has no terminators, it just falls into the block after it.
177 MachineBasicBlock::iterator I = MBB.end();
178 if (I == MBB.begin())
181 // A basic block may looks like this:
191 // It has two succs but does not have a terminator
192 // Don't know how to handle it.
197 } while (I != MBB.begin());
202 while (I->isDebugValue()) {
203 if (I == MBB.begin())
207 if (!isUnpredicatedTerminator(I))
210 // Get the last instruction in the block.
211 MachineInstr *LastInst = I;
213 // If there is only one terminator instruction, process it.
214 if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
215 if (LastInst->getOpcode() == Hexagon::JMP) {
216 TBB = LastInst->getOperand(0).getMBB();
219 if (LastInst->getOpcode() == Hexagon::JMP_c) {
220 // Block ends with fall-through true condbranch.
221 TBB = LastInst->getOperand(1).getMBB();
222 Cond.push_back(LastInst->getOperand(0));
225 if (LastInst->getOpcode() == Hexagon::JMP_cNot) {
226 // Block ends with fall-through false condbranch.
227 TBB = LastInst->getOperand(1).getMBB();
228 Cond.push_back(MachineOperand::CreateImm(0));
229 Cond.push_back(LastInst->getOperand(0));
232 // Otherwise, don't know what this is.
236 // Get the instruction before it if it's a terminator.
237 MachineInstr *SecondLastInst = I;
239 // If there are three terminators, we don't know what sort of block this is.
240 if (SecondLastInst && I != MBB.begin() &&
241 isUnpredicatedTerminator(--I))
244 // If the block ends with Hexagon::BRCOND and Hexagon:JMP, handle it.
245 if (((SecondLastInst->getOpcode() == Hexagon::BRCOND) ||
246 (SecondLastInst->getOpcode() == Hexagon::JMP_c)) &&
247 LastInst->getOpcode() == Hexagon::JMP) {
248 TBB = SecondLastInst->getOperand(1).getMBB();
249 Cond.push_back(SecondLastInst->getOperand(0));
250 FBB = LastInst->getOperand(0).getMBB();
254 // If the block ends with Hexagon::JMP_cNot and Hexagon:JMP, handle it.
255 if ((SecondLastInst->getOpcode() == Hexagon::JMP_cNot) &&
256 LastInst->getOpcode() == Hexagon::JMP) {
257 TBB = SecondLastInst->getOperand(1).getMBB();
258 Cond.push_back(MachineOperand::CreateImm(0));
259 Cond.push_back(SecondLastInst->getOperand(0));
260 FBB = LastInst->getOperand(0).getMBB();
264 // If the block ends with two Hexagon:JMPs, handle it. The second one is not
265 // executed, so remove it.
266 if (SecondLastInst->getOpcode() == Hexagon::JMP &&
267 LastInst->getOpcode() == Hexagon::JMP) {
268 TBB = SecondLastInst->getOperand(0).getMBB();
271 I->eraseFromParent();
275 // Otherwise, can't handle this.
280 unsigned HexagonInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
281 int BOpc = Hexagon::JMP;
282 int BccOpc = Hexagon::JMP_c;
283 int BccOpcNot = Hexagon::JMP_cNot;
285 MachineBasicBlock::iterator I = MBB.end();
286 if (I == MBB.begin()) return 0;
288 if (I->getOpcode() != BOpc && I->getOpcode() != BccOpc &&
289 I->getOpcode() != BccOpcNot)
292 // Remove the branch.
293 I->eraseFromParent();
297 if (I == MBB.begin()) return 1;
299 if (I->getOpcode() != BccOpc && I->getOpcode() != BccOpcNot)
302 // Remove the branch.
303 I->eraseFromParent();
308 /// \brief For a comparison instruction, return the source registers in
309 /// \p SrcReg and \p SrcReg2 if having two register operands, and the value it
310 /// compares against in CmpValue. Return true if the comparison instruction
312 bool HexagonInstrInfo::analyzeCompare(const MachineInstr *MI,
313 unsigned &SrcReg, unsigned &SrcReg2,
314 int &Mask, int &Value) const {
315 unsigned Opc = MI->getOpcode();
317 // Set mask and the first source register.
319 case Hexagon::CMPEHexagon4rr:
320 case Hexagon::CMPEQri:
321 case Hexagon::CMPEQrr:
322 case Hexagon::CMPGT64rr:
323 case Hexagon::CMPGTU64rr:
324 case Hexagon::CMPGTUri:
325 case Hexagon::CMPGTUrr:
326 case Hexagon::CMPGTri:
327 case Hexagon::CMPGTrr:
328 case Hexagon::CMPLTUrr:
329 case Hexagon::CMPLTrr:
330 SrcReg = MI->getOperand(1).getReg();
333 case Hexagon::CMPbEQri_V4:
334 case Hexagon::CMPbEQrr_sbsb_V4:
335 case Hexagon::CMPbEQrr_ubub_V4:
336 case Hexagon::CMPbGTUri_V4:
337 case Hexagon::CMPbGTUrr_V4:
338 case Hexagon::CMPbGTrr_V4:
339 SrcReg = MI->getOperand(1).getReg();
342 case Hexagon::CMPhEQri_V4:
343 case Hexagon::CMPhEQrr_shl_V4:
344 case Hexagon::CMPhEQrr_xor_V4:
345 case Hexagon::CMPhGTUri_V4:
346 case Hexagon::CMPhGTUrr_V4:
347 case Hexagon::CMPhGTrr_shl_V4:
348 SrcReg = MI->getOperand(1).getReg();
353 // Set the value/second source register.
355 case Hexagon::CMPEHexagon4rr:
356 case Hexagon::CMPEQrr:
357 case Hexagon::CMPGT64rr:
358 case Hexagon::CMPGTU64rr:
359 case Hexagon::CMPGTUrr:
360 case Hexagon::CMPGTrr:
361 case Hexagon::CMPbEQrr_sbsb_V4:
362 case Hexagon::CMPbEQrr_ubub_V4:
363 case Hexagon::CMPbGTUrr_V4:
364 case Hexagon::CMPbGTrr_V4:
365 case Hexagon::CMPhEQrr_shl_V4:
366 case Hexagon::CMPhEQrr_xor_V4:
367 case Hexagon::CMPhGTUrr_V4:
368 case Hexagon::CMPhGTrr_shl_V4:
369 case Hexagon::CMPLTUrr:
370 case Hexagon::CMPLTrr:
371 SrcReg2 = MI->getOperand(2).getReg();
374 case Hexagon::CMPEQri:
375 case Hexagon::CMPGTUri:
376 case Hexagon::CMPGTri:
377 case Hexagon::CMPbEQri_V4:
378 case Hexagon::CMPbGTUri_V4:
379 case Hexagon::CMPhEQri_V4:
380 case Hexagon::CMPhGTUri_V4:
382 Value = MI->getOperand(2).getImm();
390 void HexagonInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
391 MachineBasicBlock::iterator I, DebugLoc DL,
392 unsigned DestReg, unsigned SrcReg,
393 bool KillSrc) const {
394 if (Hexagon::IntRegsRegClass.contains(SrcReg, DestReg)) {
395 BuildMI(MBB, I, DL, get(Hexagon::TFR), DestReg).addReg(SrcReg);
398 if (Hexagon::DoubleRegsRegClass.contains(SrcReg, DestReg)) {
399 BuildMI(MBB, I, DL, get(Hexagon::TFR64), DestReg).addReg(SrcReg);
402 if (Hexagon::PredRegsRegClass.contains(SrcReg, DestReg)) {
403 // Map Pd = Ps to Pd = or(Ps, Ps).
404 BuildMI(MBB, I, DL, get(Hexagon::OR_pp),
405 DestReg).addReg(SrcReg).addReg(SrcReg);
408 if (Hexagon::DoubleRegsRegClass.contains(DestReg) &&
409 Hexagon::IntRegsRegClass.contains(SrcReg)) {
410 // We can have an overlap between single and double reg: r1:0 = r0.
411 if(SrcReg == RI.getSubReg(DestReg, Hexagon::subreg_loreg)) {
413 BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg,
414 Hexagon::subreg_hireg))).addImm(0);
416 // r1:0 = r1 or no overlap.
417 BuildMI(MBB, I, DL, get(Hexagon::TFR), (RI.getSubReg(DestReg,
418 Hexagon::subreg_loreg))).addReg(SrcReg);
419 BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg,
420 Hexagon::subreg_hireg))).addImm(0);
424 if (Hexagon::CRRegsRegClass.contains(DestReg) &&
425 Hexagon::IntRegsRegClass.contains(SrcReg)) {
426 BuildMI(MBB, I, DL, get(Hexagon::TFCR), DestReg).addReg(SrcReg);
429 if (Hexagon::PredRegsRegClass.contains(SrcReg) &&
430 Hexagon::IntRegsRegClass.contains(DestReg)) {
431 BuildMI(MBB, I, DL, get(Hexagon::TFR_RsPd), DestReg).
432 addReg(SrcReg, getKillRegState(KillSrc));
435 if (Hexagon::IntRegsRegClass.contains(SrcReg) &&
436 Hexagon::PredRegsRegClass.contains(DestReg)) {
437 BuildMI(MBB, I, DL, get(Hexagon::TFR_PdRs), DestReg).
438 addReg(SrcReg, getKillRegState(KillSrc));
442 llvm_unreachable("Unimplemented");
446 void HexagonInstrInfo::
447 storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
448 unsigned SrcReg, bool isKill, int FI,
449 const TargetRegisterClass *RC,
450 const TargetRegisterInfo *TRI) const {
452 DebugLoc DL = MBB.findDebugLoc(I);
453 MachineFunction &MF = *MBB.getParent();
454 MachineFrameInfo &MFI = *MF.getFrameInfo();
455 unsigned Align = MFI.getObjectAlignment(FI);
457 MachineMemOperand *MMO =
458 MF.getMachineMemOperand(
459 MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
460 MachineMemOperand::MOStore,
461 MFI.getObjectSize(FI),
464 if (Hexagon::IntRegsRegClass.hasSubClassEq(RC)) {
465 BuildMI(MBB, I, DL, get(Hexagon::STriw))
466 .addFrameIndex(FI).addImm(0)
467 .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
468 } else if (Hexagon::DoubleRegsRegClass.hasSubClassEq(RC)) {
469 BuildMI(MBB, I, DL, get(Hexagon::STrid))
470 .addFrameIndex(FI).addImm(0)
471 .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
472 } else if (Hexagon::PredRegsRegClass.hasSubClassEq(RC)) {
473 BuildMI(MBB, I, DL, get(Hexagon::STriw_pred))
474 .addFrameIndex(FI).addImm(0)
475 .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
477 llvm_unreachable("Unimplemented");
482 void HexagonInstrInfo::storeRegToAddr(
483 MachineFunction &MF, unsigned SrcReg,
485 SmallVectorImpl<MachineOperand> &Addr,
486 const TargetRegisterClass *RC,
487 SmallVectorImpl<MachineInstr*> &NewMIs) const
489 llvm_unreachable("Unimplemented");
493 void HexagonInstrInfo::
494 loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
495 unsigned DestReg, int FI,
496 const TargetRegisterClass *RC,
497 const TargetRegisterInfo *TRI) const {
498 DebugLoc DL = MBB.findDebugLoc(I);
499 MachineFunction &MF = *MBB.getParent();
500 MachineFrameInfo &MFI = *MF.getFrameInfo();
501 unsigned Align = MFI.getObjectAlignment(FI);
503 MachineMemOperand *MMO =
504 MF.getMachineMemOperand(
505 MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
506 MachineMemOperand::MOLoad,
507 MFI.getObjectSize(FI),
509 if (RC == &Hexagon::IntRegsRegClass) {
510 BuildMI(MBB, I, DL, get(Hexagon::LDriw), DestReg)
511 .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
512 } else if (RC == &Hexagon::DoubleRegsRegClass) {
513 BuildMI(MBB, I, DL, get(Hexagon::LDrid), DestReg)
514 .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
515 } else if (RC == &Hexagon::PredRegsRegClass) {
516 BuildMI(MBB, I, DL, get(Hexagon::LDriw_pred), DestReg)
517 .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
519 llvm_unreachable("Can't store this register to stack slot");
524 void HexagonInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
525 SmallVectorImpl<MachineOperand> &Addr,
526 const TargetRegisterClass *RC,
527 SmallVectorImpl<MachineInstr*> &NewMIs) const {
528 llvm_unreachable("Unimplemented");
532 MachineInstr *HexagonInstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
534 const SmallVectorImpl<unsigned> &Ops,
536 // Hexagon_TODO: Implement.
541 unsigned HexagonInstrInfo::createVR(MachineFunction* MF, MVT VT) const {
543 MachineRegisterInfo &RegInfo = MF->getRegInfo();
544 const TargetRegisterClass *TRC;
546 TRC = &Hexagon::PredRegsRegClass;
547 } else if (VT == MVT::i32 || VT == MVT::f32) {
548 TRC = &Hexagon::IntRegsRegClass;
549 } else if (VT == MVT::i64 || VT == MVT::f64) {
550 TRC = &Hexagon::DoubleRegsRegClass;
552 llvm_unreachable("Cannot handle this register class");
555 unsigned NewReg = RegInfo.createVirtualRegister(TRC);
559 bool HexagonInstrInfo::isExtendable(const MachineInstr *MI) const {
560 switch(MI->getOpcode()) {
561 default: return false;
563 case Hexagon::JMP_EQriPt_nv_V4:
564 case Hexagon::JMP_EQriPnt_nv_V4:
565 case Hexagon::JMP_EQriNotPt_nv_V4:
566 case Hexagon::JMP_EQriNotPnt_nv_V4:
568 // JMP_EQri - with -1
569 case Hexagon::JMP_EQriPtneg_nv_V4:
570 case Hexagon::JMP_EQriPntneg_nv_V4:
571 case Hexagon::JMP_EQriNotPtneg_nv_V4:
572 case Hexagon::JMP_EQriNotPntneg_nv_V4:
575 case Hexagon::JMP_EQrrPt_nv_V4:
576 case Hexagon::JMP_EQrrPnt_nv_V4:
577 case Hexagon::JMP_EQrrNotPt_nv_V4:
578 case Hexagon::JMP_EQrrNotPnt_nv_V4:
581 case Hexagon::JMP_GTriPt_nv_V4:
582 case Hexagon::JMP_GTriPnt_nv_V4:
583 case Hexagon::JMP_GTriNotPt_nv_V4:
584 case Hexagon::JMP_GTriNotPnt_nv_V4:
586 // JMP_GTri - with -1
587 case Hexagon::JMP_GTriPtneg_nv_V4:
588 case Hexagon::JMP_GTriPntneg_nv_V4:
589 case Hexagon::JMP_GTriNotPtneg_nv_V4:
590 case Hexagon::JMP_GTriNotPntneg_nv_V4:
593 case Hexagon::JMP_GTrrPt_nv_V4:
594 case Hexagon::JMP_GTrrPnt_nv_V4:
595 case Hexagon::JMP_GTrrNotPt_nv_V4:
596 case Hexagon::JMP_GTrrNotPnt_nv_V4:
599 case Hexagon::JMP_GTrrdnPt_nv_V4:
600 case Hexagon::JMP_GTrrdnPnt_nv_V4:
601 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
602 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
605 case Hexagon::JMP_GTUriPt_nv_V4:
606 case Hexagon::JMP_GTUriPnt_nv_V4:
607 case Hexagon::JMP_GTUriNotPt_nv_V4:
608 case Hexagon::JMP_GTUriNotPnt_nv_V4:
611 case Hexagon::JMP_GTUrrPt_nv_V4:
612 case Hexagon::JMP_GTUrrPnt_nv_V4:
613 case Hexagon::JMP_GTUrrNotPt_nv_V4:
614 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
617 case Hexagon::JMP_GTUrrdnPt_nv_V4:
618 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
619 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
620 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
623 case Hexagon::TFR_FI:
628 bool HexagonInstrInfo::isExtended(const MachineInstr *MI) const {
629 switch(MI->getOpcode()) {
630 default: return false;
632 case Hexagon::JMP_EQriPt_ie_nv_V4:
633 case Hexagon::JMP_EQriPnt_ie_nv_V4:
634 case Hexagon::JMP_EQriNotPt_ie_nv_V4:
635 case Hexagon::JMP_EQriNotPnt_ie_nv_V4:
637 // JMP_EQri - with -1
638 case Hexagon::JMP_EQriPtneg_ie_nv_V4:
639 case Hexagon::JMP_EQriPntneg_ie_nv_V4:
640 case Hexagon::JMP_EQriNotPtneg_ie_nv_V4:
641 case Hexagon::JMP_EQriNotPntneg_ie_nv_V4:
644 case Hexagon::JMP_EQrrPt_ie_nv_V4:
645 case Hexagon::JMP_EQrrPnt_ie_nv_V4:
646 case Hexagon::JMP_EQrrNotPt_ie_nv_V4:
647 case Hexagon::JMP_EQrrNotPnt_ie_nv_V4:
650 case Hexagon::JMP_GTriPt_ie_nv_V4:
651 case Hexagon::JMP_GTriPnt_ie_nv_V4:
652 case Hexagon::JMP_GTriNotPt_ie_nv_V4:
653 case Hexagon::JMP_GTriNotPnt_ie_nv_V4:
655 // JMP_GTri - with -1
656 case Hexagon::JMP_GTriPtneg_ie_nv_V4:
657 case Hexagon::JMP_GTriPntneg_ie_nv_V4:
658 case Hexagon::JMP_GTriNotPtneg_ie_nv_V4:
659 case Hexagon::JMP_GTriNotPntneg_ie_nv_V4:
662 case Hexagon::JMP_GTrrPt_ie_nv_V4:
663 case Hexagon::JMP_GTrrPnt_ie_nv_V4:
664 case Hexagon::JMP_GTrrNotPt_ie_nv_V4:
665 case Hexagon::JMP_GTrrNotPnt_ie_nv_V4:
668 case Hexagon::JMP_GTrrdnPt_ie_nv_V4:
669 case Hexagon::JMP_GTrrdnPnt_ie_nv_V4:
670 case Hexagon::JMP_GTrrdnNotPt_ie_nv_V4:
671 case Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4:
674 case Hexagon::JMP_GTUriPt_ie_nv_V4:
675 case Hexagon::JMP_GTUriPnt_ie_nv_V4:
676 case Hexagon::JMP_GTUriNotPt_ie_nv_V4:
677 case Hexagon::JMP_GTUriNotPnt_ie_nv_V4:
680 case Hexagon::JMP_GTUrrPt_ie_nv_V4:
681 case Hexagon::JMP_GTUrrPnt_ie_nv_V4:
682 case Hexagon::JMP_GTUrrNotPt_ie_nv_V4:
683 case Hexagon::JMP_GTUrrNotPnt_ie_nv_V4:
686 case Hexagon::JMP_GTUrrdnPt_ie_nv_V4:
687 case Hexagon::JMP_GTUrrdnPnt_ie_nv_V4:
688 case Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4:
689 case Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4:
691 // V4 absolute set addressing.
692 case Hexagon::LDrid_abs_setimm_V4:
693 case Hexagon::LDriw_abs_setimm_V4:
694 case Hexagon::LDrih_abs_setimm_V4:
695 case Hexagon::LDrib_abs_setimm_V4:
696 case Hexagon::LDriuh_abs_setimm_V4:
697 case Hexagon::LDriub_abs_setimm_V4:
699 case Hexagon::STrid_abs_setimm_V4:
700 case Hexagon::STrib_abs_setimm_V4:
701 case Hexagon::STrih_abs_setimm_V4:
702 case Hexagon::STriw_abs_setimm_V4:
704 // V4 global address load.
705 case Hexagon::LDd_GP_cPt_V4 :
706 case Hexagon::LDd_GP_cNotPt_V4 :
707 case Hexagon::LDd_GP_cdnPt_V4 :
708 case Hexagon::LDd_GP_cdnNotPt_V4 :
709 case Hexagon::LDb_GP_cPt_V4 :
710 case Hexagon::LDb_GP_cNotPt_V4 :
711 case Hexagon::LDb_GP_cdnPt_V4 :
712 case Hexagon::LDb_GP_cdnNotPt_V4 :
713 case Hexagon::LDub_GP_cPt_V4 :
714 case Hexagon::LDub_GP_cNotPt_V4 :
715 case Hexagon::LDub_GP_cdnPt_V4 :
716 case Hexagon::LDub_GP_cdnNotPt_V4 :
717 case Hexagon::LDh_GP_cPt_V4 :
718 case Hexagon::LDh_GP_cNotPt_V4 :
719 case Hexagon::LDh_GP_cdnPt_V4 :
720 case Hexagon::LDh_GP_cdnNotPt_V4 :
721 case Hexagon::LDuh_GP_cPt_V4 :
722 case Hexagon::LDuh_GP_cNotPt_V4 :
723 case Hexagon::LDuh_GP_cdnPt_V4 :
724 case Hexagon::LDuh_GP_cdnNotPt_V4 :
725 case Hexagon::LDw_GP_cPt_V4 :
726 case Hexagon::LDw_GP_cNotPt_V4 :
727 case Hexagon::LDw_GP_cdnPt_V4 :
728 case Hexagon::LDw_GP_cdnNotPt_V4 :
730 // V4 global address store.
731 case Hexagon::STd_GP_cPt_V4 :
732 case Hexagon::STd_GP_cNotPt_V4 :
733 case Hexagon::STd_GP_cdnPt_V4 :
734 case Hexagon::STd_GP_cdnNotPt_V4 :
735 case Hexagon::STb_GP_cPt_V4 :
736 case Hexagon::STb_GP_cNotPt_V4 :
737 case Hexagon::STb_GP_cdnPt_V4 :
738 case Hexagon::STb_GP_cdnNotPt_V4 :
739 case Hexagon::STh_GP_cPt_V4 :
740 case Hexagon::STh_GP_cNotPt_V4 :
741 case Hexagon::STh_GP_cdnPt_V4 :
742 case Hexagon::STh_GP_cdnNotPt_V4 :
743 case Hexagon::STw_GP_cPt_V4 :
744 case Hexagon::STw_GP_cNotPt_V4 :
745 case Hexagon::STw_GP_cdnPt_V4 :
746 case Hexagon::STw_GP_cdnNotPt_V4 :
748 // V4 predicated global address new value store.
749 case Hexagon::STb_GP_cPt_nv_V4 :
750 case Hexagon::STb_GP_cNotPt_nv_V4 :
751 case Hexagon::STb_GP_cdnPt_nv_V4 :
752 case Hexagon::STb_GP_cdnNotPt_nv_V4 :
753 case Hexagon::STh_GP_cPt_nv_V4 :
754 case Hexagon::STh_GP_cNotPt_nv_V4 :
755 case Hexagon::STh_GP_cdnPt_nv_V4 :
756 case Hexagon::STh_GP_cdnNotPt_nv_V4 :
757 case Hexagon::STw_GP_cPt_nv_V4 :
758 case Hexagon::STw_GP_cNotPt_nv_V4 :
759 case Hexagon::STw_GP_cdnPt_nv_V4 :
760 case Hexagon::STw_GP_cdnNotPt_nv_V4 :
763 case Hexagon::TFR_FI_immext_V4:
766 case Hexagon::TFRI_f:
767 case Hexagon::TFRI_cPt_f:
768 case Hexagon::TFRI_cNotPt_f:
769 case Hexagon::CONST64_Float_Real:
774 bool HexagonInstrInfo::isNewValueJump(const MachineInstr *MI) const {
775 switch (MI->getOpcode()) {
776 default: return false;
778 case Hexagon::JMP_EQriPt_nv_V4:
779 case Hexagon::JMP_EQriPnt_nv_V4:
780 case Hexagon::JMP_EQriNotPt_nv_V4:
781 case Hexagon::JMP_EQriNotPnt_nv_V4:
782 case Hexagon::JMP_EQriPt_ie_nv_V4:
783 case Hexagon::JMP_EQriPnt_ie_nv_V4:
784 case Hexagon::JMP_EQriNotPt_ie_nv_V4:
785 case Hexagon::JMP_EQriNotPnt_ie_nv_V4:
787 // JMP_EQri - with -1
788 case Hexagon::JMP_EQriPtneg_nv_V4:
789 case Hexagon::JMP_EQriPntneg_nv_V4:
790 case Hexagon::JMP_EQriNotPtneg_nv_V4:
791 case Hexagon::JMP_EQriNotPntneg_nv_V4:
792 case Hexagon::JMP_EQriPtneg_ie_nv_V4:
793 case Hexagon::JMP_EQriPntneg_ie_nv_V4:
794 case Hexagon::JMP_EQriNotPtneg_ie_nv_V4:
795 case Hexagon::JMP_EQriNotPntneg_ie_nv_V4:
798 case Hexagon::JMP_EQrrPt_nv_V4:
799 case Hexagon::JMP_EQrrPnt_nv_V4:
800 case Hexagon::JMP_EQrrNotPt_nv_V4:
801 case Hexagon::JMP_EQrrNotPnt_nv_V4:
802 case Hexagon::JMP_EQrrPt_ie_nv_V4:
803 case Hexagon::JMP_EQrrPnt_ie_nv_V4:
804 case Hexagon::JMP_EQrrNotPt_ie_nv_V4:
805 case Hexagon::JMP_EQrrNotPnt_ie_nv_V4:
808 case Hexagon::JMP_GTriPt_nv_V4:
809 case Hexagon::JMP_GTriPnt_nv_V4:
810 case Hexagon::JMP_GTriNotPt_nv_V4:
811 case Hexagon::JMP_GTriNotPnt_nv_V4:
812 case Hexagon::JMP_GTriPt_ie_nv_V4:
813 case Hexagon::JMP_GTriPnt_ie_nv_V4:
814 case Hexagon::JMP_GTriNotPt_ie_nv_V4:
815 case Hexagon::JMP_GTriNotPnt_ie_nv_V4:
817 // JMP_GTri - with -1
818 case Hexagon::JMP_GTriPtneg_nv_V4:
819 case Hexagon::JMP_GTriPntneg_nv_V4:
820 case Hexagon::JMP_GTriNotPtneg_nv_V4:
821 case Hexagon::JMP_GTriNotPntneg_nv_V4:
822 case Hexagon::JMP_GTriPtneg_ie_nv_V4:
823 case Hexagon::JMP_GTriPntneg_ie_nv_V4:
824 case Hexagon::JMP_GTriNotPtneg_ie_nv_V4:
825 case Hexagon::JMP_GTriNotPntneg_ie_nv_V4:
828 case Hexagon::JMP_GTrrPt_nv_V4:
829 case Hexagon::JMP_GTrrPnt_nv_V4:
830 case Hexagon::JMP_GTrrNotPt_nv_V4:
831 case Hexagon::JMP_GTrrNotPnt_nv_V4:
832 case Hexagon::JMP_GTrrPt_ie_nv_V4:
833 case Hexagon::JMP_GTrrPnt_ie_nv_V4:
834 case Hexagon::JMP_GTrrNotPt_ie_nv_V4:
835 case Hexagon::JMP_GTrrNotPnt_ie_nv_V4:
838 case Hexagon::JMP_GTrrdnPt_nv_V4:
839 case Hexagon::JMP_GTrrdnPnt_nv_V4:
840 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
841 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
842 case Hexagon::JMP_GTrrdnPt_ie_nv_V4:
843 case Hexagon::JMP_GTrrdnPnt_ie_nv_V4:
844 case Hexagon::JMP_GTrrdnNotPt_ie_nv_V4:
845 case Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4:
848 case Hexagon::JMP_GTUriPt_nv_V4:
849 case Hexagon::JMP_GTUriPnt_nv_V4:
850 case Hexagon::JMP_GTUriNotPt_nv_V4:
851 case Hexagon::JMP_GTUriNotPnt_nv_V4:
852 case Hexagon::JMP_GTUriPt_ie_nv_V4:
853 case Hexagon::JMP_GTUriPnt_ie_nv_V4:
854 case Hexagon::JMP_GTUriNotPt_ie_nv_V4:
855 case Hexagon::JMP_GTUriNotPnt_ie_nv_V4:
858 case Hexagon::JMP_GTUrrPt_nv_V4:
859 case Hexagon::JMP_GTUrrPnt_nv_V4:
860 case Hexagon::JMP_GTUrrNotPt_nv_V4:
861 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
862 case Hexagon::JMP_GTUrrPt_ie_nv_V4:
863 case Hexagon::JMP_GTUrrPnt_ie_nv_V4:
864 case Hexagon::JMP_GTUrrNotPt_ie_nv_V4:
865 case Hexagon::JMP_GTUrrNotPnt_ie_nv_V4:
868 case Hexagon::JMP_GTUrrdnPt_nv_V4:
869 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
870 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
871 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
872 case Hexagon::JMP_GTUrrdnPt_ie_nv_V4:
873 case Hexagon::JMP_GTUrrdnPnt_ie_nv_V4:
874 case Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4:
875 case Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4:
880 unsigned HexagonInstrInfo::getImmExtForm(const MachineInstr* MI) const {
881 switch(MI->getOpcode()) {
882 default: llvm_unreachable("Unknown type of instruction.");
884 case Hexagon::JMP_EQriPt_nv_V4:
885 return Hexagon::JMP_EQriPt_ie_nv_V4;
886 case Hexagon::JMP_EQriNotPt_nv_V4:
887 return Hexagon::JMP_EQriNotPt_ie_nv_V4;
888 case Hexagon::JMP_EQriPnt_nv_V4:
889 return Hexagon::JMP_EQriPnt_ie_nv_V4;
890 case Hexagon::JMP_EQriNotPnt_nv_V4:
891 return Hexagon::JMP_EQriNotPnt_ie_nv_V4;
893 // JMP_EQri -- with -1
894 case Hexagon::JMP_EQriPtneg_nv_V4:
895 return Hexagon::JMP_EQriPtneg_ie_nv_V4;
896 case Hexagon::JMP_EQriNotPtneg_nv_V4:
897 return Hexagon::JMP_EQriNotPtneg_ie_nv_V4;
898 case Hexagon::JMP_EQriPntneg_nv_V4:
899 return Hexagon::JMP_EQriPntneg_ie_nv_V4;
900 case Hexagon::JMP_EQriNotPntneg_nv_V4:
901 return Hexagon::JMP_EQriNotPntneg_ie_nv_V4;
904 case Hexagon::JMP_EQrrPt_nv_V4:
905 return Hexagon::JMP_EQrrPt_ie_nv_V4;
906 case Hexagon::JMP_EQrrNotPt_nv_V4:
907 return Hexagon::JMP_EQrrNotPt_ie_nv_V4;
908 case Hexagon::JMP_EQrrPnt_nv_V4:
909 return Hexagon::JMP_EQrrPnt_ie_nv_V4;
910 case Hexagon::JMP_EQrrNotPnt_nv_V4:
911 return Hexagon::JMP_EQrrNotPnt_ie_nv_V4;
914 case Hexagon::JMP_GTriPt_nv_V4:
915 return Hexagon::JMP_GTriPt_ie_nv_V4;
916 case Hexagon::JMP_GTriNotPt_nv_V4:
917 return Hexagon::JMP_GTriNotPt_ie_nv_V4;
918 case Hexagon::JMP_GTriPnt_nv_V4:
919 return Hexagon::JMP_GTriPnt_ie_nv_V4;
920 case Hexagon::JMP_GTriNotPnt_nv_V4:
921 return Hexagon::JMP_GTriNotPnt_ie_nv_V4;
923 // JMP_GTri -- with -1
924 case Hexagon::JMP_GTriPtneg_nv_V4:
925 return Hexagon::JMP_GTriPtneg_ie_nv_V4;
926 case Hexagon::JMP_GTriNotPtneg_nv_V4:
927 return Hexagon::JMP_GTriNotPtneg_ie_nv_V4;
928 case Hexagon::JMP_GTriPntneg_nv_V4:
929 return Hexagon::JMP_GTriPntneg_ie_nv_V4;
930 case Hexagon::JMP_GTriNotPntneg_nv_V4:
931 return Hexagon::JMP_GTriNotPntneg_ie_nv_V4;
934 case Hexagon::JMP_GTrrPt_nv_V4:
935 return Hexagon::JMP_GTrrPt_ie_nv_V4;
936 case Hexagon::JMP_GTrrNotPt_nv_V4:
937 return Hexagon::JMP_GTrrNotPt_ie_nv_V4;
938 case Hexagon::JMP_GTrrPnt_nv_V4:
939 return Hexagon::JMP_GTrrPnt_ie_nv_V4;
940 case Hexagon::JMP_GTrrNotPnt_nv_V4:
941 return Hexagon::JMP_GTrrNotPnt_ie_nv_V4;
944 case Hexagon::JMP_GTrrdnPt_nv_V4:
945 return Hexagon::JMP_GTrrdnPt_ie_nv_V4;
946 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
947 return Hexagon::JMP_GTrrdnNotPt_ie_nv_V4;
948 case Hexagon::JMP_GTrrdnPnt_nv_V4:
949 return Hexagon::JMP_GTrrdnPnt_ie_nv_V4;
950 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
951 return Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4;
954 case Hexagon::JMP_GTUriPt_nv_V4:
955 return Hexagon::JMP_GTUriPt_ie_nv_V4;
956 case Hexagon::JMP_GTUriNotPt_nv_V4:
957 return Hexagon::JMP_GTUriNotPt_ie_nv_V4;
958 case Hexagon::JMP_GTUriPnt_nv_V4:
959 return Hexagon::JMP_GTUriPnt_ie_nv_V4;
960 case Hexagon::JMP_GTUriNotPnt_nv_V4:
961 return Hexagon::JMP_GTUriNotPnt_ie_nv_V4;
964 case Hexagon::JMP_GTUrrPt_nv_V4:
965 return Hexagon::JMP_GTUrrPt_ie_nv_V4;
966 case Hexagon::JMP_GTUrrNotPt_nv_V4:
967 return Hexagon::JMP_GTUrrNotPt_ie_nv_V4;
968 case Hexagon::JMP_GTUrrPnt_nv_V4:
969 return Hexagon::JMP_GTUrrPnt_ie_nv_V4;
970 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
971 return Hexagon::JMP_GTUrrNotPnt_ie_nv_V4;
974 case Hexagon::JMP_GTUrrdnPt_nv_V4:
975 return Hexagon::JMP_GTUrrdnPt_ie_nv_V4;
976 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
977 return Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4;
978 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
979 return Hexagon::JMP_GTUrrdnPnt_ie_nv_V4;
980 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
981 return Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4;
983 case Hexagon::TFR_FI:
984 return Hexagon::TFR_FI_immext_V4;
986 case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
987 case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
988 case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
989 case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
990 case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
991 case Hexagon::MEMw_ORr_indexed_MEM_V4 :
992 case Hexagon::MEMw_ADDi_MEM_V4 :
993 case Hexagon::MEMw_SUBi_MEM_V4 :
994 case Hexagon::MEMw_ADDr_MEM_V4 :
995 case Hexagon::MEMw_SUBr_MEM_V4 :
996 case Hexagon::MEMw_ANDr_MEM_V4 :
997 case Hexagon::MEMw_ORr_MEM_V4 :
998 case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
999 case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
1000 case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
1001 case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
1002 case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
1003 case Hexagon::MEMh_ORr_indexed_MEM_V4 :
1004 case Hexagon::MEMh_ADDi_MEM_V4 :
1005 case Hexagon::MEMh_SUBi_MEM_V4 :
1006 case Hexagon::MEMh_ADDr_MEM_V4 :
1007 case Hexagon::MEMh_SUBr_MEM_V4 :
1008 case Hexagon::MEMh_ANDr_MEM_V4 :
1009 case Hexagon::MEMh_ORr_MEM_V4 :
1010 case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
1011 case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
1012 case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
1013 case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
1014 case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
1015 case Hexagon::MEMb_ORr_indexed_MEM_V4 :
1016 case Hexagon::MEMb_ADDi_MEM_V4 :
1017 case Hexagon::MEMb_SUBi_MEM_V4 :
1018 case Hexagon::MEMb_ADDr_MEM_V4 :
1019 case Hexagon::MEMb_SUBr_MEM_V4 :
1020 case Hexagon::MEMb_ANDr_MEM_V4 :
1021 case Hexagon::MEMb_ORr_MEM_V4 :
1022 llvm_unreachable("Needs implementing.");
1026 unsigned HexagonInstrInfo::getNormalBranchForm(const MachineInstr* MI) const {
1027 switch(MI->getOpcode()) {
1028 default: llvm_unreachable("Unknown type of jump instruction.");
1030 case Hexagon::JMP_EQriPt_ie_nv_V4:
1031 return Hexagon::JMP_EQriPt_nv_V4;
1032 case Hexagon::JMP_EQriNotPt_ie_nv_V4:
1033 return Hexagon::JMP_EQriNotPt_nv_V4;
1034 case Hexagon::JMP_EQriPnt_ie_nv_V4:
1035 return Hexagon::JMP_EQriPnt_nv_V4;
1036 case Hexagon::JMP_EQriNotPnt_ie_nv_V4:
1037 return Hexagon::JMP_EQriNotPnt_nv_V4;
1039 // JMP_EQri -- with -1
1040 case Hexagon::JMP_EQriPtneg_ie_nv_V4:
1041 return Hexagon::JMP_EQriPtneg_nv_V4;
1042 case Hexagon::JMP_EQriNotPtneg_ie_nv_V4:
1043 return Hexagon::JMP_EQriNotPtneg_nv_V4;
1044 case Hexagon::JMP_EQriPntneg_ie_nv_V4:
1045 return Hexagon::JMP_EQriPntneg_nv_V4;
1046 case Hexagon::JMP_EQriNotPntneg_ie_nv_V4:
1047 return Hexagon::JMP_EQriNotPntneg_nv_V4;
1050 case Hexagon::JMP_EQrrPt_ie_nv_V4:
1051 return Hexagon::JMP_EQrrPt_nv_V4;
1052 case Hexagon::JMP_EQrrNotPt_ie_nv_V4:
1053 return Hexagon::JMP_EQrrNotPt_nv_V4;
1054 case Hexagon::JMP_EQrrPnt_ie_nv_V4:
1055 return Hexagon::JMP_EQrrPnt_nv_V4;
1056 case Hexagon::JMP_EQrrNotPnt_ie_nv_V4:
1057 return Hexagon::JMP_EQrrNotPnt_nv_V4;
1060 case Hexagon::JMP_GTriPt_ie_nv_V4:
1061 return Hexagon::JMP_GTriPt_nv_V4;
1062 case Hexagon::JMP_GTriNotPt_ie_nv_V4:
1063 return Hexagon::JMP_GTriNotPt_nv_V4;
1064 case Hexagon::JMP_GTriPnt_ie_nv_V4:
1065 return Hexagon::JMP_GTriPnt_nv_V4;
1066 case Hexagon::JMP_GTriNotPnt_ie_nv_V4:
1067 return Hexagon::JMP_GTriNotPnt_nv_V4;
1069 // JMP_GTri -- with -1
1070 case Hexagon::JMP_GTriPtneg_ie_nv_V4:
1071 return Hexagon::JMP_GTriPtneg_nv_V4;
1072 case Hexagon::JMP_GTriNotPtneg_ie_nv_V4:
1073 return Hexagon::JMP_GTriNotPtneg_nv_V4;
1074 case Hexagon::JMP_GTriPntneg_ie_nv_V4:
1075 return Hexagon::JMP_GTriPntneg_nv_V4;
1076 case Hexagon::JMP_GTriNotPntneg_ie_nv_V4:
1077 return Hexagon::JMP_GTriNotPntneg_nv_V4;
1080 case Hexagon::JMP_GTrrPt_ie_nv_V4:
1081 return Hexagon::JMP_GTrrPt_nv_V4;
1082 case Hexagon::JMP_GTrrNotPt_ie_nv_V4:
1083 return Hexagon::JMP_GTrrNotPt_nv_V4;
1084 case Hexagon::JMP_GTrrPnt_ie_nv_V4:
1085 return Hexagon::JMP_GTrrPnt_nv_V4;
1086 case Hexagon::JMP_GTrrNotPnt_ie_nv_V4:
1087 return Hexagon::JMP_GTrrNotPnt_nv_V4;
1090 case Hexagon::JMP_GTrrdnPt_ie_nv_V4:
1091 return Hexagon::JMP_GTrrdnPt_nv_V4;
1092 case Hexagon::JMP_GTrrdnNotPt_ie_nv_V4:
1093 return Hexagon::JMP_GTrrdnNotPt_nv_V4;
1094 case Hexagon::JMP_GTrrdnPnt_ie_nv_V4:
1095 return Hexagon::JMP_GTrrdnPnt_nv_V4;
1096 case Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4:
1097 return Hexagon::JMP_GTrrdnNotPnt_nv_V4;
1100 case Hexagon::JMP_GTUriPt_ie_nv_V4:
1101 return Hexagon::JMP_GTUriPt_nv_V4;
1102 case Hexagon::JMP_GTUriNotPt_ie_nv_V4:
1103 return Hexagon::JMP_GTUriNotPt_nv_V4;
1104 case Hexagon::JMP_GTUriPnt_ie_nv_V4:
1105 return Hexagon::JMP_GTUriPnt_nv_V4;
1106 case Hexagon::JMP_GTUriNotPnt_ie_nv_V4:
1107 return Hexagon::JMP_GTUriNotPnt_nv_V4;
1110 case Hexagon::JMP_GTUrrPt_ie_nv_V4:
1111 return Hexagon::JMP_GTUrrPt_nv_V4;
1112 case Hexagon::JMP_GTUrrNotPt_ie_nv_V4:
1113 return Hexagon::JMP_GTUrrNotPt_nv_V4;
1114 case Hexagon::JMP_GTUrrPnt_ie_nv_V4:
1115 return Hexagon::JMP_GTUrrPnt_nv_V4;
1116 case Hexagon::JMP_GTUrrNotPnt_ie_nv_V4:
1117 return Hexagon::JMP_GTUrrNotPnt_nv_V4;
1120 case Hexagon::JMP_GTUrrdnPt_ie_nv_V4:
1121 return Hexagon::JMP_GTUrrdnPt_nv_V4;
1122 case Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4:
1123 return Hexagon::JMP_GTUrrdnNotPt_nv_V4;
1124 case Hexagon::JMP_GTUrrdnPnt_ie_nv_V4:
1125 return Hexagon::JMP_GTUrrdnPnt_nv_V4;
1126 case Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4:
1127 return Hexagon::JMP_GTUrrdnNotPnt_nv_V4;
1132 bool HexagonInstrInfo::isNewValueStore(const MachineInstr *MI) const {
1133 switch (MI->getOpcode()) {
1134 default: return false;
1136 case Hexagon::STrib_nv_V4:
1137 case Hexagon::STrib_indexed_nv_V4:
1138 case Hexagon::STrib_indexed_shl_nv_V4:
1139 case Hexagon::STrib_shl_nv_V4:
1140 case Hexagon::STb_GP_nv_V4:
1141 case Hexagon::POST_STbri_nv_V4:
1142 case Hexagon::STrib_cPt_nv_V4:
1143 case Hexagon::STrib_cdnPt_nv_V4:
1144 case Hexagon::STrib_cNotPt_nv_V4:
1145 case Hexagon::STrib_cdnNotPt_nv_V4:
1146 case Hexagon::STrib_indexed_cPt_nv_V4:
1147 case Hexagon::STrib_indexed_cdnPt_nv_V4:
1148 case Hexagon::STrib_indexed_cNotPt_nv_V4:
1149 case Hexagon::STrib_indexed_cdnNotPt_nv_V4:
1150 case Hexagon::STrib_indexed_shl_cPt_nv_V4:
1151 case Hexagon::STrib_indexed_shl_cdnPt_nv_V4:
1152 case Hexagon::STrib_indexed_shl_cNotPt_nv_V4:
1153 case Hexagon::STrib_indexed_shl_cdnNotPt_nv_V4:
1154 case Hexagon::POST_STbri_cPt_nv_V4:
1155 case Hexagon::POST_STbri_cdnPt_nv_V4:
1156 case Hexagon::POST_STbri_cNotPt_nv_V4:
1157 case Hexagon::POST_STbri_cdnNotPt_nv_V4:
1158 case Hexagon::STb_GP_cPt_nv_V4:
1159 case Hexagon::STb_GP_cNotPt_nv_V4:
1160 case Hexagon::STb_GP_cdnPt_nv_V4:
1161 case Hexagon::STb_GP_cdnNotPt_nv_V4:
1162 case Hexagon::STrib_abs_nv_V4:
1163 case Hexagon::STrib_abs_cPt_nv_V4:
1164 case Hexagon::STrib_abs_cdnPt_nv_V4:
1165 case Hexagon::STrib_abs_cNotPt_nv_V4:
1166 case Hexagon::STrib_abs_cdnNotPt_nv_V4:
1167 case Hexagon::STrib_imm_abs_nv_V4:
1168 case Hexagon::STrib_imm_abs_cPt_nv_V4:
1169 case Hexagon::STrib_imm_abs_cdnPt_nv_V4:
1170 case Hexagon::STrib_imm_abs_cNotPt_nv_V4:
1171 case Hexagon::STrib_imm_abs_cdnNotPt_nv_V4:
1174 case Hexagon::STrih_nv_V4:
1175 case Hexagon::STrih_indexed_nv_V4:
1176 case Hexagon::STrih_indexed_shl_nv_V4:
1177 case Hexagon::STrih_shl_nv_V4:
1178 case Hexagon::STh_GP_nv_V4:
1179 case Hexagon::POST_SThri_nv_V4:
1180 case Hexagon::STrih_cPt_nv_V4:
1181 case Hexagon::STrih_cdnPt_nv_V4:
1182 case Hexagon::STrih_cNotPt_nv_V4:
1183 case Hexagon::STrih_cdnNotPt_nv_V4:
1184 case Hexagon::STrih_indexed_cPt_nv_V4:
1185 case Hexagon::STrih_indexed_cdnPt_nv_V4:
1186 case Hexagon::STrih_indexed_cNotPt_nv_V4:
1187 case Hexagon::STrih_indexed_cdnNotPt_nv_V4:
1188 case Hexagon::STrih_indexed_shl_cPt_nv_V4:
1189 case Hexagon::STrih_indexed_shl_cdnPt_nv_V4:
1190 case Hexagon::STrih_indexed_shl_cNotPt_nv_V4:
1191 case Hexagon::STrih_indexed_shl_cdnNotPt_nv_V4:
1192 case Hexagon::POST_SThri_cPt_nv_V4:
1193 case Hexagon::POST_SThri_cdnPt_nv_V4:
1194 case Hexagon::POST_SThri_cNotPt_nv_V4:
1195 case Hexagon::POST_SThri_cdnNotPt_nv_V4:
1196 case Hexagon::STh_GP_cPt_nv_V4:
1197 case Hexagon::STh_GP_cNotPt_nv_V4:
1198 case Hexagon::STh_GP_cdnPt_nv_V4:
1199 case Hexagon::STh_GP_cdnNotPt_nv_V4:
1200 case Hexagon::STrih_abs_nv_V4:
1201 case Hexagon::STrih_abs_cPt_nv_V4:
1202 case Hexagon::STrih_abs_cdnPt_nv_V4:
1203 case Hexagon::STrih_abs_cNotPt_nv_V4:
1204 case Hexagon::STrih_abs_cdnNotPt_nv_V4:
1205 case Hexagon::STrih_imm_abs_nv_V4:
1206 case Hexagon::STrih_imm_abs_cPt_nv_V4:
1207 case Hexagon::STrih_imm_abs_cdnPt_nv_V4:
1208 case Hexagon::STrih_imm_abs_cNotPt_nv_V4:
1209 case Hexagon::STrih_imm_abs_cdnNotPt_nv_V4:
1212 case Hexagon::STriw_nv_V4:
1213 case Hexagon::STriw_indexed_nv_V4:
1214 case Hexagon::STriw_indexed_shl_nv_V4:
1215 case Hexagon::STriw_shl_nv_V4:
1216 case Hexagon::STw_GP_nv_V4:
1217 case Hexagon::POST_STwri_nv_V4:
1218 case Hexagon::STriw_cPt_nv_V4:
1219 case Hexagon::STriw_cdnPt_nv_V4:
1220 case Hexagon::STriw_cNotPt_nv_V4:
1221 case Hexagon::STriw_cdnNotPt_nv_V4:
1222 case Hexagon::STriw_indexed_cPt_nv_V4:
1223 case Hexagon::STriw_indexed_cdnPt_nv_V4:
1224 case Hexagon::STriw_indexed_cNotPt_nv_V4:
1225 case Hexagon::STriw_indexed_cdnNotPt_nv_V4:
1226 case Hexagon::STriw_indexed_shl_cPt_nv_V4:
1227 case Hexagon::STriw_indexed_shl_cdnPt_nv_V4:
1228 case Hexagon::STriw_indexed_shl_cNotPt_nv_V4:
1229 case Hexagon::STriw_indexed_shl_cdnNotPt_nv_V4:
1230 case Hexagon::POST_STwri_cPt_nv_V4:
1231 case Hexagon::POST_STwri_cdnPt_nv_V4:
1232 case Hexagon::POST_STwri_cNotPt_nv_V4:
1233 case Hexagon::POST_STwri_cdnNotPt_nv_V4:
1234 case Hexagon::STw_GP_cPt_nv_V4:
1235 case Hexagon::STw_GP_cNotPt_nv_V4:
1236 case Hexagon::STw_GP_cdnPt_nv_V4:
1237 case Hexagon::STw_GP_cdnNotPt_nv_V4:
1238 case Hexagon::STriw_abs_nv_V4:
1239 case Hexagon::STriw_abs_cPt_nv_V4:
1240 case Hexagon::STriw_abs_cdnPt_nv_V4:
1241 case Hexagon::STriw_abs_cNotPt_nv_V4:
1242 case Hexagon::STriw_abs_cdnNotPt_nv_V4:
1243 case Hexagon::STriw_imm_abs_nv_V4:
1244 case Hexagon::STriw_imm_abs_cPt_nv_V4:
1245 case Hexagon::STriw_imm_abs_cdnPt_nv_V4:
1246 case Hexagon::STriw_imm_abs_cNotPt_nv_V4:
1247 case Hexagon::STriw_imm_abs_cdnNotPt_nv_V4:
1252 bool HexagonInstrInfo::isPostIncrement (const MachineInstr* MI) const {
1253 switch (MI->getOpcode())
1255 default: return false;
1257 case Hexagon::POST_LDrib:
1258 case Hexagon::POST_LDrib_cPt:
1259 case Hexagon::POST_LDrib_cNotPt:
1260 case Hexagon::POST_LDrib_cdnPt_V4:
1261 case Hexagon::POST_LDrib_cdnNotPt_V4:
1263 // Load unsigned byte
1264 case Hexagon::POST_LDriub:
1265 case Hexagon::POST_LDriub_cPt:
1266 case Hexagon::POST_LDriub_cNotPt:
1267 case Hexagon::POST_LDriub_cdnPt_V4:
1268 case Hexagon::POST_LDriub_cdnNotPt_V4:
1271 case Hexagon::POST_LDrih:
1272 case Hexagon::POST_LDrih_cPt:
1273 case Hexagon::POST_LDrih_cNotPt:
1274 case Hexagon::POST_LDrih_cdnPt_V4:
1275 case Hexagon::POST_LDrih_cdnNotPt_V4:
1277 // Load unsigned halfword
1278 case Hexagon::POST_LDriuh:
1279 case Hexagon::POST_LDriuh_cPt:
1280 case Hexagon::POST_LDriuh_cNotPt:
1281 case Hexagon::POST_LDriuh_cdnPt_V4:
1282 case Hexagon::POST_LDriuh_cdnNotPt_V4:
1285 case Hexagon::POST_LDriw:
1286 case Hexagon::POST_LDriw_cPt:
1287 case Hexagon::POST_LDriw_cNotPt:
1288 case Hexagon::POST_LDriw_cdnPt_V4:
1289 case Hexagon::POST_LDriw_cdnNotPt_V4:
1292 case Hexagon::POST_LDrid:
1293 case Hexagon::POST_LDrid_cPt:
1294 case Hexagon::POST_LDrid_cNotPt:
1295 case Hexagon::POST_LDrid_cdnPt_V4:
1296 case Hexagon::POST_LDrid_cdnNotPt_V4:
1299 case Hexagon::POST_STbri:
1300 case Hexagon::POST_STbri_cPt:
1301 case Hexagon::POST_STbri_cNotPt:
1302 case Hexagon::POST_STbri_cdnPt_V4:
1303 case Hexagon::POST_STbri_cdnNotPt_V4:
1306 case Hexagon::POST_SThri:
1307 case Hexagon::POST_SThri_cPt:
1308 case Hexagon::POST_SThri_cNotPt:
1309 case Hexagon::POST_SThri_cdnPt_V4:
1310 case Hexagon::POST_SThri_cdnNotPt_V4:
1313 case Hexagon::POST_STwri:
1314 case Hexagon::POST_STwri_cPt:
1315 case Hexagon::POST_STwri_cNotPt:
1316 case Hexagon::POST_STwri_cdnPt_V4:
1317 case Hexagon::POST_STwri_cdnNotPt_V4:
1319 // Store double word
1320 case Hexagon::POST_STdri:
1321 case Hexagon::POST_STdri_cPt:
1322 case Hexagon::POST_STdri_cNotPt:
1323 case Hexagon::POST_STdri_cdnPt_V4:
1324 case Hexagon::POST_STdri_cdnNotPt_V4:
1329 bool HexagonInstrInfo::isSaveCalleeSavedRegsCall(const MachineInstr *MI) const {
1330 return MI->getOpcode() == Hexagon::SAVE_REGISTERS_CALL_V4;
1333 bool HexagonInstrInfo::isPredicable(MachineInstr *MI) const {
1334 bool isPred = MI->getDesc().isPredicable();
1339 const int Opc = MI->getOpcode();
1343 return isInt<12>(MI->getOperand(1).getImm());
1345 case Hexagon::STrid:
1346 case Hexagon::STrid_indexed:
1347 return isShiftedUInt<6,3>(MI->getOperand(1).getImm());
1349 case Hexagon::STriw:
1350 case Hexagon::STriw_indexed:
1351 case Hexagon::STriw_nv_V4:
1352 return isShiftedUInt<6,2>(MI->getOperand(1).getImm());
1354 case Hexagon::STrih:
1355 case Hexagon::STrih_indexed:
1356 case Hexagon::STrih_nv_V4:
1357 return isShiftedUInt<6,1>(MI->getOperand(1).getImm());
1359 case Hexagon::STrib:
1360 case Hexagon::STrib_indexed:
1361 case Hexagon::STrib_nv_V4:
1362 return isUInt<6>(MI->getOperand(1).getImm());
1364 case Hexagon::LDrid:
1365 case Hexagon::LDrid_indexed:
1366 return isShiftedUInt<6,3>(MI->getOperand(2).getImm());
1368 case Hexagon::LDriw:
1369 case Hexagon::LDriw_indexed:
1370 return isShiftedUInt<6,2>(MI->getOperand(2).getImm());
1372 case Hexagon::LDrih:
1373 case Hexagon::LDriuh:
1374 case Hexagon::LDrih_indexed:
1375 case Hexagon::LDriuh_indexed:
1376 return isShiftedUInt<6,1>(MI->getOperand(2).getImm());
1378 case Hexagon::LDrib:
1379 case Hexagon::LDriub:
1380 case Hexagon::LDrib_indexed:
1381 case Hexagon::LDriub_indexed:
1382 return isUInt<6>(MI->getOperand(2).getImm());
1384 case Hexagon::POST_LDrid:
1385 return isShiftedInt<4,3>(MI->getOperand(3).getImm());
1387 case Hexagon::POST_LDriw:
1388 return isShiftedInt<4,2>(MI->getOperand(3).getImm());
1390 case Hexagon::POST_LDrih:
1391 case Hexagon::POST_LDriuh:
1392 return isShiftedInt<4,1>(MI->getOperand(3).getImm());
1394 case Hexagon::POST_LDrib:
1395 case Hexagon::POST_LDriub:
1396 return isInt<4>(MI->getOperand(3).getImm());
1398 case Hexagon::STrib_imm_V4:
1399 case Hexagon::STrih_imm_V4:
1400 case Hexagon::STriw_imm_V4:
1401 return (isUInt<6>(MI->getOperand(1).getImm()) &&
1402 isInt<6>(MI->getOperand(2).getImm()));
1404 case Hexagon::ADD_ri:
1405 return isInt<8>(MI->getOperand(2).getImm());
1413 return Subtarget.hasV4TOps();
1422 // This function performs the following inversiones:
1427 // however, these inversiones are NOT included:
1429 // cdnPt -X-> cdnNotPt
1430 // cdnNotPt -X-> cdnPt
1431 // cPt_nv -X-> cNotPt_nv (new value stores)
1432 // cNotPt_nv -X-> cPt_nv (new value stores)
1434 // because only the following transformations are allowed:
1436 // cNotPt ---> cdnNotPt
1438 // cNotPt ---> cNotPt_nv
1440 unsigned HexagonInstrInfo::getInvertedPredicatedOpcode(const int Opc) const {
1442 default: llvm_unreachable("Unexpected predicated instruction");
1443 case Hexagon::TFR_cPt:
1444 return Hexagon::TFR_cNotPt;
1445 case Hexagon::TFR_cNotPt:
1446 return Hexagon::TFR_cPt;
1448 case Hexagon::TFRI_cPt:
1449 return Hexagon::TFRI_cNotPt;
1450 case Hexagon::TFRI_cNotPt:
1451 return Hexagon::TFRI_cPt;
1453 case Hexagon::JMP_c:
1454 return Hexagon::JMP_cNot;
1455 case Hexagon::JMP_cNot:
1456 return Hexagon::JMP_c;
1458 case Hexagon::ADD_ri_cPt:
1459 return Hexagon::ADD_ri_cNotPt;
1460 case Hexagon::ADD_ri_cNotPt:
1461 return Hexagon::ADD_ri_cPt;
1463 case Hexagon::ADD_rr_cPt:
1464 return Hexagon::ADD_rr_cNotPt;
1465 case Hexagon::ADD_rr_cNotPt:
1466 return Hexagon::ADD_rr_cPt;
1468 case Hexagon::XOR_rr_cPt:
1469 return Hexagon::XOR_rr_cNotPt;
1470 case Hexagon::XOR_rr_cNotPt:
1471 return Hexagon::XOR_rr_cPt;
1473 case Hexagon::AND_rr_cPt:
1474 return Hexagon::AND_rr_cNotPt;
1475 case Hexagon::AND_rr_cNotPt:
1476 return Hexagon::AND_rr_cPt;
1478 case Hexagon::OR_rr_cPt:
1479 return Hexagon::OR_rr_cNotPt;
1480 case Hexagon::OR_rr_cNotPt:
1481 return Hexagon::OR_rr_cPt;
1483 case Hexagon::SUB_rr_cPt:
1484 return Hexagon::SUB_rr_cNotPt;
1485 case Hexagon::SUB_rr_cNotPt:
1486 return Hexagon::SUB_rr_cPt;
1488 case Hexagon::COMBINE_rr_cPt:
1489 return Hexagon::COMBINE_rr_cNotPt;
1490 case Hexagon::COMBINE_rr_cNotPt:
1491 return Hexagon::COMBINE_rr_cPt;
1493 case Hexagon::ASLH_cPt_V4:
1494 return Hexagon::ASLH_cNotPt_V4;
1495 case Hexagon::ASLH_cNotPt_V4:
1496 return Hexagon::ASLH_cPt_V4;
1498 case Hexagon::ASRH_cPt_V4:
1499 return Hexagon::ASRH_cNotPt_V4;
1500 case Hexagon::ASRH_cNotPt_V4:
1501 return Hexagon::ASRH_cPt_V4;
1503 case Hexagon::SXTB_cPt_V4:
1504 return Hexagon::SXTB_cNotPt_V4;
1505 case Hexagon::SXTB_cNotPt_V4:
1506 return Hexagon::SXTB_cPt_V4;
1508 case Hexagon::SXTH_cPt_V4:
1509 return Hexagon::SXTH_cNotPt_V4;
1510 case Hexagon::SXTH_cNotPt_V4:
1511 return Hexagon::SXTH_cPt_V4;
1513 case Hexagon::ZXTB_cPt_V4:
1514 return Hexagon::ZXTB_cNotPt_V4;
1515 case Hexagon::ZXTB_cNotPt_V4:
1516 return Hexagon::ZXTB_cPt_V4;
1518 case Hexagon::ZXTH_cPt_V4:
1519 return Hexagon::ZXTH_cNotPt_V4;
1520 case Hexagon::ZXTH_cNotPt_V4:
1521 return Hexagon::ZXTH_cPt_V4;
1524 case Hexagon::JMPR_cPt:
1525 return Hexagon::JMPR_cNotPt;
1526 case Hexagon::JMPR_cNotPt:
1527 return Hexagon::JMPR_cPt;
1529 // V4 indexed+scaled load.
1530 case Hexagon::LDrid_indexed_shl_cPt_V4:
1531 return Hexagon::LDrid_indexed_shl_cNotPt_V4;
1532 case Hexagon::LDrid_indexed_shl_cNotPt_V4:
1533 return Hexagon::LDrid_indexed_shl_cPt_V4;
1535 case Hexagon::LDrib_indexed_shl_cPt_V4:
1536 return Hexagon::LDrib_indexed_shl_cNotPt_V4;
1537 case Hexagon::LDrib_indexed_shl_cNotPt_V4:
1538 return Hexagon::LDrib_indexed_shl_cPt_V4;
1540 case Hexagon::LDriub_indexed_shl_cPt_V4:
1541 return Hexagon::LDriub_indexed_shl_cNotPt_V4;
1542 case Hexagon::LDriub_indexed_shl_cNotPt_V4:
1543 return Hexagon::LDriub_indexed_shl_cPt_V4;
1545 case Hexagon::LDrih_indexed_shl_cPt_V4:
1546 return Hexagon::LDrih_indexed_shl_cNotPt_V4;
1547 case Hexagon::LDrih_indexed_shl_cNotPt_V4:
1548 return Hexagon::LDrih_indexed_shl_cPt_V4;
1550 case Hexagon::LDriuh_indexed_shl_cPt_V4:
1551 return Hexagon::LDriuh_indexed_shl_cNotPt_V4;
1552 case Hexagon::LDriuh_indexed_shl_cNotPt_V4:
1553 return Hexagon::LDriuh_indexed_shl_cPt_V4;
1555 case Hexagon::LDriw_indexed_shl_cPt_V4:
1556 return Hexagon::LDriw_indexed_shl_cNotPt_V4;
1557 case Hexagon::LDriw_indexed_shl_cNotPt_V4:
1558 return Hexagon::LDriw_indexed_shl_cPt_V4;
1561 case Hexagon::POST_STbri_cPt:
1562 return Hexagon::POST_STbri_cNotPt;
1563 case Hexagon::POST_STbri_cNotPt:
1564 return Hexagon::POST_STbri_cPt;
1566 case Hexagon::STrib_cPt:
1567 return Hexagon::STrib_cNotPt;
1568 case Hexagon::STrib_cNotPt:
1569 return Hexagon::STrib_cPt;
1571 case Hexagon::STrib_indexed_cPt:
1572 return Hexagon::STrib_indexed_cNotPt;
1573 case Hexagon::STrib_indexed_cNotPt:
1574 return Hexagon::STrib_indexed_cPt;
1576 case Hexagon::STrib_imm_cPt_V4:
1577 return Hexagon::STrib_imm_cNotPt_V4;
1578 case Hexagon::STrib_imm_cNotPt_V4:
1579 return Hexagon::STrib_imm_cPt_V4;
1581 case Hexagon::STrib_indexed_shl_cPt_V4:
1582 return Hexagon::STrib_indexed_shl_cNotPt_V4;
1583 case Hexagon::STrib_indexed_shl_cNotPt_V4:
1584 return Hexagon::STrib_indexed_shl_cPt_V4;
1587 case Hexagon::POST_SThri_cPt:
1588 return Hexagon::POST_SThri_cNotPt;
1589 case Hexagon::POST_SThri_cNotPt:
1590 return Hexagon::POST_SThri_cPt;
1592 case Hexagon::STrih_cPt:
1593 return Hexagon::STrih_cNotPt;
1594 case Hexagon::STrih_cNotPt:
1595 return Hexagon::STrih_cPt;
1597 case Hexagon::STrih_indexed_cPt:
1598 return Hexagon::STrih_indexed_cNotPt;
1599 case Hexagon::STrih_indexed_cNotPt:
1600 return Hexagon::STrih_indexed_cPt;
1602 case Hexagon::STrih_imm_cPt_V4:
1603 return Hexagon::STrih_imm_cNotPt_V4;
1604 case Hexagon::STrih_imm_cNotPt_V4:
1605 return Hexagon::STrih_imm_cPt_V4;
1607 case Hexagon::STrih_indexed_shl_cPt_V4:
1608 return Hexagon::STrih_indexed_shl_cNotPt_V4;
1609 case Hexagon::STrih_indexed_shl_cNotPt_V4:
1610 return Hexagon::STrih_indexed_shl_cPt_V4;
1613 case Hexagon::POST_STwri_cPt:
1614 return Hexagon::POST_STwri_cNotPt;
1615 case Hexagon::POST_STwri_cNotPt:
1616 return Hexagon::POST_STwri_cPt;
1618 case Hexagon::STriw_cPt:
1619 return Hexagon::STriw_cNotPt;
1620 case Hexagon::STriw_cNotPt:
1621 return Hexagon::STriw_cPt;
1623 case Hexagon::STriw_indexed_cPt:
1624 return Hexagon::STriw_indexed_cNotPt;
1625 case Hexagon::STriw_indexed_cNotPt:
1626 return Hexagon::STriw_indexed_cPt;
1628 case Hexagon::STriw_indexed_shl_cPt_V4:
1629 return Hexagon::STriw_indexed_shl_cNotPt_V4;
1630 case Hexagon::STriw_indexed_shl_cNotPt_V4:
1631 return Hexagon::STriw_indexed_shl_cPt_V4;
1633 case Hexagon::STriw_imm_cPt_V4:
1634 return Hexagon::STriw_imm_cNotPt_V4;
1635 case Hexagon::STriw_imm_cNotPt_V4:
1636 return Hexagon::STriw_imm_cPt_V4;
1639 case Hexagon::POST_STdri_cPt:
1640 return Hexagon::POST_STdri_cNotPt;
1641 case Hexagon::POST_STdri_cNotPt:
1642 return Hexagon::POST_STdri_cPt;
1644 case Hexagon::STrid_cPt:
1645 return Hexagon::STrid_cNotPt;
1646 case Hexagon::STrid_cNotPt:
1647 return Hexagon::STrid_cPt;
1649 case Hexagon::STrid_indexed_cPt:
1650 return Hexagon::STrid_indexed_cNotPt;
1651 case Hexagon::STrid_indexed_cNotPt:
1652 return Hexagon::STrid_indexed_cPt;
1654 case Hexagon::STrid_indexed_shl_cPt_V4:
1655 return Hexagon::STrid_indexed_shl_cNotPt_V4;
1656 case Hexagon::STrid_indexed_shl_cNotPt_V4:
1657 return Hexagon::STrid_indexed_shl_cPt_V4;
1659 // V4 Store to global address.
1660 case Hexagon::STd_GP_cPt_V4:
1661 return Hexagon::STd_GP_cNotPt_V4;
1662 case Hexagon::STd_GP_cNotPt_V4:
1663 return Hexagon::STd_GP_cPt_V4;
1665 case Hexagon::STb_GP_cPt_V4:
1666 return Hexagon::STb_GP_cNotPt_V4;
1667 case Hexagon::STb_GP_cNotPt_V4:
1668 return Hexagon::STb_GP_cPt_V4;
1670 case Hexagon::STh_GP_cPt_V4:
1671 return Hexagon::STh_GP_cNotPt_V4;
1672 case Hexagon::STh_GP_cNotPt_V4:
1673 return Hexagon::STh_GP_cPt_V4;
1675 case Hexagon::STw_GP_cPt_V4:
1676 return Hexagon::STw_GP_cNotPt_V4;
1677 case Hexagon::STw_GP_cNotPt_V4:
1678 return Hexagon::STw_GP_cPt_V4;
1681 case Hexagon::LDrid_cPt:
1682 return Hexagon::LDrid_cNotPt;
1683 case Hexagon::LDrid_cNotPt:
1684 return Hexagon::LDrid_cPt;
1686 case Hexagon::LDriw_cPt:
1687 return Hexagon::LDriw_cNotPt;
1688 case Hexagon::LDriw_cNotPt:
1689 return Hexagon::LDriw_cPt;
1691 case Hexagon::LDrih_cPt:
1692 return Hexagon::LDrih_cNotPt;
1693 case Hexagon::LDrih_cNotPt:
1694 return Hexagon::LDrih_cPt;
1696 case Hexagon::LDriuh_cPt:
1697 return Hexagon::LDriuh_cNotPt;
1698 case Hexagon::LDriuh_cNotPt:
1699 return Hexagon::LDriuh_cPt;
1701 case Hexagon::LDrib_cPt:
1702 return Hexagon::LDrib_cNotPt;
1703 case Hexagon::LDrib_cNotPt:
1704 return Hexagon::LDrib_cPt;
1706 case Hexagon::LDriub_cPt:
1707 return Hexagon::LDriub_cNotPt;
1708 case Hexagon::LDriub_cNotPt:
1709 return Hexagon::LDriub_cPt;
1712 case Hexagon::LDrid_indexed_cPt:
1713 return Hexagon::LDrid_indexed_cNotPt;
1714 case Hexagon::LDrid_indexed_cNotPt:
1715 return Hexagon::LDrid_indexed_cPt;
1717 case Hexagon::LDriw_indexed_cPt:
1718 return Hexagon::LDriw_indexed_cNotPt;
1719 case Hexagon::LDriw_indexed_cNotPt:
1720 return Hexagon::LDriw_indexed_cPt;
1722 case Hexagon::LDrih_indexed_cPt:
1723 return Hexagon::LDrih_indexed_cNotPt;
1724 case Hexagon::LDrih_indexed_cNotPt:
1725 return Hexagon::LDrih_indexed_cPt;
1727 case Hexagon::LDriuh_indexed_cPt:
1728 return Hexagon::LDriuh_indexed_cNotPt;
1729 case Hexagon::LDriuh_indexed_cNotPt:
1730 return Hexagon::LDriuh_indexed_cPt;
1732 case Hexagon::LDrib_indexed_cPt:
1733 return Hexagon::LDrib_indexed_cNotPt;
1734 case Hexagon::LDrib_indexed_cNotPt:
1735 return Hexagon::LDrib_indexed_cPt;
1737 case Hexagon::LDriub_indexed_cPt:
1738 return Hexagon::LDriub_indexed_cNotPt;
1739 case Hexagon::LDriub_indexed_cNotPt:
1740 return Hexagon::LDriub_indexed_cPt;
1743 case Hexagon::POST_LDrid_cPt:
1744 return Hexagon::POST_LDrid_cNotPt;
1745 case Hexagon::POST_LDriw_cNotPt:
1746 return Hexagon::POST_LDriw_cPt;
1748 case Hexagon::POST_LDrih_cPt:
1749 return Hexagon::POST_LDrih_cNotPt;
1750 case Hexagon::POST_LDrih_cNotPt:
1751 return Hexagon::POST_LDrih_cPt;
1753 case Hexagon::POST_LDriuh_cPt:
1754 return Hexagon::POST_LDriuh_cNotPt;
1755 case Hexagon::POST_LDriuh_cNotPt:
1756 return Hexagon::POST_LDriuh_cPt;
1758 case Hexagon::POST_LDrib_cPt:
1759 return Hexagon::POST_LDrib_cNotPt;
1760 case Hexagon::POST_LDrib_cNotPt:
1761 return Hexagon::POST_LDrib_cPt;
1763 case Hexagon::POST_LDriub_cPt:
1764 return Hexagon::POST_LDriub_cNotPt;
1765 case Hexagon::POST_LDriub_cNotPt:
1766 return Hexagon::POST_LDriub_cPt;
1769 case Hexagon::DEALLOC_RET_cPt_V4:
1770 return Hexagon::DEALLOC_RET_cNotPt_V4;
1771 case Hexagon::DEALLOC_RET_cNotPt_V4:
1772 return Hexagon::DEALLOC_RET_cPt_V4;
1775 // JMPEQ_ri - with -1.
1776 case Hexagon::JMP_EQriPtneg_nv_V4:
1777 return Hexagon::JMP_EQriNotPtneg_nv_V4;
1778 case Hexagon::JMP_EQriNotPtneg_nv_V4:
1779 return Hexagon::JMP_EQriPtneg_nv_V4;
1781 case Hexagon::JMP_EQriPntneg_nv_V4:
1782 return Hexagon::JMP_EQriNotPntneg_nv_V4;
1783 case Hexagon::JMP_EQriNotPntneg_nv_V4:
1784 return Hexagon::JMP_EQriPntneg_nv_V4;
1787 case Hexagon::JMP_EQriPt_nv_V4:
1788 return Hexagon::JMP_EQriNotPt_nv_V4;
1789 case Hexagon::JMP_EQriNotPt_nv_V4:
1790 return Hexagon::JMP_EQriPt_nv_V4;
1792 case Hexagon::JMP_EQriPnt_nv_V4:
1793 return Hexagon::JMP_EQriNotPnt_nv_V4;
1794 case Hexagon::JMP_EQriNotPnt_nv_V4:
1795 return Hexagon::JMP_EQriPnt_nv_V4;
1798 case Hexagon::JMP_EQrrPt_nv_V4:
1799 return Hexagon::JMP_EQrrNotPt_nv_V4;
1800 case Hexagon::JMP_EQrrNotPt_nv_V4:
1801 return Hexagon::JMP_EQrrPt_nv_V4;
1803 case Hexagon::JMP_EQrrPnt_nv_V4:
1804 return Hexagon::JMP_EQrrNotPnt_nv_V4;
1805 case Hexagon::JMP_EQrrNotPnt_nv_V4:
1806 return Hexagon::JMP_EQrrPnt_nv_V4;
1808 // JMPGT_ri - with -1.
1809 case Hexagon::JMP_GTriPtneg_nv_V4:
1810 return Hexagon::JMP_GTriNotPtneg_nv_V4;
1811 case Hexagon::JMP_GTriNotPtneg_nv_V4:
1812 return Hexagon::JMP_GTriPtneg_nv_V4;
1814 case Hexagon::JMP_GTriPntneg_nv_V4:
1815 return Hexagon::JMP_GTriNotPntneg_nv_V4;
1816 case Hexagon::JMP_GTriNotPntneg_nv_V4:
1817 return Hexagon::JMP_GTriPntneg_nv_V4;
1820 case Hexagon::JMP_GTriPt_nv_V4:
1821 return Hexagon::JMP_GTriNotPt_nv_V4;
1822 case Hexagon::JMP_GTriNotPt_nv_V4:
1823 return Hexagon::JMP_GTriPt_nv_V4;
1825 case Hexagon::JMP_GTriPnt_nv_V4:
1826 return Hexagon::JMP_GTriNotPnt_nv_V4;
1827 case Hexagon::JMP_GTriNotPnt_nv_V4:
1828 return Hexagon::JMP_GTriPnt_nv_V4;
1831 case Hexagon::JMP_GTrrPt_nv_V4:
1832 return Hexagon::JMP_GTrrNotPt_nv_V4;
1833 case Hexagon::JMP_GTrrNotPt_nv_V4:
1834 return Hexagon::JMP_GTrrPt_nv_V4;
1836 case Hexagon::JMP_GTrrPnt_nv_V4:
1837 return Hexagon::JMP_GTrrNotPnt_nv_V4;
1838 case Hexagon::JMP_GTrrNotPnt_nv_V4:
1839 return Hexagon::JMP_GTrrPnt_nv_V4;
1842 case Hexagon::JMP_GTrrdnPt_nv_V4:
1843 return Hexagon::JMP_GTrrdnNotPt_nv_V4;
1844 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
1845 return Hexagon::JMP_GTrrdnPt_nv_V4;
1847 case Hexagon::JMP_GTrrdnPnt_nv_V4:
1848 return Hexagon::JMP_GTrrdnNotPnt_nv_V4;
1849 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
1850 return Hexagon::JMP_GTrrdnPnt_nv_V4;
1853 case Hexagon::JMP_GTUriPt_nv_V4:
1854 return Hexagon::JMP_GTUriNotPt_nv_V4;
1855 case Hexagon::JMP_GTUriNotPt_nv_V4:
1856 return Hexagon::JMP_GTUriPt_nv_V4;
1858 case Hexagon::JMP_GTUriPnt_nv_V4:
1859 return Hexagon::JMP_GTUriNotPnt_nv_V4;
1860 case Hexagon::JMP_GTUriNotPnt_nv_V4:
1861 return Hexagon::JMP_GTUriPnt_nv_V4;
1864 case Hexagon::JMP_GTUrrPt_nv_V4:
1865 return Hexagon::JMP_GTUrrNotPt_nv_V4;
1866 case Hexagon::JMP_GTUrrNotPt_nv_V4:
1867 return Hexagon::JMP_GTUrrPt_nv_V4;
1869 case Hexagon::JMP_GTUrrPnt_nv_V4:
1870 return Hexagon::JMP_GTUrrNotPnt_nv_V4;
1871 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
1872 return Hexagon::JMP_GTUrrPnt_nv_V4;
1875 case Hexagon::JMP_GTUrrdnPt_nv_V4:
1876 return Hexagon::JMP_GTUrrdnNotPt_nv_V4;
1877 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
1878 return Hexagon::JMP_GTUrrdnPt_nv_V4;
1880 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
1881 return Hexagon::JMP_GTUrrdnNotPnt_nv_V4;
1882 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
1883 return Hexagon::JMP_GTUrrdnPnt_nv_V4;
1888 int HexagonInstrInfo::
1889 getMatchingCondBranchOpcode(int Opc, bool invertPredicate) const {
1890 enum Hexagon::PredSense inPredSense;
1891 inPredSense = invertPredicate ? Hexagon::PredSense_false :
1892 Hexagon::PredSense_true;
1893 int CondOpcode = Hexagon::getPredOpcode(Opc, inPredSense);
1894 if (CondOpcode >= 0) // Valid Conditional opcode/instruction
1897 // This switch case will be removed once all the instructions have been
1898 // modified to use relation maps.
1901 return !invertPredicate ? Hexagon::TFR_cPt :
1902 Hexagon::TFR_cNotPt;
1903 case Hexagon::TFRI_f:
1904 return !invertPredicate ? Hexagon::TFRI_cPt_f :
1905 Hexagon::TFRI_cNotPt_f;
1907 return !invertPredicate ? Hexagon::TFRI_cPt :
1908 Hexagon::TFRI_cNotPt;
1910 return !invertPredicate ? Hexagon::JMP_c :
1912 case Hexagon::JMP_EQrrPt_nv_V4:
1913 return !invertPredicate ? Hexagon::JMP_EQrrPt_nv_V4 :
1914 Hexagon::JMP_EQrrNotPt_nv_V4;
1915 case Hexagon::JMP_EQriPt_nv_V4:
1916 return !invertPredicate ? Hexagon::JMP_EQriPt_nv_V4 :
1917 Hexagon::JMP_EQriNotPt_nv_V4;
1918 case Hexagon::COMBINE_rr:
1919 return !invertPredicate ? Hexagon::COMBINE_rr_cPt :
1920 Hexagon::COMBINE_rr_cNotPt;
1922 return !invertPredicate ? Hexagon::ASLH_cPt_V4 :
1923 Hexagon::ASLH_cNotPt_V4;
1925 return !invertPredicate ? Hexagon::ASRH_cPt_V4 :
1926 Hexagon::ASRH_cNotPt_V4;
1928 return !invertPredicate ? Hexagon::SXTB_cPt_V4 :
1929 Hexagon::SXTB_cNotPt_V4;
1931 return !invertPredicate ? Hexagon::SXTH_cPt_V4 :
1932 Hexagon::SXTH_cNotPt_V4;
1934 return !invertPredicate ? Hexagon::ZXTB_cPt_V4 :
1935 Hexagon::ZXTB_cNotPt_V4;
1937 return !invertPredicate ? Hexagon::ZXTH_cPt_V4 :
1938 Hexagon::ZXTH_cNotPt_V4;
1941 return !invertPredicate ? Hexagon::JMPR_cPt :
1942 Hexagon::JMPR_cNotPt;
1944 // V4 indexed+scaled load.
1945 case Hexagon::LDrid_indexed_shl_V4:
1946 return !invertPredicate ? Hexagon::LDrid_indexed_shl_cPt_V4 :
1947 Hexagon::LDrid_indexed_shl_cNotPt_V4;
1948 case Hexagon::LDrib_indexed_shl_V4:
1949 return !invertPredicate ? Hexagon::LDrib_indexed_shl_cPt_V4 :
1950 Hexagon::LDrib_indexed_shl_cNotPt_V4;
1951 case Hexagon::LDriub_indexed_shl_V4:
1952 return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 :
1953 Hexagon::LDriub_indexed_shl_cNotPt_V4;
1954 case Hexagon::LDrih_indexed_shl_V4:
1955 return !invertPredicate ? Hexagon::LDrih_indexed_shl_cPt_V4 :
1956 Hexagon::LDrih_indexed_shl_cNotPt_V4;
1957 case Hexagon::LDriuh_indexed_shl_V4:
1958 return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 :
1959 Hexagon::LDriuh_indexed_shl_cNotPt_V4;
1960 case Hexagon::LDriw_indexed_shl_V4:
1961 return !invertPredicate ? Hexagon::LDriw_indexed_shl_cPt_V4 :
1962 Hexagon::LDriw_indexed_shl_cNotPt_V4;
1964 // V4 Load from global address
1965 case Hexagon::LDd_GP_V4:
1966 return !invertPredicate ? Hexagon::LDd_GP_cPt_V4 :
1967 Hexagon::LDd_GP_cNotPt_V4;
1968 case Hexagon::LDb_GP_V4:
1969 return !invertPredicate ? Hexagon::LDb_GP_cPt_V4 :
1970 Hexagon::LDb_GP_cNotPt_V4;
1971 case Hexagon::LDub_GP_V4:
1972 return !invertPredicate ? Hexagon::LDub_GP_cPt_V4 :
1973 Hexagon::LDub_GP_cNotPt_V4;
1974 case Hexagon::LDh_GP_V4:
1975 return !invertPredicate ? Hexagon::LDh_GP_cPt_V4 :
1976 Hexagon::LDh_GP_cNotPt_V4;
1977 case Hexagon::LDuh_GP_V4:
1978 return !invertPredicate ? Hexagon::LDuh_GP_cPt_V4 :
1979 Hexagon::LDuh_GP_cNotPt_V4;
1980 case Hexagon::LDw_GP_V4:
1981 return !invertPredicate ? Hexagon::LDw_GP_cPt_V4 :
1982 Hexagon::LDw_GP_cNotPt_V4;
1985 case Hexagon::POST_STbri:
1986 return !invertPredicate ? Hexagon::POST_STbri_cPt :
1987 Hexagon::POST_STbri_cNotPt;
1988 case Hexagon::STrib:
1989 return !invertPredicate ? Hexagon::STrib_cPt :
1990 Hexagon::STrib_cNotPt;
1991 case Hexagon::STrib_indexed:
1992 return !invertPredicate ? Hexagon::STrib_indexed_cPt :
1993 Hexagon::STrib_indexed_cNotPt;
1994 case Hexagon::STrib_imm_V4:
1995 return !invertPredicate ? Hexagon::STrib_imm_cPt_V4 :
1996 Hexagon::STrib_imm_cNotPt_V4;
1997 case Hexagon::STrib_indexed_shl_V4:
1998 return !invertPredicate ? Hexagon::STrib_indexed_shl_cPt_V4 :
1999 Hexagon::STrib_indexed_shl_cNotPt_V4;
2001 case Hexagon::POST_SThri:
2002 return !invertPredicate ? Hexagon::POST_SThri_cPt :
2003 Hexagon::POST_SThri_cNotPt;
2004 case Hexagon::STrih:
2005 return !invertPredicate ? Hexagon::STrih_cPt :
2006 Hexagon::STrih_cNotPt;
2007 case Hexagon::STrih_indexed:
2008 return !invertPredicate ? Hexagon::STrih_indexed_cPt :
2009 Hexagon::STrih_indexed_cNotPt;
2010 case Hexagon::STrih_imm_V4:
2011 return !invertPredicate ? Hexagon::STrih_imm_cPt_V4 :
2012 Hexagon::STrih_imm_cNotPt_V4;
2013 case Hexagon::STrih_indexed_shl_V4:
2014 return !invertPredicate ? Hexagon::STrih_indexed_shl_cPt_V4 :
2015 Hexagon::STrih_indexed_shl_cNotPt_V4;
2017 case Hexagon::POST_STwri:
2018 return !invertPredicate ? Hexagon::POST_STwri_cPt :
2019 Hexagon::POST_STwri_cNotPt;
2020 case Hexagon::STriw:
2021 return !invertPredicate ? Hexagon::STriw_cPt :
2022 Hexagon::STriw_cNotPt;
2023 case Hexagon::STriw_indexed:
2024 return !invertPredicate ? Hexagon::STriw_indexed_cPt :
2025 Hexagon::STriw_indexed_cNotPt;
2026 case Hexagon::STriw_indexed_shl_V4:
2027 return !invertPredicate ? Hexagon::STriw_indexed_shl_cPt_V4 :
2028 Hexagon::STriw_indexed_shl_cNotPt_V4;
2029 case Hexagon::STriw_imm_V4:
2030 return !invertPredicate ? Hexagon::STriw_imm_cPt_V4 :
2031 Hexagon::STriw_imm_cNotPt_V4;
2033 case Hexagon::POST_STdri:
2034 return !invertPredicate ? Hexagon::POST_STdri_cPt :
2035 Hexagon::POST_STdri_cNotPt;
2036 case Hexagon::STrid:
2037 return !invertPredicate ? Hexagon::STrid_cPt :
2038 Hexagon::STrid_cNotPt;
2039 case Hexagon::STrid_indexed:
2040 return !invertPredicate ? Hexagon::STrid_indexed_cPt :
2041 Hexagon::STrid_indexed_cNotPt;
2042 case Hexagon::STrid_indexed_shl_V4:
2043 return !invertPredicate ? Hexagon::STrid_indexed_shl_cPt_V4 :
2044 Hexagon::STrid_indexed_shl_cNotPt_V4;
2046 // V4 Store to global address
2047 case Hexagon::STd_GP_V4:
2048 return !invertPredicate ? Hexagon::STd_GP_cPt_V4 :
2049 Hexagon::STd_GP_cNotPt_V4;
2050 case Hexagon::STb_GP_V4:
2051 return !invertPredicate ? Hexagon::STb_GP_cPt_V4 :
2052 Hexagon::STb_GP_cNotPt_V4;
2053 case Hexagon::STh_GP_V4:
2054 return !invertPredicate ? Hexagon::STh_GP_cPt_V4 :
2055 Hexagon::STh_GP_cNotPt_V4;
2056 case Hexagon::STw_GP_V4:
2057 return !invertPredicate ? Hexagon::STw_GP_cPt_V4 :
2058 Hexagon::STw_GP_cNotPt_V4;
2061 case Hexagon::LDrid:
2062 return !invertPredicate ? Hexagon::LDrid_cPt :
2063 Hexagon::LDrid_cNotPt;
2064 case Hexagon::LDriw:
2065 return !invertPredicate ? Hexagon::LDriw_cPt :
2066 Hexagon::LDriw_cNotPt;
2067 case Hexagon::LDrih:
2068 return !invertPredicate ? Hexagon::LDrih_cPt :
2069 Hexagon::LDrih_cNotPt;
2070 case Hexagon::LDriuh:
2071 return !invertPredicate ? Hexagon::LDriuh_cPt :
2072 Hexagon::LDriuh_cNotPt;
2073 case Hexagon::LDrib:
2074 return !invertPredicate ? Hexagon::LDrib_cPt :
2075 Hexagon::LDrib_cNotPt;
2076 case Hexagon::LDriub:
2077 return !invertPredicate ? Hexagon::LDriub_cPt :
2078 Hexagon::LDriub_cNotPt;
2080 case Hexagon::LDrid_indexed:
2081 return !invertPredicate ? Hexagon::LDrid_indexed_cPt :
2082 Hexagon::LDrid_indexed_cNotPt;
2083 case Hexagon::LDriw_indexed:
2084 return !invertPredicate ? Hexagon::LDriw_indexed_cPt :
2085 Hexagon::LDriw_indexed_cNotPt;
2086 case Hexagon::LDrih_indexed:
2087 return !invertPredicate ? Hexagon::LDrih_indexed_cPt :
2088 Hexagon::LDrih_indexed_cNotPt;
2089 case Hexagon::LDriuh_indexed:
2090 return !invertPredicate ? Hexagon::LDriuh_indexed_cPt :
2091 Hexagon::LDriuh_indexed_cNotPt;
2092 case Hexagon::LDrib_indexed:
2093 return !invertPredicate ? Hexagon::LDrib_indexed_cPt :
2094 Hexagon::LDrib_indexed_cNotPt;
2095 case Hexagon::LDriub_indexed:
2096 return !invertPredicate ? Hexagon::LDriub_indexed_cPt :
2097 Hexagon::LDriub_indexed_cNotPt;
2098 // Post Increment Load.
2099 case Hexagon::POST_LDrid:
2100 return !invertPredicate ? Hexagon::POST_LDrid_cPt :
2101 Hexagon::POST_LDrid_cNotPt;
2102 case Hexagon::POST_LDriw:
2103 return !invertPredicate ? Hexagon::POST_LDriw_cPt :
2104 Hexagon::POST_LDriw_cNotPt;
2105 case Hexagon::POST_LDrih:
2106 return !invertPredicate ? Hexagon::POST_LDrih_cPt :
2107 Hexagon::POST_LDrih_cNotPt;
2108 case Hexagon::POST_LDriuh:
2109 return !invertPredicate ? Hexagon::POST_LDriuh_cPt :
2110 Hexagon::POST_LDriuh_cNotPt;
2111 case Hexagon::POST_LDrib:
2112 return !invertPredicate ? Hexagon::POST_LDrib_cPt :
2113 Hexagon::POST_LDrib_cNotPt;
2114 case Hexagon::POST_LDriub:
2115 return !invertPredicate ? Hexagon::POST_LDriub_cPt :
2116 Hexagon::POST_LDriub_cNotPt;
2118 case Hexagon::DEALLOC_RET_V4:
2119 return !invertPredicate ? Hexagon::DEALLOC_RET_cPt_V4 :
2120 Hexagon::DEALLOC_RET_cNotPt_V4;
2122 llvm_unreachable("Unexpected predicable instruction");
2126 bool HexagonInstrInfo::
2127 PredicateInstruction(MachineInstr *MI,
2128 const SmallVectorImpl<MachineOperand> &Cond) const {
2129 int Opc = MI->getOpcode();
2130 assert (isPredicable(MI) && "Expected predicable instruction");
2131 bool invertJump = (!Cond.empty() && Cond[0].isImm() &&
2132 (Cond[0].getImm() == 0));
2134 // This will change MI's opcode to its predicate version.
2135 // However, its operand list is still the old one, i.e. the
2136 // non-predicate one.
2137 MI->setDesc(get(getMatchingCondBranchOpcode(Opc, invertJump)));
2140 unsigned int GAIdx = 0;
2142 // Indicates whether the current MI has a GlobalAddress operand
2143 bool hasGAOpnd = false;
2144 std::vector<MachineOperand> tmpOpnds;
2146 // Indicates whether we need to shift operands to right.
2147 bool needShift = true;
2149 // The predicate is ALWAYS the FIRST input operand !!!
2150 if (MI->getNumOperands() == 0) {
2151 // The non-predicate version of MI does not take any operands,
2152 // i.e. no outs and no ins. In this condition, the predicate
2153 // operand will be directly placed at Operands[0]. No operand
2159 else if ( MI->getOperand(MI->getNumOperands()-1).isReg()
2160 && MI->getOperand(MI->getNumOperands()-1).isDef()
2161 && !MI->getOperand(MI->getNumOperands()-1).isImplicit()) {
2162 // The non-predicate version of MI does not have any input operands.
2163 // In this condition, we extend the length of Operands[] by one and
2164 // copy the original last operand to the newly allocated slot.
2165 // At this moment, it is just a place holder. Later, we will put
2166 // predicate operand directly into it. No operand shift is needed.
2167 // Example: r0=BARRIER (this is a faked insn used here for illustration)
2168 MI->addOperand(MI->getOperand(MI->getNumOperands()-1));
2170 oper = MI->getNumOperands() - 2;
2173 // We need to right shift all input operands by one. Duplicate the
2174 // last operand into the newly allocated slot.
2175 MI->addOperand(MI->getOperand(MI->getNumOperands()-1));
2180 // Operands[ MI->getNumOperands() - 2 ] has been copied into
2181 // Operands[ MI->getNumOperands() - 1 ], so we start from
2182 // Operands[ MI->getNumOperands() - 3 ].
2183 // oper is a signed int.
2184 // It is ok if "MI->getNumOperands()-3" is -3, -2, or -1.
2185 for (oper = MI->getNumOperands() - 3; oper >= 0; --oper)
2187 MachineOperand &MO = MI->getOperand(oper);
2189 // Opnd[0] Opnd[1] Opnd[2] Opnd[3] Opnd[4] Opnd[5] Opnd[6] Opnd[7]
2190 // <Def0> <Def1> <Use0> <Use1> <ImpDef0> <ImpDef1> <ImpUse0> <ImpUse1>
2194 // Predicate Operand here
2195 if (MO.isReg() && !MO.isUse() && !MO.isImplicit()) {
2199 MI->getOperand(oper+1).ChangeToRegister(MO.getReg(), MO.isDef(),
2200 MO.isImplicit(), MO.isKill(),
2201 MO.isDead(), MO.isUndef(),
2204 else if (MO.isImm()) {
2205 MI->getOperand(oper+1).ChangeToImmediate(MO.getImm());
2207 else if (MO.isGlobal()) {
2208 // MI can not have more than one GlobalAddress operand.
2209 assert(hasGAOpnd == false && "MI can only have one GlobalAddress opnd");
2211 // There is no member function called "ChangeToGlobalAddress" in the
2212 // MachineOperand class (not like "ChangeToRegister" and
2213 // "ChangeToImmediate"). So we have to remove them from Operands[] list
2214 // first, and then add them back after we have inserted the predicate
2215 // operand. tmpOpnds[] is to remember these operands before we remove
2217 tmpOpnds.push_back(MO);
2219 // Operands[oper] is a GlobalAddress operand;
2220 // Operands[oper+1] has been copied into Operands[oper+2];
2226 assert(false && "Unexpected operand type");
2231 int regPos = invertJump ? 1 : 0;
2232 MachineOperand PredMO = Cond[regPos];
2234 // [oper] now points to the last explicit Def. Predicate operand must be
2235 // located at [oper+1]. See diagram above.
2236 // This assumes that the predicate is always the first operand,
2237 // i.e. Operands[0+numResults], in the set of inputs
2238 // It is better to have an assert here to check this. But I don't know how
2239 // to write this assert because findFirstPredOperandIdx() would return -1
2240 if (oper < -1) oper = -1;
2241 MI->getOperand(oper+1).ChangeToRegister(PredMO.getReg(), PredMO.isDef(),
2242 PredMO.isImplicit(), PredMO.isKill(),
2243 PredMO.isDead(), PredMO.isUndef(),
2250 // Operands[GAIdx] is the original GlobalAddress operand, which is
2251 // already copied into tmpOpnds[0].
2252 // Operands[GAIdx] now stores a copy of Operands[GAIdx-1]
2253 // Operands[GAIdx+1] has already been copied into Operands[GAIdx+2],
2254 // so we start from [GAIdx+2]
2255 for (i = GAIdx + 2; i < MI->getNumOperands(); ++i)
2256 tmpOpnds.push_back(MI->getOperand(i));
2258 // Remove all operands in range [ (GAIdx+1) ... (MI->getNumOperands()-1) ]
2259 // It is very important that we always remove from the end of Operands[]
2260 // MI->getNumOperands() is at least 2 if program goes to here.
2261 for (i = MI->getNumOperands() - 1; i > GAIdx; --i)
2262 MI->RemoveOperand(i);
2264 for (i = 0; i < tmpOpnds.size(); ++i)
2265 MI->addOperand(tmpOpnds[i]);
2274 isProfitableToIfCvt(MachineBasicBlock &MBB,
2276 unsigned ExtraPredCycles,
2277 const BranchProbability &Probability) const {
2284 isProfitableToIfCvt(MachineBasicBlock &TMBB,
2285 unsigned NumTCycles,
2286 unsigned ExtraTCycles,
2287 MachineBasicBlock &FMBB,
2288 unsigned NumFCycles,
2289 unsigned ExtraFCycles,
2290 const BranchProbability &Probability) const {
2295 bool HexagonInstrInfo::isPredicated(const MachineInstr *MI) const {
2296 const uint64_t F = MI->getDesc().TSFlags;
2298 return ((F >> HexagonII::PredicatedPos) & HexagonII::PredicatedMask);
2302 HexagonInstrInfo::DefinesPredicate(MachineInstr *MI,
2303 std::vector<MachineOperand> &Pred) const {
2304 for (unsigned oper = 0; oper < MI->getNumOperands(); ++oper) {
2305 MachineOperand MO = MI->getOperand(oper);
2306 if (MO.isReg() && MO.isDef()) {
2307 const TargetRegisterClass* RC = RI.getMinimalPhysRegClass(MO.getReg());
2308 if (RC == &Hexagon::PredRegsRegClass) {
2320 SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
2321 const SmallVectorImpl<MachineOperand> &Pred2) const {
2328 // We indicate that we want to reverse the branch by
2329 // inserting a 0 at the beginning of the Cond vector.
2331 bool HexagonInstrInfo::
2332 ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
2333 if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) {
2334 Cond.erase(Cond.begin());
2336 Cond.insert(Cond.begin(), MachineOperand::CreateImm(0));
2342 bool HexagonInstrInfo::
2343 isProfitableToDupForIfCvt(MachineBasicBlock &MBB,unsigned NumInstrs,
2344 const BranchProbability &Probability) const {
2345 return (NumInstrs <= 4);
2348 bool HexagonInstrInfo::isDeallocRet(const MachineInstr *MI) const {
2349 switch (MI->getOpcode()) {
2350 default: return false;
2351 case Hexagon::DEALLOC_RET_V4 :
2352 case Hexagon::DEALLOC_RET_cPt_V4 :
2353 case Hexagon::DEALLOC_RET_cNotPt_V4 :
2354 case Hexagon::DEALLOC_RET_cdnPnt_V4 :
2355 case Hexagon::DEALLOC_RET_cNotdnPnt_V4 :
2356 case Hexagon::DEALLOC_RET_cdnPt_V4 :
2357 case Hexagon::DEALLOC_RET_cNotdnPt_V4 :
2363 bool HexagonInstrInfo::
2364 isValidOffset(const int Opcode, const int Offset) const {
2365 // This function is to check whether the "Offset" is in the correct range of
2366 // the given "Opcode". If "Offset" is not in the correct range, "ADD_ri" is
2367 // inserted to calculate the final address. Due to this reason, the function
2368 // assumes that the "Offset" has correct alignment.
2372 case Hexagon::LDriw:
2373 case Hexagon::LDriw_indexed:
2374 case Hexagon::LDriw_f:
2375 case Hexagon::STriw_indexed:
2376 case Hexagon::STriw:
2377 case Hexagon::STriw_f:
2378 assert((Offset % 4 == 0) && "Offset has incorrect alignment");
2379 return (Offset >= Hexagon_MEMW_OFFSET_MIN) &&
2380 (Offset <= Hexagon_MEMW_OFFSET_MAX);
2382 case Hexagon::LDrid:
2383 case Hexagon::LDrid_indexed:
2384 case Hexagon::LDrid_f:
2385 case Hexagon::STrid:
2386 case Hexagon::STrid_indexed:
2387 case Hexagon::STrid_f:
2388 assert((Offset % 8 == 0) && "Offset has incorrect alignment");
2389 return (Offset >= Hexagon_MEMD_OFFSET_MIN) &&
2390 (Offset <= Hexagon_MEMD_OFFSET_MAX);
2392 case Hexagon::LDrih:
2393 case Hexagon::LDriuh:
2394 case Hexagon::STrih:
2395 assert((Offset % 2 == 0) && "Offset has incorrect alignment");
2396 return (Offset >= Hexagon_MEMH_OFFSET_MIN) &&
2397 (Offset <= Hexagon_MEMH_OFFSET_MAX);
2399 case Hexagon::LDrib:
2400 case Hexagon::STrib:
2401 case Hexagon::LDriub:
2402 return (Offset >= Hexagon_MEMB_OFFSET_MIN) &&
2403 (Offset <= Hexagon_MEMB_OFFSET_MAX);
2405 case Hexagon::ADD_ri:
2406 case Hexagon::TFR_FI:
2407 return (Offset >= Hexagon_ADDI_OFFSET_MIN) &&
2408 (Offset <= Hexagon_ADDI_OFFSET_MAX);
2410 case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
2411 case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
2412 case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
2413 case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
2414 case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
2415 case Hexagon::MEMw_ORr_indexed_MEM_V4 :
2416 case Hexagon::MEMw_ADDi_MEM_V4 :
2417 case Hexagon::MEMw_SUBi_MEM_V4 :
2418 case Hexagon::MEMw_ADDr_MEM_V4 :
2419 case Hexagon::MEMw_SUBr_MEM_V4 :
2420 case Hexagon::MEMw_ANDr_MEM_V4 :
2421 case Hexagon::MEMw_ORr_MEM_V4 :
2422 assert ((Offset % 4) == 0 && "MEMOPw offset is not aligned correctly." );
2423 return (0 <= Offset && Offset <= 255);
2425 case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
2426 case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
2427 case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
2428 case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
2429 case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
2430 case Hexagon::MEMh_ORr_indexed_MEM_V4 :
2431 case Hexagon::MEMh_ADDi_MEM_V4 :
2432 case Hexagon::MEMh_SUBi_MEM_V4 :
2433 case Hexagon::MEMh_ADDr_MEM_V4 :
2434 case Hexagon::MEMh_SUBr_MEM_V4 :
2435 case Hexagon::MEMh_ANDr_MEM_V4 :
2436 case Hexagon::MEMh_ORr_MEM_V4 :
2437 assert ((Offset % 2) == 0 && "MEMOPh offset is not aligned correctly." );
2438 return (0 <= Offset && Offset <= 127);
2440 case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
2441 case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
2442 case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
2443 case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
2444 case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
2445 case Hexagon::MEMb_ORr_indexed_MEM_V4 :
2446 case Hexagon::MEMb_ADDi_MEM_V4 :
2447 case Hexagon::MEMb_SUBi_MEM_V4 :
2448 case Hexagon::MEMb_ADDr_MEM_V4 :
2449 case Hexagon::MEMb_SUBr_MEM_V4 :
2450 case Hexagon::MEMb_ANDr_MEM_V4 :
2451 case Hexagon::MEMb_ORr_MEM_V4 :
2452 return (0 <= Offset && Offset <= 63);
2454 // LDri_pred and STriw_pred are pseudo operations, so it has to take offset of
2455 // any size. Later pass knows how to handle it.
2456 case Hexagon::STriw_pred:
2457 case Hexagon::LDriw_pred:
2460 case Hexagon::LOOP0_i:
2461 return isUInt<10>(Offset);
2463 // INLINEASM is very special.
2464 case Hexagon::INLINEASM:
2468 llvm_unreachable("No offset range is defined for this opcode. "
2469 "Please define it in the above switch statement!");
2474 // Check if the Offset is a valid auto-inc imm by Load/Store Type.
2476 bool HexagonInstrInfo::
2477 isValidAutoIncImm(const EVT VT, const int Offset) const {
2479 if (VT == MVT::i64) {
2480 return (Offset >= Hexagon_MEMD_AUTOINC_MIN &&
2481 Offset <= Hexagon_MEMD_AUTOINC_MAX &&
2482 (Offset & 0x7) == 0);
2484 if (VT == MVT::i32) {
2485 return (Offset >= Hexagon_MEMW_AUTOINC_MIN &&
2486 Offset <= Hexagon_MEMW_AUTOINC_MAX &&
2487 (Offset & 0x3) == 0);
2489 if (VT == MVT::i16) {
2490 return (Offset >= Hexagon_MEMH_AUTOINC_MIN &&
2491 Offset <= Hexagon_MEMH_AUTOINC_MAX &&
2492 (Offset & 0x1) == 0);
2494 if (VT == MVT::i8) {
2495 return (Offset >= Hexagon_MEMB_AUTOINC_MIN &&
2496 Offset <= Hexagon_MEMB_AUTOINC_MAX);
2498 llvm_unreachable("Not an auto-inc opc!");
2502 bool HexagonInstrInfo::
2503 isMemOp(const MachineInstr *MI) const {
2504 switch (MI->getOpcode())
2506 default: return false;
2507 case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
2508 case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
2509 case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
2510 case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
2511 case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
2512 case Hexagon::MEMw_ORr_indexed_MEM_V4 :
2513 case Hexagon::MEMw_ADDi_MEM_V4 :
2514 case Hexagon::MEMw_SUBi_MEM_V4 :
2515 case Hexagon::MEMw_ADDr_MEM_V4 :
2516 case Hexagon::MEMw_SUBr_MEM_V4 :
2517 case Hexagon::MEMw_ANDr_MEM_V4 :
2518 case Hexagon::MEMw_ORr_MEM_V4 :
2519 case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
2520 case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
2521 case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
2522 case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
2523 case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
2524 case Hexagon::MEMh_ORr_indexed_MEM_V4 :
2525 case Hexagon::MEMh_ADDi_MEM_V4 :
2526 case Hexagon::MEMh_SUBi_MEM_V4 :
2527 case Hexagon::MEMh_ADDr_MEM_V4 :
2528 case Hexagon::MEMh_SUBr_MEM_V4 :
2529 case Hexagon::MEMh_ANDr_MEM_V4 :
2530 case Hexagon::MEMh_ORr_MEM_V4 :
2531 case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
2532 case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
2533 case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
2534 case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
2535 case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
2536 case Hexagon::MEMb_ORr_indexed_MEM_V4 :
2537 case Hexagon::MEMb_ADDi_MEM_V4 :
2538 case Hexagon::MEMb_SUBi_MEM_V4 :
2539 case Hexagon::MEMb_ADDr_MEM_V4 :
2540 case Hexagon::MEMb_SUBr_MEM_V4 :
2541 case Hexagon::MEMb_ANDr_MEM_V4 :
2542 case Hexagon::MEMb_ORr_MEM_V4 :
2548 bool HexagonInstrInfo::
2549 isSpillPredRegOp(const MachineInstr *MI) const {
2550 switch (MI->getOpcode()) {
2551 default: return false;
2552 case Hexagon::STriw_pred :
2553 case Hexagon::LDriw_pred :
2558 bool HexagonInstrInfo::isNewValueJumpCandidate(const MachineInstr *MI) const {
2559 switch (MI->getOpcode()) {
2560 default: return false;
2561 case Hexagon::CMPEQrr:
2562 case Hexagon::CMPEQri:
2563 case Hexagon::CMPLTrr:
2564 case Hexagon::CMPGTrr:
2565 case Hexagon::CMPGTri:
2566 case Hexagon::CMPLTUrr:
2567 case Hexagon::CMPGTUrr:
2568 case Hexagon::CMPGTUri:
2569 case Hexagon::CMPGEri:
2570 case Hexagon::CMPGEUri:
2575 bool HexagonInstrInfo::
2576 isConditionalTransfer (const MachineInstr *MI) const {
2577 switch (MI->getOpcode()) {
2578 default: return false;
2579 case Hexagon::TFR_cPt:
2580 case Hexagon::TFR_cNotPt:
2581 case Hexagon::TFRI_cPt:
2582 case Hexagon::TFRI_cNotPt:
2583 case Hexagon::TFR_cdnPt:
2584 case Hexagon::TFR_cdnNotPt:
2585 case Hexagon::TFRI_cdnPt:
2586 case Hexagon::TFRI_cdnNotPt:
2591 bool HexagonInstrInfo::isConditionalALU32 (const MachineInstr* MI) const {
2592 const HexagonRegisterInfo& QRI = getRegisterInfo();
2593 switch (MI->getOpcode())
2595 default: return false;
2596 case Hexagon::ADD_ri_cPt:
2597 case Hexagon::ADD_ri_cNotPt:
2598 case Hexagon::ADD_rr_cPt:
2599 case Hexagon::ADD_rr_cNotPt:
2600 case Hexagon::XOR_rr_cPt:
2601 case Hexagon::XOR_rr_cNotPt:
2602 case Hexagon::AND_rr_cPt:
2603 case Hexagon::AND_rr_cNotPt:
2604 case Hexagon::OR_rr_cPt:
2605 case Hexagon::OR_rr_cNotPt:
2606 case Hexagon::SUB_rr_cPt:
2607 case Hexagon::SUB_rr_cNotPt:
2608 case Hexagon::COMBINE_rr_cPt:
2609 case Hexagon::COMBINE_rr_cNotPt:
2611 case Hexagon::ASLH_cPt_V4:
2612 case Hexagon::ASLH_cNotPt_V4:
2613 case Hexagon::ASRH_cPt_V4:
2614 case Hexagon::ASRH_cNotPt_V4:
2615 case Hexagon::SXTB_cPt_V4:
2616 case Hexagon::SXTB_cNotPt_V4:
2617 case Hexagon::SXTH_cPt_V4:
2618 case Hexagon::SXTH_cNotPt_V4:
2619 case Hexagon::ZXTB_cPt_V4:
2620 case Hexagon::ZXTB_cNotPt_V4:
2621 case Hexagon::ZXTH_cPt_V4:
2622 case Hexagon::ZXTH_cNotPt_V4:
2623 return QRI.Subtarget.hasV4TOps();
2627 bool HexagonInstrInfo::
2628 isConditionalLoad (const MachineInstr* MI) const {
2629 const HexagonRegisterInfo& QRI = getRegisterInfo();
2630 switch (MI->getOpcode())
2632 default: return false;
2633 case Hexagon::LDrid_cPt :
2634 case Hexagon::LDrid_cNotPt :
2635 case Hexagon::LDrid_indexed_cPt :
2636 case Hexagon::LDrid_indexed_cNotPt :
2637 case Hexagon::LDriw_cPt :
2638 case Hexagon::LDriw_cNotPt :
2639 case Hexagon::LDriw_indexed_cPt :
2640 case Hexagon::LDriw_indexed_cNotPt :
2641 case Hexagon::LDrih_cPt :
2642 case Hexagon::LDrih_cNotPt :
2643 case Hexagon::LDrih_indexed_cPt :
2644 case Hexagon::LDrih_indexed_cNotPt :
2645 case Hexagon::LDrib_cPt :
2646 case Hexagon::LDrib_cNotPt :
2647 case Hexagon::LDrib_indexed_cPt :
2648 case Hexagon::LDrib_indexed_cNotPt :
2649 case Hexagon::LDriuh_cPt :
2650 case Hexagon::LDriuh_cNotPt :
2651 case Hexagon::LDriuh_indexed_cPt :
2652 case Hexagon::LDriuh_indexed_cNotPt :
2653 case Hexagon::LDriub_cPt :
2654 case Hexagon::LDriub_cNotPt :
2655 case Hexagon::LDriub_indexed_cPt :
2656 case Hexagon::LDriub_indexed_cNotPt :
2658 case Hexagon::POST_LDrid_cPt :
2659 case Hexagon::POST_LDrid_cNotPt :
2660 case Hexagon::POST_LDriw_cPt :
2661 case Hexagon::POST_LDriw_cNotPt :
2662 case Hexagon::POST_LDrih_cPt :
2663 case Hexagon::POST_LDrih_cNotPt :
2664 case Hexagon::POST_LDrib_cPt :
2665 case Hexagon::POST_LDrib_cNotPt :
2666 case Hexagon::POST_LDriuh_cPt :
2667 case Hexagon::POST_LDriuh_cNotPt :
2668 case Hexagon::POST_LDriub_cPt :
2669 case Hexagon::POST_LDriub_cNotPt :
2670 return QRI.Subtarget.hasV4TOps();
2671 case Hexagon::LDrid_indexed_shl_cPt_V4 :
2672 case Hexagon::LDrid_indexed_shl_cNotPt_V4 :
2673 case Hexagon::LDrib_indexed_shl_cPt_V4 :
2674 case Hexagon::LDrib_indexed_shl_cNotPt_V4 :
2675 case Hexagon::LDriub_indexed_shl_cPt_V4 :
2676 case Hexagon::LDriub_indexed_shl_cNotPt_V4 :
2677 case Hexagon::LDrih_indexed_shl_cPt_V4 :
2678 case Hexagon::LDrih_indexed_shl_cNotPt_V4 :
2679 case Hexagon::LDriuh_indexed_shl_cPt_V4 :
2680 case Hexagon::LDriuh_indexed_shl_cNotPt_V4 :
2681 case Hexagon::LDriw_indexed_shl_cPt_V4 :
2682 case Hexagon::LDriw_indexed_shl_cNotPt_V4 :
2683 return QRI.Subtarget.hasV4TOps();
2687 // Returns true if an instruction is a conditional store.
2689 // Note: It doesn't include conditional new-value stores as they can't be
2690 // converted to .new predicate.
2692 // p.new NV store [ if(p0.new)memw(R0+#0)=R2.new ]
2694 // / \ (not OK. it will cause new-value store to be
2695 // / X conditional on p0.new while R2 producer is
2698 // p.new store p.old NV store
2699 // [if(p0.new)memw(R0+#0)=R2] [if(p0)memw(R0+#0)=R2.new]
2705 // [if (p0)memw(R0+#0)=R2]
2707 // The above diagram shows the steps involoved in the conversion of a predicated
2708 // store instruction to its .new predicated new-value form.
2710 // The following set of instructions further explains the scenario where
2711 // conditional new-value store becomes invalid when promoted to .new predicate
2714 // { 1) if (p0) r0 = add(r1, r2)
2715 // 2) p0 = cmp.eq(r3, #0) }
2717 // 3) if (p0) memb(r1+#0) = r0 --> this instruction can't be grouped with
2718 // the first two instructions because in instr 1, r0 is conditional on old value
2719 // of p0 but its use in instr 3 is conditional on p0 modified by instr 2 which
2720 // is not valid for new-value stores.
2721 bool HexagonInstrInfo::
2722 isConditionalStore (const MachineInstr* MI) const {
2723 const HexagonRegisterInfo& QRI = getRegisterInfo();
2724 switch (MI->getOpcode())
2726 default: return false;
2727 case Hexagon::STrib_imm_cPt_V4 :
2728 case Hexagon::STrib_imm_cNotPt_V4 :
2729 case Hexagon::STrib_indexed_shl_cPt_V4 :
2730 case Hexagon::STrib_indexed_shl_cNotPt_V4 :
2731 case Hexagon::STrib_cPt :
2732 case Hexagon::STrib_cNotPt :
2733 case Hexagon::POST_STbri_cPt :
2734 case Hexagon::POST_STbri_cNotPt :
2735 case Hexagon::STrid_indexed_cPt :
2736 case Hexagon::STrid_indexed_cNotPt :
2737 case Hexagon::STrid_indexed_shl_cPt_V4 :
2738 case Hexagon::POST_STdri_cPt :
2739 case Hexagon::POST_STdri_cNotPt :
2740 case Hexagon::STrih_cPt :
2741 case Hexagon::STrih_cNotPt :
2742 case Hexagon::STrih_indexed_cPt :
2743 case Hexagon::STrih_indexed_cNotPt :
2744 case Hexagon::STrih_imm_cPt_V4 :
2745 case Hexagon::STrih_imm_cNotPt_V4 :
2746 case Hexagon::STrih_indexed_shl_cPt_V4 :
2747 case Hexagon::STrih_indexed_shl_cNotPt_V4 :
2748 case Hexagon::POST_SThri_cPt :
2749 case Hexagon::POST_SThri_cNotPt :
2750 case Hexagon::STriw_cPt :
2751 case Hexagon::STriw_cNotPt :
2752 case Hexagon::STriw_indexed_cPt :
2753 case Hexagon::STriw_indexed_cNotPt :
2754 case Hexagon::STriw_imm_cPt_V4 :
2755 case Hexagon::STriw_imm_cNotPt_V4 :
2756 case Hexagon::STriw_indexed_shl_cPt_V4 :
2757 case Hexagon::STriw_indexed_shl_cNotPt_V4 :
2758 case Hexagon::POST_STwri_cPt :
2759 case Hexagon::POST_STwri_cNotPt :
2760 return QRI.Subtarget.hasV4TOps();
2762 // V4 global address store before promoting to dot new.
2763 case Hexagon::STd_GP_cPt_V4 :
2764 case Hexagon::STd_GP_cNotPt_V4 :
2765 case Hexagon::STb_GP_cPt_V4 :
2766 case Hexagon::STb_GP_cNotPt_V4 :
2767 case Hexagon::STh_GP_cPt_V4 :
2768 case Hexagon::STh_GP_cNotPt_V4 :
2769 case Hexagon::STw_GP_cPt_V4 :
2770 case Hexagon::STw_GP_cNotPt_V4 :
2771 return QRI.Subtarget.hasV4TOps();
2773 // Predicated new value stores (i.e. if (p0) memw(..)=r0.new) are excluded
2774 // from the "Conditional Store" list. Because a predicated new value store
2775 // would NOT be promoted to a double dot new store. See diagram below:
2776 // This function returns yes for those stores that are predicated but not
2777 // yet promoted to predicate dot new instructions.
2779 // +---------------------+
2780 // /-----| if (p0) memw(..)=r0 |---------\~
2781 // || +---------------------+ ||
2782 // promote || /\ /\ || promote
2784 // \||/ demote || \||/
2786 // +-------------------------+ || +-------------------------+
2787 // | if (p0.new) memw(..)=r0 | || | if (p0) memw(..)=r0.new |
2788 // +-------------------------+ || +-------------------------+
2791 // promote || \/ NOT possible
2795 // +-----------------------------+
2796 // | if (p0.new) memw(..)=r0.new |
2797 // +-----------------------------+
2798 // Double Dot New Store
2803 unsigned HexagonInstrInfo::getAddrMode(const MachineInstr* MI) const {
2804 const uint64_t F = MI->getDesc().TSFlags;
2806 return((F >> HexagonII::AddrModePos) & HexagonII::AddrModeMask);
2809 /// immediateExtend - Changes the instruction in place to one using an immediate
2811 void HexagonInstrInfo::immediateExtend(MachineInstr *MI) const {
2812 assert((isExtendable(MI)||isConstExtended(MI)) &&
2813 "Instruction must be extendable");
2814 // Find which operand is extendable.
2815 short ExtOpNum = getCExtOpNum(MI);
2816 MachineOperand &MO = MI->getOperand(ExtOpNum);
2817 // This needs to be something we understand.
2818 assert((MO.isMBB() || MO.isImm()) &&
2819 "Branch with unknown extendable field type");
2820 // Mark given operand as extended.
2821 MO.addTargetFlag(HexagonII::HMOTF_ConstExtended);
2824 DFAPacketizer *HexagonInstrInfo::
2825 CreateTargetScheduleState(const TargetMachine *TM,
2826 const ScheduleDAG *DAG) const {
2827 const InstrItineraryData *II = TM->getInstrItineraryData();
2828 return TM->getSubtarget<HexagonGenSubtargetInfo>().createDFAPacketizer(II);
2831 bool HexagonInstrInfo::isSchedulingBoundary(const MachineInstr *MI,
2832 const MachineBasicBlock *MBB,
2833 const MachineFunction &MF) const {
2834 // Debug info is never a scheduling boundary. It's necessary to be explicit
2835 // due to the special treatment of IT instructions below, otherwise a
2836 // dbg_value followed by an IT will result in the IT instruction being
2837 // considered a scheduling hazard, which is wrong. It should be the actual
2838 // instruction preceding the dbg_value instruction(s), just like it is
2839 // when debug info is not present.
2840 if (MI->isDebugValue())
2843 // Terminators and labels can't be scheduled around.
2844 if (MI->getDesc().isTerminator() || MI->isLabel() || MI->isInlineAsm())
2850 bool HexagonInstrInfo::isConstExtended(MachineInstr *MI) const {
2852 // Constant extenders are allowed only for V4 and above.
2853 if (!Subtarget.hasV4TOps())
2856 const uint64_t F = MI->getDesc().TSFlags;
2857 unsigned isExtended = (F >> HexagonII::ExtendedPos) & HexagonII::ExtendedMask;
2858 if (isExtended) // Instruction must be extended.
2861 unsigned isExtendable = (F >> HexagonII::ExtendablePos)
2862 & HexagonII::ExtendableMask;
2866 short ExtOpNum = getCExtOpNum(MI);
2867 const MachineOperand &MO = MI->getOperand(ExtOpNum);
2868 // Use MO operand flags to determine if MO
2869 // has the HMOTF_ConstExtended flag set.
2870 if (MO.getTargetFlags() && HexagonII::HMOTF_ConstExtended)
2872 // If this is a Machine BB address we are talking about, and it is
2873 // not marked as extended, say so.
2877 // We could be using an instruction with an extendable immediate and shoehorn
2878 // a global address into it. If it is a global address it will be constant
2879 // extended. We do this for COMBINE.
2880 // We currently only handle isGlobal() because it is the only kind of
2881 // object we are going to end up with here for now.
2882 // In the future we probably should add isSymbol(), etc.
2883 if (MO.isGlobal() || MO.isSymbol())
2886 // If the extendable operand is not 'Immediate' type, the instruction should
2887 // have 'isExtended' flag set.
2888 assert(MO.isImm() && "Extendable operand must be Immediate type");
2890 int MinValue = getMinValue(MI);
2891 int MaxValue = getMaxValue(MI);
2892 int ImmValue = MO.getImm();
2894 return (ImmValue < MinValue || ImmValue > MaxValue);
2897 // Returns true if a particular operand is extendable for an instruction.
2898 bool HexagonInstrInfo::isOperandExtended(const MachineInstr *MI,
2899 unsigned short OperandNum) const {
2900 // Constant extenders are allowed only for V4 and above.
2901 if (!Subtarget.hasV4TOps())
2904 const uint64_t F = MI->getDesc().TSFlags;
2906 return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask)
2910 // Returns Operand Index for the constant extended instruction.
2911 unsigned short HexagonInstrInfo::getCExtOpNum(const MachineInstr *MI) const {
2912 const uint64_t F = MI->getDesc().TSFlags;
2913 return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask);
2916 // Returns the min value that doesn't need to be extended.
2917 int HexagonInstrInfo::getMinValue(const MachineInstr *MI) const {
2918 const uint64_t F = MI->getDesc().TSFlags;
2919 unsigned isSigned = (F >> HexagonII::ExtentSignedPos)
2920 & HexagonII::ExtentSignedMask;
2921 unsigned bits = (F >> HexagonII::ExtentBitsPos)
2922 & HexagonII::ExtentBitsMask;
2924 if (isSigned) // if value is signed
2925 return -1 << (bits - 1);
2930 // Returns the max value that doesn't need to be extended.
2931 int HexagonInstrInfo::getMaxValue(const MachineInstr *MI) const {
2932 const uint64_t F = MI->getDesc().TSFlags;
2933 unsigned isSigned = (F >> HexagonII::ExtentSignedPos)
2934 & HexagonII::ExtentSignedMask;
2935 unsigned bits = (F >> HexagonII::ExtentBitsPos)
2936 & HexagonII::ExtentBitsMask;
2938 if (isSigned) // if value is signed
2939 return ~(-1 << (bits - 1));
2941 return ~(-1 << bits);
2944 // Returns true if an instruction can be converted into a non-extended
2945 // equivalent instruction.
2946 bool HexagonInstrInfo::NonExtEquivalentExists (const MachineInstr *MI) const {
2949 // Check if the instruction has a register form that uses register in place
2950 // of the extended operand, if so return that as the non-extended form.
2951 if (Hexagon::getRegForm(MI->getOpcode()) >= 0)
2954 if (MI->getDesc().mayLoad() || MI->getDesc().mayStore()) {
2955 // Check addressing mode and retreive non-ext equivalent instruction.
2957 switch (getAddrMode(MI)) {
2958 case HexagonII::Absolute :
2959 // Load/store with absolute addressing mode can be converted into
2960 // base+offset mode.
2961 NonExtOpcode = Hexagon::getBasedWithImmOffset(MI->getOpcode());
2963 case HexagonII::BaseImmOffset :
2964 // Load/store with base+offset addressing mode can be converted into
2965 // base+register offset addressing mode. However left shift operand should
2967 NonExtOpcode = Hexagon::getBaseWithRegOffset(MI->getOpcode());
2972 if (NonExtOpcode < 0)
2979 // Returns opcode of the non-extended equivalent instruction.
2980 short HexagonInstrInfo::getNonExtOpcode (const MachineInstr *MI) const {
2982 // Check if the instruction has a register form that uses register in place
2983 // of the extended operand, if so return that as the non-extended form.
2984 short NonExtOpcode = Hexagon::getRegForm(MI->getOpcode());
2985 if (NonExtOpcode >= 0)
2986 return NonExtOpcode;
2988 if (MI->getDesc().mayLoad() || MI->getDesc().mayStore()) {
2989 // Check addressing mode and retreive non-ext equivalent instruction.
2990 switch (getAddrMode(MI)) {
2991 case HexagonII::Absolute :
2992 return Hexagon::getBasedWithImmOffset(MI->getOpcode());
2993 case HexagonII::BaseImmOffset :
2994 return Hexagon::getBaseWithRegOffset(MI->getOpcode());