blob: d30cddaca5e2a0543d98be2e2ef8ea6fa3457e96 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- HexagonInstrInfo.cpp - Hexagon Instruction Information ------------===//
Tony Linthicumb4b54152011-12-12 21:14:40 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the Hexagon implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
Tony Linthicumb4b54152011-12-12 21:14:40 +000014#include "HexagonInstrInfo.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000015#include "Hexagon.h"
Craig Topper79aa3412012-03-17 18:46:09 +000016#include "HexagonRegisterInfo.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000017#include "HexagonSubtarget.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000018#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/SmallVector.h"
Benjamin Kramerf3fd7ee2012-02-06 10:19:29 +000020#include "llvm/CodeGen/DFAPacketizer.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000021#include "llvm/CodeGen/MachineFrameInfo.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000022#include "llvm/CodeGen/MachineInstrBuilder.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000023#include "llvm/CodeGen/MachineMemOperand.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000024#include "llvm/CodeGen/MachineRegisterInfo.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000025#include "llvm/CodeGen/PseudoSourceValue.h"
Benjamin Kramerf3fd7ee2012-02-06 10:19:29 +000026#include "llvm/Support/MathExtras.h"
Tony Linthicumb4b54152011-12-12 21:14:40 +000027#define GET_INSTRINFO_CTOR
Pranav Bhandarkar8aa138c2012-11-01 19:13:23 +000028#define GET_INSTRMAP_INFO
Tony Linthicumb4b54152011-12-12 21:14:40 +000029#include "HexagonGenInstrInfo.inc"
Andrew Trickee498d32012-02-01 22:13:57 +000030#include "HexagonGenDFAPacketizer.inc"
Tony Linthicumb4b54152011-12-12 21:14:40 +000031
Tony Linthicumb4b54152011-12-12 21:14:40 +000032using namespace llvm;
33
34///
35/// Constants for Hexagon instructions.
36///
37const int Hexagon_MEMW_OFFSET_MAX = 4095;
Sirish Pande26f61a12012-05-03 21:52:53 +000038const int Hexagon_MEMW_OFFSET_MIN = -4096;
Tony Linthicumb4b54152011-12-12 21:14:40 +000039const int Hexagon_MEMD_OFFSET_MAX = 8191;
Sirish Pande26f61a12012-05-03 21:52:53 +000040const int Hexagon_MEMD_OFFSET_MIN = -8192;
Tony Linthicumb4b54152011-12-12 21:14:40 +000041const int Hexagon_MEMH_OFFSET_MAX = 2047;
Sirish Pande26f61a12012-05-03 21:52:53 +000042const int Hexagon_MEMH_OFFSET_MIN = -2048;
Tony Linthicumb4b54152011-12-12 21:14:40 +000043const int Hexagon_MEMB_OFFSET_MAX = 1023;
Sirish Pande26f61a12012-05-03 21:52:53 +000044const int Hexagon_MEMB_OFFSET_MIN = -1024;
Tony Linthicumb4b54152011-12-12 21:14:40 +000045const int Hexagon_ADDI_OFFSET_MAX = 32767;
Sirish Pande26f61a12012-05-03 21:52:53 +000046const int Hexagon_ADDI_OFFSET_MIN = -32768;
Tony Linthicumb4b54152011-12-12 21:14:40 +000047const int Hexagon_MEMD_AUTOINC_MAX = 56;
Sirish Pande26f61a12012-05-03 21:52:53 +000048const int Hexagon_MEMD_AUTOINC_MIN = -64;
Tony Linthicumb4b54152011-12-12 21:14:40 +000049const int Hexagon_MEMW_AUTOINC_MAX = 28;
Sirish Pande26f61a12012-05-03 21:52:53 +000050const int Hexagon_MEMW_AUTOINC_MIN = -32;
Tony Linthicumb4b54152011-12-12 21:14:40 +000051const int Hexagon_MEMH_AUTOINC_MAX = 14;
Sirish Pande26f61a12012-05-03 21:52:53 +000052const int Hexagon_MEMH_AUTOINC_MIN = -16;
Tony Linthicumb4b54152011-12-12 21:14:40 +000053const int Hexagon_MEMB_AUTOINC_MAX = 7;
Sirish Pande26f61a12012-05-03 21:52:53 +000054const int Hexagon_MEMB_AUTOINC_MIN = -8;
Tony Linthicumb4b54152011-12-12 21:14:40 +000055
56
57HexagonInstrInfo::HexagonInstrInfo(HexagonSubtarget &ST)
58 : HexagonGenInstrInfo(Hexagon::ADJCALLSTACKDOWN, Hexagon::ADJCALLSTACKUP),
59 RI(ST, *this), Subtarget(ST) {
60}
61
62
63/// isLoadFromStackSlot - If the specified machine instruction is a direct
64/// load from a stack slot, return the virtual or physical register number of
65/// the destination along with the FrameIndex of the loaded stack slot. If
66/// not, return 0. This predicate must return 0 if the instruction has
67/// any side effects other than loading from the stack slot.
68unsigned HexagonInstrInfo::isLoadFromStackSlot(const MachineInstr *MI,
69 int &FrameIndex) const {
70
71
72 switch (MI->getOpcode()) {
Sirish Pande26f61a12012-05-03 21:52:53 +000073 default: break;
Tony Linthicumb4b54152011-12-12 21:14:40 +000074 case Hexagon::LDriw:
75 case Hexagon::LDrid:
76 case Hexagon::LDrih:
77 case Hexagon::LDrib:
78 case Hexagon::LDriub:
79 if (MI->getOperand(2).isFI() &&
80 MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) {
81 FrameIndex = MI->getOperand(2).getIndex();
82 return MI->getOperand(0).getReg();
83 }
84 break;
Tony Linthicumb4b54152011-12-12 21:14:40 +000085 }
Tony Linthicumb4b54152011-12-12 21:14:40 +000086 return 0;
87}
88
89
90/// isStoreToStackSlot - If the specified machine instruction is a direct
91/// store to a stack slot, return the virtual or physical register number of
92/// the source reg along with the FrameIndex of the loaded stack slot. If
93/// not, return 0. This predicate must return 0 if the instruction has
94/// any side effects other than storing to the stack slot.
95unsigned HexagonInstrInfo::isStoreToStackSlot(const MachineInstr *MI,
96 int &FrameIndex) const {
97 switch (MI->getOpcode()) {
Sirish Pande26f61a12012-05-03 21:52:53 +000098 default: break;
Tony Linthicumb4b54152011-12-12 21:14:40 +000099 case Hexagon::STriw:
100 case Hexagon::STrid:
101 case Hexagon::STrih:
102 case Hexagon::STrib:
103 if (MI->getOperand(2).isFI() &&
104 MI->getOperand(1).isImm() && (MI->getOperand(1).getImm() == 0)) {
Sirish Pande2b38c122012-05-12 05:54:15 +0000105 FrameIndex = MI->getOperand(0).getIndex();
106 return MI->getOperand(2).getReg();
Tony Linthicumb4b54152011-12-12 21:14:40 +0000107 }
108 break;
Tony Linthicumb4b54152011-12-12 21:14:40 +0000109 }
Tony Linthicumb4b54152011-12-12 21:14:40 +0000110 return 0;
111}
112
113
114unsigned
115HexagonInstrInfo::InsertBranch(MachineBasicBlock &MBB,MachineBasicBlock *TBB,
116 MachineBasicBlock *FBB,
117 const SmallVectorImpl<MachineOperand> &Cond,
118 DebugLoc DL) const{
119
120 int BOpc = Hexagon::JMP;
Sirish Pandeab7955b2012-02-15 18:52:27 +0000121 int BccOpc = Hexagon::JMP_c;
Tony Linthicumb4b54152011-12-12 21:14:40 +0000122
123 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
124
125 int regPos = 0;
126 // Check if ReverseBranchCondition has asked to reverse this branch
127 // If we want to reverse the branch an odd number of times, we want
Sirish Pandeab7955b2012-02-15 18:52:27 +0000128 // JMP_cNot.
Tony Linthicumb4b54152011-12-12 21:14:40 +0000129 if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) {
Sirish Pandeab7955b2012-02-15 18:52:27 +0000130 BccOpc = Hexagon::JMP_cNot;
Tony Linthicumb4b54152011-12-12 21:14:40 +0000131 regPos = 1;
132 }
133
134 if (FBB == 0) {
135 if (Cond.empty()) {
136 // Due to a bug in TailMerging/CFG Optimization, we need to add a
137 // special case handling of a predicated jump followed by an
138 // unconditional jump. If not, Tail Merging and CFG Optimization go
139 // into an infinite loop.
140 MachineBasicBlock *NewTBB, *NewFBB;
141 SmallVector<MachineOperand, 4> Cond;
142 MachineInstr *Term = MBB.getFirstTerminator();
143 if (isPredicated(Term) && !AnalyzeBranch(MBB, NewTBB, NewFBB, Cond,
144 false)) {
145 MachineBasicBlock *NextBB =
146 llvm::next(MachineFunction::iterator(&MBB));
147 if (NewTBB == NextBB) {
148 ReverseBranchCondition(Cond);
149 RemoveBranch(MBB);
150 return InsertBranch(MBB, TBB, 0, Cond, DL);
151 }
152 }
153 BuildMI(&MBB, DL, get(BOpc)).addMBB(TBB);
154 } else {
155 BuildMI(&MBB, DL,
156 get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB);
157 }
158 return 1;
159 }
160
161 BuildMI(&MBB, DL, get(BccOpc)).addReg(Cond[regPos].getReg()).addMBB(TBB);
162 BuildMI(&MBB, DL, get(BOpc)).addMBB(FBB);
163
164 return 2;
165}
166
167
168bool HexagonInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
169 MachineBasicBlock *&TBB,
170 MachineBasicBlock *&FBB,
171 SmallVectorImpl<MachineOperand> &Cond,
172 bool AllowModify) const {
Benjamin Kramer51b49c52012-05-13 15:13:22 +0000173 TBB = NULL;
Tony Linthicumb4b54152011-12-12 21:14:40 +0000174 FBB = NULL;
175
176 // If the block has no terminators, it just falls into the block after it.
177 MachineBasicBlock::iterator I = MBB.end();
178 if (I == MBB.begin())
179 return false;
180
181 // A basic block may looks like this:
182 //
183 // [ insn
184 // EH_LABEL
185 // insn
186 // insn
187 // insn
188 // EH_LABEL
189 // insn ]
190 //
191 // It has two succs but does not have a terminator
192 // Don't know how to handle it.
193 do {
194 --I;
195 if (I->isEHLabel())
196 return true;
197 } while (I != MBB.begin());
198
199 I = MBB.end();
200 --I;
201
202 while (I->isDebugValue()) {
203 if (I == MBB.begin())
204 return false;
205 --I;
206 }
207 if (!isUnpredicatedTerminator(I))
208 return false;
209
210 // Get the last instruction in the block.
211 MachineInstr *LastInst = I;
212
213 // If there is only one terminator instruction, process it.
214 if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
215 if (LastInst->getOpcode() == Hexagon::JMP) {
216 TBB = LastInst->getOperand(0).getMBB();
217 return false;
218 }
Sirish Pandeab7955b2012-02-15 18:52:27 +0000219 if (LastInst->getOpcode() == Hexagon::JMP_c) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000220 // Block ends with fall-through true condbranch.
221 TBB = LastInst->getOperand(1).getMBB();
222 Cond.push_back(LastInst->getOperand(0));
223 return false;
224 }
Sirish Pandeab7955b2012-02-15 18:52:27 +0000225 if (LastInst->getOpcode() == Hexagon::JMP_cNot) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000226 // Block ends with fall-through false condbranch.
227 TBB = LastInst->getOperand(1).getMBB();
228 Cond.push_back(MachineOperand::CreateImm(0));
229 Cond.push_back(LastInst->getOperand(0));
230 return false;
231 }
232 // Otherwise, don't know what this is.
233 return true;
234 }
235
236 // Get the instruction before it if it's a terminator.
237 MachineInstr *SecondLastInst = I;
238
239 // If there are three terminators, we don't know what sort of block this is.
240 if (SecondLastInst && I != MBB.begin() &&
241 isUnpredicatedTerminator(--I))
242 return true;
243
244 // If the block ends with Hexagon::BRCOND and Hexagon:JMP, handle it.
245 if (((SecondLastInst->getOpcode() == Hexagon::BRCOND) ||
Sirish Pandeab7955b2012-02-15 18:52:27 +0000246 (SecondLastInst->getOpcode() == Hexagon::JMP_c)) &&
Tony Linthicumb4b54152011-12-12 21:14:40 +0000247 LastInst->getOpcode() == Hexagon::JMP) {
248 TBB = SecondLastInst->getOperand(1).getMBB();
249 Cond.push_back(SecondLastInst->getOperand(0));
250 FBB = LastInst->getOperand(0).getMBB();
251 return false;
252 }
253
Sirish Pandeab7955b2012-02-15 18:52:27 +0000254 // If the block ends with Hexagon::JMP_cNot and Hexagon:JMP, handle it.
255 if ((SecondLastInst->getOpcode() == Hexagon::JMP_cNot) &&
Tony Linthicumb4b54152011-12-12 21:14:40 +0000256 LastInst->getOpcode() == Hexagon::JMP) {
257 TBB = SecondLastInst->getOperand(1).getMBB();
258 Cond.push_back(MachineOperand::CreateImm(0));
259 Cond.push_back(SecondLastInst->getOperand(0));
260 FBB = LastInst->getOperand(0).getMBB();
261 return false;
262 }
263
264 // If the block ends with two Hexagon:JMPs, handle it. The second one is not
265 // executed, so remove it.
266 if (SecondLastInst->getOpcode() == Hexagon::JMP &&
267 LastInst->getOpcode() == Hexagon::JMP) {
268 TBB = SecondLastInst->getOperand(0).getMBB();
269 I = LastInst;
270 if (AllowModify)
271 I->eraseFromParent();
272 return false;
273 }
274
275 // Otherwise, can't handle this.
276 return true;
277}
278
279
280unsigned HexagonInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
281 int BOpc = Hexagon::JMP;
Sirish Pandeab7955b2012-02-15 18:52:27 +0000282 int BccOpc = Hexagon::JMP_c;
283 int BccOpcNot = Hexagon::JMP_cNot;
Tony Linthicumb4b54152011-12-12 21:14:40 +0000284
285 MachineBasicBlock::iterator I = MBB.end();
286 if (I == MBB.begin()) return 0;
287 --I;
288 if (I->getOpcode() != BOpc && I->getOpcode() != BccOpc &&
289 I->getOpcode() != BccOpcNot)
290 return 0;
291
292 // Remove the branch.
293 I->eraseFromParent();
294
295 I = MBB.end();
296
297 if (I == MBB.begin()) return 1;
298 --I;
299 if (I->getOpcode() != BccOpc && I->getOpcode() != BccOpcNot)
300 return 1;
301
302 // Remove the branch.
303 I->eraseFromParent();
304 return 2;
305}
306
307
Krzysztof Parzyszekce55d912013-02-11 20:04:29 +0000308/// \brief For a comparison instruction, return the source registers in
309/// \p SrcReg and \p SrcReg2 if having two register operands, and the value it
310/// compares against in CmpValue. Return true if the comparison instruction
311/// can be analyzed.
312bool HexagonInstrInfo::analyzeCompare(const MachineInstr *MI,
313 unsigned &SrcReg, unsigned &SrcReg2,
314 int &Mask, int &Value) const {
315 unsigned Opc = MI->getOpcode();
316
317 // Set mask and the first source register.
318 switch (Opc) {
319 case Hexagon::CMPEHexagon4rr:
320 case Hexagon::CMPEQri:
321 case Hexagon::CMPEQrr:
322 case Hexagon::CMPGT64rr:
323 case Hexagon::CMPGTU64rr:
324 case Hexagon::CMPGTUri:
325 case Hexagon::CMPGTUrr:
326 case Hexagon::CMPGTri:
327 case Hexagon::CMPGTrr:
328 case Hexagon::CMPLTUrr:
329 case Hexagon::CMPLTrr:
330 SrcReg = MI->getOperand(1).getReg();
331 Mask = ~0;
332 break;
333 case Hexagon::CMPbEQri_V4:
334 case Hexagon::CMPbEQrr_sbsb_V4:
335 case Hexagon::CMPbEQrr_ubub_V4:
336 case Hexagon::CMPbGTUri_V4:
337 case Hexagon::CMPbGTUrr_V4:
338 case Hexagon::CMPbGTrr_V4:
339 SrcReg = MI->getOperand(1).getReg();
340 Mask = 0xFF;
341 break;
342 case Hexagon::CMPhEQri_V4:
343 case Hexagon::CMPhEQrr_shl_V4:
344 case Hexagon::CMPhEQrr_xor_V4:
345 case Hexagon::CMPhGTUri_V4:
346 case Hexagon::CMPhGTUrr_V4:
347 case Hexagon::CMPhGTrr_shl_V4:
348 SrcReg = MI->getOperand(1).getReg();
349 Mask = 0xFFFF;
350 break;
351 }
352
353 // Set the value/second source register.
354 switch (Opc) {
355 case Hexagon::CMPEHexagon4rr:
356 case Hexagon::CMPEQrr:
357 case Hexagon::CMPGT64rr:
358 case Hexagon::CMPGTU64rr:
359 case Hexagon::CMPGTUrr:
360 case Hexagon::CMPGTrr:
361 case Hexagon::CMPbEQrr_sbsb_V4:
362 case Hexagon::CMPbEQrr_ubub_V4:
363 case Hexagon::CMPbGTUrr_V4:
364 case Hexagon::CMPbGTrr_V4:
365 case Hexagon::CMPhEQrr_shl_V4:
366 case Hexagon::CMPhEQrr_xor_V4:
367 case Hexagon::CMPhGTUrr_V4:
368 case Hexagon::CMPhGTrr_shl_V4:
369 case Hexagon::CMPLTUrr:
370 case Hexagon::CMPLTrr:
371 SrcReg2 = MI->getOperand(2).getReg();
372 return true;
373
374 case Hexagon::CMPEQri:
375 case Hexagon::CMPGTUri:
376 case Hexagon::CMPGTri:
377 case Hexagon::CMPbEQri_V4:
378 case Hexagon::CMPbGTUri_V4:
379 case Hexagon::CMPhEQri_V4:
380 case Hexagon::CMPhGTUri_V4:
381 SrcReg2 = 0;
382 Value = MI->getOperand(2).getImm();
383 return true;
384 }
385
386 return false;
387}
388
389
Tony Linthicumb4b54152011-12-12 21:14:40 +0000390void HexagonInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
391 MachineBasicBlock::iterator I, DebugLoc DL,
392 unsigned DestReg, unsigned SrcReg,
393 bool KillSrc) const {
394 if (Hexagon::IntRegsRegClass.contains(SrcReg, DestReg)) {
395 BuildMI(MBB, I, DL, get(Hexagon::TFR), DestReg).addReg(SrcReg);
396 return;
397 }
398 if (Hexagon::DoubleRegsRegClass.contains(SrcReg, DestReg)) {
Jyotsna Vermab53b7912012-11-29 19:35:44 +0000399 BuildMI(MBB, I, DL, get(Hexagon::TFR64), DestReg).addReg(SrcReg);
Tony Linthicumb4b54152011-12-12 21:14:40 +0000400 return;
401 }
402 if (Hexagon::PredRegsRegClass.contains(SrcReg, DestReg)) {
403 // Map Pd = Ps to Pd = or(Ps, Ps).
404 BuildMI(MBB, I, DL, get(Hexagon::OR_pp),
405 DestReg).addReg(SrcReg).addReg(SrcReg);
406 return;
407 }
Sirish Pande2b38c122012-05-12 05:54:15 +0000408 if (Hexagon::DoubleRegsRegClass.contains(DestReg) &&
409 Hexagon::IntRegsRegClass.contains(SrcReg)) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000410 // We can have an overlap between single and double reg: r1:0 = r0.
411 if(SrcReg == RI.getSubReg(DestReg, Hexagon::subreg_loreg)) {
412 // r1:0 = r0
413 BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg,
414 Hexagon::subreg_hireg))).addImm(0);
415 } else {
416 // r1:0 = r1 or no overlap.
417 BuildMI(MBB, I, DL, get(Hexagon::TFR), (RI.getSubReg(DestReg,
418 Hexagon::subreg_loreg))).addReg(SrcReg);
419 BuildMI(MBB, I, DL, get(Hexagon::TFRI), (RI.getSubReg(DestReg,
420 Hexagon::subreg_hireg))).addImm(0);
421 }
422 return;
423 }
Sirish Pande2b38c122012-05-12 05:54:15 +0000424 if (Hexagon::CRRegsRegClass.contains(DestReg) &&
425 Hexagon::IntRegsRegClass.contains(SrcReg)) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000426 BuildMI(MBB, I, DL, get(Hexagon::TFCR), DestReg).addReg(SrcReg);
427 return;
Sirish Pandeab7955b2012-02-15 18:52:27 +0000428 }
Anshuman Dasgupta666e0d32013-02-13 22:56:34 +0000429 if (Hexagon::PredRegsRegClass.contains(SrcReg) &&
430 Hexagon::IntRegsRegClass.contains(DestReg)) {
431 BuildMI(MBB, I, DL, get(Hexagon::TFR_RsPd), DestReg).
432 addReg(SrcReg, getKillRegState(KillSrc));
433 return;
434 }
435 if (Hexagon::IntRegsRegClass.contains(SrcReg) &&
436 Hexagon::PredRegsRegClass.contains(DestReg)) {
437 BuildMI(MBB, I, DL, get(Hexagon::TFR_PdRs), DestReg).
438 addReg(SrcReg, getKillRegState(KillSrc));
439 return;
440 }
Sirish Pandeab7955b2012-02-15 18:52:27 +0000441
442 llvm_unreachable("Unimplemented");
Tony Linthicumb4b54152011-12-12 21:14:40 +0000443}
444
445
446void HexagonInstrInfo::
447storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
448 unsigned SrcReg, bool isKill, int FI,
449 const TargetRegisterClass *RC,
450 const TargetRegisterInfo *TRI) const {
451
452 DebugLoc DL = MBB.findDebugLoc(I);
453 MachineFunction &MF = *MBB.getParent();
454 MachineFrameInfo &MFI = *MF.getFrameInfo();
455 unsigned Align = MFI.getObjectAlignment(FI);
456
457 MachineMemOperand *MMO =
458 MF.getMachineMemOperand(
459 MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
460 MachineMemOperand::MOStore,
461 MFI.getObjectSize(FI),
462 Align);
463
Craig Topper420761a2012-04-20 07:30:17 +0000464 if (Hexagon::IntRegsRegClass.hasSubClassEq(RC)) {
Brendon Cahoon5262abb2012-05-14 19:35:42 +0000465 BuildMI(MBB, I, DL, get(Hexagon::STriw))
Tony Linthicumb4b54152011-12-12 21:14:40 +0000466 .addFrameIndex(FI).addImm(0)
467 .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
Craig Topper420761a2012-04-20 07:30:17 +0000468 } else if (Hexagon::DoubleRegsRegClass.hasSubClassEq(RC)) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000469 BuildMI(MBB, I, DL, get(Hexagon::STrid))
470 .addFrameIndex(FI).addImm(0)
471 .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
Craig Topper420761a2012-04-20 07:30:17 +0000472 } else if (Hexagon::PredRegsRegClass.hasSubClassEq(RC)) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000473 BuildMI(MBB, I, DL, get(Hexagon::STriw_pred))
474 .addFrameIndex(FI).addImm(0)
475 .addReg(SrcReg, getKillRegState(isKill)).addMemOperand(MMO);
476 } else {
Craig Topperbc219812012-02-07 02:50:20 +0000477 llvm_unreachable("Unimplemented");
Tony Linthicumb4b54152011-12-12 21:14:40 +0000478 }
479}
480
481
482void HexagonInstrInfo::storeRegToAddr(
483 MachineFunction &MF, unsigned SrcReg,
484 bool isKill,
485 SmallVectorImpl<MachineOperand> &Addr,
486 const TargetRegisterClass *RC,
487 SmallVectorImpl<MachineInstr*> &NewMIs) const
488{
Craig Topperbc219812012-02-07 02:50:20 +0000489 llvm_unreachable("Unimplemented");
Tony Linthicumb4b54152011-12-12 21:14:40 +0000490}
491
492
493void HexagonInstrInfo::
494loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
495 unsigned DestReg, int FI,
496 const TargetRegisterClass *RC,
497 const TargetRegisterInfo *TRI) const {
498 DebugLoc DL = MBB.findDebugLoc(I);
499 MachineFunction &MF = *MBB.getParent();
500 MachineFrameInfo &MFI = *MF.getFrameInfo();
501 unsigned Align = MFI.getObjectAlignment(FI);
502
503 MachineMemOperand *MMO =
504 MF.getMachineMemOperand(
505 MachinePointerInfo(PseudoSourceValue::getFixedStack(FI)),
506 MachineMemOperand::MOLoad,
507 MFI.getObjectSize(FI),
508 Align);
Craig Topper420761a2012-04-20 07:30:17 +0000509 if (RC == &Hexagon::IntRegsRegClass) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000510 BuildMI(MBB, I, DL, get(Hexagon::LDriw), DestReg)
511 .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
Craig Topper420761a2012-04-20 07:30:17 +0000512 } else if (RC == &Hexagon::DoubleRegsRegClass) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000513 BuildMI(MBB, I, DL, get(Hexagon::LDrid), DestReg)
514 .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
Craig Topper420761a2012-04-20 07:30:17 +0000515 } else if (RC == &Hexagon::PredRegsRegClass) {
Tony Linthicumb4b54152011-12-12 21:14:40 +0000516 BuildMI(MBB, I, DL, get(Hexagon::LDriw_pred), DestReg)
517 .addFrameIndex(FI).addImm(0).addMemOperand(MMO);
518 } else {
Craig Topperbc219812012-02-07 02:50:20 +0000519 llvm_unreachable("Can't store this register to stack slot");
Tony Linthicumb4b54152011-12-12 21:14:40 +0000520 }
521}
522
523
524void HexagonInstrInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
525 SmallVectorImpl<MachineOperand> &Addr,
526 const TargetRegisterClass *RC,
527 SmallVectorImpl<MachineInstr*> &NewMIs) const {
Craig Topperbc219812012-02-07 02:50:20 +0000528 llvm_unreachable("Unimplemented");
Tony Linthicumb4b54152011-12-12 21:14:40 +0000529}
530
531
532MachineInstr *HexagonInstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
533 MachineInstr* MI,
534 const SmallVectorImpl<unsigned> &Ops,
535 int FI) const {
536 // Hexagon_TODO: Implement.
537 return(0);
538}
539
540
541unsigned HexagonInstrInfo::createVR(MachineFunction* MF, MVT VT) const {
542
543 MachineRegisterInfo &RegInfo = MF->getRegInfo();
544 const TargetRegisterClass *TRC;
Sirish Pande7517bbc2012-05-10 20:20:25 +0000545 if (VT == MVT::i1) {
Craig Topper420761a2012-04-20 07:30:17 +0000546 TRC = &Hexagon::PredRegsRegClass;
Sirish Pande7517bbc2012-05-10 20:20:25 +0000547 } else if (VT == MVT::i32 || VT == MVT::f32) {
Craig Topper420761a2012-04-20 07:30:17 +0000548 TRC = &Hexagon::IntRegsRegClass;
Sirish Pande7517bbc2012-05-10 20:20:25 +0000549 } else if (VT == MVT::i64 || VT == MVT::f64) {
Craig Topper420761a2012-04-20 07:30:17 +0000550 TRC = &Hexagon::DoubleRegsRegClass;
Sirish Pande7517bbc2012-05-10 20:20:25 +0000551 } else {
Benjamin Kramer27baab62011-12-27 11:41:05 +0000552 llvm_unreachable("Cannot handle this register class");
Sirish Pande7517bbc2012-05-10 20:20:25 +0000553 }
Tony Linthicumb4b54152011-12-12 21:14:40 +0000554
555 unsigned NewReg = RegInfo.createVirtualRegister(TRC);
556 return NewReg;
557}
558
Sirish Pande26f61a12012-05-03 21:52:53 +0000559bool HexagonInstrInfo::isExtendable(const MachineInstr *MI) const {
560 switch(MI->getOpcode()) {
561 default: return false;
562 // JMP_EQri
563 case Hexagon::JMP_EQriPt_nv_V4:
564 case Hexagon::JMP_EQriPnt_nv_V4:
565 case Hexagon::JMP_EQriNotPt_nv_V4:
566 case Hexagon::JMP_EQriNotPnt_nv_V4:
Sirish Pande0dac3912012-04-23 17:49:20 +0000567
Sirish Pande26f61a12012-05-03 21:52:53 +0000568 // JMP_EQri - with -1
569 case Hexagon::JMP_EQriPtneg_nv_V4:
570 case Hexagon::JMP_EQriPntneg_nv_V4:
571 case Hexagon::JMP_EQriNotPtneg_nv_V4:
572 case Hexagon::JMP_EQriNotPntneg_nv_V4:
573
574 // JMP_EQrr
575 case Hexagon::JMP_EQrrPt_nv_V4:
576 case Hexagon::JMP_EQrrPnt_nv_V4:
577 case Hexagon::JMP_EQrrNotPt_nv_V4:
578 case Hexagon::JMP_EQrrNotPnt_nv_V4:
579
580 // JMP_GTri
581 case Hexagon::JMP_GTriPt_nv_V4:
582 case Hexagon::JMP_GTriPnt_nv_V4:
583 case Hexagon::JMP_GTriNotPt_nv_V4:
584 case Hexagon::JMP_GTriNotPnt_nv_V4:
585
586 // JMP_GTri - with -1
587 case Hexagon::JMP_GTriPtneg_nv_V4:
588 case Hexagon::JMP_GTriPntneg_nv_V4:
589 case Hexagon::JMP_GTriNotPtneg_nv_V4:
590 case Hexagon::JMP_GTriNotPntneg_nv_V4:
591
592 // JMP_GTrr
593 case Hexagon::JMP_GTrrPt_nv_V4:
594 case Hexagon::JMP_GTrrPnt_nv_V4:
595 case Hexagon::JMP_GTrrNotPt_nv_V4:
596 case Hexagon::JMP_GTrrNotPnt_nv_V4:
597
598 // JMP_GTrrdn
599 case Hexagon::JMP_GTrrdnPt_nv_V4:
600 case Hexagon::JMP_GTrrdnPnt_nv_V4:
601 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
602 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
603
604 // JMP_GTUri
605 case Hexagon::JMP_GTUriPt_nv_V4:
606 case Hexagon::JMP_GTUriPnt_nv_V4:
607 case Hexagon::JMP_GTUriNotPt_nv_V4:
608 case Hexagon::JMP_GTUriNotPnt_nv_V4:
609
610 // JMP_GTUrr
611 case Hexagon::JMP_GTUrrPt_nv_V4:
612 case Hexagon::JMP_GTUrrPnt_nv_V4:
613 case Hexagon::JMP_GTUrrNotPt_nv_V4:
614 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
615
616 // JMP_GTUrrdn
617 case Hexagon::JMP_GTUrrdnPt_nv_V4:
618 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
619 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
620 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
621
622 // TFR_FI
623 case Hexagon::TFR_FI:
624 return true;
625 }
626}
627
628bool HexagonInstrInfo::isExtended(const MachineInstr *MI) const {
629 switch(MI->getOpcode()) {
630 default: return false;
631 // JMP_EQri
632 case Hexagon::JMP_EQriPt_ie_nv_V4:
633 case Hexagon::JMP_EQriPnt_ie_nv_V4:
634 case Hexagon::JMP_EQriNotPt_ie_nv_V4:
635 case Hexagon::JMP_EQriNotPnt_ie_nv_V4:
636
637 // JMP_EQri - with -1
638 case Hexagon::JMP_EQriPtneg_ie_nv_V4:
639 case Hexagon::JMP_EQriPntneg_ie_nv_V4:
640 case Hexagon::JMP_EQriNotPtneg_ie_nv_V4:
641 case Hexagon::JMP_EQriNotPntneg_ie_nv_V4:
642
643 // JMP_EQrr
644 case Hexagon::JMP_EQrrPt_ie_nv_V4:
645 case Hexagon::JMP_EQrrPnt_ie_nv_V4:
646 case Hexagon::JMP_EQrrNotPt_ie_nv_V4:
647 case Hexagon::JMP_EQrrNotPnt_ie_nv_V4:
648
649 // JMP_GTri
650 case Hexagon::JMP_GTriPt_ie_nv_V4:
651 case Hexagon::JMP_GTriPnt_ie_nv_V4:
652 case Hexagon::JMP_GTriNotPt_ie_nv_V4:
653 case Hexagon::JMP_GTriNotPnt_ie_nv_V4:
654
655 // JMP_GTri - with -1
656 case Hexagon::JMP_GTriPtneg_ie_nv_V4:
657 case Hexagon::JMP_GTriPntneg_ie_nv_V4:
658 case Hexagon::JMP_GTriNotPtneg_ie_nv_V4:
659 case Hexagon::JMP_GTriNotPntneg_ie_nv_V4:
660
661 // JMP_GTrr
662 case Hexagon::JMP_GTrrPt_ie_nv_V4:
663 case Hexagon::JMP_GTrrPnt_ie_nv_V4:
664 case Hexagon::JMP_GTrrNotPt_ie_nv_V4:
665 case Hexagon::JMP_GTrrNotPnt_ie_nv_V4:
666
667 // JMP_GTrrdn
668 case Hexagon::JMP_GTrrdnPt_ie_nv_V4:
669 case Hexagon::JMP_GTrrdnPnt_ie_nv_V4:
670 case Hexagon::JMP_GTrrdnNotPt_ie_nv_V4:
671 case Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4:
672
673 // JMP_GTUri
674 case Hexagon::JMP_GTUriPt_ie_nv_V4:
675 case Hexagon::JMP_GTUriPnt_ie_nv_V4:
676 case Hexagon::JMP_GTUriNotPt_ie_nv_V4:
677 case Hexagon::JMP_GTUriNotPnt_ie_nv_V4:
678
679 // JMP_GTUrr
680 case Hexagon::JMP_GTUrrPt_ie_nv_V4:
681 case Hexagon::JMP_GTUrrPnt_ie_nv_V4:
682 case Hexagon::JMP_GTUrrNotPt_ie_nv_V4:
683 case Hexagon::JMP_GTUrrNotPnt_ie_nv_V4:
684
685 // JMP_GTUrrdn
686 case Hexagon::JMP_GTUrrdnPt_ie_nv_V4:
687 case Hexagon::JMP_GTUrrdnPnt_ie_nv_V4:
688 case Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4:
689 case Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4:
690
691 // V4 absolute set addressing.
692 case Hexagon::LDrid_abs_setimm_V4:
693 case Hexagon::LDriw_abs_setimm_V4:
694 case Hexagon::LDrih_abs_setimm_V4:
695 case Hexagon::LDrib_abs_setimm_V4:
696 case Hexagon::LDriuh_abs_setimm_V4:
697 case Hexagon::LDriub_abs_setimm_V4:
698
699 case Hexagon::STrid_abs_setimm_V4:
700 case Hexagon::STrib_abs_setimm_V4:
701 case Hexagon::STrih_abs_setimm_V4:
702 case Hexagon::STriw_abs_setimm_V4:
703
704 // V4 global address load.
Sirish Pande26f61a12012-05-03 21:52:53 +0000705 case Hexagon::LDd_GP_cPt_V4 :
706 case Hexagon::LDd_GP_cNotPt_V4 :
707 case Hexagon::LDd_GP_cdnPt_V4 :
708 case Hexagon::LDd_GP_cdnNotPt_V4 :
709 case Hexagon::LDb_GP_cPt_V4 :
710 case Hexagon::LDb_GP_cNotPt_V4 :
711 case Hexagon::LDb_GP_cdnPt_V4 :
712 case Hexagon::LDb_GP_cdnNotPt_V4 :
713 case Hexagon::LDub_GP_cPt_V4 :
714 case Hexagon::LDub_GP_cNotPt_V4 :
715 case Hexagon::LDub_GP_cdnPt_V4 :
716 case Hexagon::LDub_GP_cdnNotPt_V4 :
717 case Hexagon::LDh_GP_cPt_V4 :
718 case Hexagon::LDh_GP_cNotPt_V4 :
719 case Hexagon::LDh_GP_cdnPt_V4 :
720 case Hexagon::LDh_GP_cdnNotPt_V4 :
721 case Hexagon::LDuh_GP_cPt_V4 :
722 case Hexagon::LDuh_GP_cNotPt_V4 :
723 case Hexagon::LDuh_GP_cdnPt_V4 :
724 case Hexagon::LDuh_GP_cdnNotPt_V4 :
725 case Hexagon::LDw_GP_cPt_V4 :
726 case Hexagon::LDw_GP_cNotPt_V4 :
727 case Hexagon::LDw_GP_cdnPt_V4 :
728 case Hexagon::LDw_GP_cdnNotPt_V4 :
729
730 // V4 global address store.
Sirish Pande26f61a12012-05-03 21:52:53 +0000731 case Hexagon::STd_GP_cPt_V4 :
732 case Hexagon::STd_GP_cNotPt_V4 :
733 case Hexagon::STd_GP_cdnPt_V4 :
734 case Hexagon::STd_GP_cdnNotPt_V4 :
735 case Hexagon::STb_GP_cPt_V4 :
736 case Hexagon::STb_GP_cNotPt_V4 :
737 case Hexagon::STb_GP_cdnPt_V4 :
738 case Hexagon::STb_GP_cdnNotPt_V4 :
739 case Hexagon::STh_GP_cPt_V4 :
740 case Hexagon::STh_GP_cNotPt_V4 :
741 case Hexagon::STh_GP_cdnPt_V4 :
742 case Hexagon::STh_GP_cdnNotPt_V4 :
743 case Hexagon::STw_GP_cPt_V4 :
744 case Hexagon::STw_GP_cNotPt_V4 :
745 case Hexagon::STw_GP_cdnPt_V4 :
746 case Hexagon::STw_GP_cdnNotPt_V4 :
747
748 // V4 predicated global address new value store.
Sirish Pande26f61a12012-05-03 21:52:53 +0000749 case Hexagon::STb_GP_cPt_nv_V4 :
750 case Hexagon::STb_GP_cNotPt_nv_V4 :
751 case Hexagon::STb_GP_cdnPt_nv_V4 :
752 case Hexagon::STb_GP_cdnNotPt_nv_V4 :
753 case Hexagon::STh_GP_cPt_nv_V4 :
754 case Hexagon::STh_GP_cNotPt_nv_V4 :
755 case Hexagon::STh_GP_cdnPt_nv_V4 :
756 case Hexagon::STh_GP_cdnNotPt_nv_V4 :
757 case Hexagon::STw_GP_cPt_nv_V4 :
758 case Hexagon::STw_GP_cNotPt_nv_V4 :
759 case Hexagon::STw_GP_cdnPt_nv_V4 :
760 case Hexagon::STw_GP_cdnNotPt_nv_V4 :
761
762 // TFR_FI
763 case Hexagon::TFR_FI_immext_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +0000764
Sirish Pande7517bbc2012-05-10 20:20:25 +0000765 // TFRI_F
766 case Hexagon::TFRI_f:
767 case Hexagon::TFRI_cPt_f:
768 case Hexagon::TFRI_cNotPt_f:
769 case Hexagon::CONST64_Float_Real:
770 return true;
Sirish Pande26f61a12012-05-03 21:52:53 +0000771 }
772}
773
774bool HexagonInstrInfo::isNewValueJump(const MachineInstr *MI) const {
775 switch (MI->getOpcode()) {
776 default: return false;
777 // JMP_EQri
778 case Hexagon::JMP_EQriPt_nv_V4:
779 case Hexagon::JMP_EQriPnt_nv_V4:
780 case Hexagon::JMP_EQriNotPt_nv_V4:
781 case Hexagon::JMP_EQriNotPnt_nv_V4:
782 case Hexagon::JMP_EQriPt_ie_nv_V4:
783 case Hexagon::JMP_EQriPnt_ie_nv_V4:
784 case Hexagon::JMP_EQriNotPt_ie_nv_V4:
785 case Hexagon::JMP_EQriNotPnt_ie_nv_V4:
786
787 // JMP_EQri - with -1
788 case Hexagon::JMP_EQriPtneg_nv_V4:
789 case Hexagon::JMP_EQriPntneg_nv_V4:
790 case Hexagon::JMP_EQriNotPtneg_nv_V4:
791 case Hexagon::JMP_EQriNotPntneg_nv_V4:
792 case Hexagon::JMP_EQriPtneg_ie_nv_V4:
793 case Hexagon::JMP_EQriPntneg_ie_nv_V4:
794 case Hexagon::JMP_EQriNotPtneg_ie_nv_V4:
795 case Hexagon::JMP_EQriNotPntneg_ie_nv_V4:
796
797 // JMP_EQrr
798 case Hexagon::JMP_EQrrPt_nv_V4:
799 case Hexagon::JMP_EQrrPnt_nv_V4:
800 case Hexagon::JMP_EQrrNotPt_nv_V4:
801 case Hexagon::JMP_EQrrNotPnt_nv_V4:
802 case Hexagon::JMP_EQrrPt_ie_nv_V4:
803 case Hexagon::JMP_EQrrPnt_ie_nv_V4:
804 case Hexagon::JMP_EQrrNotPt_ie_nv_V4:
805 case Hexagon::JMP_EQrrNotPnt_ie_nv_V4:
806
807 // JMP_GTri
808 case Hexagon::JMP_GTriPt_nv_V4:
809 case Hexagon::JMP_GTriPnt_nv_V4:
810 case Hexagon::JMP_GTriNotPt_nv_V4:
811 case Hexagon::JMP_GTriNotPnt_nv_V4:
812 case Hexagon::JMP_GTriPt_ie_nv_V4:
813 case Hexagon::JMP_GTriPnt_ie_nv_V4:
814 case Hexagon::JMP_GTriNotPt_ie_nv_V4:
815 case Hexagon::JMP_GTriNotPnt_ie_nv_V4:
816
817 // JMP_GTri - with -1
818 case Hexagon::JMP_GTriPtneg_nv_V4:
819 case Hexagon::JMP_GTriPntneg_nv_V4:
820 case Hexagon::JMP_GTriNotPtneg_nv_V4:
821 case Hexagon::JMP_GTriNotPntneg_nv_V4:
822 case Hexagon::JMP_GTriPtneg_ie_nv_V4:
823 case Hexagon::JMP_GTriPntneg_ie_nv_V4:
824 case Hexagon::JMP_GTriNotPtneg_ie_nv_V4:
825 case Hexagon::JMP_GTriNotPntneg_ie_nv_V4:
826
827 // JMP_GTrr
828 case Hexagon::JMP_GTrrPt_nv_V4:
829 case Hexagon::JMP_GTrrPnt_nv_V4:
830 case Hexagon::JMP_GTrrNotPt_nv_V4:
831 case Hexagon::JMP_GTrrNotPnt_nv_V4:
832 case Hexagon::JMP_GTrrPt_ie_nv_V4:
833 case Hexagon::JMP_GTrrPnt_ie_nv_V4:
834 case Hexagon::JMP_GTrrNotPt_ie_nv_V4:
835 case Hexagon::JMP_GTrrNotPnt_ie_nv_V4:
836
837 // JMP_GTrrdn
838 case Hexagon::JMP_GTrrdnPt_nv_V4:
839 case Hexagon::JMP_GTrrdnPnt_nv_V4:
840 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
841 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
842 case Hexagon::JMP_GTrrdnPt_ie_nv_V4:
843 case Hexagon::JMP_GTrrdnPnt_ie_nv_V4:
844 case Hexagon::JMP_GTrrdnNotPt_ie_nv_V4:
845 case Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4:
846
847 // JMP_GTUri
848 case Hexagon::JMP_GTUriPt_nv_V4:
849 case Hexagon::JMP_GTUriPnt_nv_V4:
850 case Hexagon::JMP_GTUriNotPt_nv_V4:
851 case Hexagon::JMP_GTUriNotPnt_nv_V4:
852 case Hexagon::JMP_GTUriPt_ie_nv_V4:
853 case Hexagon::JMP_GTUriPnt_ie_nv_V4:
854 case Hexagon::JMP_GTUriNotPt_ie_nv_V4:
855 case Hexagon::JMP_GTUriNotPnt_ie_nv_V4:
856
857 // JMP_GTUrr
858 case Hexagon::JMP_GTUrrPt_nv_V4:
859 case Hexagon::JMP_GTUrrPnt_nv_V4:
860 case Hexagon::JMP_GTUrrNotPt_nv_V4:
861 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
862 case Hexagon::JMP_GTUrrPt_ie_nv_V4:
863 case Hexagon::JMP_GTUrrPnt_ie_nv_V4:
864 case Hexagon::JMP_GTUrrNotPt_ie_nv_V4:
865 case Hexagon::JMP_GTUrrNotPnt_ie_nv_V4:
866
867 // JMP_GTUrrdn
868 case Hexagon::JMP_GTUrrdnPt_nv_V4:
869 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
870 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
871 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
872 case Hexagon::JMP_GTUrrdnPt_ie_nv_V4:
873 case Hexagon::JMP_GTUrrdnPnt_ie_nv_V4:
874 case Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4:
875 case Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4:
876 return true;
877 }
878}
879
880unsigned HexagonInstrInfo::getImmExtForm(const MachineInstr* MI) const {
881 switch(MI->getOpcode()) {
882 default: llvm_unreachable("Unknown type of instruction.");
883 // JMP_EQri
884 case Hexagon::JMP_EQriPt_nv_V4:
885 return Hexagon::JMP_EQriPt_ie_nv_V4;
886 case Hexagon::JMP_EQriNotPt_nv_V4:
887 return Hexagon::JMP_EQriNotPt_ie_nv_V4;
888 case Hexagon::JMP_EQriPnt_nv_V4:
889 return Hexagon::JMP_EQriPnt_ie_nv_V4;
890 case Hexagon::JMP_EQriNotPnt_nv_V4:
891 return Hexagon::JMP_EQriNotPnt_ie_nv_V4;
892
893 // JMP_EQri -- with -1
894 case Hexagon::JMP_EQriPtneg_nv_V4:
895 return Hexagon::JMP_EQriPtneg_ie_nv_V4;
896 case Hexagon::JMP_EQriNotPtneg_nv_V4:
897 return Hexagon::JMP_EQriNotPtneg_ie_nv_V4;
898 case Hexagon::JMP_EQriPntneg_nv_V4:
899 return Hexagon::JMP_EQriPntneg_ie_nv_V4;
900 case Hexagon::JMP_EQriNotPntneg_nv_V4:
901 return Hexagon::JMP_EQriNotPntneg_ie_nv_V4;
902
903 // JMP_EQrr
904 case Hexagon::JMP_EQrrPt_nv_V4:
905 return Hexagon::JMP_EQrrPt_ie_nv_V4;
906 case Hexagon::JMP_EQrrNotPt_nv_V4:
907 return Hexagon::JMP_EQrrNotPt_ie_nv_V4;
908 case Hexagon::JMP_EQrrPnt_nv_V4:
909 return Hexagon::JMP_EQrrPnt_ie_nv_V4;
910 case Hexagon::JMP_EQrrNotPnt_nv_V4:
911 return Hexagon::JMP_EQrrNotPnt_ie_nv_V4;
912
913 // JMP_GTri
914 case Hexagon::JMP_GTriPt_nv_V4:
915 return Hexagon::JMP_GTriPt_ie_nv_V4;
916 case Hexagon::JMP_GTriNotPt_nv_V4:
917 return Hexagon::JMP_GTriNotPt_ie_nv_V4;
918 case Hexagon::JMP_GTriPnt_nv_V4:
919 return Hexagon::JMP_GTriPnt_ie_nv_V4;
920 case Hexagon::JMP_GTriNotPnt_nv_V4:
921 return Hexagon::JMP_GTriNotPnt_ie_nv_V4;
922
923 // JMP_GTri -- with -1
924 case Hexagon::JMP_GTriPtneg_nv_V4:
925 return Hexagon::JMP_GTriPtneg_ie_nv_V4;
926 case Hexagon::JMP_GTriNotPtneg_nv_V4:
927 return Hexagon::JMP_GTriNotPtneg_ie_nv_V4;
928 case Hexagon::JMP_GTriPntneg_nv_V4:
929 return Hexagon::JMP_GTriPntneg_ie_nv_V4;
930 case Hexagon::JMP_GTriNotPntneg_nv_V4:
931 return Hexagon::JMP_GTriNotPntneg_ie_nv_V4;
932
933 // JMP_GTrr
934 case Hexagon::JMP_GTrrPt_nv_V4:
935 return Hexagon::JMP_GTrrPt_ie_nv_V4;
936 case Hexagon::JMP_GTrrNotPt_nv_V4:
937 return Hexagon::JMP_GTrrNotPt_ie_nv_V4;
938 case Hexagon::JMP_GTrrPnt_nv_V4:
939 return Hexagon::JMP_GTrrPnt_ie_nv_V4;
940 case Hexagon::JMP_GTrrNotPnt_nv_V4:
941 return Hexagon::JMP_GTrrNotPnt_ie_nv_V4;
942
943 // JMP_GTrrdn
944 case Hexagon::JMP_GTrrdnPt_nv_V4:
945 return Hexagon::JMP_GTrrdnPt_ie_nv_V4;
946 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
947 return Hexagon::JMP_GTrrdnNotPt_ie_nv_V4;
948 case Hexagon::JMP_GTrrdnPnt_nv_V4:
949 return Hexagon::JMP_GTrrdnPnt_ie_nv_V4;
950 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
951 return Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4;
952
953 // JMP_GTUri
954 case Hexagon::JMP_GTUriPt_nv_V4:
955 return Hexagon::JMP_GTUriPt_ie_nv_V4;
956 case Hexagon::JMP_GTUriNotPt_nv_V4:
957 return Hexagon::JMP_GTUriNotPt_ie_nv_V4;
958 case Hexagon::JMP_GTUriPnt_nv_V4:
959 return Hexagon::JMP_GTUriPnt_ie_nv_V4;
960 case Hexagon::JMP_GTUriNotPnt_nv_V4:
961 return Hexagon::JMP_GTUriNotPnt_ie_nv_V4;
962
963 // JMP_GTUrr
964 case Hexagon::JMP_GTUrrPt_nv_V4:
965 return Hexagon::JMP_GTUrrPt_ie_nv_V4;
966 case Hexagon::JMP_GTUrrNotPt_nv_V4:
967 return Hexagon::JMP_GTUrrNotPt_ie_nv_V4;
968 case Hexagon::JMP_GTUrrPnt_nv_V4:
969 return Hexagon::JMP_GTUrrPnt_ie_nv_V4;
970 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
971 return Hexagon::JMP_GTUrrNotPnt_ie_nv_V4;
972
973 // JMP_GTUrrdn
974 case Hexagon::JMP_GTUrrdnPt_nv_V4:
975 return Hexagon::JMP_GTUrrdnPt_ie_nv_V4;
976 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
977 return Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4;
978 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
979 return Hexagon::JMP_GTUrrdnPnt_ie_nv_V4;
980 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
981 return Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4;
982
983 case Hexagon::TFR_FI:
984 return Hexagon::TFR_FI_immext_V4;
985
Sirish Pande26f61a12012-05-03 21:52:53 +0000986 case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
987 case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
988 case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
989 case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
990 case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
991 case Hexagon::MEMw_ORr_indexed_MEM_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +0000992 case Hexagon::MEMw_ADDi_MEM_V4 :
993 case Hexagon::MEMw_SUBi_MEM_V4 :
994 case Hexagon::MEMw_ADDr_MEM_V4 :
995 case Hexagon::MEMw_SUBr_MEM_V4 :
996 case Hexagon::MEMw_ANDr_MEM_V4 :
997 case Hexagon::MEMw_ORr_MEM_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +0000998 case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
999 case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
1000 case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
1001 case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
1002 case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
1003 case Hexagon::MEMh_ORr_indexed_MEM_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +00001004 case Hexagon::MEMh_ADDi_MEM_V4 :
1005 case Hexagon::MEMh_SUBi_MEM_V4 :
1006 case Hexagon::MEMh_ADDr_MEM_V4 :
1007 case Hexagon::MEMh_SUBr_MEM_V4 :
1008 case Hexagon::MEMh_ANDr_MEM_V4 :
1009 case Hexagon::MEMh_ORr_MEM_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +00001010 case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
1011 case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
1012 case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
1013 case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
1014 case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
1015 case Hexagon::MEMb_ORr_indexed_MEM_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +00001016 case Hexagon::MEMb_ADDi_MEM_V4 :
1017 case Hexagon::MEMb_SUBi_MEM_V4 :
1018 case Hexagon::MEMb_ADDr_MEM_V4 :
1019 case Hexagon::MEMb_SUBr_MEM_V4 :
1020 case Hexagon::MEMb_ANDr_MEM_V4 :
1021 case Hexagon::MEMb_ORr_MEM_V4 :
1022 llvm_unreachable("Needs implementing.");
1023 }
1024}
1025
1026unsigned HexagonInstrInfo::getNormalBranchForm(const MachineInstr* MI) const {
1027 switch(MI->getOpcode()) {
1028 default: llvm_unreachable("Unknown type of jump instruction.");
1029 // JMP_EQri
1030 case Hexagon::JMP_EQriPt_ie_nv_V4:
1031 return Hexagon::JMP_EQriPt_nv_V4;
1032 case Hexagon::JMP_EQriNotPt_ie_nv_V4:
1033 return Hexagon::JMP_EQriNotPt_nv_V4;
1034 case Hexagon::JMP_EQriPnt_ie_nv_V4:
1035 return Hexagon::JMP_EQriPnt_nv_V4;
1036 case Hexagon::JMP_EQriNotPnt_ie_nv_V4:
1037 return Hexagon::JMP_EQriNotPnt_nv_V4;
1038
1039 // JMP_EQri -- with -1
1040 case Hexagon::JMP_EQriPtneg_ie_nv_V4:
1041 return Hexagon::JMP_EQriPtneg_nv_V4;
1042 case Hexagon::JMP_EQriNotPtneg_ie_nv_V4:
1043 return Hexagon::JMP_EQriNotPtneg_nv_V4;
1044 case Hexagon::JMP_EQriPntneg_ie_nv_V4:
1045 return Hexagon::JMP_EQriPntneg_nv_V4;
1046 case Hexagon::JMP_EQriNotPntneg_ie_nv_V4:
1047 return Hexagon::JMP_EQriNotPntneg_nv_V4;
1048
1049 // JMP_EQrr
1050 case Hexagon::JMP_EQrrPt_ie_nv_V4:
1051 return Hexagon::JMP_EQrrPt_nv_V4;
1052 case Hexagon::JMP_EQrrNotPt_ie_nv_V4:
1053 return Hexagon::JMP_EQrrNotPt_nv_V4;
1054 case Hexagon::JMP_EQrrPnt_ie_nv_V4:
1055 return Hexagon::JMP_EQrrPnt_nv_V4;
1056 case Hexagon::JMP_EQrrNotPnt_ie_nv_V4:
1057 return Hexagon::JMP_EQrrNotPnt_nv_V4;
1058
1059 // JMP_GTri
1060 case Hexagon::JMP_GTriPt_ie_nv_V4:
1061 return Hexagon::JMP_GTriPt_nv_V4;
1062 case Hexagon::JMP_GTriNotPt_ie_nv_V4:
1063 return Hexagon::JMP_GTriNotPt_nv_V4;
1064 case Hexagon::JMP_GTriPnt_ie_nv_V4:
1065 return Hexagon::JMP_GTriPnt_nv_V4;
1066 case Hexagon::JMP_GTriNotPnt_ie_nv_V4:
1067 return Hexagon::JMP_GTriNotPnt_nv_V4;
1068
1069 // JMP_GTri -- with -1
1070 case Hexagon::JMP_GTriPtneg_ie_nv_V4:
1071 return Hexagon::JMP_GTriPtneg_nv_V4;
1072 case Hexagon::JMP_GTriNotPtneg_ie_nv_V4:
1073 return Hexagon::JMP_GTriNotPtneg_nv_V4;
1074 case Hexagon::JMP_GTriPntneg_ie_nv_V4:
1075 return Hexagon::JMP_GTriPntneg_nv_V4;
1076 case Hexagon::JMP_GTriNotPntneg_ie_nv_V4:
1077 return Hexagon::JMP_GTriNotPntneg_nv_V4;
1078
1079 // JMP_GTrr
1080 case Hexagon::JMP_GTrrPt_ie_nv_V4:
1081 return Hexagon::JMP_GTrrPt_nv_V4;
1082 case Hexagon::JMP_GTrrNotPt_ie_nv_V4:
1083 return Hexagon::JMP_GTrrNotPt_nv_V4;
1084 case Hexagon::JMP_GTrrPnt_ie_nv_V4:
1085 return Hexagon::JMP_GTrrPnt_nv_V4;
1086 case Hexagon::JMP_GTrrNotPnt_ie_nv_V4:
1087 return Hexagon::JMP_GTrrNotPnt_nv_V4;
1088
1089 // JMP_GTrrdn
1090 case Hexagon::JMP_GTrrdnPt_ie_nv_V4:
1091 return Hexagon::JMP_GTrrdnPt_nv_V4;
1092 case Hexagon::JMP_GTrrdnNotPt_ie_nv_V4:
1093 return Hexagon::JMP_GTrrdnNotPt_nv_V4;
1094 case Hexagon::JMP_GTrrdnPnt_ie_nv_V4:
1095 return Hexagon::JMP_GTrrdnPnt_nv_V4;
1096 case Hexagon::JMP_GTrrdnNotPnt_ie_nv_V4:
1097 return Hexagon::JMP_GTrrdnNotPnt_nv_V4;
1098
1099 // JMP_GTUri
1100 case Hexagon::JMP_GTUriPt_ie_nv_V4:
1101 return Hexagon::JMP_GTUriPt_nv_V4;
1102 case Hexagon::JMP_GTUriNotPt_ie_nv_V4:
1103 return Hexagon::JMP_GTUriNotPt_nv_V4;
1104 case Hexagon::JMP_GTUriPnt_ie_nv_V4:
1105 return Hexagon::JMP_GTUriPnt_nv_V4;
1106 case Hexagon::JMP_GTUriNotPnt_ie_nv_V4:
1107 return Hexagon::JMP_GTUriNotPnt_nv_V4;
1108
1109 // JMP_GTUrr
1110 case Hexagon::JMP_GTUrrPt_ie_nv_V4:
1111 return Hexagon::JMP_GTUrrPt_nv_V4;
1112 case Hexagon::JMP_GTUrrNotPt_ie_nv_V4:
1113 return Hexagon::JMP_GTUrrNotPt_nv_V4;
1114 case Hexagon::JMP_GTUrrPnt_ie_nv_V4:
1115 return Hexagon::JMP_GTUrrPnt_nv_V4;
1116 case Hexagon::JMP_GTUrrNotPnt_ie_nv_V4:
1117 return Hexagon::JMP_GTUrrNotPnt_nv_V4;
1118
1119 // JMP_GTUrrdn
1120 case Hexagon::JMP_GTUrrdnPt_ie_nv_V4:
1121 return Hexagon::JMP_GTUrrdnPt_nv_V4;
1122 case Hexagon::JMP_GTUrrdnNotPt_ie_nv_V4:
1123 return Hexagon::JMP_GTUrrdnNotPt_nv_V4;
1124 case Hexagon::JMP_GTUrrdnPnt_ie_nv_V4:
1125 return Hexagon::JMP_GTUrrdnPnt_nv_V4;
1126 case Hexagon::JMP_GTUrrdnNotPnt_ie_nv_V4:
1127 return Hexagon::JMP_GTUrrdnNotPnt_nv_V4;
1128 }
1129}
1130
1131
1132bool HexagonInstrInfo::isNewValueStore(const MachineInstr *MI) const {
1133 switch (MI->getOpcode()) {
1134 default: return false;
1135 // Store Byte
1136 case Hexagon::STrib_nv_V4:
1137 case Hexagon::STrib_indexed_nv_V4:
1138 case Hexagon::STrib_indexed_shl_nv_V4:
1139 case Hexagon::STrib_shl_nv_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00001140 case Hexagon::STb_GP_nv_V4:
1141 case Hexagon::POST_STbri_nv_V4:
1142 case Hexagon::STrib_cPt_nv_V4:
1143 case Hexagon::STrib_cdnPt_nv_V4:
1144 case Hexagon::STrib_cNotPt_nv_V4:
1145 case Hexagon::STrib_cdnNotPt_nv_V4:
1146 case Hexagon::STrib_indexed_cPt_nv_V4:
1147 case Hexagon::STrib_indexed_cdnPt_nv_V4:
1148 case Hexagon::STrib_indexed_cNotPt_nv_V4:
1149 case Hexagon::STrib_indexed_cdnNotPt_nv_V4:
1150 case Hexagon::STrib_indexed_shl_cPt_nv_V4:
1151 case Hexagon::STrib_indexed_shl_cdnPt_nv_V4:
1152 case Hexagon::STrib_indexed_shl_cNotPt_nv_V4:
1153 case Hexagon::STrib_indexed_shl_cdnNotPt_nv_V4:
1154 case Hexagon::POST_STbri_cPt_nv_V4:
1155 case Hexagon::POST_STbri_cdnPt_nv_V4:
1156 case Hexagon::POST_STbri_cNotPt_nv_V4:
1157 case Hexagon::POST_STbri_cdnNotPt_nv_V4:
1158 case Hexagon::STb_GP_cPt_nv_V4:
1159 case Hexagon::STb_GP_cNotPt_nv_V4:
1160 case Hexagon::STb_GP_cdnPt_nv_V4:
1161 case Hexagon::STb_GP_cdnNotPt_nv_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00001162 case Hexagon::STrib_abs_nv_V4:
1163 case Hexagon::STrib_abs_cPt_nv_V4:
1164 case Hexagon::STrib_abs_cdnPt_nv_V4:
1165 case Hexagon::STrib_abs_cNotPt_nv_V4:
1166 case Hexagon::STrib_abs_cdnNotPt_nv_V4:
1167 case Hexagon::STrib_imm_abs_nv_V4:
1168 case Hexagon::STrib_imm_abs_cPt_nv_V4:
1169 case Hexagon::STrib_imm_abs_cdnPt_nv_V4:
1170 case Hexagon::STrib_imm_abs_cNotPt_nv_V4:
1171 case Hexagon::STrib_imm_abs_cdnNotPt_nv_V4:
1172
1173 // Store Halfword
1174 case Hexagon::STrih_nv_V4:
1175 case Hexagon::STrih_indexed_nv_V4:
1176 case Hexagon::STrih_indexed_shl_nv_V4:
1177 case Hexagon::STrih_shl_nv_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00001178 case Hexagon::STh_GP_nv_V4:
1179 case Hexagon::POST_SThri_nv_V4:
1180 case Hexagon::STrih_cPt_nv_V4:
1181 case Hexagon::STrih_cdnPt_nv_V4:
1182 case Hexagon::STrih_cNotPt_nv_V4:
1183 case Hexagon::STrih_cdnNotPt_nv_V4:
1184 case Hexagon::STrih_indexed_cPt_nv_V4:
1185 case Hexagon::STrih_indexed_cdnPt_nv_V4:
1186 case Hexagon::STrih_indexed_cNotPt_nv_V4:
1187 case Hexagon::STrih_indexed_cdnNotPt_nv_V4:
1188 case Hexagon::STrih_indexed_shl_cPt_nv_V4:
1189 case Hexagon::STrih_indexed_shl_cdnPt_nv_V4:
1190 case Hexagon::STrih_indexed_shl_cNotPt_nv_V4:
1191 case Hexagon::STrih_indexed_shl_cdnNotPt_nv_V4:
1192 case Hexagon::POST_SThri_cPt_nv_V4:
1193 case Hexagon::POST_SThri_cdnPt_nv_V4:
1194 case Hexagon::POST_SThri_cNotPt_nv_V4:
1195 case Hexagon::POST_SThri_cdnNotPt_nv_V4:
1196 case Hexagon::STh_GP_cPt_nv_V4:
1197 case Hexagon::STh_GP_cNotPt_nv_V4:
1198 case Hexagon::STh_GP_cdnPt_nv_V4:
1199 case Hexagon::STh_GP_cdnNotPt_nv_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00001200 case Hexagon::STrih_abs_nv_V4:
1201 case Hexagon::STrih_abs_cPt_nv_V4:
1202 case Hexagon::STrih_abs_cdnPt_nv_V4:
1203 case Hexagon::STrih_abs_cNotPt_nv_V4:
1204 case Hexagon::STrih_abs_cdnNotPt_nv_V4:
1205 case Hexagon::STrih_imm_abs_nv_V4:
1206 case Hexagon::STrih_imm_abs_cPt_nv_V4:
1207 case Hexagon::STrih_imm_abs_cdnPt_nv_V4:
1208 case Hexagon::STrih_imm_abs_cNotPt_nv_V4:
1209 case Hexagon::STrih_imm_abs_cdnNotPt_nv_V4:
1210
1211 // Store Word
1212 case Hexagon::STriw_nv_V4:
1213 case Hexagon::STriw_indexed_nv_V4:
1214 case Hexagon::STriw_indexed_shl_nv_V4:
1215 case Hexagon::STriw_shl_nv_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00001216 case Hexagon::STw_GP_nv_V4:
1217 case Hexagon::POST_STwri_nv_V4:
1218 case Hexagon::STriw_cPt_nv_V4:
1219 case Hexagon::STriw_cdnPt_nv_V4:
1220 case Hexagon::STriw_cNotPt_nv_V4:
1221 case Hexagon::STriw_cdnNotPt_nv_V4:
1222 case Hexagon::STriw_indexed_cPt_nv_V4:
1223 case Hexagon::STriw_indexed_cdnPt_nv_V4:
1224 case Hexagon::STriw_indexed_cNotPt_nv_V4:
1225 case Hexagon::STriw_indexed_cdnNotPt_nv_V4:
1226 case Hexagon::STriw_indexed_shl_cPt_nv_V4:
1227 case Hexagon::STriw_indexed_shl_cdnPt_nv_V4:
1228 case Hexagon::STriw_indexed_shl_cNotPt_nv_V4:
1229 case Hexagon::STriw_indexed_shl_cdnNotPt_nv_V4:
1230 case Hexagon::POST_STwri_cPt_nv_V4:
1231 case Hexagon::POST_STwri_cdnPt_nv_V4:
1232 case Hexagon::POST_STwri_cNotPt_nv_V4:
1233 case Hexagon::POST_STwri_cdnNotPt_nv_V4:
1234 case Hexagon::STw_GP_cPt_nv_V4:
1235 case Hexagon::STw_GP_cNotPt_nv_V4:
1236 case Hexagon::STw_GP_cdnPt_nv_V4:
1237 case Hexagon::STw_GP_cdnNotPt_nv_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00001238 case Hexagon::STriw_abs_nv_V4:
1239 case Hexagon::STriw_abs_cPt_nv_V4:
1240 case Hexagon::STriw_abs_cdnPt_nv_V4:
1241 case Hexagon::STriw_abs_cNotPt_nv_V4:
1242 case Hexagon::STriw_abs_cdnNotPt_nv_V4:
1243 case Hexagon::STriw_imm_abs_nv_V4:
1244 case Hexagon::STriw_imm_abs_cPt_nv_V4:
1245 case Hexagon::STriw_imm_abs_cdnPt_nv_V4:
1246 case Hexagon::STriw_imm_abs_cNotPt_nv_V4:
1247 case Hexagon::STriw_imm_abs_cdnNotPt_nv_V4:
1248 return true;
1249 }
1250}
1251
1252bool HexagonInstrInfo::isPostIncrement (const MachineInstr* MI) const {
1253 switch (MI->getOpcode())
1254 {
1255 default: return false;
1256 // Load Byte
1257 case Hexagon::POST_LDrib:
1258 case Hexagon::POST_LDrib_cPt:
1259 case Hexagon::POST_LDrib_cNotPt:
1260 case Hexagon::POST_LDrib_cdnPt_V4:
1261 case Hexagon::POST_LDrib_cdnNotPt_V4:
1262
1263 // Load unsigned byte
1264 case Hexagon::POST_LDriub:
1265 case Hexagon::POST_LDriub_cPt:
1266 case Hexagon::POST_LDriub_cNotPt:
1267 case Hexagon::POST_LDriub_cdnPt_V4:
1268 case Hexagon::POST_LDriub_cdnNotPt_V4:
1269
1270 // Load halfword
1271 case Hexagon::POST_LDrih:
1272 case Hexagon::POST_LDrih_cPt:
1273 case Hexagon::POST_LDrih_cNotPt:
1274 case Hexagon::POST_LDrih_cdnPt_V4:
1275 case Hexagon::POST_LDrih_cdnNotPt_V4:
1276
1277 // Load unsigned halfword
1278 case Hexagon::POST_LDriuh:
1279 case Hexagon::POST_LDriuh_cPt:
1280 case Hexagon::POST_LDriuh_cNotPt:
1281 case Hexagon::POST_LDriuh_cdnPt_V4:
1282 case Hexagon::POST_LDriuh_cdnNotPt_V4:
1283
1284 // Load word
1285 case Hexagon::POST_LDriw:
1286 case Hexagon::POST_LDriw_cPt:
1287 case Hexagon::POST_LDriw_cNotPt:
1288 case Hexagon::POST_LDriw_cdnPt_V4:
1289 case Hexagon::POST_LDriw_cdnNotPt_V4:
1290
1291 // Load double word
1292 case Hexagon::POST_LDrid:
1293 case Hexagon::POST_LDrid_cPt:
1294 case Hexagon::POST_LDrid_cNotPt:
1295 case Hexagon::POST_LDrid_cdnPt_V4:
1296 case Hexagon::POST_LDrid_cdnNotPt_V4:
1297
1298 // Store byte
1299 case Hexagon::POST_STbri:
1300 case Hexagon::POST_STbri_cPt:
1301 case Hexagon::POST_STbri_cNotPt:
1302 case Hexagon::POST_STbri_cdnPt_V4:
1303 case Hexagon::POST_STbri_cdnNotPt_V4:
1304
1305 // Store halfword
1306 case Hexagon::POST_SThri:
1307 case Hexagon::POST_SThri_cPt:
1308 case Hexagon::POST_SThri_cNotPt:
1309 case Hexagon::POST_SThri_cdnPt_V4:
1310 case Hexagon::POST_SThri_cdnNotPt_V4:
1311
1312 // Store word
1313 case Hexagon::POST_STwri:
1314 case Hexagon::POST_STwri_cPt:
1315 case Hexagon::POST_STwri_cNotPt:
1316 case Hexagon::POST_STwri_cdnPt_V4:
1317 case Hexagon::POST_STwri_cdnNotPt_V4:
1318
1319 // Store double word
1320 case Hexagon::POST_STdri:
1321 case Hexagon::POST_STdri_cPt:
1322 case Hexagon::POST_STdri_cNotPt:
1323 case Hexagon::POST_STdri_cdnPt_V4:
1324 case Hexagon::POST_STdri_cdnNotPt_V4:
1325 return true;
1326 }
1327}
1328
1329bool HexagonInstrInfo::isSaveCalleeSavedRegsCall(const MachineInstr *MI) const {
1330 return MI->getOpcode() == Hexagon::SAVE_REGISTERS_CALL_V4;
1331}
Andrew Trickee498d32012-02-01 22:13:57 +00001332
Tony Linthicumb4b54152011-12-12 21:14:40 +00001333bool HexagonInstrInfo::isPredicable(MachineInstr *MI) const {
1334 bool isPred = MI->getDesc().isPredicable();
1335
1336 if (!isPred)
1337 return false;
1338
1339 const int Opc = MI->getOpcode();
1340
1341 switch(Opc) {
1342 case Hexagon::TFRI:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001343 return isInt<12>(MI->getOperand(1).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001344
1345 case Hexagon::STrid:
1346 case Hexagon::STrid_indexed:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001347 return isShiftedUInt<6,3>(MI->getOperand(1).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001348
1349 case Hexagon::STriw:
1350 case Hexagon::STriw_indexed:
1351 case Hexagon::STriw_nv_V4:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001352 return isShiftedUInt<6,2>(MI->getOperand(1).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001353
1354 case Hexagon::STrih:
1355 case Hexagon::STrih_indexed:
1356 case Hexagon::STrih_nv_V4:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001357 return isShiftedUInt<6,1>(MI->getOperand(1).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001358
1359 case Hexagon::STrib:
1360 case Hexagon::STrib_indexed:
1361 case Hexagon::STrib_nv_V4:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001362 return isUInt<6>(MI->getOperand(1).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001363
1364 case Hexagon::LDrid:
1365 case Hexagon::LDrid_indexed:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001366 return isShiftedUInt<6,3>(MI->getOperand(2).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001367
1368 case Hexagon::LDriw:
1369 case Hexagon::LDriw_indexed:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001370 return isShiftedUInt<6,2>(MI->getOperand(2).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001371
1372 case Hexagon::LDrih:
1373 case Hexagon::LDriuh:
1374 case Hexagon::LDrih_indexed:
1375 case Hexagon::LDriuh_indexed:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001376 return isShiftedUInt<6,1>(MI->getOperand(2).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001377
1378 case Hexagon::LDrib:
1379 case Hexagon::LDriub:
1380 case Hexagon::LDrib_indexed:
1381 case Hexagon::LDriub_indexed:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001382 return isUInt<6>(MI->getOperand(2).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001383
1384 case Hexagon::POST_LDrid:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001385 return isShiftedInt<4,3>(MI->getOperand(3).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001386
1387 case Hexagon::POST_LDriw:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001388 return isShiftedInt<4,2>(MI->getOperand(3).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001389
1390 case Hexagon::POST_LDrih:
1391 case Hexagon::POST_LDriuh:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001392 return isShiftedInt<4,1>(MI->getOperand(3).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001393
1394 case Hexagon::POST_LDrib:
1395 case Hexagon::POST_LDriub:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001396 return isInt<4>(MI->getOperand(3).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001397
1398 case Hexagon::STrib_imm_V4:
1399 case Hexagon::STrih_imm_V4:
1400 case Hexagon::STriw_imm_V4:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001401 return (isUInt<6>(MI->getOperand(1).getImm()) &&
1402 isInt<6>(MI->getOperand(2).getImm()));
Tony Linthicumb4b54152011-12-12 21:14:40 +00001403
1404 case Hexagon::ADD_ri:
Brendon Cahoon5262abb2012-05-14 19:35:42 +00001405 return isInt<8>(MI->getOperand(2).getImm());
Tony Linthicumb4b54152011-12-12 21:14:40 +00001406
1407 case Hexagon::ASLH:
1408 case Hexagon::ASRH:
1409 case Hexagon::SXTB:
1410 case Hexagon::SXTH:
1411 case Hexagon::ZXTB:
1412 case Hexagon::ZXTH:
Sirish Pande2b38c122012-05-12 05:54:15 +00001413 return Subtarget.hasV4TOps();
Tony Linthicumb4b54152011-12-12 21:14:40 +00001414
1415 case Hexagon::JMPR:
1416 return false;
Tony Linthicumb4b54152011-12-12 21:14:40 +00001417 }
1418
1419 return true;
1420}
1421
Sirish Pande2b38c122012-05-12 05:54:15 +00001422// This function performs the following inversiones:
1423//
1424// cPt ---> cNotPt
1425// cNotPt ---> cPt
1426//
1427// however, these inversiones are NOT included:
1428//
1429// cdnPt -X-> cdnNotPt
1430// cdnNotPt -X-> cdnPt
1431// cPt_nv -X-> cNotPt_nv (new value stores)
1432// cNotPt_nv -X-> cPt_nv (new value stores)
1433//
1434// because only the following transformations are allowed:
1435//
1436// cNotPt ---> cdnNotPt
1437// cPt ---> cdnPt
1438// cNotPt ---> cNotPt_nv
1439// cPt ---> cPt_nv
Sirish Pandeab7955b2012-02-15 18:52:27 +00001440unsigned HexagonInstrInfo::getInvertedPredicatedOpcode(const int Opc) const {
1441 switch(Opc) {
Sirish Pande26f61a12012-05-03 21:52:53 +00001442 default: llvm_unreachable("Unexpected predicated instruction");
Sirish Pandeab7955b2012-02-15 18:52:27 +00001443 case Hexagon::TFR_cPt:
1444 return Hexagon::TFR_cNotPt;
1445 case Hexagon::TFR_cNotPt:
1446 return Hexagon::TFR_cPt;
1447
1448 case Hexagon::TFRI_cPt:
1449 return Hexagon::TFRI_cNotPt;
1450 case Hexagon::TFRI_cNotPt:
1451 return Hexagon::TFRI_cPt;
1452
1453 case Hexagon::JMP_c:
1454 return Hexagon::JMP_cNot;
1455 case Hexagon::JMP_cNot:
1456 return Hexagon::JMP_c;
1457
1458 case Hexagon::ADD_ri_cPt:
1459 return Hexagon::ADD_ri_cNotPt;
1460 case Hexagon::ADD_ri_cNotPt:
1461 return Hexagon::ADD_ri_cPt;
1462
1463 case Hexagon::ADD_rr_cPt:
1464 return Hexagon::ADD_rr_cNotPt;
1465 case Hexagon::ADD_rr_cNotPt:
1466 return Hexagon::ADD_rr_cPt;
1467
1468 case Hexagon::XOR_rr_cPt:
1469 return Hexagon::XOR_rr_cNotPt;
1470 case Hexagon::XOR_rr_cNotPt:
1471 return Hexagon::XOR_rr_cPt;
1472
1473 case Hexagon::AND_rr_cPt:
1474 return Hexagon::AND_rr_cNotPt;
1475 case Hexagon::AND_rr_cNotPt:
1476 return Hexagon::AND_rr_cPt;
1477
1478 case Hexagon::OR_rr_cPt:
1479 return Hexagon::OR_rr_cNotPt;
1480 case Hexagon::OR_rr_cNotPt:
1481 return Hexagon::OR_rr_cPt;
1482
1483 case Hexagon::SUB_rr_cPt:
1484 return Hexagon::SUB_rr_cNotPt;
1485 case Hexagon::SUB_rr_cNotPt:
1486 return Hexagon::SUB_rr_cPt;
1487
1488 case Hexagon::COMBINE_rr_cPt:
1489 return Hexagon::COMBINE_rr_cNotPt;
1490 case Hexagon::COMBINE_rr_cNotPt:
1491 return Hexagon::COMBINE_rr_cPt;
1492
1493 case Hexagon::ASLH_cPt_V4:
1494 return Hexagon::ASLH_cNotPt_V4;
1495 case Hexagon::ASLH_cNotPt_V4:
1496 return Hexagon::ASLH_cPt_V4;
1497
1498 case Hexagon::ASRH_cPt_V4:
1499 return Hexagon::ASRH_cNotPt_V4;
1500 case Hexagon::ASRH_cNotPt_V4:
1501 return Hexagon::ASRH_cPt_V4;
1502
1503 case Hexagon::SXTB_cPt_V4:
1504 return Hexagon::SXTB_cNotPt_V4;
1505 case Hexagon::SXTB_cNotPt_V4:
1506 return Hexagon::SXTB_cPt_V4;
1507
1508 case Hexagon::SXTH_cPt_V4:
1509 return Hexagon::SXTH_cNotPt_V4;
1510 case Hexagon::SXTH_cNotPt_V4:
1511 return Hexagon::SXTH_cPt_V4;
1512
1513 case Hexagon::ZXTB_cPt_V4:
1514 return Hexagon::ZXTB_cNotPt_V4;
1515 case Hexagon::ZXTB_cNotPt_V4:
1516 return Hexagon::ZXTB_cPt_V4;
1517
1518 case Hexagon::ZXTH_cPt_V4:
1519 return Hexagon::ZXTH_cNotPt_V4;
1520 case Hexagon::ZXTH_cNotPt_V4:
1521 return Hexagon::ZXTH_cPt_V4;
1522
1523
1524 case Hexagon::JMPR_cPt:
1525 return Hexagon::JMPR_cNotPt;
1526 case Hexagon::JMPR_cNotPt:
1527 return Hexagon::JMPR_cPt;
1528
1529 // V4 indexed+scaled load.
Sirish Pandeab7955b2012-02-15 18:52:27 +00001530 case Hexagon::LDrid_indexed_shl_cPt_V4:
1531 return Hexagon::LDrid_indexed_shl_cNotPt_V4;
1532 case Hexagon::LDrid_indexed_shl_cNotPt_V4:
1533 return Hexagon::LDrid_indexed_shl_cPt_V4;
1534
Sirish Pandeab7955b2012-02-15 18:52:27 +00001535 case Hexagon::LDrib_indexed_shl_cPt_V4:
1536 return Hexagon::LDrib_indexed_shl_cNotPt_V4;
1537 case Hexagon::LDrib_indexed_shl_cNotPt_V4:
1538 return Hexagon::LDrib_indexed_shl_cPt_V4;
1539
1540 case Hexagon::LDriub_indexed_shl_cPt_V4:
1541 return Hexagon::LDriub_indexed_shl_cNotPt_V4;
1542 case Hexagon::LDriub_indexed_shl_cNotPt_V4:
1543 return Hexagon::LDriub_indexed_shl_cPt_V4;
1544
Sirish Pandeab7955b2012-02-15 18:52:27 +00001545 case Hexagon::LDrih_indexed_shl_cPt_V4:
1546 return Hexagon::LDrih_indexed_shl_cNotPt_V4;
1547 case Hexagon::LDrih_indexed_shl_cNotPt_V4:
1548 return Hexagon::LDrih_indexed_shl_cPt_V4;
1549
1550 case Hexagon::LDriuh_indexed_shl_cPt_V4:
1551 return Hexagon::LDriuh_indexed_shl_cNotPt_V4;
1552 case Hexagon::LDriuh_indexed_shl_cNotPt_V4:
1553 return Hexagon::LDriuh_indexed_shl_cPt_V4;
1554
Sirish Pandeab7955b2012-02-15 18:52:27 +00001555 case Hexagon::LDriw_indexed_shl_cPt_V4:
1556 return Hexagon::LDriw_indexed_shl_cNotPt_V4;
1557 case Hexagon::LDriw_indexed_shl_cNotPt_V4:
1558 return Hexagon::LDriw_indexed_shl_cPt_V4;
1559
1560 // Byte.
1561 case Hexagon::POST_STbri_cPt:
1562 return Hexagon::POST_STbri_cNotPt;
1563 case Hexagon::POST_STbri_cNotPt:
1564 return Hexagon::POST_STbri_cPt;
1565
1566 case Hexagon::STrib_cPt:
1567 return Hexagon::STrib_cNotPt;
1568 case Hexagon::STrib_cNotPt:
1569 return Hexagon::STrib_cPt;
1570
1571 case Hexagon::STrib_indexed_cPt:
1572 return Hexagon::STrib_indexed_cNotPt;
1573 case Hexagon::STrib_indexed_cNotPt:
1574 return Hexagon::STrib_indexed_cPt;
1575
1576 case Hexagon::STrib_imm_cPt_V4:
1577 return Hexagon::STrib_imm_cNotPt_V4;
1578 case Hexagon::STrib_imm_cNotPt_V4:
1579 return Hexagon::STrib_imm_cPt_V4;
1580
1581 case Hexagon::STrib_indexed_shl_cPt_V4:
1582 return Hexagon::STrib_indexed_shl_cNotPt_V4;
1583 case Hexagon::STrib_indexed_shl_cNotPt_V4:
1584 return Hexagon::STrib_indexed_shl_cPt_V4;
1585
1586 // Halfword.
1587 case Hexagon::POST_SThri_cPt:
1588 return Hexagon::POST_SThri_cNotPt;
1589 case Hexagon::POST_SThri_cNotPt:
1590 return Hexagon::POST_SThri_cPt;
1591
1592 case Hexagon::STrih_cPt:
1593 return Hexagon::STrih_cNotPt;
1594 case Hexagon::STrih_cNotPt:
1595 return Hexagon::STrih_cPt;
1596
1597 case Hexagon::STrih_indexed_cPt:
1598 return Hexagon::STrih_indexed_cNotPt;
1599 case Hexagon::STrih_indexed_cNotPt:
1600 return Hexagon::STrih_indexed_cPt;
1601
1602 case Hexagon::STrih_imm_cPt_V4:
1603 return Hexagon::STrih_imm_cNotPt_V4;
1604 case Hexagon::STrih_imm_cNotPt_V4:
1605 return Hexagon::STrih_imm_cPt_V4;
1606
1607 case Hexagon::STrih_indexed_shl_cPt_V4:
1608 return Hexagon::STrih_indexed_shl_cNotPt_V4;
1609 case Hexagon::STrih_indexed_shl_cNotPt_V4:
1610 return Hexagon::STrih_indexed_shl_cPt_V4;
1611
1612 // Word.
1613 case Hexagon::POST_STwri_cPt:
1614 return Hexagon::POST_STwri_cNotPt;
1615 case Hexagon::POST_STwri_cNotPt:
1616 return Hexagon::POST_STwri_cPt;
1617
1618 case Hexagon::STriw_cPt:
1619 return Hexagon::STriw_cNotPt;
1620 case Hexagon::STriw_cNotPt:
1621 return Hexagon::STriw_cPt;
1622
1623 case Hexagon::STriw_indexed_cPt:
1624 return Hexagon::STriw_indexed_cNotPt;
1625 case Hexagon::STriw_indexed_cNotPt:
1626 return Hexagon::STriw_indexed_cPt;
1627
1628 case Hexagon::STriw_indexed_shl_cPt_V4:
1629 return Hexagon::STriw_indexed_shl_cNotPt_V4;
1630 case Hexagon::STriw_indexed_shl_cNotPt_V4:
1631 return Hexagon::STriw_indexed_shl_cPt_V4;
1632
1633 case Hexagon::STriw_imm_cPt_V4:
1634 return Hexagon::STriw_imm_cNotPt_V4;
1635 case Hexagon::STriw_imm_cNotPt_V4:
1636 return Hexagon::STriw_imm_cPt_V4;
1637
1638 // Double word.
1639 case Hexagon::POST_STdri_cPt:
1640 return Hexagon::POST_STdri_cNotPt;
1641 case Hexagon::POST_STdri_cNotPt:
1642 return Hexagon::POST_STdri_cPt;
1643
1644 case Hexagon::STrid_cPt:
1645 return Hexagon::STrid_cNotPt;
1646 case Hexagon::STrid_cNotPt:
1647 return Hexagon::STrid_cPt;
1648
1649 case Hexagon::STrid_indexed_cPt:
1650 return Hexagon::STrid_indexed_cNotPt;
1651 case Hexagon::STrid_indexed_cNotPt:
1652 return Hexagon::STrid_indexed_cPt;
1653
1654 case Hexagon::STrid_indexed_shl_cPt_V4:
1655 return Hexagon::STrid_indexed_shl_cNotPt_V4;
1656 case Hexagon::STrid_indexed_shl_cNotPt_V4:
1657 return Hexagon::STrid_indexed_shl_cPt_V4;
1658
Sirish Pande26f61a12012-05-03 21:52:53 +00001659 // V4 Store to global address.
1660 case Hexagon::STd_GP_cPt_V4:
1661 return Hexagon::STd_GP_cNotPt_V4;
1662 case Hexagon::STd_GP_cNotPt_V4:
1663 return Hexagon::STd_GP_cPt_V4;
1664
1665 case Hexagon::STb_GP_cPt_V4:
1666 return Hexagon::STb_GP_cNotPt_V4;
1667 case Hexagon::STb_GP_cNotPt_V4:
1668 return Hexagon::STb_GP_cPt_V4;
1669
1670 case Hexagon::STh_GP_cPt_V4:
1671 return Hexagon::STh_GP_cNotPt_V4;
1672 case Hexagon::STh_GP_cNotPt_V4:
1673 return Hexagon::STh_GP_cPt_V4;
1674
1675 case Hexagon::STw_GP_cPt_V4:
1676 return Hexagon::STw_GP_cNotPt_V4;
1677 case Hexagon::STw_GP_cNotPt_V4:
1678 return Hexagon::STw_GP_cPt_V4;
1679
Sirish Pandeab7955b2012-02-15 18:52:27 +00001680 // Load.
1681 case Hexagon::LDrid_cPt:
1682 return Hexagon::LDrid_cNotPt;
1683 case Hexagon::LDrid_cNotPt:
1684 return Hexagon::LDrid_cPt;
1685
1686 case Hexagon::LDriw_cPt:
1687 return Hexagon::LDriw_cNotPt;
1688 case Hexagon::LDriw_cNotPt:
1689 return Hexagon::LDriw_cPt;
1690
1691 case Hexagon::LDrih_cPt:
1692 return Hexagon::LDrih_cNotPt;
1693 case Hexagon::LDrih_cNotPt:
1694 return Hexagon::LDrih_cPt;
1695
1696 case Hexagon::LDriuh_cPt:
1697 return Hexagon::LDriuh_cNotPt;
1698 case Hexagon::LDriuh_cNotPt:
1699 return Hexagon::LDriuh_cPt;
1700
1701 case Hexagon::LDrib_cPt:
1702 return Hexagon::LDrib_cNotPt;
1703 case Hexagon::LDrib_cNotPt:
1704 return Hexagon::LDrib_cPt;
1705
1706 case Hexagon::LDriub_cPt:
1707 return Hexagon::LDriub_cNotPt;
1708 case Hexagon::LDriub_cNotPt:
1709 return Hexagon::LDriub_cPt;
1710
1711 // Load Indexed.
1712 case Hexagon::LDrid_indexed_cPt:
1713 return Hexagon::LDrid_indexed_cNotPt;
1714 case Hexagon::LDrid_indexed_cNotPt:
1715 return Hexagon::LDrid_indexed_cPt;
1716
1717 case Hexagon::LDriw_indexed_cPt:
1718 return Hexagon::LDriw_indexed_cNotPt;
1719 case Hexagon::LDriw_indexed_cNotPt:
1720 return Hexagon::LDriw_indexed_cPt;
1721
1722 case Hexagon::LDrih_indexed_cPt:
1723 return Hexagon::LDrih_indexed_cNotPt;
1724 case Hexagon::LDrih_indexed_cNotPt:
1725 return Hexagon::LDrih_indexed_cPt;
1726
1727 case Hexagon::LDriuh_indexed_cPt:
1728 return Hexagon::LDriuh_indexed_cNotPt;
1729 case Hexagon::LDriuh_indexed_cNotPt:
1730 return Hexagon::LDriuh_indexed_cPt;
1731
1732 case Hexagon::LDrib_indexed_cPt:
1733 return Hexagon::LDrib_indexed_cNotPt;
1734 case Hexagon::LDrib_indexed_cNotPt:
1735 return Hexagon::LDrib_indexed_cPt;
1736
1737 case Hexagon::LDriub_indexed_cPt:
1738 return Hexagon::LDriub_indexed_cNotPt;
1739 case Hexagon::LDriub_indexed_cNotPt:
1740 return Hexagon::LDriub_indexed_cPt;
1741
1742 // Post Inc Load.
1743 case Hexagon::POST_LDrid_cPt:
1744 return Hexagon::POST_LDrid_cNotPt;
1745 case Hexagon::POST_LDriw_cNotPt:
1746 return Hexagon::POST_LDriw_cPt;
1747
1748 case Hexagon::POST_LDrih_cPt:
1749 return Hexagon::POST_LDrih_cNotPt;
1750 case Hexagon::POST_LDrih_cNotPt:
1751 return Hexagon::POST_LDrih_cPt;
1752
1753 case Hexagon::POST_LDriuh_cPt:
1754 return Hexagon::POST_LDriuh_cNotPt;
1755 case Hexagon::POST_LDriuh_cNotPt:
1756 return Hexagon::POST_LDriuh_cPt;
1757
1758 case Hexagon::POST_LDrib_cPt:
1759 return Hexagon::POST_LDrib_cNotPt;
1760 case Hexagon::POST_LDrib_cNotPt:
1761 return Hexagon::POST_LDrib_cPt;
1762
1763 case Hexagon::POST_LDriub_cPt:
1764 return Hexagon::POST_LDriub_cNotPt;
1765 case Hexagon::POST_LDriub_cNotPt:
1766 return Hexagon::POST_LDriub_cPt;
1767
1768 // Dealloc_return.
1769 case Hexagon::DEALLOC_RET_cPt_V4:
1770 return Hexagon::DEALLOC_RET_cNotPt_V4;
1771 case Hexagon::DEALLOC_RET_cNotPt_V4:
1772 return Hexagon::DEALLOC_RET_cPt_V4;
1773
1774 // New Value Jump.
1775 // JMPEQ_ri - with -1.
1776 case Hexagon::JMP_EQriPtneg_nv_V4:
1777 return Hexagon::JMP_EQriNotPtneg_nv_V4;
1778 case Hexagon::JMP_EQriNotPtneg_nv_V4:
1779 return Hexagon::JMP_EQriPtneg_nv_V4;
1780
1781 case Hexagon::JMP_EQriPntneg_nv_V4:
1782 return Hexagon::JMP_EQriNotPntneg_nv_V4;
1783 case Hexagon::JMP_EQriNotPntneg_nv_V4:
1784 return Hexagon::JMP_EQriPntneg_nv_V4;
1785
1786 // JMPEQ_ri.
1787 case Hexagon::JMP_EQriPt_nv_V4:
1788 return Hexagon::JMP_EQriNotPt_nv_V4;
1789 case Hexagon::JMP_EQriNotPt_nv_V4:
1790 return Hexagon::JMP_EQriPt_nv_V4;
1791
1792 case Hexagon::JMP_EQriPnt_nv_V4:
1793 return Hexagon::JMP_EQriNotPnt_nv_V4;
1794 case Hexagon::JMP_EQriNotPnt_nv_V4:
1795 return Hexagon::JMP_EQriPnt_nv_V4;
1796
1797 // JMPEQ_rr.
1798 case Hexagon::JMP_EQrrPt_nv_V4:
1799 return Hexagon::JMP_EQrrNotPt_nv_V4;
1800 case Hexagon::JMP_EQrrNotPt_nv_V4:
1801 return Hexagon::JMP_EQrrPt_nv_V4;
1802
1803 case Hexagon::JMP_EQrrPnt_nv_V4:
1804 return Hexagon::JMP_EQrrNotPnt_nv_V4;
1805 case Hexagon::JMP_EQrrNotPnt_nv_V4:
1806 return Hexagon::JMP_EQrrPnt_nv_V4;
1807
1808 // JMPGT_ri - with -1.
1809 case Hexagon::JMP_GTriPtneg_nv_V4:
1810 return Hexagon::JMP_GTriNotPtneg_nv_V4;
1811 case Hexagon::JMP_GTriNotPtneg_nv_V4:
1812 return Hexagon::JMP_GTriPtneg_nv_V4;
1813
1814 case Hexagon::JMP_GTriPntneg_nv_V4:
1815 return Hexagon::JMP_GTriNotPntneg_nv_V4;
1816 case Hexagon::JMP_GTriNotPntneg_nv_V4:
1817 return Hexagon::JMP_GTriPntneg_nv_V4;
1818
1819 // JMPGT_ri.
1820 case Hexagon::JMP_GTriPt_nv_V4:
1821 return Hexagon::JMP_GTriNotPt_nv_V4;
1822 case Hexagon::JMP_GTriNotPt_nv_V4:
1823 return Hexagon::JMP_GTriPt_nv_V4;
1824
1825 case Hexagon::JMP_GTriPnt_nv_V4:
1826 return Hexagon::JMP_GTriNotPnt_nv_V4;
1827 case Hexagon::JMP_GTriNotPnt_nv_V4:
1828 return Hexagon::JMP_GTriPnt_nv_V4;
1829
1830 // JMPGT_rr.
1831 case Hexagon::JMP_GTrrPt_nv_V4:
1832 return Hexagon::JMP_GTrrNotPt_nv_V4;
1833 case Hexagon::JMP_GTrrNotPt_nv_V4:
1834 return Hexagon::JMP_GTrrPt_nv_V4;
1835
1836 case Hexagon::JMP_GTrrPnt_nv_V4:
1837 return Hexagon::JMP_GTrrNotPnt_nv_V4;
1838 case Hexagon::JMP_GTrrNotPnt_nv_V4:
1839 return Hexagon::JMP_GTrrPnt_nv_V4;
1840
1841 // JMPGT_rrdn.
1842 case Hexagon::JMP_GTrrdnPt_nv_V4:
1843 return Hexagon::JMP_GTrrdnNotPt_nv_V4;
1844 case Hexagon::JMP_GTrrdnNotPt_nv_V4:
1845 return Hexagon::JMP_GTrrdnPt_nv_V4;
1846
1847 case Hexagon::JMP_GTrrdnPnt_nv_V4:
1848 return Hexagon::JMP_GTrrdnNotPnt_nv_V4;
1849 case Hexagon::JMP_GTrrdnNotPnt_nv_V4:
1850 return Hexagon::JMP_GTrrdnPnt_nv_V4;
1851
1852 // JMPGTU_ri.
1853 case Hexagon::JMP_GTUriPt_nv_V4:
1854 return Hexagon::JMP_GTUriNotPt_nv_V4;
1855 case Hexagon::JMP_GTUriNotPt_nv_V4:
1856 return Hexagon::JMP_GTUriPt_nv_V4;
1857
1858 case Hexagon::JMP_GTUriPnt_nv_V4:
1859 return Hexagon::JMP_GTUriNotPnt_nv_V4;
1860 case Hexagon::JMP_GTUriNotPnt_nv_V4:
1861 return Hexagon::JMP_GTUriPnt_nv_V4;
1862
1863 // JMPGTU_rr.
1864 case Hexagon::JMP_GTUrrPt_nv_V4:
1865 return Hexagon::JMP_GTUrrNotPt_nv_V4;
1866 case Hexagon::JMP_GTUrrNotPt_nv_V4:
1867 return Hexagon::JMP_GTUrrPt_nv_V4;
1868
1869 case Hexagon::JMP_GTUrrPnt_nv_V4:
1870 return Hexagon::JMP_GTUrrNotPnt_nv_V4;
1871 case Hexagon::JMP_GTUrrNotPnt_nv_V4:
1872 return Hexagon::JMP_GTUrrPnt_nv_V4;
1873
1874 // JMPGTU_rrdn.
1875 case Hexagon::JMP_GTUrrdnPt_nv_V4:
1876 return Hexagon::JMP_GTUrrdnNotPt_nv_V4;
1877 case Hexagon::JMP_GTUrrdnNotPt_nv_V4:
1878 return Hexagon::JMP_GTUrrdnPt_nv_V4;
1879
1880 case Hexagon::JMP_GTUrrdnPnt_nv_V4:
1881 return Hexagon::JMP_GTUrrdnNotPnt_nv_V4;
1882 case Hexagon::JMP_GTUrrdnNotPnt_nv_V4:
1883 return Hexagon::JMP_GTUrrdnPnt_nv_V4;
Sirish Pandeab7955b2012-02-15 18:52:27 +00001884 }
1885}
Tony Linthicumb4b54152011-12-12 21:14:40 +00001886
Andrew Trickee498d32012-02-01 22:13:57 +00001887
Tony Linthicumb4b54152011-12-12 21:14:40 +00001888int HexagonInstrInfo::
1889getMatchingCondBranchOpcode(int Opc, bool invertPredicate) const {
Pranav Bhandarkar8aa138c2012-11-01 19:13:23 +00001890 enum Hexagon::PredSense inPredSense;
1891 inPredSense = invertPredicate ? Hexagon::PredSense_false :
1892 Hexagon::PredSense_true;
1893 int CondOpcode = Hexagon::getPredOpcode(Opc, inPredSense);
1894 if (CondOpcode >= 0) // Valid Conditional opcode/instruction
1895 return CondOpcode;
1896
1897 // This switch case will be removed once all the instructions have been
1898 // modified to use relation maps.
Tony Linthicumb4b54152011-12-12 21:14:40 +00001899 switch(Opc) {
1900 case Hexagon::TFR:
1901 return !invertPredicate ? Hexagon::TFR_cPt :
1902 Hexagon::TFR_cNotPt;
Sirish Pande7517bbc2012-05-10 20:20:25 +00001903 case Hexagon::TFRI_f:
1904 return !invertPredicate ? Hexagon::TFRI_cPt_f :
1905 Hexagon::TFRI_cNotPt_f;
Tony Linthicumb4b54152011-12-12 21:14:40 +00001906 case Hexagon::TFRI:
1907 return !invertPredicate ? Hexagon::TFRI_cPt :
1908 Hexagon::TFRI_cNotPt;
1909 case Hexagon::JMP:
Sirish Pandeab7955b2012-02-15 18:52:27 +00001910 return !invertPredicate ? Hexagon::JMP_c :
1911 Hexagon::JMP_cNot;
Sirish Pandeb3385702012-05-12 05:10:30 +00001912 case Hexagon::JMP_EQrrPt_nv_V4:
1913 return !invertPredicate ? Hexagon::JMP_EQrrPt_nv_V4 :
1914 Hexagon::JMP_EQrrNotPt_nv_V4;
1915 case Hexagon::JMP_EQriPt_nv_V4:
1916 return !invertPredicate ? Hexagon::JMP_EQriPt_nv_V4 :
1917 Hexagon::JMP_EQriNotPt_nv_V4;
Tony Linthicumb4b54152011-12-12 21:14:40 +00001918 case Hexagon::COMBINE_rr:
1919 return !invertPredicate ? Hexagon::COMBINE_rr_cPt :
1920 Hexagon::COMBINE_rr_cNotPt;
1921 case Hexagon::ASLH:
1922 return !invertPredicate ? Hexagon::ASLH_cPt_V4 :
1923 Hexagon::ASLH_cNotPt_V4;
1924 case Hexagon::ASRH:
1925 return !invertPredicate ? Hexagon::ASRH_cPt_V4 :
1926 Hexagon::ASRH_cNotPt_V4;
1927 case Hexagon::SXTB:
1928 return !invertPredicate ? Hexagon::SXTB_cPt_V4 :
1929 Hexagon::SXTB_cNotPt_V4;
1930 case Hexagon::SXTH:
1931 return !invertPredicate ? Hexagon::SXTH_cPt_V4 :
1932 Hexagon::SXTH_cNotPt_V4;
1933 case Hexagon::ZXTB:
1934 return !invertPredicate ? Hexagon::ZXTB_cPt_V4 :
1935 Hexagon::ZXTB_cNotPt_V4;
1936 case Hexagon::ZXTH:
1937 return !invertPredicate ? Hexagon::ZXTH_cPt_V4 :
1938 Hexagon::ZXTH_cNotPt_V4;
1939
1940 case Hexagon::JMPR:
1941 return !invertPredicate ? Hexagon::JMPR_cPt :
1942 Hexagon::JMPR_cNotPt;
1943
1944 // V4 indexed+scaled load.
Tony Linthicumb4b54152011-12-12 21:14:40 +00001945 case Hexagon::LDrid_indexed_shl_V4:
1946 return !invertPredicate ? Hexagon::LDrid_indexed_shl_cPt_V4 :
1947 Hexagon::LDrid_indexed_shl_cNotPt_V4;
Tony Linthicumb4b54152011-12-12 21:14:40 +00001948 case Hexagon::LDrib_indexed_shl_V4:
1949 return !invertPredicate ? Hexagon::LDrib_indexed_shl_cPt_V4 :
1950 Hexagon::LDrib_indexed_shl_cNotPt_V4;
1951 case Hexagon::LDriub_indexed_shl_V4:
1952 return !invertPredicate ? Hexagon::LDriub_indexed_shl_cPt_V4 :
1953 Hexagon::LDriub_indexed_shl_cNotPt_V4;
Tony Linthicumb4b54152011-12-12 21:14:40 +00001954 case Hexagon::LDrih_indexed_shl_V4:
1955 return !invertPredicate ? Hexagon::LDrih_indexed_shl_cPt_V4 :
1956 Hexagon::LDrih_indexed_shl_cNotPt_V4;
1957 case Hexagon::LDriuh_indexed_shl_V4:
1958 return !invertPredicate ? Hexagon::LDriuh_indexed_shl_cPt_V4 :
1959 Hexagon::LDriuh_indexed_shl_cNotPt_V4;
Tony Linthicumb4b54152011-12-12 21:14:40 +00001960 case Hexagon::LDriw_indexed_shl_V4:
1961 return !invertPredicate ? Hexagon::LDriw_indexed_shl_cPt_V4 :
1962 Hexagon::LDriw_indexed_shl_cNotPt_V4;
Sirish Pande26f61a12012-05-03 21:52:53 +00001963
1964 // V4 Load from global address
Sirish Pande26f61a12012-05-03 21:52:53 +00001965 case Hexagon::LDd_GP_V4:
1966 return !invertPredicate ? Hexagon::LDd_GP_cPt_V4 :
1967 Hexagon::LDd_GP_cNotPt_V4;
1968 case Hexagon::LDb_GP_V4:
1969 return !invertPredicate ? Hexagon::LDb_GP_cPt_V4 :
1970 Hexagon::LDb_GP_cNotPt_V4;
1971 case Hexagon::LDub_GP_V4:
1972 return !invertPredicate ? Hexagon::LDub_GP_cPt_V4 :
1973 Hexagon::LDub_GP_cNotPt_V4;
1974 case Hexagon::LDh_GP_V4:
1975 return !invertPredicate ? Hexagon::LDh_GP_cPt_V4 :
1976 Hexagon::LDh_GP_cNotPt_V4;
1977 case Hexagon::LDuh_GP_V4:
1978 return !invertPredicate ? Hexagon::LDuh_GP_cPt_V4 :
1979 Hexagon::LDuh_GP_cNotPt_V4;
1980 case Hexagon::LDw_GP_V4:
1981 return !invertPredicate ? Hexagon::LDw_GP_cPt_V4 :
1982 Hexagon::LDw_GP_cNotPt_V4;
1983
Tony Linthicumb4b54152011-12-12 21:14:40 +00001984 // Byte.
1985 case Hexagon::POST_STbri:
1986 return !invertPredicate ? Hexagon::POST_STbri_cPt :
1987 Hexagon::POST_STbri_cNotPt;
1988 case Hexagon::STrib:
1989 return !invertPredicate ? Hexagon::STrib_cPt :
1990 Hexagon::STrib_cNotPt;
1991 case Hexagon::STrib_indexed:
1992 return !invertPredicate ? Hexagon::STrib_indexed_cPt :
1993 Hexagon::STrib_indexed_cNotPt;
1994 case Hexagon::STrib_imm_V4:
1995 return !invertPredicate ? Hexagon::STrib_imm_cPt_V4 :
1996 Hexagon::STrib_imm_cNotPt_V4;
1997 case Hexagon::STrib_indexed_shl_V4:
1998 return !invertPredicate ? Hexagon::STrib_indexed_shl_cPt_V4 :
1999 Hexagon::STrib_indexed_shl_cNotPt_V4;
2000 // Halfword.
2001 case Hexagon::POST_SThri:
2002 return !invertPredicate ? Hexagon::POST_SThri_cPt :
2003 Hexagon::POST_SThri_cNotPt;
2004 case Hexagon::STrih:
2005 return !invertPredicate ? Hexagon::STrih_cPt :
2006 Hexagon::STrih_cNotPt;
2007 case Hexagon::STrih_indexed:
2008 return !invertPredicate ? Hexagon::STrih_indexed_cPt :
2009 Hexagon::STrih_indexed_cNotPt;
2010 case Hexagon::STrih_imm_V4:
2011 return !invertPredicate ? Hexagon::STrih_imm_cPt_V4 :
2012 Hexagon::STrih_imm_cNotPt_V4;
2013 case Hexagon::STrih_indexed_shl_V4:
2014 return !invertPredicate ? Hexagon::STrih_indexed_shl_cPt_V4 :
2015 Hexagon::STrih_indexed_shl_cNotPt_V4;
2016 // Word.
2017 case Hexagon::POST_STwri:
2018 return !invertPredicate ? Hexagon::POST_STwri_cPt :
2019 Hexagon::POST_STwri_cNotPt;
2020 case Hexagon::STriw:
2021 return !invertPredicate ? Hexagon::STriw_cPt :
2022 Hexagon::STriw_cNotPt;
2023 case Hexagon::STriw_indexed:
2024 return !invertPredicate ? Hexagon::STriw_indexed_cPt :
2025 Hexagon::STriw_indexed_cNotPt;
2026 case Hexagon::STriw_indexed_shl_V4:
2027 return !invertPredicate ? Hexagon::STriw_indexed_shl_cPt_V4 :
2028 Hexagon::STriw_indexed_shl_cNotPt_V4;
2029 case Hexagon::STriw_imm_V4:
2030 return !invertPredicate ? Hexagon::STriw_imm_cPt_V4 :
2031 Hexagon::STriw_imm_cNotPt_V4;
2032 // Double word.
2033 case Hexagon::POST_STdri:
2034 return !invertPredicate ? Hexagon::POST_STdri_cPt :
2035 Hexagon::POST_STdri_cNotPt;
2036 case Hexagon::STrid:
2037 return !invertPredicate ? Hexagon::STrid_cPt :
2038 Hexagon::STrid_cNotPt;
2039 case Hexagon::STrid_indexed:
2040 return !invertPredicate ? Hexagon::STrid_indexed_cPt :
2041 Hexagon::STrid_indexed_cNotPt;
2042 case Hexagon::STrid_indexed_shl_V4:
2043 return !invertPredicate ? Hexagon::STrid_indexed_shl_cPt_V4 :
2044 Hexagon::STrid_indexed_shl_cNotPt_V4;
Sirish Pande26f61a12012-05-03 21:52:53 +00002045
2046 // V4 Store to global address
Sirish Pande26f61a12012-05-03 21:52:53 +00002047 case Hexagon::STd_GP_V4:
2048 return !invertPredicate ? Hexagon::STd_GP_cPt_V4 :
2049 Hexagon::STd_GP_cNotPt_V4;
2050 case Hexagon::STb_GP_V4:
2051 return !invertPredicate ? Hexagon::STb_GP_cPt_V4 :
2052 Hexagon::STb_GP_cNotPt_V4;
2053 case Hexagon::STh_GP_V4:
2054 return !invertPredicate ? Hexagon::STh_GP_cPt_V4 :
2055 Hexagon::STh_GP_cNotPt_V4;
2056 case Hexagon::STw_GP_V4:
2057 return !invertPredicate ? Hexagon::STw_GP_cPt_V4 :
2058 Hexagon::STw_GP_cNotPt_V4;
2059
Tony Linthicumb4b54152011-12-12 21:14:40 +00002060 // Load.
2061 case Hexagon::LDrid:
2062 return !invertPredicate ? Hexagon::LDrid_cPt :
2063 Hexagon::LDrid_cNotPt;
2064 case Hexagon::LDriw:
2065 return !invertPredicate ? Hexagon::LDriw_cPt :
2066 Hexagon::LDriw_cNotPt;
2067 case Hexagon::LDrih:
2068 return !invertPredicate ? Hexagon::LDrih_cPt :
2069 Hexagon::LDrih_cNotPt;
2070 case Hexagon::LDriuh:
2071 return !invertPredicate ? Hexagon::LDriuh_cPt :
2072 Hexagon::LDriuh_cNotPt;
2073 case Hexagon::LDrib:
2074 return !invertPredicate ? Hexagon::LDrib_cPt :
2075 Hexagon::LDrib_cNotPt;
2076 case Hexagon::LDriub:
2077 return !invertPredicate ? Hexagon::LDriub_cPt :
2078 Hexagon::LDriub_cNotPt;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002079 // Load Indexed.
2080 case Hexagon::LDrid_indexed:
2081 return !invertPredicate ? Hexagon::LDrid_indexed_cPt :
2082 Hexagon::LDrid_indexed_cNotPt;
2083 case Hexagon::LDriw_indexed:
2084 return !invertPredicate ? Hexagon::LDriw_indexed_cPt :
2085 Hexagon::LDriw_indexed_cNotPt;
2086 case Hexagon::LDrih_indexed:
2087 return !invertPredicate ? Hexagon::LDrih_indexed_cPt :
2088 Hexagon::LDrih_indexed_cNotPt;
2089 case Hexagon::LDriuh_indexed:
2090 return !invertPredicate ? Hexagon::LDriuh_indexed_cPt :
2091 Hexagon::LDriuh_indexed_cNotPt;
2092 case Hexagon::LDrib_indexed:
2093 return !invertPredicate ? Hexagon::LDrib_indexed_cPt :
2094 Hexagon::LDrib_indexed_cNotPt;
2095 case Hexagon::LDriub_indexed:
2096 return !invertPredicate ? Hexagon::LDriub_indexed_cPt :
2097 Hexagon::LDriub_indexed_cNotPt;
2098 // Post Increment Load.
2099 case Hexagon::POST_LDrid:
2100 return !invertPredicate ? Hexagon::POST_LDrid_cPt :
2101 Hexagon::POST_LDrid_cNotPt;
2102 case Hexagon::POST_LDriw:
2103 return !invertPredicate ? Hexagon::POST_LDriw_cPt :
2104 Hexagon::POST_LDriw_cNotPt;
2105 case Hexagon::POST_LDrih:
2106 return !invertPredicate ? Hexagon::POST_LDrih_cPt :
2107 Hexagon::POST_LDrih_cNotPt;
2108 case Hexagon::POST_LDriuh:
2109 return !invertPredicate ? Hexagon::POST_LDriuh_cPt :
2110 Hexagon::POST_LDriuh_cNotPt;
2111 case Hexagon::POST_LDrib:
2112 return !invertPredicate ? Hexagon::POST_LDrib_cPt :
2113 Hexagon::POST_LDrib_cNotPt;
2114 case Hexagon::POST_LDriub:
2115 return !invertPredicate ? Hexagon::POST_LDriub_cPt :
2116 Hexagon::POST_LDriub_cNotPt;
2117 // DEALLOC_RETURN.
2118 case Hexagon::DEALLOC_RET_V4:
2119 return !invertPredicate ? Hexagon::DEALLOC_RET_cPt_V4 :
2120 Hexagon::DEALLOC_RET_cNotPt_V4;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002121 }
Benjamin Kramer27baab62011-12-27 11:41:05 +00002122 llvm_unreachable("Unexpected predicable instruction");
Tony Linthicumb4b54152011-12-12 21:14:40 +00002123}
2124
2125
2126bool HexagonInstrInfo::
2127PredicateInstruction(MachineInstr *MI,
2128 const SmallVectorImpl<MachineOperand> &Cond) const {
2129 int Opc = MI->getOpcode();
2130 assert (isPredicable(MI) && "Expected predicable instruction");
2131 bool invertJump = (!Cond.empty() && Cond[0].isImm() &&
2132 (Cond[0].getImm() == 0));
Tony Linthicumb4b54152011-12-12 21:14:40 +00002133
Jyotsna Verma6b8d2022013-02-12 16:06:23 +00002134 // This will change MI's opcode to its predicate version.
2135 // However, its operand list is still the old one, i.e. the
2136 // non-predicate one.
2137 MI->setDesc(get(getMatchingCondBranchOpcode(Opc, invertJump)));
2138
2139 int oper = -1;
2140 unsigned int GAIdx = 0;
2141
2142 // Indicates whether the current MI has a GlobalAddress operand
2143 bool hasGAOpnd = false;
2144 std::vector<MachineOperand> tmpOpnds;
2145
2146 // Indicates whether we need to shift operands to right.
2147 bool needShift = true;
2148
2149 // The predicate is ALWAYS the FIRST input operand !!!
2150 if (MI->getNumOperands() == 0) {
2151 // The non-predicate version of MI does not take any operands,
2152 // i.e. no outs and no ins. In this condition, the predicate
2153 // operand will be directly placed at Operands[0]. No operand
2154 // shift is needed.
2155 // Example: BARRIER
2156 needShift = false;
2157 oper = -1;
2158 }
2159 else if ( MI->getOperand(MI->getNumOperands()-1).isReg()
2160 && MI->getOperand(MI->getNumOperands()-1).isDef()
2161 && !MI->getOperand(MI->getNumOperands()-1).isImplicit()) {
2162 // The non-predicate version of MI does not have any input operands.
2163 // In this condition, we extend the length of Operands[] by one and
2164 // copy the original last operand to the newly allocated slot.
2165 // At this moment, it is just a place holder. Later, we will put
2166 // predicate operand directly into it. No operand shift is needed.
2167 // Example: r0=BARRIER (this is a faked insn used here for illustration)
2168 MI->addOperand(MI->getOperand(MI->getNumOperands()-1));
2169 needShift = false;
2170 oper = MI->getNumOperands() - 2;
2171 }
2172 else {
2173 // We need to right shift all input operands by one. Duplicate the
2174 // last operand into the newly allocated slot.
2175 MI->addOperand(MI->getOperand(MI->getNumOperands()-1));
2176 }
2177
2178 if (needShift)
2179 {
2180 // Operands[ MI->getNumOperands() - 2 ] has been copied into
2181 // Operands[ MI->getNumOperands() - 1 ], so we start from
2182 // Operands[ MI->getNumOperands() - 3 ].
2183 // oper is a signed int.
2184 // It is ok if "MI->getNumOperands()-3" is -3, -2, or -1.
2185 for (oper = MI->getNumOperands() - 3; oper >= 0; --oper)
2186 {
2187 MachineOperand &MO = MI->getOperand(oper);
2188
2189 // Opnd[0] Opnd[1] Opnd[2] Opnd[3] Opnd[4] Opnd[5] Opnd[6] Opnd[7]
2190 // <Def0> <Def1> <Use0> <Use1> <ImpDef0> <ImpDef1> <ImpUse0> <ImpUse1>
2191 // /\~
2192 // /||\~
2193 // ||
2194 // Predicate Operand here
2195 if (MO.isReg() && !MO.isUse() && !MO.isImplicit()) {
2196 break;
2197 }
2198 if (MO.isReg()) {
2199 MI->getOperand(oper+1).ChangeToRegister(MO.getReg(), MO.isDef(),
2200 MO.isImplicit(), MO.isKill(),
2201 MO.isDead(), MO.isUndef(),
2202 MO.isDebug());
2203 }
2204 else if (MO.isImm()) {
2205 MI->getOperand(oper+1).ChangeToImmediate(MO.getImm());
2206 }
2207 else if (MO.isGlobal()) {
2208 // MI can not have more than one GlobalAddress operand.
2209 assert(hasGAOpnd == false && "MI can only have one GlobalAddress opnd");
2210
2211 // There is no member function called "ChangeToGlobalAddress" in the
2212 // MachineOperand class (not like "ChangeToRegister" and
2213 // "ChangeToImmediate"). So we have to remove them from Operands[] list
2214 // first, and then add them back after we have inserted the predicate
2215 // operand. tmpOpnds[] is to remember these operands before we remove
2216 // them.
2217 tmpOpnds.push_back(MO);
2218
2219 // Operands[oper] is a GlobalAddress operand;
2220 // Operands[oper+1] has been copied into Operands[oper+2];
2221 hasGAOpnd = true;
2222 GAIdx = oper;
2223 continue;
2224 }
2225 else {
2226 assert(false && "Unexpected operand type");
2227 }
Tony Linthicumb4b54152011-12-12 21:14:40 +00002228 }
2229 }
2230
2231 int regPos = invertJump ? 1 : 0;
2232 MachineOperand PredMO = Cond[regPos];
Jyotsna Verma6b8d2022013-02-12 16:06:23 +00002233
2234 // [oper] now points to the last explicit Def. Predicate operand must be
2235 // located at [oper+1]. See diagram above.
2236 // This assumes that the predicate is always the first operand,
2237 // i.e. Operands[0+numResults], in the set of inputs
2238 // It is better to have an assert here to check this. But I don't know how
2239 // to write this assert because findFirstPredOperandIdx() would return -1
2240 if (oper < -1) oper = -1;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002241 MI->getOperand(oper+1).ChangeToRegister(PredMO.getReg(), PredMO.isDef(),
2242 PredMO.isImplicit(), PredMO.isKill(),
2243 PredMO.isDead(), PredMO.isUndef(),
2244 PredMO.isDebug());
2245
Jyotsna Verma6b8d2022013-02-12 16:06:23 +00002246 if (hasGAOpnd)
2247 {
2248 unsigned int i;
2249
2250 // Operands[GAIdx] is the original GlobalAddress operand, which is
2251 // already copied into tmpOpnds[0].
2252 // Operands[GAIdx] now stores a copy of Operands[GAIdx-1]
2253 // Operands[GAIdx+1] has already been copied into Operands[GAIdx+2],
2254 // so we start from [GAIdx+2]
2255 for (i = GAIdx + 2; i < MI->getNumOperands(); ++i)
2256 tmpOpnds.push_back(MI->getOperand(i));
2257
2258 // Remove all operands in range [ (GAIdx+1) ... (MI->getNumOperands()-1) ]
2259 // It is very important that we always remove from the end of Operands[]
2260 // MI->getNumOperands() is at least 2 if program goes to here.
2261 for (i = MI->getNumOperands() - 1; i > GAIdx; --i)
2262 MI->RemoveOperand(i);
2263
2264 for (i = 0; i < tmpOpnds.size(); ++i)
2265 MI->addOperand(tmpOpnds[i]);
2266 }
2267
Tony Linthicumb4b54152011-12-12 21:14:40 +00002268 return true;
2269}
2270
2271
2272bool
2273HexagonInstrInfo::
2274isProfitableToIfCvt(MachineBasicBlock &MBB,
Kay Tiong Khoo575e90e2012-06-13 15:53:04 +00002275 unsigned NumCycles,
Tony Linthicumb4b54152011-12-12 21:14:40 +00002276 unsigned ExtraPredCycles,
2277 const BranchProbability &Probability) const {
2278 return true;
2279}
2280
2281
2282bool
2283HexagonInstrInfo::
2284isProfitableToIfCvt(MachineBasicBlock &TMBB,
2285 unsigned NumTCycles,
2286 unsigned ExtraTCycles,
2287 MachineBasicBlock &FMBB,
2288 unsigned NumFCycles,
2289 unsigned ExtraFCycles,
2290 const BranchProbability &Probability) const {
2291 return true;
2292}
2293
2294
2295bool HexagonInstrInfo::isPredicated(const MachineInstr *MI) const {
Brendon Cahoonc635ebd2012-02-08 18:25:47 +00002296 const uint64_t F = MI->getDesc().TSFlags;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002297
Brendon Cahoonc635ebd2012-02-08 18:25:47 +00002298 return ((F >> HexagonII::PredicatedPos) & HexagonII::PredicatedMask);
Tony Linthicumb4b54152011-12-12 21:14:40 +00002299}
2300
Tony Linthicumb4b54152011-12-12 21:14:40 +00002301bool
2302HexagonInstrInfo::DefinesPredicate(MachineInstr *MI,
2303 std::vector<MachineOperand> &Pred) const {
2304 for (unsigned oper = 0; oper < MI->getNumOperands(); ++oper) {
2305 MachineOperand MO = MI->getOperand(oper);
2306 if (MO.isReg() && MO.isDef()) {
2307 const TargetRegisterClass* RC = RI.getMinimalPhysRegClass(MO.getReg());
Craig Topper420761a2012-04-20 07:30:17 +00002308 if (RC == &Hexagon::PredRegsRegClass) {
Tony Linthicumb4b54152011-12-12 21:14:40 +00002309 Pred.push_back(MO);
2310 return true;
2311 }
2312 }
2313 }
2314 return false;
2315}
2316
2317
2318bool
2319HexagonInstrInfo::
2320SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
2321 const SmallVectorImpl<MachineOperand> &Pred2) const {
2322 // TODO: Fix this
2323 return false;
2324}
2325
2326
2327//
2328// We indicate that we want to reverse the branch by
2329// inserting a 0 at the beginning of the Cond vector.
2330//
2331bool HexagonInstrInfo::
2332ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
2333 if (!Cond.empty() && Cond[0].isImm() && Cond[0].getImm() == 0) {
2334 Cond.erase(Cond.begin());
2335 } else {
2336 Cond.insert(Cond.begin(), MachineOperand::CreateImm(0));
2337 }
2338 return false;
2339}
2340
2341
2342bool HexagonInstrInfo::
2343isProfitableToDupForIfCvt(MachineBasicBlock &MBB,unsigned NumInstrs,
2344 const BranchProbability &Probability) const {
2345 return (NumInstrs <= 4);
2346}
2347
2348bool HexagonInstrInfo::isDeallocRet(const MachineInstr *MI) const {
2349 switch (MI->getOpcode()) {
Sirish Pande26f61a12012-05-03 21:52:53 +00002350 default: return false;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002351 case Hexagon::DEALLOC_RET_V4 :
2352 case Hexagon::DEALLOC_RET_cPt_V4 :
2353 case Hexagon::DEALLOC_RET_cNotPt_V4 :
2354 case Hexagon::DEALLOC_RET_cdnPnt_V4 :
2355 case Hexagon::DEALLOC_RET_cNotdnPnt_V4 :
2356 case Hexagon::DEALLOC_RET_cdnPt_V4 :
2357 case Hexagon::DEALLOC_RET_cNotdnPt_V4 :
2358 return true;
2359 }
Tony Linthicumb4b54152011-12-12 21:14:40 +00002360}
2361
2362
2363bool HexagonInstrInfo::
2364isValidOffset(const int Opcode, const int Offset) const {
2365 // This function is to check whether the "Offset" is in the correct range of
2366 // the given "Opcode". If "Offset" is not in the correct range, "ADD_ri" is
2367 // inserted to calculate the final address. Due to this reason, the function
2368 // assumes that the "Offset" has correct alignment.
2369
2370 switch(Opcode) {
2371
2372 case Hexagon::LDriw:
Jyotsna Vermaa454ffd2013-01-17 18:42:37 +00002373 case Hexagon::LDriw_indexed:
Sirish Pande7517bbc2012-05-10 20:20:25 +00002374 case Hexagon::LDriw_f:
Jyotsna Vermaa454ffd2013-01-17 18:42:37 +00002375 case Hexagon::STriw_indexed:
Tony Linthicumb4b54152011-12-12 21:14:40 +00002376 case Hexagon::STriw:
Sirish Pande7517bbc2012-05-10 20:20:25 +00002377 case Hexagon::STriw_f:
Tony Linthicumb4b54152011-12-12 21:14:40 +00002378 assert((Offset % 4 == 0) && "Offset has incorrect alignment");
2379 return (Offset >= Hexagon_MEMW_OFFSET_MIN) &&
2380 (Offset <= Hexagon_MEMW_OFFSET_MAX);
2381
2382 case Hexagon::LDrid:
Jyotsna Vermaa454ffd2013-01-17 18:42:37 +00002383 case Hexagon::LDrid_indexed:
Sirish Pande7517bbc2012-05-10 20:20:25 +00002384 case Hexagon::LDrid_f:
Tony Linthicumb4b54152011-12-12 21:14:40 +00002385 case Hexagon::STrid:
Jyotsna Vermaa454ffd2013-01-17 18:42:37 +00002386 case Hexagon::STrid_indexed:
Sirish Pande7517bbc2012-05-10 20:20:25 +00002387 case Hexagon::STrid_f:
Tony Linthicumb4b54152011-12-12 21:14:40 +00002388 assert((Offset % 8 == 0) && "Offset has incorrect alignment");
2389 return (Offset >= Hexagon_MEMD_OFFSET_MIN) &&
2390 (Offset <= Hexagon_MEMD_OFFSET_MAX);
2391
2392 case Hexagon::LDrih:
2393 case Hexagon::LDriuh:
2394 case Hexagon::STrih:
Tony Linthicumb4b54152011-12-12 21:14:40 +00002395 assert((Offset % 2 == 0) && "Offset has incorrect alignment");
2396 return (Offset >= Hexagon_MEMH_OFFSET_MIN) &&
2397 (Offset <= Hexagon_MEMH_OFFSET_MAX);
2398
2399 case Hexagon::LDrib:
2400 case Hexagon::STrib:
2401 case Hexagon::LDriub:
Tony Linthicumb4b54152011-12-12 21:14:40 +00002402 return (Offset >= Hexagon_MEMB_OFFSET_MIN) &&
2403 (Offset <= Hexagon_MEMB_OFFSET_MAX);
2404
2405 case Hexagon::ADD_ri:
2406 case Hexagon::TFR_FI:
2407 return (Offset >= Hexagon_ADDI_OFFSET_MIN) &&
2408 (Offset <= Hexagon_ADDI_OFFSET_MAX);
2409
Tony Linthicumb4b54152011-12-12 21:14:40 +00002410 case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
2411 case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
2412 case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
2413 case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
2414 case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
2415 case Hexagon::MEMw_ORr_indexed_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002416 case Hexagon::MEMw_ADDi_MEM_V4 :
2417 case Hexagon::MEMw_SUBi_MEM_V4 :
2418 case Hexagon::MEMw_ADDr_MEM_V4 :
2419 case Hexagon::MEMw_SUBr_MEM_V4 :
2420 case Hexagon::MEMw_ANDr_MEM_V4 :
2421 case Hexagon::MEMw_ORr_MEM_V4 :
2422 assert ((Offset % 4) == 0 && "MEMOPw offset is not aligned correctly." );
2423 return (0 <= Offset && Offset <= 255);
2424
Tony Linthicumb4b54152011-12-12 21:14:40 +00002425 case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
2426 case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
2427 case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
2428 case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
2429 case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
2430 case Hexagon::MEMh_ORr_indexed_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002431 case Hexagon::MEMh_ADDi_MEM_V4 :
2432 case Hexagon::MEMh_SUBi_MEM_V4 :
2433 case Hexagon::MEMh_ADDr_MEM_V4 :
2434 case Hexagon::MEMh_SUBr_MEM_V4 :
2435 case Hexagon::MEMh_ANDr_MEM_V4 :
2436 case Hexagon::MEMh_ORr_MEM_V4 :
2437 assert ((Offset % 2) == 0 && "MEMOPh offset is not aligned correctly." );
2438 return (0 <= Offset && Offset <= 127);
2439
Tony Linthicumb4b54152011-12-12 21:14:40 +00002440 case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
2441 case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
2442 case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
2443 case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
2444 case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
2445 case Hexagon::MEMb_ORr_indexed_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002446 case Hexagon::MEMb_ADDi_MEM_V4 :
2447 case Hexagon::MEMb_SUBi_MEM_V4 :
2448 case Hexagon::MEMb_ADDr_MEM_V4 :
2449 case Hexagon::MEMb_SUBr_MEM_V4 :
2450 case Hexagon::MEMb_ANDr_MEM_V4 :
2451 case Hexagon::MEMb_ORr_MEM_V4 :
2452 return (0 <= Offset && Offset <= 63);
2453
2454 // LDri_pred and STriw_pred are pseudo operations, so it has to take offset of
2455 // any size. Later pass knows how to handle it.
2456 case Hexagon::STriw_pred:
2457 case Hexagon::LDriw_pred:
2458 return true;
2459
Krzysztof Parzyszek71490fa2013-02-11 21:37:55 +00002460 case Hexagon::LOOP0_i:
2461 return isUInt<10>(Offset);
2462
Tony Linthicumb4b54152011-12-12 21:14:40 +00002463 // INLINEASM is very special.
2464 case Hexagon::INLINEASM:
2465 return true;
2466 }
2467
Benjamin Kramer27baab62011-12-27 11:41:05 +00002468 llvm_unreachable("No offset range is defined for this opcode. "
2469 "Please define it in the above switch statement!");
Tony Linthicumb4b54152011-12-12 21:14:40 +00002470}
2471
2472
2473//
2474// Check if the Offset is a valid auto-inc imm by Load/Store Type.
2475//
2476bool HexagonInstrInfo::
2477isValidAutoIncImm(const EVT VT, const int Offset) const {
2478
2479 if (VT == MVT::i64) {
2480 return (Offset >= Hexagon_MEMD_AUTOINC_MIN &&
2481 Offset <= Hexagon_MEMD_AUTOINC_MAX &&
2482 (Offset & 0x7) == 0);
2483 }
2484 if (VT == MVT::i32) {
2485 return (Offset >= Hexagon_MEMW_AUTOINC_MIN &&
2486 Offset <= Hexagon_MEMW_AUTOINC_MAX &&
2487 (Offset & 0x3) == 0);
2488 }
2489 if (VT == MVT::i16) {
2490 return (Offset >= Hexagon_MEMH_AUTOINC_MIN &&
2491 Offset <= Hexagon_MEMH_AUTOINC_MAX &&
2492 (Offset & 0x1) == 0);
2493 }
2494 if (VT == MVT::i8) {
2495 return (Offset >= Hexagon_MEMB_AUTOINC_MIN &&
2496 Offset <= Hexagon_MEMB_AUTOINC_MAX);
2497 }
Craig Topperbc219812012-02-07 02:50:20 +00002498 llvm_unreachable("Not an auto-inc opc!");
Tony Linthicumb4b54152011-12-12 21:14:40 +00002499}
2500
2501
2502bool HexagonInstrInfo::
2503isMemOp(const MachineInstr *MI) const {
2504 switch (MI->getOpcode())
2505 {
Sirish Pande26f61a12012-05-03 21:52:53 +00002506 default: return false;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002507 case Hexagon::MEMw_ADDi_indexed_MEM_V4 :
2508 case Hexagon::MEMw_SUBi_indexed_MEM_V4 :
2509 case Hexagon::MEMw_ADDr_indexed_MEM_V4 :
2510 case Hexagon::MEMw_SUBr_indexed_MEM_V4 :
2511 case Hexagon::MEMw_ANDr_indexed_MEM_V4 :
2512 case Hexagon::MEMw_ORr_indexed_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002513 case Hexagon::MEMw_ADDi_MEM_V4 :
2514 case Hexagon::MEMw_SUBi_MEM_V4 :
2515 case Hexagon::MEMw_ADDr_MEM_V4 :
2516 case Hexagon::MEMw_SUBr_MEM_V4 :
2517 case Hexagon::MEMw_ANDr_MEM_V4 :
2518 case Hexagon::MEMw_ORr_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002519 case Hexagon::MEMh_ADDi_indexed_MEM_V4 :
2520 case Hexagon::MEMh_SUBi_indexed_MEM_V4 :
2521 case Hexagon::MEMh_ADDr_indexed_MEM_V4 :
2522 case Hexagon::MEMh_SUBr_indexed_MEM_V4 :
2523 case Hexagon::MEMh_ANDr_indexed_MEM_V4 :
2524 case Hexagon::MEMh_ORr_indexed_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002525 case Hexagon::MEMh_ADDi_MEM_V4 :
2526 case Hexagon::MEMh_SUBi_MEM_V4 :
2527 case Hexagon::MEMh_ADDr_MEM_V4 :
2528 case Hexagon::MEMh_SUBr_MEM_V4 :
2529 case Hexagon::MEMh_ANDr_MEM_V4 :
2530 case Hexagon::MEMh_ORr_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002531 case Hexagon::MEMb_ADDi_indexed_MEM_V4 :
2532 case Hexagon::MEMb_SUBi_indexed_MEM_V4 :
2533 case Hexagon::MEMb_ADDr_indexed_MEM_V4 :
2534 case Hexagon::MEMb_SUBr_indexed_MEM_V4 :
2535 case Hexagon::MEMb_ANDr_indexed_MEM_V4 :
2536 case Hexagon::MEMb_ORr_indexed_MEM_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002537 case Hexagon::MEMb_ADDi_MEM_V4 :
2538 case Hexagon::MEMb_SUBi_MEM_V4 :
2539 case Hexagon::MEMb_ADDr_MEM_V4 :
2540 case Hexagon::MEMb_SUBr_MEM_V4 :
2541 case Hexagon::MEMb_ANDr_MEM_V4 :
2542 case Hexagon::MEMb_ORr_MEM_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +00002543 return true;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002544 }
Tony Linthicumb4b54152011-12-12 21:14:40 +00002545}
2546
2547
2548bool HexagonInstrInfo::
2549isSpillPredRegOp(const MachineInstr *MI) const {
Sirish Pande26f61a12012-05-03 21:52:53 +00002550 switch (MI->getOpcode()) {
2551 default: return false;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002552 case Hexagon::STriw_pred :
2553 case Hexagon::LDriw_pred :
Sirish Pande26f61a12012-05-03 21:52:53 +00002554 return true;
Sirish Pande1bfd2482012-04-23 17:49:28 +00002555 }
Sirish Pandeb3385702012-05-12 05:10:30 +00002556}
2557
2558bool HexagonInstrInfo::isNewValueJumpCandidate(const MachineInstr *MI) const {
2559 switch (MI->getOpcode()) {
Sirish Pande2b38c122012-05-12 05:54:15 +00002560 default: return false;
Sirish Pandeb3385702012-05-12 05:10:30 +00002561 case Hexagon::CMPEQrr:
2562 case Hexagon::CMPEQri:
2563 case Hexagon::CMPLTrr:
2564 case Hexagon::CMPGTrr:
2565 case Hexagon::CMPGTri:
2566 case Hexagon::CMPLTUrr:
2567 case Hexagon::CMPGTUrr:
2568 case Hexagon::CMPGTUri:
2569 case Hexagon::CMPGEri:
2570 case Hexagon::CMPGEUri:
2571 return true;
Sirish Pandeb3385702012-05-12 05:10:30 +00002572 }
Sirish Pande1bfd2482012-04-23 17:49:28 +00002573}
2574
Sirish Pande26f61a12012-05-03 21:52:53 +00002575bool HexagonInstrInfo::
2576isConditionalTransfer (const MachineInstr *MI) const {
2577 switch (MI->getOpcode()) {
2578 default: return false;
2579 case Hexagon::TFR_cPt:
2580 case Hexagon::TFR_cNotPt:
2581 case Hexagon::TFRI_cPt:
2582 case Hexagon::TFRI_cNotPt:
2583 case Hexagon::TFR_cdnPt:
2584 case Hexagon::TFR_cdnNotPt:
2585 case Hexagon::TFRI_cdnPt:
2586 case Hexagon::TFRI_cdnNotPt:
2587 return true;
2588 }
2589}
Tony Linthicumb4b54152011-12-12 21:14:40 +00002590
2591bool HexagonInstrInfo::isConditionalALU32 (const MachineInstr* MI) const {
2592 const HexagonRegisterInfo& QRI = getRegisterInfo();
2593 switch (MI->getOpcode())
2594 {
Sirish Pande26f61a12012-05-03 21:52:53 +00002595 default: return false;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002596 case Hexagon::ADD_ri_cPt:
2597 case Hexagon::ADD_ri_cNotPt:
2598 case Hexagon::ADD_rr_cPt:
2599 case Hexagon::ADD_rr_cNotPt:
2600 case Hexagon::XOR_rr_cPt:
2601 case Hexagon::XOR_rr_cNotPt:
2602 case Hexagon::AND_rr_cPt:
2603 case Hexagon::AND_rr_cNotPt:
2604 case Hexagon::OR_rr_cPt:
2605 case Hexagon::OR_rr_cNotPt:
2606 case Hexagon::SUB_rr_cPt:
2607 case Hexagon::SUB_rr_cNotPt:
2608 case Hexagon::COMBINE_rr_cPt:
2609 case Hexagon::COMBINE_rr_cNotPt:
2610 return true;
2611 case Hexagon::ASLH_cPt_V4:
2612 case Hexagon::ASLH_cNotPt_V4:
2613 case Hexagon::ASRH_cPt_V4:
2614 case Hexagon::ASRH_cNotPt_V4:
2615 case Hexagon::SXTB_cPt_V4:
2616 case Hexagon::SXTB_cNotPt_V4:
2617 case Hexagon::SXTH_cPt_V4:
2618 case Hexagon::SXTH_cNotPt_V4:
2619 case Hexagon::ZXTB_cPt_V4:
2620 case Hexagon::ZXTB_cNotPt_V4:
2621 case Hexagon::ZXTH_cPt_V4:
2622 case Hexagon::ZXTH_cNotPt_V4:
Sirish Pande26f61a12012-05-03 21:52:53 +00002623 return QRI.Subtarget.hasV4TOps();
Tony Linthicumb4b54152011-12-12 21:14:40 +00002624 }
Tony Linthicumb4b54152011-12-12 21:14:40 +00002625}
2626
Tony Linthicumb4b54152011-12-12 21:14:40 +00002627bool HexagonInstrInfo::
2628isConditionalLoad (const MachineInstr* MI) const {
2629 const HexagonRegisterInfo& QRI = getRegisterInfo();
2630 switch (MI->getOpcode())
2631 {
Sirish Pande26f61a12012-05-03 21:52:53 +00002632 default: return false;
Tony Linthicumb4b54152011-12-12 21:14:40 +00002633 case Hexagon::LDrid_cPt :
2634 case Hexagon::LDrid_cNotPt :
2635 case Hexagon::LDrid_indexed_cPt :
2636 case Hexagon::LDrid_indexed_cNotPt :
2637 case Hexagon::LDriw_cPt :
2638 case Hexagon::LDriw_cNotPt :
2639 case Hexagon::LDriw_indexed_cPt :
2640 case Hexagon::LDriw_indexed_cNotPt :
2641 case Hexagon::LDrih_cPt :
2642 case Hexagon::LDrih_cNotPt :
2643 case Hexagon::LDrih_indexed_cPt :
2644 case Hexagon::LDrih_indexed_cNotPt :
2645 case Hexagon::LDrib_cPt :
2646 case Hexagon::LDrib_cNotPt :
2647 case Hexagon::LDrib_indexed_cPt :
2648 case Hexagon::LDrib_indexed_cNotPt :
2649 case Hexagon::LDriuh_cPt :
2650 case Hexagon::LDriuh_cNotPt :
2651 case Hexagon::LDriuh_indexed_cPt :
2652 case Hexagon::LDriuh_indexed_cNotPt :
2653 case Hexagon::LDriub_cPt :
2654 case Hexagon::LDriub_cNotPt :
2655 case Hexagon::LDriub_indexed_cPt :
2656 case Hexagon::LDriub_indexed_cNotPt :
2657 return true;
2658 case Hexagon::POST_LDrid_cPt :
2659 case Hexagon::POST_LDrid_cNotPt :
2660 case Hexagon::POST_LDriw_cPt :
2661 case Hexagon::POST_LDriw_cNotPt :
2662 case Hexagon::POST_LDrih_cPt :
2663 case Hexagon::POST_LDrih_cNotPt :
2664 case Hexagon::POST_LDrib_cPt :
2665 case Hexagon::POST_LDrib_cNotPt :
2666 case Hexagon::POST_LDriuh_cPt :
2667 case Hexagon::POST_LDriuh_cNotPt :
2668 case Hexagon::POST_LDriub_cPt :
2669 case Hexagon::POST_LDriub_cNotPt :
Sirish Pande26f61a12012-05-03 21:52:53 +00002670 return QRI.Subtarget.hasV4TOps();
Tony Linthicumb4b54152011-12-12 21:14:40 +00002671 case Hexagon::LDrid_indexed_shl_cPt_V4 :
2672 case Hexagon::LDrid_indexed_shl_cNotPt_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002673 case Hexagon::LDrib_indexed_shl_cPt_V4 :
2674 case Hexagon::LDrib_indexed_shl_cNotPt_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002675 case Hexagon::LDriub_indexed_shl_cPt_V4 :
2676 case Hexagon::LDriub_indexed_shl_cNotPt_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002677 case Hexagon::LDrih_indexed_shl_cPt_V4 :
2678 case Hexagon::LDrih_indexed_shl_cNotPt_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002679 case Hexagon::LDriuh_indexed_shl_cPt_V4 :
2680 case Hexagon::LDriuh_indexed_shl_cNotPt_V4 :
Tony Linthicumb4b54152011-12-12 21:14:40 +00002681 case Hexagon::LDriw_indexed_shl_cPt_V4 :
2682 case Hexagon::LDriw_indexed_shl_cNotPt_V4 :
Sirish Pande26f61a12012-05-03 21:52:53 +00002683 return QRI.Subtarget.hasV4TOps();
Tony Linthicumb4b54152011-12-12 21:14:40 +00002684 }
Tony Linthicumb4b54152011-12-12 21:14:40 +00002685}
Andrew Trickee498d32012-02-01 22:13:57 +00002686
Sirish Pande26f61a12012-05-03 21:52:53 +00002687// Returns true if an instruction is a conditional store.
2688//
2689// Note: It doesn't include conditional new-value stores as they can't be
2690// converted to .new predicate.
2691//
2692// p.new NV store [ if(p0.new)memw(R0+#0)=R2.new ]
2693// ^ ^
2694// / \ (not OK. it will cause new-value store to be
2695// / X conditional on p0.new while R2 producer is
2696// / \ on p0)
2697// / \.
2698// p.new store p.old NV store
2699// [if(p0.new)memw(R0+#0)=R2] [if(p0)memw(R0+#0)=R2.new]
2700// ^ ^
2701// \ /
2702// \ /
2703// \ /
2704// p.old store
2705// [if (p0)memw(R0+#0)=R2]
2706//
2707// The above diagram shows the steps involoved in the conversion of a predicated
2708// store instruction to its .new predicated new-value form.
2709//
2710// The following set of instructions further explains the scenario where
2711// conditional new-value store becomes invalid when promoted to .new predicate
2712// form.
2713//
2714// { 1) if (p0) r0 = add(r1, r2)
2715// 2) p0 = cmp.eq(r3, #0) }
2716//
2717// 3) if (p0) memb(r1+#0) = r0 --> this instruction can't be grouped with
2718// the first two instructions because in instr 1, r0 is conditional on old value
2719// of p0 but its use in instr 3 is conditional on p0 modified by instr 2 which
2720// is not valid for new-value stores.
2721bool HexagonInstrInfo::
2722isConditionalStore (const MachineInstr* MI) const {
2723 const HexagonRegisterInfo& QRI = getRegisterInfo();
2724 switch (MI->getOpcode())
2725 {
2726 default: return false;
2727 case Hexagon::STrib_imm_cPt_V4 :
2728 case Hexagon::STrib_imm_cNotPt_V4 :
2729 case Hexagon::STrib_indexed_shl_cPt_V4 :
2730 case Hexagon::STrib_indexed_shl_cNotPt_V4 :
2731 case Hexagon::STrib_cPt :
2732 case Hexagon::STrib_cNotPt :
2733 case Hexagon::POST_STbri_cPt :
2734 case Hexagon::POST_STbri_cNotPt :
2735 case Hexagon::STrid_indexed_cPt :
2736 case Hexagon::STrid_indexed_cNotPt :
2737 case Hexagon::STrid_indexed_shl_cPt_V4 :
2738 case Hexagon::POST_STdri_cPt :
2739 case Hexagon::POST_STdri_cNotPt :
2740 case Hexagon::STrih_cPt :
2741 case Hexagon::STrih_cNotPt :
2742 case Hexagon::STrih_indexed_cPt :
2743 case Hexagon::STrih_indexed_cNotPt :
2744 case Hexagon::STrih_imm_cPt_V4 :
2745 case Hexagon::STrih_imm_cNotPt_V4 :
2746 case Hexagon::STrih_indexed_shl_cPt_V4 :
2747 case Hexagon::STrih_indexed_shl_cNotPt_V4 :
2748 case Hexagon::POST_SThri_cPt :
2749 case Hexagon::POST_SThri_cNotPt :
2750 case Hexagon::STriw_cPt :
2751 case Hexagon::STriw_cNotPt :
2752 case Hexagon::STriw_indexed_cPt :
2753 case Hexagon::STriw_indexed_cNotPt :
2754 case Hexagon::STriw_imm_cPt_V4 :
2755 case Hexagon::STriw_imm_cNotPt_V4 :
2756 case Hexagon::STriw_indexed_shl_cPt_V4 :
2757 case Hexagon::STriw_indexed_shl_cNotPt_V4 :
2758 case Hexagon::POST_STwri_cPt :
2759 case Hexagon::POST_STwri_cNotPt :
2760 return QRI.Subtarget.hasV4TOps();
2761
2762 // V4 global address store before promoting to dot new.
Sirish Pande26f61a12012-05-03 21:52:53 +00002763 case Hexagon::STd_GP_cPt_V4 :
2764 case Hexagon::STd_GP_cNotPt_V4 :
2765 case Hexagon::STb_GP_cPt_V4 :
2766 case Hexagon::STb_GP_cNotPt_V4 :
2767 case Hexagon::STh_GP_cPt_V4 :
2768 case Hexagon::STh_GP_cNotPt_V4 :
2769 case Hexagon::STw_GP_cPt_V4 :
2770 case Hexagon::STw_GP_cNotPt_V4 :
2771 return QRI.Subtarget.hasV4TOps();
2772
2773 // Predicated new value stores (i.e. if (p0) memw(..)=r0.new) are excluded
2774 // from the "Conditional Store" list. Because a predicated new value store
2775 // would NOT be promoted to a double dot new store. See diagram below:
2776 // This function returns yes for those stores that are predicated but not
2777 // yet promoted to predicate dot new instructions.
2778 //
2779 // +---------------------+
2780 // /-----| if (p0) memw(..)=r0 |---------\~
2781 // || +---------------------+ ||
2782 // promote || /\ /\ || promote
2783 // || /||\ /||\ ||
2784 // \||/ demote || \||/
2785 // \/ || || \/
2786 // +-------------------------+ || +-------------------------+
2787 // | if (p0.new) memw(..)=r0 | || | if (p0) memw(..)=r0.new |
2788 // +-------------------------+ || +-------------------------+
2789 // || || ||
2790 // || demote \||/
2791 // promote || \/ NOT possible
2792 // || || /\~
2793 // \||/ || /||\~
2794 // \/ || ||
2795 // +-----------------------------+
2796 // | if (p0.new) memw(..)=r0.new |
2797 // +-----------------------------+
2798 // Double Dot New Store
2799 //
2800 }
2801}
2802
2803
2804
Andrew Trickee498d32012-02-01 22:13:57 +00002805DFAPacketizer *HexagonInstrInfo::
2806CreateTargetScheduleState(const TargetMachine *TM,
2807 const ScheduleDAG *DAG) const {
2808 const InstrItineraryData *II = TM->getInstrItineraryData();
2809 return TM->getSubtarget<HexagonGenSubtargetInfo>().createDFAPacketizer(II);
2810}
2811
2812bool HexagonInstrInfo::isSchedulingBoundary(const MachineInstr *MI,
2813 const MachineBasicBlock *MBB,
2814 const MachineFunction &MF) const {
2815 // Debug info is never a scheduling boundary. It's necessary to be explicit
2816 // due to the special treatment of IT instructions below, otherwise a
2817 // dbg_value followed by an IT will result in the IT instruction being
2818 // considered a scheduling hazard, which is wrong. It should be the actual
2819 // instruction preceding the dbg_value instruction(s), just like it is
2820 // when debug info is not present.
2821 if (MI->isDebugValue())
2822 return false;
2823
2824 // Terminators and labels can't be scheduled around.
2825 if (MI->getDesc().isTerminator() || MI->isLabel() || MI->isInlineAsm())
2826 return true;
2827
2828 return false;
2829}