HexagonInstrInfo.cpp revision ab7955b9ce3197215406bc9fc97b22074127d035
1f3fd7ee415ec8a6475a060e29959d04d6158f45fBenjamin Kramer//===- HexagonInstrInfo.cpp - Hexagon Instruction Information -------------===//
2b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
3b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//                     The LLVM Compiler Infrastructure
4b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
5b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// This file is distributed under the University of Illinois Open Source
6b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// License. See LICENSE.TXT for details.
7b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
8b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//===----------------------------------------------------------------------===//
9b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
10b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// This file contains the Hexagon implementation of the TargetInstrInfo class.
11b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
12b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//===----------------------------------------------------------------------===//
13b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
14b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "HexagonRegisterInfo.h"
15b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "HexagonInstrInfo.h"
16b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "HexagonSubtarget.h"
17b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "Hexagon.h"
18b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/ADT/STLExtras.h"
19b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/ADT/SmallVector.h"
20f3fd7ee415ec8a6475a060e29959d04d6158f45fBenjamin Kramer#include "llvm/CodeGen/DFAPacketizer.h"
21b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/CodeGen/MachineInstrBuilder.h"
22b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/CodeGen/MachineRegisterInfo.h"
23b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/CodeGen/MachineFrameInfo.h"
24b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/CodeGen/MachineMemOperand.h"
25b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "llvm/CodeGen/PseudoSourceValue.h"
26f3fd7ee415ec8a6475a060e29959d04d6158f45fBenjamin Kramer#include "llvm/Support/MathExtras.h"
27b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#define GET_INSTRINFO_CTOR
28b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum#include "HexagonGenInstrInfo.inc"
29ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick#include "HexagonGenDFAPacketizer.inc"
30b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
31b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumusing namespace llvm;
32b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
33b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum///
34b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// Constants for Hexagon instructions.
35b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum///
36b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMW_OFFSET_MAX = 4095;
37b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMW_OFFSET_MIN = 4096;
38b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMD_OFFSET_MAX = 8191;
39b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMD_OFFSET_MIN = 8192;
40b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMH_OFFSET_MAX = 2047;
41b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMH_OFFSET_MIN = 2048;
42b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMB_OFFSET_MAX = 1023;
43b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMB_OFFSET_MIN = 1024;
44b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_ADDI_OFFSET_MAX = 32767;
45b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_ADDI_OFFSET_MIN = 32768;
46b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMD_AUTOINC_MAX = 56;
47b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMD_AUTOINC_MIN = 64;
48b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMW_AUTOINC_MAX = 28;
49b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMW_AUTOINC_MIN = 32;
50b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMH_AUTOINC_MAX = 14;
51b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMH_AUTOINC_MIN = 16;
52b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMB_AUTOINC_MAX = 7;
53b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumconst int Hexagon_MEMB_AUTOINC_MIN = 8;
54b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
55b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
56b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
57b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumHexagonInstrInfo::HexagonInstrInfo(HexagonSubtarget &ST)
58b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  : HexagonGenInstrInfo(Hexagon::ADJCALLSTACKDOWN, Hexagon::ADJCALLSTACKUP),
59b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    RI(ST, *this), Subtarget(ST) {
60b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
61b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
62b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
63b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// isLoadFromStackSlot - If the specified machine instruction is a direct
64b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// load from a stack slot, return the virtual or physical register number of
65b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// the destination along with the FrameIndex of the loaded stack slot.  If
66b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// not, return 0.  This predicate must return 0 if the instruction has
67b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// any side effects other than loading from the stack slot.
68b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumunsigned HexagonInstrInfo::isLoadFromStackSlot(const MachineInstr *MI,
69b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                             int &FrameIndex) const {
70b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
71b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
72b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode()) {
73b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw:
74b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid:
75b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih:
76b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib:
77b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub:
78b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (MI->getOperand(2).isFI() &&
79b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) {
80b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      FrameIndex = MI->getOperand(2).getIndex();
81b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return MI->getOperand(0).getReg();
82b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
83b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    break;
84b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
85b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  default:
86b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    break;
87b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
88b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
89b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return 0;
90b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
91b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
92b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
93b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// isStoreToStackSlot - If the specified machine instruction is a direct
94b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// store to a stack slot, return the virtual or physical register number of
95b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// the source reg along with the FrameIndex of the loaded stack slot.  If
96b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// not, return 0.  This predicate must return 0 if the instruction has
97b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum/// any side effects other than storing to the stack slot.
98b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumunsigned HexagonInstrInfo::isStoreToStackSlot(const MachineInstr *MI,
99b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                            int &FrameIndex) const {
100b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode()) {
101b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw:
102b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid:
103b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih:
104b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib:
105b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (MI->getOperand(2).isFI() &&
106b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) {
107b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      FrameIndex = MI->getOperand(2).getIndex();
108b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return MI->getOperand(0).getReg();
109b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
110b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    break;
111b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
112b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  default:
113b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    break;
114b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
115b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
116b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return 0;
117b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
118b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
119b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
120b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumunsigned
121b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumHexagonInstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB,
122b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                             MachineBasicBlock *FBB,
123b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                             const SmallVectorImpl<MachineOperand> &Cond,
124b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                             DebugLoc DL) const{
125b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
126b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    int BOpc   = Hexagon::JMP;
127ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    int BccOpc = Hexagon::JMP_c;
128b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
129b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    assert(TBB && "InsertBranch must not be told to insert a fallthrough");
130b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
131b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    int regPos = 0;
132b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    // Check if ReverseBranchCondition has asked to reverse this branch
133b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    // If we want to reverse the branch an odd number of times, we want
134ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    // JMP_cNot.
135b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) {
136ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      BccOpc = Hexagon::JMP_cNot;
137b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      regPos = 1;
138b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
139b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
140b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (FBB == 0) {
141b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      if (Cond.empty()) {
142b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        // Due to a bug in TailMerging/CFG Optimization, we need to add a
143b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        // special case handling of a predicated jump followed by an
144b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        // unconditional jump. If not, Tail Merging and CFG Optimization go
145b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        // into an infinite loop.
146b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        MachineBasicBlock *NewTBB, *NewFBB;
147b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        SmallVector<MachineOperand, 4> Cond;
148b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        MachineInstr *Term = MBB.getFirstTerminator();
149b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        if (isPredicated(Term) && !AnalyzeBranch(MBB, NewTBB, NewFBB, Cond,
150b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                                 false)) {
151b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          MachineBasicBlock *NextBB =
152b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            llvm::next(MachineFunction::iterator(&MBB));
153b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          if (NewTBB == NextBB) {
154b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            ReverseBranchCondition(Cond);
155b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            RemoveBranch(MBB);
156b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            return InsertBranch(MBB, TBB, 0, Cond, DL);
157b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          }
158b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        }
159b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB);
160b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      } else {
161b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        BuildMI(&MBB, DL,
162b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB);
163b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      }
164b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return 1;
165b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
166b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
167b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(&MBB, DL, get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB);
168b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(&MBB, DL, get(BOpc)).addMBB(FBB);
169b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
170b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return 2;
171b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
172b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
173b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
174b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
175b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                     MachineBasicBlock *&TBB,
176b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 MachineBasicBlock *&FBB,
177b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 SmallVectorImpl<MachineOperand> &Cond,
178b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 bool AllowModify) const {
179b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  FBB = NULL;
180b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
181b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // If the block has no terminators, it just falls into the block after it.
182b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineBasicBlock::iterator I = MBB.end();
183b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (I == MBB.begin())
184b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
185b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
186b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // A basic block may looks like this:
187b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //
188b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //  [   insn
189b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //     EH_LABEL
190b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //      insn
191b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //      insn
192b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //      insn
193b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //     EH_LABEL
194b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //      insn     ]
195b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //
196b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // It has two succs but does not have a terminator
197b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Don't know how to handle it.
198b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  do {
199b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    --I;
200b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (I->isEHLabel())
201b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return true;
202b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } while (I != MBB.begin());
203b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
204b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  I = MBB.end();
205b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  --I;
206b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
207b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  while (I->isDebugValue()) {
208b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (I == MBB.begin())
209b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return false;
210b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    --I;
211b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
212b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (!isUnpredicatedTerminator(I))
213b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
214b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
215b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Get the last instruction in the block.
216b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineInstr *LastInst = I;
217b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
218b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // If there is only one terminator instruction, process it.
219b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
220b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (LastInst->getOpcode() == Hexagon::JMP) {
221b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      TBB = LastInst->getOperand(0).getMBB();
222b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return false;
223b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
224ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    if (LastInst->getOpcode() == Hexagon::JMP_c) {
225b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      // Block ends with fall-through true condbranch.
226b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      TBB = LastInst->getOperand(1).getMBB();
227b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      Cond.push_back(LastInst->getOperand(0));
228b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return false;
229b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
230ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    if (LastInst->getOpcode() == Hexagon::JMP_cNot) {
231b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      // Block ends with fall-through false condbranch.
232b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      TBB = LastInst->getOperand(1).getMBB();
233b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      Cond.push_back(MachineOperand::CreateImm(0));
234b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      Cond.push_back(LastInst->getOperand(0));
235b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return false;
236b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
237b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    // Otherwise, don't know what this is.
238b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return true;
239b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
240b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
241b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Get the instruction before it if it's a terminator.
242b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineInstr *SecondLastInst = I;
243b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
244b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // If there are three terminators, we don't know what sort of block this is.
245b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (SecondLastInst && I != MBB.begin() &&
246b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      isUnpredicatedTerminator(--I))
247b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return true;
248b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
249b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // If the block ends with Hexagon::BRCOND and Hexagon:JMP, handle it.
250b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (((SecondLastInst->getOpcode() == Hexagon::BRCOND) ||
251ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      (SecondLastInst->getOpcode() == Hexagon::JMP_c)) &&
252b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      LastInst->getOpcode() == Hexagon::JMP) {
253b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    TBB =  SecondLastInst->getOperand(1).getMBB();
254b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    Cond.push_back(SecondLastInst->getOperand(0));
255b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    FBB = LastInst->getOperand(0).getMBB();
256b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
257b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
258b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
259ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // If the block ends with Hexagon::JMP_cNot and Hexagon:JMP, handle it.
260ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  if ((SecondLastInst->getOpcode() == Hexagon::JMP_cNot) &&
261b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      LastInst->getOpcode() == Hexagon::JMP) {
262b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    TBB =  SecondLastInst->getOperand(1).getMBB();
263b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    Cond.push_back(MachineOperand::CreateImm(0));
264b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    Cond.push_back(SecondLastInst->getOperand(0));
265b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    FBB = LastInst->getOperand(0).getMBB();
266b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
267b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
268b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
269b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // If the block ends with two Hexagon:JMPs, handle it.  The second one is not
270b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // executed, so remove it.
271b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (SecondLastInst->getOpcode() == Hexagon::JMP &&
272b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      LastInst->getOpcode() == Hexagon::JMP) {
273b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    TBB = SecondLastInst->getOperand(0).getMBB();
274b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    I = LastInst;
275b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (AllowModify)
276b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      I->eraseFromParent();
277b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
278b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
279b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
280b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Otherwise, can't handle this.
281b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return true;
282b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
283b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
284b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
285b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumunsigned HexagonInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
286b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  int BOpc   = Hexagon::JMP;
287ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  int BccOpc = Hexagon::JMP_c;
288ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  int BccOpcNot = Hexagon::JMP_cNot;
289b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
290b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineBasicBlock::iterator I = MBB.end();
291b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (I == MBB.begin()) return 0;
292b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  --I;
293b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (I->getOpcode() != BOpc && I->getOpcode() != BccOpc &&
294b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      I->getOpcode() != BccOpcNot)
295b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return 0;
296b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
297b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Remove the branch.
298b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  I->eraseFromParent();
299b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
300b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  I = MBB.end();
301b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
302b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (I == MBB.begin()) return 1;
303b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  --I;
304b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (I->getOpcode() != BccOpc && I->getOpcode() != BccOpcNot)
305b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return 1;
306b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
307b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Remove the branch.
308b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  I->eraseFromParent();
309b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return 2;
310b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
311b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
312b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
313b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumvoid HexagonInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
314b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 MachineBasicBlock::iterator I, DebugLoc DL,
315b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 unsigned DestReg, unsigned SrcReg,
316b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 bool KillSrc) const {
317b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (Hexagon::IntRegsRegClass.contains(SrcReg, DestReg)) {
318b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::TFR), DestReg).addReg(SrcReg);
319b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return;
320b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
321b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (Hexagon::DoubleRegsRegClass.contains(SrcReg, DestReg)) {
322b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::TFR_64), DestReg).addReg(SrcReg);
323b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return;
324b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
325b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (Hexagon::PredRegsRegClass.contains(SrcReg, DestReg)) {
326b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    // Map Pd = Ps to Pd = or(Ps, Ps).
327b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::OR_pp),
328b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            DestReg).addReg(SrcReg).addReg(SrcReg);
329b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return;
330b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
331b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (Hexagon::DoubleRegsRegClass.contains(DestReg, SrcReg)) {
332b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    // We can have an overlap between single and double reg: r1:0 = r0.
333b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if(SrcReg == RI.getSubReg(DestReg, Hexagon::subreg_loreg)) {
334b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        // r1:0 = r0
335b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg,
336b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                Hexagon::subreg_hireg))).addImm(0);
337b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    } else {
338b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        // r1:0 = r1 or no overlap.
339b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        BuildMI(MBB, I, DL, get(Hexagon::TFR), (RI.getSubReg(DestReg,
340b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                Hexagon::subreg_loreg))).addReg(SrcReg);
341b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg,
342b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                Hexagon::subreg_hireg))).addImm(0);
343b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
344b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return;
345b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
346b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (Hexagon::CRRegsRegClass.contains(DestReg, SrcReg)) {
347b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::TFCR), DestReg).addReg(SrcReg);
348b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return;
349ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  }
350ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
351ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  llvm_unreachable("Unimplemented");
352b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
353b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
354b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
355b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumvoid HexagonInstrInfo::
356b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumstoreRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
357b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned SrcReg, bool isKill, int FI,
358b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    const TargetRegisterClass *RC,
359b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    const TargetRegisterInfo *TRI) const {
360b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
361b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  DebugLoc DL = MBB.findDebugLoc(I);
362b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineFunction &MF = *MBB.getParent();
363b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineFrameInfo &MFI = *MF.getFrameInfo();
364b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  unsigned Align = MFI.getObjectAlignment(FI);
365b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
366b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineMemOperand *MMO =
367b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      MF.getMachineMemOperand(
368b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
369b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      MachineMemOperand::MOStore,
370b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      MFI.getObjectSize(FI),
371b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      Align);
372b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
373b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (Hexagon::IntRegsRegisterClass->hasSubClassEq(RC)) {
374b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::STriw))
375b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addFrameIndex(FI).addImm(0)
376b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
377b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else if (Hexagon::DoubleRegsRegisterClass->hasSubClassEq(RC)) {
378b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::STrid))
379b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addFrameIndex(FI).addImm(0)
380b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
381b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else if (Hexagon::PredRegsRegisterClass->hasSubClassEq(RC)) {
382b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::STriw_pred))
383b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addFrameIndex(FI).addImm(0)
384b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
385b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else {
386bc2198133a1836598b54b943420748e75d5dea94Craig Topper    llvm_unreachable("Unimplemented");
387b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
388b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
389b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
390b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
391b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumvoid HexagonInstrInfo::storeRegToAddr(
392b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 MachineFunction &MF, unsigned SrcReg,
393b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 bool isKill,
394b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 SmallVectorImpl<MachineOperand> &Addr,
395b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 const TargetRegisterClass *RC,
396b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 SmallVectorImpl<MachineInstr*> &NewMIs) const
397b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum{
398bc2198133a1836598b54b943420748e75d5dea94Craig Topper  llvm_unreachable("Unimplemented");
399b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
400b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
401b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
402b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumvoid HexagonInstrInfo::
403b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumloadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
404b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                     unsigned DestReg, int FI,
405b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                     const TargetRegisterClass *RC,
406b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                     const TargetRegisterInfo *TRI) const {
407b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  DebugLoc DL = MBB.findDebugLoc(I);
408b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineFunction &MF = *MBB.getParent();
409b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineFrameInfo &MFI = *MF.getFrameInfo();
410b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  unsigned Align = MFI.getObjectAlignment(FI);
411b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
412b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineMemOperand *MMO =
413b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      MF.getMachineMemOperand(
414b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
415b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      MachineMemOperand::MOLoad,
416b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      MFI.getObjectSize(FI),
417b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                      Align);
418b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
419b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (RC == Hexagon::IntRegsRegisterClass) {
420b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::LDriw), DestReg)
421b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
422b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else if (RC == Hexagon::DoubleRegsRegisterClass) {
423b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::LDrid), DestReg)
424b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
425b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else if (RC == Hexagon::PredRegsRegisterClass) {
426b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    BuildMI(MBB, I, DL, get(Hexagon::LDriw_pred), DestReg)
427b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum          .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
428b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else {
429bc2198133a1836598b54b943420748e75d5dea94Craig Topper    llvm_unreachable("Can't store this register to stack slot");
430b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
431b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
432b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
433b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
434b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumvoid HexagonInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
435b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                        SmallVectorImpl<MachineOperand> &Addr,
436b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                        const TargetRegisterClass *RC,
437b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                 SmallVectorImpl<MachineInstr*> &NewMIs) const {
438bc2198133a1836598b54b943420748e75d5dea94Craig Topper  llvm_unreachable("Unimplemented");
439b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
440b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
441b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
442b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumMachineInstr *HexagonInstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
443b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                                    MachineInstr* MI,
444b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                          const SmallVectorImpl<unsigned> &Ops,
445b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                                    int FI) const {
446b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Hexagon_TODO: Implement.
447b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return(0);
448b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
449b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
450b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
451b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumunsigned HexagonInstrInfo::createVR(MachineFunction* MF, MVT VT) const {
452b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
453b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineRegisterInfo &RegInfo = MF->getRegInfo();
454b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  const TargetRegisterClass *TRC;
455b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (VT == MVT::i1) {
456b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    TRC =  Hexagon::PredRegsRegisterClass;
457b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else if (VT == MVT::i32) {
458b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    TRC =  Hexagon::IntRegsRegisterClass;
459b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else if (VT == MVT::i64) {
460b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    TRC =  Hexagon::DoubleRegsRegisterClass;
461b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else {
46227baab62e7d6267d9b18e4665c6bb1b75dae10d4Benjamin Kramer    llvm_unreachable("Cannot handle this register class");
463b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
464b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
465b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  unsigned NewReg = RegInfo.createVirtualRegister(TRC);
466b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return NewReg;
467b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
468b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
469b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
470ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick
471b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::isPredicable(MachineInstr *MI) const {
472b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  bool isPred = MI->getDesc().isPredicable();
473b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
474b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (!isPred)
475b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
476b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
477b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  const int Opc = MI->getOpcode();
478b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
479b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch(Opc) {
480b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::TFRI:
481b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isInt<12>(MI->getOperand(1).getImm());
482b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
483b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid:
484b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid_indexed:
485b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedUInt<6,3>(MI->getOperand(1).getImm());
486b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
487b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw:
488b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_indexed:
489b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_nv_V4:
490b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedUInt<6,2>(MI->getOperand(1).getImm());
491b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
492b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih:
493b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih_indexed:
494b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih_nv_V4:
495b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedUInt<6,1>(MI->getOperand(1).getImm());
496b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
497b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib:
498b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib_indexed:
499b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib_nv_V4:
500b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isUInt<6>(MI->getOperand(1).getImm());
501b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
502b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid:
503b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid_indexed:
504b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedUInt<6,3>(MI->getOperand(2).getImm());
505b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
506b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw:
507b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw_indexed:
508b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedUInt<6,2>(MI->getOperand(2).getImm());
509b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
510b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih:
511b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh:
512b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih_indexed:
513b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh_indexed:
514b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedUInt<6,1>(MI->getOperand(2).getImm());
515b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
516b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib:
517b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub:
518b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib_indexed:
519b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_indexed:
520b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isUInt<6>(MI->getOperand(2).getImm());
521b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
522b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDrid:
523b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedInt<4,3>(MI->getOperand(3).getImm());
524b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
525b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDriw:
526b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedInt<4,2>(MI->getOperand(3).getImm());
527b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
528b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDrih:
529b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDriuh:
530b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isShiftedInt<4,1>(MI->getOperand(3).getImm());
531b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
532b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDrib:
533b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDriub:
534b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isInt<4>(MI->getOperand(3).getImm());
535b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
536b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib_imm_V4:
537b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih_imm_V4:
538b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_imm_V4:
539b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (isUInt<6>(MI->getOperand(1).getImm()) &&
540b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum            isInt<6>(MI->getOperand(2).getImm()));
541b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
542b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ADD_ri:
543b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return isInt<8>(MI->getOperand(2).getImm());
544b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
545b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ASLH:
546b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ASRH:
547b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::SXTB:
548b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::SXTH:
549b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ZXTB:
550b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ZXTH:
551b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4;
552b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
553b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::JMPR:
554b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return false;
555b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
556b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
557b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return true;
558b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
559b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
560ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pandeunsigned HexagonInstrInfo::getInvertedPredicatedOpcode(const int Opc) const {
561ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  switch(Opc) {
562ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::TFR_cPt:
563ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::TFR_cNotPt;
564ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::TFR_cNotPt:
565ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::TFR_cPt;
566ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
567ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::TFRI_cPt:
568ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::TFRI_cNotPt;
569ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::TFRI_cNotPt:
570ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::TFRI_cPt;
571ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
572ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_c:
573ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_cNot;
574ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_cNot:
575ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_c;
576ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
577ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ADD_ri_cPt:
578ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ADD_ri_cNotPt;
579ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ADD_ri_cNotPt:
580ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ADD_ri_cPt;
581ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
582ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ADD_rr_cPt:
583ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ADD_rr_cNotPt;
584ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ADD_rr_cNotPt:
585ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ADD_rr_cPt;
586ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
587ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::XOR_rr_cPt:
588ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::XOR_rr_cNotPt;
589ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::XOR_rr_cNotPt:
590ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::XOR_rr_cPt;
591ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
592ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::AND_rr_cPt:
593ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::AND_rr_cNotPt;
594ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::AND_rr_cNotPt:
595ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::AND_rr_cPt;
596ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
597ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::OR_rr_cPt:
598ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::OR_rr_cNotPt;
599ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::OR_rr_cNotPt:
600ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::OR_rr_cPt;
601ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
602ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::SUB_rr_cPt:
603ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::SUB_rr_cNotPt;
604ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::SUB_rr_cNotPt:
605ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::SUB_rr_cPt;
606ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
607ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::COMBINE_rr_cPt:
608ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::COMBINE_rr_cNotPt;
609ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::COMBINE_rr_cNotPt:
610ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::COMBINE_rr_cPt;
611ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
612ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ASLH_cPt_V4:
613ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ASLH_cNotPt_V4;
614ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ASLH_cNotPt_V4:
615ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ASLH_cPt_V4;
616ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
617ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ASRH_cPt_V4:
618ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ASRH_cNotPt_V4;
619ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ASRH_cNotPt_V4:
620ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ASRH_cPt_V4;
621ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
622ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::SXTB_cPt_V4:
623ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::SXTB_cNotPt_V4;
624ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::SXTB_cNotPt_V4:
625ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::SXTB_cPt_V4;
626ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
627ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::SXTH_cPt_V4:
628ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::SXTH_cNotPt_V4;
629ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::SXTH_cNotPt_V4:
630ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::SXTH_cPt_V4;
631ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
632ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ZXTB_cPt_V4:
633ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ZXTB_cNotPt_V4;
634ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ZXTB_cNotPt_V4:
635ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ZXTB_cPt_V4;
636ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
637ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ZXTH_cPt_V4:
638ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ZXTH_cNotPt_V4;
639ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::ZXTH_cNotPt_V4:
640ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::ZXTH_cPt_V4;
641ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
642ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
643ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMPR_cPt:
644ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMPR_cNotPt;
645ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMPR_cNotPt:
646ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMPR_cPt;
647ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
648ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // V4 indexed+scaled load.
649ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_indexed_cPt_V4:
650ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_indexed_cNotPt_V4;
651ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_indexed_cNotPt_V4:
652ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_indexed_cPt_V4;
653ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
654ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_indexed_shl_cPt_V4:
655ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_indexed_shl_cNotPt_V4;
656ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_indexed_shl_cNotPt_V4:
657ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_indexed_shl_cPt_V4;
658ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
659ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_indexed_cPt_V4:
660ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_indexed_cNotPt_V4;
661ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_indexed_cNotPt_V4:
662ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_indexed_cPt_V4;
663ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
664ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_indexed_cPt_V4:
665ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_indexed_cNotPt_V4;
666ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_indexed_cNotPt_V4:
667ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_indexed_cPt_V4;
668ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
669ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_indexed_shl_cPt_V4:
670ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_indexed_shl_cNotPt_V4;
671ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_indexed_shl_cNotPt_V4:
672ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_indexed_shl_cPt_V4;
673ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
674ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_indexed_shl_cPt_V4:
675ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_indexed_shl_cNotPt_V4;
676ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_indexed_shl_cNotPt_V4:
677ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_indexed_shl_cPt_V4;
678ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
679ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_indexed_cPt_V4:
680ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_indexed_cNotPt_V4;
681ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_indexed_cNotPt_V4:
682ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_indexed_cPt_V4;
683ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
684ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_indexed_cPt_V4:
685ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_indexed_cNotPt_V4;
686ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_indexed_cNotPt_V4:
687ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_indexed_cPt_V4;
688ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
689ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_indexed_shl_cPt_V4:
690ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_indexed_shl_cNotPt_V4;
691ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_indexed_shl_cNotPt_V4:
692ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_indexed_shl_cPt_V4;
693ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
694ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_indexed_shl_cPt_V4:
695ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_indexed_shl_cNotPt_V4;
696ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_indexed_shl_cNotPt_V4:
697ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_indexed_shl_cPt_V4;
698ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
699ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_indexed_cPt_V4:
700ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_indexed_cNotPt_V4;
701ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_indexed_cNotPt_V4:
702ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_indexed_cPt_V4;
703ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
704ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_indexed_shl_cPt_V4:
705ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_indexed_shl_cNotPt_V4;
706ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_indexed_shl_cNotPt_V4:
707ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_indexed_shl_cPt_V4;
708ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
709ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    // Byte.
710ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_STbri_cPt:
711ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_STbri_cNotPt;
712ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_STbri_cNotPt:
713ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_STbri_cPt;
714ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
715ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_cPt:
716ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_cNotPt;
717ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_cNotPt:
718ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_cPt;
719ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
720ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_indexed_cPt:
721ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_indexed_cNotPt;
722ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_indexed_cNotPt:
723ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_indexed_cPt;
724ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
725ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_imm_cPt_V4:
726ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_imm_cNotPt_V4;
727ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_imm_cNotPt_V4:
728ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_imm_cPt_V4;
729ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
730ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_indexed_shl_cPt_V4:
731ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_indexed_shl_cNotPt_V4;
732ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrib_indexed_shl_cNotPt_V4:
733ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrib_indexed_shl_cPt_V4;
734ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
735ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // Halfword.
736ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_SThri_cPt:
737ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_SThri_cNotPt;
738ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_SThri_cNotPt:
739ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_SThri_cPt;
740ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
741ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_cPt:
742ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_cNotPt;
743ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_cNotPt:
744ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_cPt;
745ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
746ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_indexed_cPt:
747ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_indexed_cNotPt;
748ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_indexed_cNotPt:
749ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_indexed_cPt;
750ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
751ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_imm_cPt_V4:
752ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_imm_cNotPt_V4;
753ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_imm_cNotPt_V4:
754ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_imm_cPt_V4;
755ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
756ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_indexed_shl_cPt_V4:
757ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_indexed_shl_cNotPt_V4;
758ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrih_indexed_shl_cNotPt_V4:
759ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrih_indexed_shl_cPt_V4;
760ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
761ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // Word.
762ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_STwri_cPt:
763ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_STwri_cNotPt;
764ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_STwri_cNotPt:
765ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_STwri_cPt;
766ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
767ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_cPt:
768ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_cNotPt;
769ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_cNotPt:
770ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_cPt;
771ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
772ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_indexed_cPt:
773ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_indexed_cNotPt;
774ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_indexed_cNotPt:
775ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_indexed_cPt;
776ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
777ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_indexed_shl_cPt_V4:
778ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_indexed_shl_cNotPt_V4;
779ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_indexed_shl_cNotPt_V4:
780ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_indexed_shl_cPt_V4;
781ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
782ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_imm_cPt_V4:
783ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_imm_cNotPt_V4;
784ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STriw_imm_cNotPt_V4:
785ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STriw_imm_cPt_V4;
786ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
787ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // Double word.
788ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_STdri_cPt:
789ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_STdri_cNotPt;
790ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_STdri_cNotPt:
791ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_STdri_cPt;
792ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
793ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrid_cPt:
794ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrid_cNotPt;
795ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrid_cNotPt:
796ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrid_cPt;
797ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
798ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrid_indexed_cPt:
799ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrid_indexed_cNotPt;
800ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrid_indexed_cNotPt:
801ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrid_indexed_cPt;
802ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
803ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrid_indexed_shl_cPt_V4:
804ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrid_indexed_shl_cNotPt_V4;
805ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::STrid_indexed_shl_cNotPt_V4:
806ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::STrid_indexed_shl_cPt_V4;
807ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
808ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // Load.
809ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_cPt:
810ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_cNotPt;
811ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_cNotPt:
812ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_cPt;
813ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
814ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_cPt:
815ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_cNotPt;
816ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_cNotPt:
817ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_cPt;
818ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
819ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_cPt:
820ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_cNotPt;
821ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_cNotPt:
822ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_cPt;
823ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
824ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_cPt:
825ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_cNotPt;
826ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_cNotPt:
827ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_cPt;
828ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
829ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_cPt:
830ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_cNotPt;
831ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_cNotPt:
832ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_cPt;
833ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
834ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_cPt:
835ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_cNotPt;
836ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_cNotPt:
837ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_cPt;
838ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
839ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande // Load Indexed.
840ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_indexed_cPt:
841ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_indexed_cNotPt;
842ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrid_indexed_cNotPt:
843ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrid_indexed_cPt;
844ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
845ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_indexed_cPt:
846ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_indexed_cNotPt;
847ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriw_indexed_cNotPt:
848ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriw_indexed_cPt;
849ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
850ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_indexed_cPt:
851ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_indexed_cNotPt;
852ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrih_indexed_cNotPt:
853ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrih_indexed_cPt;
854ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
855ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_indexed_cPt:
856ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_indexed_cNotPt;
857ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriuh_indexed_cNotPt:
858ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriuh_indexed_cPt;
859ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
860ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_indexed_cPt:
861ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_indexed_cNotPt;
862ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDrib_indexed_cNotPt:
863ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDrib_indexed_cPt;
864ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
865ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_indexed_cPt:
866ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_indexed_cNotPt;
867ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::LDriub_indexed_cNotPt:
868ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::LDriub_indexed_cPt;
869ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
870ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // Post Inc Load.
871ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDrid_cPt:
872ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDrid_cNotPt;
873ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDriw_cNotPt:
874ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDriw_cPt;
875ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
876ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDrih_cPt:
877ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDrih_cNotPt;
878ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDrih_cNotPt:
879ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDrih_cPt;
880ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
881ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDriuh_cPt:
882ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDriuh_cNotPt;
883ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDriuh_cNotPt:
884ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDriuh_cPt;
885ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
886ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDrib_cPt:
887ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDrib_cNotPt;
888ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDrib_cNotPt:
889ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDrib_cPt;
890ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
891ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDriub_cPt:
892ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDriub_cNotPt;
893ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::POST_LDriub_cNotPt:
894ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::POST_LDriub_cPt;
895ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
896ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  // Dealloc_return.
897ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::DEALLOC_RET_cPt_V4:
898ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::DEALLOC_RET_cNotPt_V4;
899ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::DEALLOC_RET_cNotPt_V4:
900ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::DEALLOC_RET_cPt_V4;
901ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
902ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // New Value Jump.
903ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPEQ_ri - with -1.
904ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQriPtneg_nv_V4:
905ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriNotPtneg_nv_V4;
906ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQriNotPtneg_nv_V4:
907ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriPtneg_nv_V4;
908ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
909ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQriPntneg_nv_V4:
910ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriNotPntneg_nv_V4;
911ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQriNotPntneg_nv_V4:
912ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriPntneg_nv_V4;
913ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
914ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPEQ_ri.
915ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_EQriPt_nv_V4:
916ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriNotPt_nv_V4;
917ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQriNotPt_nv_V4:
918ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriPt_nv_V4;
919ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
920ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_EQriPnt_nv_V4:
921ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriNotPnt_nv_V4;
922ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQriNotPnt_nv_V4:
923ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQriPnt_nv_V4;
924ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
925ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPEQ_rr.
926ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_EQrrPt_nv_V4:
927ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQrrNotPt_nv_V4;
928ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQrrNotPt_nv_V4:
929ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQrrPt_nv_V4;
930ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
931ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_EQrrPnt_nv_V4:
932ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQrrNotPnt_nv_V4;
933ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_EQrrNotPnt_nv_V4:
934ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_EQrrPnt_nv_V4;
935ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
936ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGT_ri - with -1.
937ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTriPtneg_nv_V4:
938ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriNotPtneg_nv_V4;
939ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTriNotPtneg_nv_V4:
940ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriPtneg_nv_V4;
941ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
942ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTriPntneg_nv_V4:
943ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriNotPntneg_nv_V4;
944ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTriNotPntneg_nv_V4:
945ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriPntneg_nv_V4;
946ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
947ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGT_ri.
948ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTriPt_nv_V4:
949ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriNotPt_nv_V4;
950ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTriNotPt_nv_V4:
951ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriPt_nv_V4;
952ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
953ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTriPnt_nv_V4:
954ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriNotPnt_nv_V4;
955ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTriNotPnt_nv_V4:
956ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTriPnt_nv_V4;
957ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
958ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGT_rr.
959ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTrrPt_nv_V4:
960ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrNotPt_nv_V4;
961ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTrrNotPt_nv_V4:
962ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrPt_nv_V4;
963ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
964ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTrrPnt_nv_V4:
965ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrNotPnt_nv_V4;
966ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTrrNotPnt_nv_V4:
967ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrPnt_nv_V4;
968ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
969ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGT_rrdn.
970ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTrrdnPt_nv_V4:
971ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrdnNotPt_nv_V4;
972ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTrrdnNotPt_nv_V4:
973ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrdnPt_nv_V4;
974ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
975ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTrrdnPnt_nv_V4:
976ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrdnNotPnt_nv_V4;
977ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
978ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTrrdnPnt_nv_V4;
979ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
980ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGTU_ri.
981ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTUriPt_nv_V4:
982ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUriNotPt_nv_V4;
983ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTUriNotPt_nv_V4:
984ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUriPt_nv_V4;
985ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
986ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTUriPnt_nv_V4:
987ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUriNotPnt_nv_V4;
988ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTUriNotPnt_nv_V4:
989ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUriPnt_nv_V4;
990ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
991ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGTU_rr.
992ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTUrrPt_nv_V4:
993ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrNotPt_nv_V4;
994ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTUrrNotPt_nv_V4:
995ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrPt_nv_V4;
996ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
997ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTUrrPnt_nv_V4:
998ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrNotPnt_nv_V4;
999ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTUrrNotPnt_nv_V4:
1000ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrPnt_nv_V4;
1001ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
1002ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande   // JMPGTU_rrdn.
1003ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTUrrdnPt_nv_V4:
1004ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrdnNotPt_nv_V4;
1005ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
1006ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrdnPt_nv_V4;
1007ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
1008ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande     case Hexagon::JMP_GTUrrdnPnt_nv_V4:
1009ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrdnNotPnt_nv_V4;
1010ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
1011ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande      return Hexagon::JMP_GTUrrdnPnt_nv_V4;
1012ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande
1013ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  default:
1014ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    llvm_unreachable("Unexpected predicated instruction");
1015ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande  }
1016ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande}
1017b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1018ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick
1019b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumint HexagonInstrInfo::
1020b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumgetMatchingCondBranchOpcode(int Opc, bool invertPredicate) const {
1021b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch(Opc) {
1022b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::TFR:
1023b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::TFR_cPt :
1024b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::TFR_cNotPt;
1025b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::TFRI:
1026b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::TFRI_cPt :
1027b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::TFRI_cNotPt;
1028b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::JMP:
1029ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande    return !invertPredicate ? Hexagon::JMP_c :
1030ab7955b9ce3197215406bc9fc97b22074127d035Sirish Pande                              Hexagon::JMP_cNot;
1031b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ADD_ri:
1032b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::ADD_ri_cPt :
1033b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::ADD_ri_cNotPt;
1034b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ADD_rr:
1035b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::ADD_rr_cPt :
1036b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::ADD_rr_cNotPt;
1037b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::XOR_rr:
1038b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::XOR_rr_cPt :
1039b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::XOR_rr_cNotPt;
1040b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::AND_rr:
1041b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::AND_rr_cPt :
1042b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::AND_rr_cNotPt;
1043b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::OR_rr:
1044b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::OR_rr_cPt :
1045b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::OR_rr_cNotPt;
1046b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::SUB_rr:
1047b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::SUB_rr_cPt :
1048b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::SUB_rr_cNotPt;
1049b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::COMBINE_rr:
1050b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::COMBINE_rr_cPt :
1051b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::COMBINE_rr_cNotPt;
1052b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ASLH:
1053b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::ASLH_cPt_V4 :
1054b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::ASLH_cNotPt_V4;
1055b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ASRH:
1056b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::ASRH_cPt_V4 :
1057b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::ASRH_cNotPt_V4;
1058b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::SXTB:
1059b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::SXTB_cPt_V4 :
1060b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::SXTB_cNotPt_V4;
1061b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::SXTH:
1062b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::SXTH_cPt_V4 :
1063b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::SXTH_cNotPt_V4;
1064b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ZXTB:
1065b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::ZXTB_cPt_V4 :
1066b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::ZXTB_cNotPt_V4;
1067b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ZXTH:
1068b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::ZXTH_cPt_V4 :
1069b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::ZXTH_cNotPt_V4;
1070b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1071b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::JMPR:
1072b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::JMPR_cPt :
1073b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::JMPR_cNotPt;
1074b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1075b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // V4 indexed+scaled load.
1076b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid_indexed_V4:
1077b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrid_indexed_cPt_V4 :
1078b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrid_indexed_cNotPt_V4;
1079b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid_indexed_shl_V4:
1080b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrid_indexed_shl_cPt_V4 :
1081b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrid_indexed_shl_cNotPt_V4;
1082b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib_indexed_V4:
1083b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrib_indexed_cPt_V4 :
1084b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrib_indexed_cNotPt_V4;
1085b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_indexed_V4:
1086b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_indexed_cPt_V4 :
1087b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_indexed_cNotPt_V4;
1088b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_ae_indexed_V4:
1089b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_indexed_cPt_V4 :
1090b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_indexed_cNotPt_V4;
1091b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib_indexed_shl_V4:
1092b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrib_indexed_shl_cPt_V4 :
1093b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrib_indexed_shl_cNotPt_V4;
1094b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_indexed_shl_V4:
1095b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 :
1096b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_indexed_shl_cNotPt_V4;
1097b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_ae_indexed_shl_V4:
1098b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 :
1099b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_indexed_shl_cNotPt_V4;
1100b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih_indexed_V4:
1101b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrih_indexed_cPt_V4 :
1102b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrih_indexed_cNotPt_V4;
1103b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh_indexed_V4:
1104b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriuh_indexed_cPt_V4 :
1105b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriuh_indexed_cNotPt_V4;
1106b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh_ae_indexed_V4:
1107b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriuh_indexed_cPt_V4 :
1108b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriuh_indexed_cNotPt_V4;
1109b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih_indexed_shl_V4:
1110b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrih_indexed_shl_cPt_V4 :
1111b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrih_indexed_shl_cNotPt_V4;
1112b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh_indexed_shl_V4:
1113b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 :
1114b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriuh_indexed_shl_cNotPt_V4;
1115b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh_ae_indexed_shl_V4:
1116b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 :
1117b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriuh_indexed_shl_cNotPt_V4;
1118b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw_indexed_V4:
1119b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriw_indexed_cPt_V4 :
1120b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriw_indexed_cNotPt_V4;
1121b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw_indexed_shl_V4:
1122b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriw_indexed_shl_cPt_V4 :
1123b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriw_indexed_shl_cNotPt_V4;
1124b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    // Byte.
1125b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_STbri:
1126b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_STbri_cPt :
1127b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_STbri_cNotPt;
1128b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib:
1129b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrib_cPt :
1130b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrib_cNotPt;
1131b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib_indexed:
1132b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrib_indexed_cPt :
1133b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrib_indexed_cNotPt;
1134b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib_imm_V4:
1135b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrib_imm_cPt_V4 :
1136b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrib_imm_cNotPt_V4;
1137b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib_indexed_shl_V4:
1138b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrib_indexed_shl_cPt_V4 :
1139b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrib_indexed_shl_cNotPt_V4;
1140b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Halfword.
1141b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_SThri:
1142b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_SThri_cPt :
1143b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_SThri_cNotPt;
1144b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih:
1145b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrih_cPt :
1146b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrih_cNotPt;
1147b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih_indexed:
1148b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrih_indexed_cPt :
1149b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrih_indexed_cNotPt;
1150b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih_imm_V4:
1151b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrih_imm_cPt_V4 :
1152b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrih_imm_cNotPt_V4;
1153b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih_indexed_shl_V4:
1154b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrih_indexed_shl_cPt_V4 :
1155b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrih_indexed_shl_cNotPt_V4;
1156b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Word.
1157b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_STwri:
1158b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_STwri_cPt :
1159b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_STwri_cNotPt;
1160b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw:
1161b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STriw_cPt :
1162b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STriw_cNotPt;
1163b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_indexed:
1164b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STriw_indexed_cPt :
1165b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STriw_indexed_cNotPt;
1166b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_indexed_shl_V4:
1167b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STriw_indexed_shl_cPt_V4 :
1168b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STriw_indexed_shl_cNotPt_V4;
1169b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_imm_V4:
1170b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STriw_imm_cPt_V4 :
1171b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STriw_imm_cNotPt_V4;
1172b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Double word.
1173b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_STdri:
1174b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_STdri_cPt :
1175b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_STdri_cNotPt;
1176b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid:
1177b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrid_cPt :
1178b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrid_cNotPt;
1179b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid_indexed:
1180b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrid_indexed_cPt :
1181b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrid_indexed_cNotPt;
1182b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid_indexed_shl_V4:
1183b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::STrid_indexed_shl_cPt_V4 :
1184b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::STrid_indexed_shl_cNotPt_V4;
1185b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Load.
1186b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid:
1187b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrid_cPt :
1188b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrid_cNotPt;
1189b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw:
1190b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriw_cPt :
1191b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriw_cNotPt;
1192b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih:
1193b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrih_cPt :
1194b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrih_cNotPt;
1195b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh:
1196b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriuh_cPt :
1197b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriuh_cNotPt;
1198b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib:
1199b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrib_cPt :
1200b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrib_cNotPt;
1201b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub:
1202b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_cPt :
1203b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_cNotPt;
1204b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriubit:
1205b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_cPt :
1206b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_cNotPt;
1207b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum // Load Indexed.
1208b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid_indexed:
1209b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrid_indexed_cPt :
1210b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrid_indexed_cNotPt;
1211b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw_indexed:
1212b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriw_indexed_cPt :
1213b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriw_indexed_cNotPt;
1214b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih_indexed:
1215b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrih_indexed_cPt :
1216b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrih_indexed_cNotPt;
1217b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh_indexed:
1218b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriuh_indexed_cPt :
1219b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriuh_indexed_cNotPt;
1220b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib_indexed:
1221b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDrib_indexed_cPt :
1222b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDrib_indexed_cNotPt;
1223b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_indexed:
1224b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::LDriub_indexed_cPt :
1225b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::LDriub_indexed_cNotPt;
1226b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // Post Increment Load.
1227b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDrid:
1228b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_LDrid_cPt :
1229b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_LDrid_cNotPt;
1230b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDriw:
1231b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_LDriw_cPt :
1232b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_LDriw_cNotPt;
1233b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDrih:
1234b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_LDrih_cPt :
1235b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_LDrih_cNotPt;
1236b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDriuh:
1237b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_LDriuh_cPt :
1238b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_LDriuh_cNotPt;
1239b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDrib:
1240b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_LDrib_cPt :
1241b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_LDrib_cNotPt;
1242b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::POST_LDriub:
1243b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::POST_LDriub_cPt :
1244b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::POST_LDriub_cNotPt;
1245b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // DEALLOC_RETURN.
1246b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_V4:
1247b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return !invertPredicate ? Hexagon::DEALLOC_RET_cPt_V4 :
1248b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                              Hexagon::DEALLOC_RET_cNotPt_V4;
1249b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
125027baab62e7d6267d9b18e4665c6bb1b75dae10d4Benjamin Kramer  llvm_unreachable("Unexpected predicable instruction");
1251b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1252b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1253b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1254b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1255b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumPredicateInstruction(MachineInstr *MI,
1256b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                     const SmallVectorImpl<MachineOperand> &Cond) const {
1257b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  int Opc = MI->getOpcode();
1258b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  assert (isPredicable(MI) && "Expected predicable instruction");
1259b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  bool invertJump = (!Cond.empty() && Cond[0].isImm() &&
1260b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                     (Cond[0].getImm() == 0));
1261b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MI->setDesc(get(getMatchingCondBranchOpcode(Opc, invertJump)));
1262b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //
1263b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // This assumes that the predicate is always the first operand
1264b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // in the set of inputs.
1265b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  //
1266b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MI->addOperand(MI->getOperand(MI->getNumOperands()-1));
1267b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  int oper;
1268b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  for (oper = MI->getNumOperands() - 3; oper >= 0; --oper) {
1269b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    MachineOperand MO = MI->getOperand(oper);
1270b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if ((MO.isReg() && !MO.isUse() && !MO.isImplicit())) {
1271b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      break;
1272b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
1273b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1274b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (MO.isReg()) {
1275b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      MI->getOperand(oper+1).ChangeToRegister(MO.getReg(), MO.isDef(),
1276b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                              MO.isImplicit(), MO.isKill(),
1277b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                              MO.isDead(), MO.isUndef(),
1278b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                              MO.isDebug());
1279b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    } else if (MO.isImm()) {
1280b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      MI->getOperand(oper+1).ChangeToImmediate(MO.getImm());
1281b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    } else {
1282bc2198133a1836598b54b943420748e75d5dea94Craig Topper      llvm_unreachable("Unexpected operand type");
1283b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
1284b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1285b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1286b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  int regPos = invertJump ? 1 : 0;
1287b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MachineOperand PredMO = Cond[regPos];
1288b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  MI->getOperand(oper+1).ChangeToRegister(PredMO.getReg(), PredMO.isDef(),
1289b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                          PredMO.isImplicit(), PredMO.isKill(),
1290b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                          PredMO.isDead(), PredMO.isUndef(),
1291b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                          PredMO.isDebug());
1292b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1293b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return true;
1294b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1295b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1296b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1297b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool
1298b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumHexagonInstrInfo::
1299b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisProfitableToIfCvt(MachineBasicBlock &MBB,
1300b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned NumCyles,
1301b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned ExtraPredCycles,
1302b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    const BranchProbability &Probability) const {
1303b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return true;
1304b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1305b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1306b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1307b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool
1308b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumHexagonInstrInfo::
1309b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisProfitableToIfCvt(MachineBasicBlock &TMBB,
1310b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned NumTCycles,
1311b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned ExtraTCycles,
1312b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    MachineBasicBlock &FMBB,
1313b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned NumFCycles,
1314b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    unsigned ExtraFCycles,
1315b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                    const BranchProbability &Probability) const {
1316b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return true;
1317b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1318b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1319b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1320b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::isPredicated(const MachineInstr *MI) const {
1321c635ebdb1a366060fe71ef3028ae888fa5e4130dBrendon Cahoon  const uint64_t F = MI->getDesc().TSFlags;
1322b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1323c635ebdb1a366060fe71ef3028ae888fa5e4130dBrendon Cahoon  return ((F >> HexagonII::PredicatedPos) & HexagonII::PredicatedMask);
1324b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1325b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1326b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1327b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool
1328b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumHexagonInstrInfo::DefinesPredicate(MachineInstr *MI,
1329b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                                   std::vector<MachineOperand> &Pred) const {
1330b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  for (unsigned oper = 0; oper < MI->getNumOperands(); ++oper) {
1331b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    MachineOperand MO = MI->getOperand(oper);
1332b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    if (MO.isReg() && MO.isDef()) {
1333b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      const TargetRegisterClass* RC = RI.getMinimalPhysRegClass(MO.getReg());
1334b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      if (RC == Hexagon::PredRegsRegisterClass) {
1335b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        Pred.push_back(MO);
1336b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum        return true;
1337b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      }
1338b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    }
1339b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1340b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return false;
1341b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1342b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1343b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1344b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool
1345b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumHexagonInstrInfo::
1346b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumSubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
1347b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                  const SmallVectorImpl<MachineOperand> &Pred2) const {
1348b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // TODO: Fix this
1349b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return false;
1350b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1351b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1352b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1353b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
1354b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// We indicate that we want to reverse the branch by
1355b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// inserting a 0 at the beginning of the Cond vector.
1356b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
1357b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1358b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
1359b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) {
1360b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    Cond.erase(Cond.begin());
1361b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  } else {
1362b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    Cond.insert(Cond.begin(), MachineOperand::CreateImm(0));
1363b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1364b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return false;
1365b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1366b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1367b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1368b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1369b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisProfitableToDupForIfCvt(MachineBasicBlock &MBB,unsigned NumInstrs,
1370b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum                          const BranchProbability &Probability) const {
1371b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return (NumInstrs <= 4);
1372b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1373b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1374b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::isDeallocRet(const MachineInstr *MI) const {
1375b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode()) {
1376b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_V4 :
1377b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_cPt_V4 :
1378b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_cNotPt_V4 :
1379b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_cdnPnt_V4 :
1380b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_cNotdnPnt_V4 :
1381b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_cdnPt_V4 :
1382b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::DEALLOC_RET_cNotdnPt_V4 :
1383b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum   return true;
1384b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1385b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return false;
1386b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1387b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1388b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1389b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1390b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisValidOffset(const int Opcode, const int Offset) const {
1391b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // This function is to check whether the "Offset" is in the correct range of
1392b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // the given "Opcode". If "Offset" is not in the correct range, "ADD_ri" is
1393b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // inserted to calculate the final address. Due to this reason, the function
1394b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // assumes that the "Offset" has correct alignment.
1395b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1396b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch(Opcode) {
1397b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1398b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw:
1399b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw:
1400b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriwt:
1401b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    assert((Offset % 4 == 0) && "Offset has incorrect alignment");
1402b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (Offset >= Hexagon_MEMW_OFFSET_MIN) &&
1403b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      (Offset <= Hexagon_MEMW_OFFSET_MAX);
1404b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1405b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrid:
1406b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrid:
1407b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    assert((Offset % 8 == 0) && "Offset has incorrect alignment");
1408b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (Offset >= Hexagon_MEMD_OFFSET_MIN) &&
1409b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      (Offset <= Hexagon_MEMD_OFFSET_MAX);
1410b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1411b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih:
1412b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriuh:
1413b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrih:
1414b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrih_ae:
1415b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    assert((Offset % 2 == 0) && "Offset has incorrect alignment");
1416b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (Offset >= Hexagon_MEMH_OFFSET_MIN) &&
1417b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      (Offset <= Hexagon_MEMH_OFFSET_MAX);
1418b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1419b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib:
1420b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STrib:
1421b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub:
1422b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriubit:
1423b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDrib_ae:
1424b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriub_ae:
1425b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (Offset >= Hexagon_MEMB_OFFSET_MIN) &&
1426b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      (Offset <= Hexagon_MEMB_OFFSET_MAX);
1427b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1428b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::ADD_ri:
1429b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::TFR_FI:
1430b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (Offset >= Hexagon_ADDI_OFFSET_MIN) &&
1431b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      (Offset <= Hexagon_ADDI_OFFSET_MAX);
1432b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1433b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ADDSUBi_indexed_MEM_V4 :
1434b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
1435b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
1436b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
1437b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
1438b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
1439b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ORr_indexed_MEM_V4 :
1440b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ADDSUBi_MEM_V4 :
1441b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ADDi_MEM_V4 :
1442b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_SUBi_MEM_V4 :
1443b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ADDr_MEM_V4 :
1444b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_SUBr_MEM_V4 :
1445b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ANDr_MEM_V4 :
1446b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMw_ORr_MEM_V4 :
1447b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    assert ((Offset % 4) == 0 && "MEMOPw offset is not aligned correctly." );
1448b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (0 <= Offset && Offset <= 255);
1449b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1450b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ADDSUBi_indexed_MEM_V4 :
1451b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
1452b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
1453b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
1454b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
1455b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
1456b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ORr_indexed_MEM_V4 :
1457b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ADDSUBi_MEM_V4 :
1458b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ADDi_MEM_V4 :
1459b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_SUBi_MEM_V4 :
1460b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ADDr_MEM_V4 :
1461b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_SUBr_MEM_V4 :
1462b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ANDr_MEM_V4 :
1463b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMh_ORr_MEM_V4 :
1464b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    assert ((Offset % 2) == 0 && "MEMOPh offset is not aligned correctly." );
1465b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (0 <= Offset && Offset <= 127);
1466b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1467b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ADDSUBi_indexed_MEM_V4 :
1468b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
1469b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
1470b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
1471b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
1472b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
1473b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ORr_indexed_MEM_V4 :
1474b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ADDSUBi_MEM_V4 :
1475b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ADDi_MEM_V4 :
1476b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_SUBi_MEM_V4 :
1477b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ADDr_MEM_V4 :
1478b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_SUBr_MEM_V4 :
1479b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ANDr_MEM_V4 :
1480b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::MEMb_ORr_MEM_V4 :
1481b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return (0 <= Offset && Offset <= 63);
1482b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1483b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // LDri_pred and STriw_pred are pseudo operations, so it has to take offset of
1484b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // any size. Later pass knows how to handle it.
1485b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::STriw_pred:
1486b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::LDriw_pred:
1487b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return true;
1488b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1489b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  // INLINEASM is very special.
1490b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  case Hexagon::INLINEASM:
1491b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return true;
1492b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1493b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
149427baab62e7d6267d9b18e4665c6bb1b75dae10d4Benjamin Kramer  llvm_unreachable("No offset range is defined for this opcode. "
149527baab62e7d6267d9b18e4665c6bb1b75dae10d4Benjamin Kramer                   "Please define it in the above switch statement!");
1496b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1497b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1498b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1499b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
1500b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum// Check if the Offset is a valid auto-inc imm by Load/Store Type.
1501b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum//
1502b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1503b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisValidAutoIncImm(const EVT VT, const int Offset) const {
1504b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1505b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (VT == MVT::i64) {
1506b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return (Offset >= Hexagon_MEMD_AUTOINC_MIN &&
1507b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              Offset <= Hexagon_MEMD_AUTOINC_MAX &&
1508b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              (Offset & 0x7) == 0);
1509b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1510b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (VT == MVT::i32) {
1511b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return (Offset >= Hexagon_MEMW_AUTOINC_MIN &&
1512b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              Offset <= Hexagon_MEMW_AUTOINC_MAX &&
1513b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              (Offset & 0x3) == 0);
1514b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1515b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (VT == MVT::i16) {
1516b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return (Offset >= Hexagon_MEMH_AUTOINC_MIN &&
1517b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              Offset <= Hexagon_MEMH_AUTOINC_MAX &&
1518b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              (Offset & 0x1) == 0);
1519b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1520b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  if (VT == MVT::i8) {
1521b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return (Offset >= Hexagon_MEMB_AUTOINC_MIN &&
1522b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum              Offset <= Hexagon_MEMB_AUTOINC_MAX);
1523b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1524bc2198133a1836598b54b943420748e75d5dea94Craig Topper  llvm_unreachable("Not an auto-inc opc!");
1525b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1526b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1527b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1528b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1529b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisMemOp(const MachineInstr *MI) const {
1530b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode())
1531b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  {
1532b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ADDSUBi_indexed_MEM_V4 :
1533b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
1534b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
1535b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
1536b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
1537b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
1538b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ORr_indexed_MEM_V4 :
1539b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ADDSUBi_MEM_V4 :
1540b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ADDi_MEM_V4 :
1541b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_SUBi_MEM_V4 :
1542b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ADDr_MEM_V4 :
1543b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_SUBr_MEM_V4 :
1544b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ANDr_MEM_V4 :
1545b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMw_ORr_MEM_V4 :
1546b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ADDSUBi_indexed_MEM_V4 :
1547b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
1548b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
1549b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
1550b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
1551b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
1552b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ORr_indexed_MEM_V4 :
1553b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ADDSUBi_MEM_V4 :
1554b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ADDi_MEM_V4 :
1555b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_SUBi_MEM_V4 :
1556b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ADDr_MEM_V4 :
1557b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_SUBr_MEM_V4 :
1558b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ANDr_MEM_V4 :
1559b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMh_ORr_MEM_V4 :
1560b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ADDSUBi_indexed_MEM_V4 :
1561b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
1562b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
1563b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
1564b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
1565b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
1566b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ORr_indexed_MEM_V4 :
1567b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ADDSUBi_MEM_V4 :
1568b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ADDi_MEM_V4 :
1569b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_SUBi_MEM_V4 :
1570b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ADDr_MEM_V4 :
1571b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_SUBr_MEM_V4 :
1572b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ANDr_MEM_V4 :
1573b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::MEMb_ORr_MEM_V4 :
1574b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return true;
1575b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1576b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return false;
1577b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1578b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1579b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1580b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1581b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisSpillPredRegOp(const MachineInstr *MI) const {
1582b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode())
1583b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  {
1584b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::STriw_pred :
1585b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_pred :
1586b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    return true;
1587b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1588b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  return false;
1589b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1590b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1591b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1592b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::isConditionalALU32 (const MachineInstr* MI) const {
1593b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  const HexagonRegisterInfo& QRI = getRegisterInfo();
1594b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode())
1595b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  {
1596b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ADD_ri_cPt:
1597b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ADD_ri_cNotPt:
1598b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ADD_rr_cPt:
1599b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ADD_rr_cNotPt:
1600b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::XOR_rr_cPt:
1601b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::XOR_rr_cNotPt:
1602b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::AND_rr_cPt:
1603b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::AND_rr_cNotPt:
1604b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::OR_rr_cPt:
1605b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::OR_rr_cNotPt:
1606b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::SUB_rr_cPt:
1607b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::SUB_rr_cNotPt:
1608b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::COMBINE_rr_cPt:
1609b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::COMBINE_rr_cNotPt:
1610b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return true;
1611b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ASLH_cPt_V4:
1612b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ASLH_cNotPt_V4:
1613b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ASRH_cPt_V4:
1614b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ASRH_cNotPt_V4:
1615b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::SXTB_cPt_V4:
1616b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::SXTB_cNotPt_V4:
1617b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::SXTH_cPt_V4:
1618b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::SXTH_cNotPt_V4:
1619b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ZXTB_cPt_V4:
1620b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ZXTB_cNotPt_V4:
1621b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ZXTH_cPt_V4:
1622b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::ZXTH_cNotPt_V4:
1623b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return QRI.Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4;
1624b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1625b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    default:
1626b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return false;
1627b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1628b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1629b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1630b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum
1631b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicumbool HexagonInstrInfo::
1632b4b54153ad760c69a00a08531abef4ed434a5092Tony LinthicumisConditionalLoad (const MachineInstr* MI) const {
1633b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  const HexagonRegisterInfo& QRI = getRegisterInfo();
1634b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  switch (MI->getOpcode())
1635b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  {
1636b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_cPt :
1637b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_cNotPt :
1638b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_indexed_cPt :
1639b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_indexed_cNotPt :
1640b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_cPt :
1641b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_cNotPt :
1642b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_indexed_cPt :
1643b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_indexed_cNotPt :
1644b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_cPt :
1645b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_cNotPt :
1646b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_indexed_cPt :
1647b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_indexed_cNotPt :
1648b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_cPt :
1649b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_cNotPt :
1650b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_indexed_cPt :
1651b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_indexed_cNotPt :
1652b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_cPt :
1653b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_cNotPt :
1654b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_indexed_cPt :
1655b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_indexed_cNotPt :
1656b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_cPt :
1657b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_cNotPt :
1658b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_indexed_cPt :
1659b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_indexed_cNotPt :
1660b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return true;
1661b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDrid_cPt :
1662b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDrid_cNotPt :
1663b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDriw_cPt :
1664b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDriw_cNotPt :
1665b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDrih_cPt :
1666b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDrih_cNotPt :
1667b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDrib_cPt :
1668b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDrib_cNotPt :
1669b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDriuh_cPt :
1670b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDriuh_cNotPt :
1671b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDriub_cPt :
1672b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::POST_LDriub_cNotPt :
1673b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return QRI.Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4;
1674b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_indexed_cPt_V4 :
1675b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_indexed_cNotPt_V4 :
1676b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_indexed_shl_cPt_V4 :
1677b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrid_indexed_shl_cNotPt_V4 :
1678b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_indexed_cPt_V4 :
1679b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_indexed_cNotPt_V4 :
1680b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_indexed_shl_cPt_V4 :
1681b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrib_indexed_shl_cNotPt_V4 :
1682b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_indexed_cPt_V4 :
1683b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_indexed_cNotPt_V4 :
1684b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_indexed_shl_cPt_V4 :
1685b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriub_indexed_shl_cNotPt_V4 :
1686b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_indexed_cPt_V4 :
1687b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_indexed_cNotPt_V4 :
1688b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_indexed_shl_cPt_V4 :
1689b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDrih_indexed_shl_cNotPt_V4 :
1690b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_indexed_cPt_V4 :
1691b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_indexed_cNotPt_V4 :
1692b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_indexed_shl_cPt_V4 :
1693b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriuh_indexed_shl_cNotPt_V4 :
1694b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_indexed_cPt_V4 :
1695b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_indexed_cNotPt_V4 :
1696b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_indexed_shl_cPt_V4 :
1697b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    case Hexagon::LDriw_indexed_shl_cNotPt_V4 :
1698b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return QRI.Subtarget.getHexagonArchVersion() == HexagonSubtarget::V4;
1699b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum    default:
1700b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum      return false;
1701b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum  }
1702b4b54153ad760c69a00a08531abef4ed434a5092Tony Linthicum}
1703ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick
1704ee498d3254b86bceb4f441741e9f442990647ce6Andrew TrickDFAPacketizer *HexagonInstrInfo::
1705ee498d3254b86bceb4f441741e9f442990647ce6Andrew TrickCreateTargetScheduleState(const TargetMachine *TM,
1706ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick                           const ScheduleDAG *DAG) const {
1707ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  const InstrItineraryData *II = TM->getInstrItineraryData();
1708ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  return TM->getSubtarget<HexagonGenSubtargetInfo>().createDFAPacketizer(II);
1709ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick}
1710ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick
1711ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trickbool HexagonInstrInfo::isSchedulingBoundary(const MachineInstr *MI,
1712ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick                                            const MachineBasicBlock *MBB,
1713ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick                                            const MachineFunction &MF) const {
1714ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // Debug info is never a scheduling boundary. It's necessary to be explicit
1715ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // due to the special treatment of IT instructions below, otherwise a
1716ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // dbg_value followed by an IT will result in the IT instruction being
1717ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // considered a scheduling hazard, which is wrong. It should be the actual
1718ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // instruction preceding the dbg_value instruction(s), just like it is
1719ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // when debug info is not present.
1720ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  if (MI->isDebugValue())
1721ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick    return false;
1722ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick
1723ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  // Terminators and labels can't be scheduled around.
1724ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  if (MI->getDesc().isTerminator() || MI->isLabel() || MI->isInlineAsm())
1725ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick    return true;
1726ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick
1727ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick  return false;
1728ee498d3254b86bceb4f441741e9f442990647ce6Andrew Trick}
1729