blob: ba82f56a2464f794c303fa3ce5b89dc2dd51c2c4 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- PPCInstrInfo.h - PowerPC Instruction Information --------*- C++ -*-===//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Misha Brukman116f9272004-08-17 04:55:41 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanb4402432005-04-21 23:30:14 +00007//
Misha Brukman116f9272004-08-17 04:55:41 +00008//===----------------------------------------------------------------------===//
9//
10// This file contains the PowerPC implementation of the TargetInstrInfo class.
11//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_POWERPC_PPCINSTRINFO_H
15#define LLVM_LIB_TARGET_POWERPC_PPCINSTRINFO_H
Misha Brukman116f9272004-08-17 04:55:41 +000016
Chris Lattnerbfca1ab2005-10-14 23:51:18 +000017#include "PPC.h"
Chris Lattner6f3b9542005-10-14 23:59:06 +000018#include "PPCRegisterInfo.h"
David Blaikie3f833ed2017-11-08 01:01:31 +000019#include "llvm/CodeGen/TargetInstrInfo.h"
Misha Brukman116f9272004-08-17 04:55:41 +000020
Evan Cheng703a0fb2011-07-01 17:57:27 +000021#define GET_INSTRINFO_HEADER
22#include "PPCGenInstrInfo.inc"
23
Misha Brukman116f9272004-08-17 04:55:41 +000024namespace llvm {
Chris Lattner51348c52006-03-12 09:13:49 +000025
26/// PPCII - This namespace holds all of the PowerPC target-specific
27/// per-instruction flags. These must match the corresponding definitions in
28/// PPC.td and PPCInstrFormats.td.
29namespace PPCII {
30enum {
31 // PPC970 Instruction Flags. These flags describe the characteristics of the
32 // PowerPC 970 (aka G5) dispatch groups and how they are formed out of
33 // raw machine instructions.
34
35 /// PPC970_First - This instruction starts a new dispatch group, so it will
36 /// always be the first one in the group.
37 PPC970_First = 0x1,
Andrew Trickc416ba62010-12-24 04:28:06 +000038
Chris Lattner51348c52006-03-12 09:13:49 +000039 /// PPC970_Single - This instruction starts a new dispatch group and
40 /// terminates it, so it will be the sole instruction in the group.
41 PPC970_Single = 0x2,
42
Chris Lattner7579cfb2006-03-13 05:15:10 +000043 /// PPC970_Cracked - This instruction is cracked into two pieces, requiring
44 /// two dispatch pipes to be available to issue.
45 PPC970_Cracked = 0x4,
Andrew Trickc416ba62010-12-24 04:28:06 +000046
Chris Lattner51348c52006-03-12 09:13:49 +000047 /// PPC970_Mask/Shift - This is a bitmask that selects the pipeline type that
48 /// an instruction is issued to.
Chris Lattner7579cfb2006-03-13 05:15:10 +000049 PPC970_Shift = 3,
Chris Lattneraa2372562006-05-24 17:04:05 +000050 PPC970_Mask = 0x07 << PPC970_Shift
Chris Lattner51348c52006-03-12 09:13:49 +000051};
52enum PPC970_Unit {
53 /// These are the various PPC970 execution unit pipelines. Each instruction
54 /// is one of these.
55 PPC970_Pseudo = 0 << PPC970_Shift, // Pseudo instruction
56 PPC970_FXU = 1 << PPC970_Shift, // Fixed Point (aka Integer/ALU) Unit
57 PPC970_LSU = 2 << PPC970_Shift, // Load Store Unit
58 PPC970_FPU = 3 << PPC970_Shift, // Floating Point Unit
59 PPC970_CRU = 4 << PPC970_Shift, // Control Register Unit
60 PPC970_VALU = 5 << PPC970_Shift, // Vector ALU
61 PPC970_VPERM = 6 << PPC970_Shift, // Vector Permute Unit
Chris Lattneraa2372562006-05-24 17:04:05 +000062 PPC970_BRU = 7 << PPC970_Shift // Branch Unit
Chris Lattner51348c52006-03-12 09:13:49 +000063};
Nemanja Ivanovic11049f82016-10-04 06:59:23 +000064
65enum {
66 /// Shift count to bypass PPC970 flags
67 NewDef_Shift = 6,
68
69 /// The VSX instruction that uses VSX register (vs0-vs63), instead of VMX
70 /// register (v0-v31).
Stefan Pintilie26d4f922018-03-26 17:39:18 +000071 UseVSXReg = 0x1 << NewDef_Shift,
72 /// This instruction is an X-Form memory operation.
73 XFormMemOp = 0x1 << (NewDef_Shift+1)
Nemanja Ivanovic11049f82016-10-04 06:59:23 +000074};
Chris Lattnerdf8e17d2010-11-14 23:42:06 +000075} // end namespace PPCII
Andrew Trickc416ba62010-12-24 04:28:06 +000076
Nemanja Ivanovic6995e5d2017-12-15 07:27:53 +000077// Instructions that have an immediate form might be convertible to that
78// form if the correct input is a result of a load immediate. In order to
79// know whether the transformation is special, we might need to know some
80// of the details of the two forms.
81struct ImmInstrInfo {
82 // Is the immediate field in the immediate form signed or unsigned?
83 uint64_t SignedImm : 1;
84 // Does the immediate need to be a multiple of some value?
85 uint64_t ImmMustBeMultipleOf : 5;
86 // Is R0/X0 treated specially by the original r+r instruction?
87 // If so, in which operand?
88 uint64_t ZeroIsSpecialOrig : 3;
89 // Is R0/X0 treated specially by the new r+i instruction?
90 // If so, in which operand?
91 uint64_t ZeroIsSpecialNew : 3;
92 // Is the operation commutative?
93 uint64_t IsCommutative : 1;
94 // The operand number to check for load immediate.
95 uint64_t ConstantOpNo : 3;
96 // The operand number for the immediate.
97 uint64_t ImmOpNo : 3;
98 // The opcode of the new instruction.
99 uint64_t ImmOpcode : 16;
100 // The size of the immediate.
101 uint64_t ImmWidth : 5;
Nemanja Ivanovic4e1f5e02017-12-29 12:22:27 +0000102 // The immediate should be truncated to N bits.
103 uint64_t TruncateImmTo : 5;
Nemanja Ivanovic6995e5d2017-12-15 07:27:53 +0000104};
105
106// Information required to convert an instruction to just a materialized
107// immediate.
108struct LoadImmediateInfo {
109 unsigned Imm : 16;
110 unsigned Is64Bit : 1;
111 unsigned SetCR : 1;
112};
113
Eric Christopher234a1ec2015-03-12 06:07:16 +0000114class PPCSubtarget;
Evan Cheng703a0fb2011-07-01 17:57:27 +0000115class PPCInstrInfo : public PPCGenInstrInfo {
Eric Christopher1dcea732014-06-12 21:48:52 +0000116 PPCSubtarget &Subtarget;
Nate Begeman6cca84e2005-10-16 05:39:50 +0000117 const PPCRegisterInfo RI;
Bill Wendlingc6c48fc2008-03-10 22:49:16 +0000118
Stefan Pintilie26d4f922018-03-26 17:39:18 +0000119 void StoreRegToStackSlot(MachineFunction &MF, unsigned SrcReg, bool isKill,
120 int FrameIdx, const TargetRegisterClass *RC,
121 SmallVectorImpl<MachineInstr *> &NewMIs) const;
122 void LoadRegFromStackSlot(MachineFunction &MF, const DebugLoc &DL,
Dan Gohman3b460302008-07-07 23:14:23 +0000123 unsigned DestReg, int FrameIdx,
Bill Wendlingc6c48fc2008-03-10 22:49:16 +0000124 const TargetRegisterClass *RC,
Stefan Pintilie26d4f922018-03-26 17:39:18 +0000125 SmallVectorImpl<MachineInstr *> &NewMIs) const;
Nemanja Ivanovic6995e5d2017-12-15 07:27:53 +0000126 bool transformToImmForm(MachineInstr &MI, const ImmInstrInfo &III,
127 unsigned ConstantOpNo, int64_t Imm) const;
128 MachineInstr *getConstantDefMI(MachineInstr &MI, unsigned &ConstOp,
129 bool &SeenIntermediateUse) const;
Stefan Pintilie26d4f922018-03-26 17:39:18 +0000130 const unsigned *getStoreOpcodesForSpillArray() const;
131 const unsigned *getLoadOpcodesForSpillArray() const;
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +0000132 virtual void anchor();
Andrew Kaylor16c4da02015-09-28 20:33:22 +0000133
134protected:
135 /// Commutes the operands in the given instruction.
136 /// The commutable operands are specified by their indices OpIdx1 and OpIdx2.
137 ///
138 /// Do not call this method for a non-commutable instruction or for
139 /// non-commutable pair of operand indices OpIdx1 and OpIdx2.
140 /// Even though the instruction is commutable, the method may still
141 /// fail to commute the operands, null pointer is returned in such cases.
142 ///
143 /// For example, we can commute rlwimi instructions, but only if the
144 /// rotate amt is zero. We also have to munge the immediates a bit.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000145 MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
Andrew Kaylor16c4da02015-09-28 20:33:22 +0000146 unsigned OpIdx1,
147 unsigned OpIdx2) const override;
148
Misha Brukman116f9272004-08-17 04:55:41 +0000149public:
Eric Christopher1dcea732014-06-12 21:48:52 +0000150 explicit PPCInstrInfo(PPCSubtarget &STI);
Misha Brukman116f9272004-08-17 04:55:41 +0000151
152 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
153 /// such, whenever a client has an instance of instruction info, it should
154 /// always be able to get register info as well (through this method).
155 ///
Craig Topper0d3fa922014-04-29 07:57:37 +0000156 const PPCRegisterInfo &getRegisterInfo() const { return RI; }
Misha Brukman116f9272004-08-17 04:55:41 +0000157
Stefan Pintilie26d4f922018-03-26 17:39:18 +0000158 bool isXFormMemOp(unsigned Opcode) const {
159 return get(Opcode).TSFlags & PPCII::XFormMemOp;
160 }
161
Andrew Trick10ffc2b2010-12-24 05:03:26 +0000162 ScheduleHazardRecognizer *
Eric Christopherf047bfd2014-06-13 22:38:52 +0000163 CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI,
Craig Topper0d3fa922014-04-29 07:57:37 +0000164 const ScheduleDAG *DAG) const override;
Hal Finkel58ca3602011-12-02 04:58:02 +0000165 ScheduleHazardRecognizer *
166 CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II,
Craig Topper0d3fa922014-04-29 07:57:37 +0000167 const ScheduleDAG *DAG) const override;
Andrew Trick10ffc2b2010-12-24 05:03:26 +0000168
Hal Finkel8acae522015-07-14 20:02:02 +0000169 unsigned getInstrLatency(const InstrItineraryData *ItinData,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000170 const MachineInstr &MI,
Hal Finkel8acae522015-07-14 20:02:02 +0000171 unsigned *PredCost = nullptr) const override;
172
Hal Finkelceb1f122013-12-12 00:19:11 +0000173 int getOperandLatency(const InstrItineraryData *ItinData,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000174 const MachineInstr &DefMI, unsigned DefIdx,
175 const MachineInstr &UseMI,
Craig Topper0d3fa922014-04-29 07:57:37 +0000176 unsigned UseIdx) const override;
Hal Finkelceb1f122013-12-12 00:19:11 +0000177 int getOperandLatency(const InstrItineraryData *ItinData,
178 SDNode *DefNode, unsigned DefIdx,
Craig Topper0d3fa922014-04-29 07:57:37 +0000179 SDNode *UseNode, unsigned UseIdx) const override {
Hal Finkelceb1f122013-12-12 00:19:11 +0000180 return PPCGenInstrInfo::getOperandLatency(ItinData, DefNode, DefIdx,
181 UseNode, UseIdx);
182 }
183
Matthias Braun88e21312015-06-13 03:42:11 +0000184 bool hasLowDefLatency(const TargetSchedModel &SchedModel,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000185 const MachineInstr &DefMI,
Hal Finkel3c0952b02015-01-08 22:11:49 +0000186 unsigned DefIdx) const override {
187 // Machine LICM should hoist all instructions in low-register-pressure
188 // situations; none are sufficiently free to justify leaving in a loop
189 // body.
190 return false;
191 }
192
Hal Finkel5d36b232015-07-15 08:23:05 +0000193 bool useMachineCombiner() const override {
194 return true;
195 }
Chad Rosier03a47302015-09-21 15:09:11 +0000196
Hal Finkel5d36b232015-07-15 08:23:05 +0000197 /// Return true when there is potentially a faster code sequence
198 /// for an instruction chain ending in <Root>. All potential patterns are
199 /// output in the <Pattern> array.
200 bool getMachineCombinerPatterns(
201 MachineInstr &Root,
Sanjay Patel387e66e2015-11-05 19:34:57 +0000202 SmallVectorImpl<MachineCombinerPattern> &P) const override;
Chad Rosier03a47302015-09-21 15:09:11 +0000203
204 bool isAssociativeAndCommutative(const MachineInstr &Inst) const override;
Hal Finkel5d36b232015-07-15 08:23:05 +0000205
Jakob Stoklund Olesen0f855e42012-06-19 21:14:34 +0000206 bool isCoalescableExtInstr(const MachineInstr &MI,
207 unsigned &SrcReg, unsigned &DstReg,
Craig Topper0d3fa922014-04-29 07:57:37 +0000208 unsigned &SubIdx) const override;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000209 unsigned isLoadFromStackSlot(const MachineInstr &MI,
Craig Topper0d3fa922014-04-29 07:57:37 +0000210 int &FrameIndex) const override;
Lei Huang84dbbfd2017-06-21 17:17:56 +0000211 bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
212 AliasAnalysis *AA) const override;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000213 unsigned isStoreToStackSlot(const MachineInstr &MI,
Craig Topper0d3fa922014-04-29 07:57:37 +0000214 int &FrameIndex) const override;
Chris Lattnerbb53acd2006-02-02 20:12:32 +0000215
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000216 bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
Craig Topper0d3fa922014-04-29 07:57:37 +0000217 unsigned &SrcOpIdx2) const override;
Hal Finkel6c32ff32014-03-25 19:26:43 +0000218
Craig Topper0d3fa922014-04-29 07:57:37 +0000219 void insertNoop(MachineBasicBlock &MBB,
220 MachineBasicBlock::iterator MI) const override;
Chris Lattnerea79d9fd732006-03-05 23:49:55 +0000221
Chris Lattnera47294ed2006-10-13 21:21:17 +0000222
223 // Branch analysis.
Jacques Pienaar71c30a12016-07-15 14:41:04 +0000224 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Craig Topper0d3fa922014-04-29 07:57:37 +0000225 MachineBasicBlock *&FBB,
226 SmallVectorImpl<MachineOperand> &Cond,
227 bool AllowModify) const override;
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000228 unsigned removeBranch(MachineBasicBlock &MBB,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000229 int *BytesRemoved = nullptr) const override;
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +0000230 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000231 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000232 const DebugLoc &DL,
233 int *BytesAdded = nullptr) const override;
Hal Finkeled6a2852013-04-05 23:29:01 +0000234
235 // Select analysis.
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000236 bool canInsertSelect(const MachineBasicBlock &, ArrayRef<MachineOperand> Cond,
237 unsigned, unsigned, int &, int &, int &) const override;
238 void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000239 const DebugLoc &DL, unsigned DstReg,
240 ArrayRef<MachineOperand> Cond, unsigned TrueReg,
241 unsigned FalseReg) const override;
Hal Finkeled6a2852013-04-05 23:29:01 +0000242
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000243 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
244 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Craig Topper0d3fa922014-04-29 07:57:37 +0000245 bool KillSrc) const override;
Andrew Trickc416ba62010-12-24 04:28:06 +0000246
Craig Topper0d3fa922014-04-29 07:57:37 +0000247 void storeRegToStackSlot(MachineBasicBlock &MBB,
248 MachineBasicBlock::iterator MBBI,
249 unsigned SrcReg, bool isKill, int FrameIndex,
250 const TargetRegisterClass *RC,
251 const TargetRegisterInfo *TRI) const override;
Owen Andersoneee14602008-01-01 21:11:32 +0000252
Craig Topper0d3fa922014-04-29 07:57:37 +0000253 void loadRegFromStackSlot(MachineBasicBlock &MBB,
254 MachineBasicBlock::iterator MBBI,
255 unsigned DestReg, int FrameIndex,
256 const TargetRegisterClass *RC,
257 const TargetRegisterInfo *TRI) const override;
Andrew Trickc416ba62010-12-24 04:28:06 +0000258
Stefan Pintilie26d4f922018-03-26 17:39:18 +0000259 unsigned getStoreOpcodeForSpill(unsigned Reg,
260 const TargetRegisterClass *RC = nullptr) const;
261
262 unsigned getLoadOpcodeForSpill(unsigned Reg,
263 const TargetRegisterClass *RC = nullptr) const;
264
Craig Topper0d3fa922014-04-29 07:57:37 +0000265 bool
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000266 reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
Andrew Trickc416ba62010-12-24 04:28:06 +0000267
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000268 bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg,
269 MachineRegisterInfo *MRI) const override;
Hal Finkeld61d4f82013-04-06 19:30:30 +0000270
Hal Finkel5711eca2013-04-09 22:58:37 +0000271 // If conversion by predication (only supported by some branch instructions).
272 // All of the profitability checks always return true; it is always
273 // profitable to use the predicated branches.
Craig Topper0d3fa922014-04-29 07:57:37 +0000274 bool isProfitableToIfCvt(MachineBasicBlock &MBB,
275 unsigned NumCycles, unsigned ExtraPredCycles,
Cong Houc536bd92015-09-10 23:10:42 +0000276 BranchProbability Probability) const override {
Hal Finkel5711eca2013-04-09 22:58:37 +0000277 return true;
278 }
279
Craig Topper0d3fa922014-04-29 07:57:37 +0000280 bool isProfitableToIfCvt(MachineBasicBlock &TMBB,
281 unsigned NumT, unsigned ExtraT,
282 MachineBasicBlock &FMBB,
283 unsigned NumF, unsigned ExtraF,
Cong Houc536bd92015-09-10 23:10:42 +0000284 BranchProbability Probability) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000285
Cong Houc536bd92015-09-10 23:10:42 +0000286 bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
287 BranchProbability Probability) const override {
Hal Finkel5711eca2013-04-09 22:58:37 +0000288 return true;
289 }
290
Craig Topper0d3fa922014-04-29 07:57:37 +0000291 bool isProfitableToUnpredicate(MachineBasicBlock &TMBB,
292 MachineBasicBlock &FMBB) const override {
Hal Finkel5711eca2013-04-09 22:58:37 +0000293 return false;
294 }
295
296 // Predication support.
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000297 bool isPredicated(const MachineInstr &MI) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000298
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000299 bool isUnpredicatedTerminator(const MachineInstr &MI) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000300
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000301 bool PredicateInstruction(MachineInstr &MI,
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000302 ArrayRef<MachineOperand> Pred) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000303
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000304 bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1,
305 ArrayRef<MachineOperand> Pred2) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000306
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000307 bool DefinesPredicate(MachineInstr &MI,
Craig Topper0d3fa922014-04-29 07:57:37 +0000308 std::vector<MachineOperand> &Pred) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000309
Krzysztof Parzyszekcc318712017-03-03 18:30:54 +0000310 bool isPredicable(const MachineInstr &MI) const override;
Hal Finkel5711eca2013-04-09 22:58:37 +0000311
Hal Finkel82656cb2013-04-18 22:15:08 +0000312 // Comparison optimization.
313
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000314 bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg,
315 unsigned &SrcReg2, int &Mask, int &Value) const override;
Hal Finkel82656cb2013-04-18 22:15:08 +0000316
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000317 bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg,
318 unsigned SrcReg2, int Mask, int Value,
Craig Topper0d3fa922014-04-29 07:57:37 +0000319 const MachineRegisterInfo *MRI) const override;
Hal Finkel82656cb2013-04-18 22:15:08 +0000320
Nicolas Geoffrayae84bbd2008-04-16 20:10:13 +0000321 /// GetInstSize - Return the number of bytes of code the specified
322 /// instruction may be. This returns the maximum number of bytes.
323 ///
Sjoerd Meijer0eb96ed2016-07-29 08:16:16 +0000324 unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
Joerg Sonnenberger7ee0f312014-08-08 19:13:23 +0000325
Hans Wennborg9b9a5352017-04-21 21:48:41 +0000326 void getNoop(MCInst &NopInst) const override;
Hal Finkel2d556982015-08-30 07:50:35 +0000327
328 std::pair<unsigned, unsigned>
329 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
330
331 ArrayRef<std::pair<unsigned, const char *>>
332 getSerializableDirectMachineOperandTargetFlags() const override;
333
334 ArrayRef<std::pair<unsigned, const char *>>
335 getSerializableBitmaskMachineOperandTargetFlags() const override;
Tim Shena1d8bc52016-04-19 20:14:52 +0000336
Tony Jiang438bf4a2017-11-20 14:38:30 +0000337 // Expand VSX Memory Pseudo instruction to either a VSX or a FP instruction.
338 bool expandVSXMemPseudo(MachineInstr &MI) const;
339
Tim Shena1d8bc52016-04-19 20:14:52 +0000340 // Lower pseudo instructions after register allocation.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000341 bool expandPostRAPseudo(MachineInstr &MI) const override;
Nemanja Ivanovic11049f82016-10-04 06:59:23 +0000342
343 static bool isVFRegister(unsigned Reg) {
344 return Reg >= PPC::VF0 && Reg <= PPC::VF31;
345 }
346 static bool isVRRegister(unsigned Reg) {
347 return Reg >= PPC::V0 && Reg <= PPC::V31;
348 }
349 const TargetRegisterClass *updatedRC(const TargetRegisterClass *RC) const;
Nemanja Ivanovice597bd82017-05-31 05:40:25 +0000350 static int getRecordFormOpcode(unsigned Opcode);
Hiroshi Inouee3a3e3c2017-10-16 04:12:57 +0000351
Zaara Syedaf94d58d2017-11-27 20:26:36 +0000352 bool isTOCSaveMI(const MachineInstr &MI) const;
353
Hiroshi Inouee3a3e3c2017-10-16 04:12:57 +0000354 bool isSignOrZeroExtended(const MachineInstr &MI, bool SignExt,
355 const unsigned PhiDepth) const;
356
357 /// Return true if the output of the instruction is always a sign-extended,
358 /// i.e. 0 to 31-th bits are same as 32-th bit.
359 bool isSignExtended(const MachineInstr &MI, const unsigned depth = 0) const {
360 return isSignOrZeroExtended(MI, true, depth);
361 }
362
363 /// Return true if the output of the instruction is always zero-extended,
364 /// i.e. 0 to 31-th bits are all zeros
365 bool isZeroExtended(const MachineInstr &MI, const unsigned depth = 0) const {
366 return isSignOrZeroExtended(MI, false, depth);
367 }
Nemanja Ivanovic6995e5d2017-12-15 07:27:53 +0000368
369 bool convertToImmediateForm(MachineInstr &MI,
370 MachineInstr **KilledDef = nullptr) const;
371 void replaceInstrWithLI(MachineInstr &MI, const LoadImmediateInfo &LII) const;
372
Nemanja Ivanovic6995e5d2017-12-15 07:27:53 +0000373 bool instrHasImmForm(const MachineInstr &MI, ImmInstrInfo &III) const;
Misha Brukman116f9272004-08-17 04:55:41 +0000374};
375
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000376}
Misha Brukman116f9272004-08-17 04:55:41 +0000377
378#endif