| Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- PPCInstrInfo.h - PowerPC Instruction Information --------*- C++ -*-===// | 
| Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 2 | // | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 3 | //                     The LLVM Compiler Infrastructure | 
|  | 4 | // | 
| Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source | 
|  | 6 | // License. See LICENSE.TXT for details. | 
| Misha Brukman | b440243 | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 7 | // | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// | 
|  | 9 | // | 
|  | 10 | // This file contains the PowerPC implementation of the TargetInstrInfo class. | 
|  | 11 | // | 
|  | 12 | //===----------------------------------------------------------------------===// | 
|  | 13 |  | 
| Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_POWERPC_PPCINSTRINFO_H | 
|  | 15 | #define LLVM_LIB_TARGET_POWERPC_PPCINSTRINFO_H | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 16 |  | 
| Chris Lattner | bfca1ab | 2005-10-14 23:51:18 +0000 | [diff] [blame] | 17 | #include "PPC.h" | 
| Chris Lattner | 6f3b954 | 2005-10-14 23:59:06 +0000 | [diff] [blame] | 18 | #include "PPCRegisterInfo.h" | 
| David Blaikie | 3f833ed | 2017-11-08 01:01:31 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/TargetInstrInfo.h" | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 20 |  | 
| Evan Cheng | 703a0fb | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 21 | #define GET_INSTRINFO_HEADER | 
|  | 22 | #include "PPCGenInstrInfo.inc" | 
|  | 23 |  | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 24 | namespace llvm { | 
| Chris Lattner | 51348c5 | 2006-03-12 09:13:49 +0000 | [diff] [blame] | 25 |  | 
|  | 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. | 
|  | 29 | namespace PPCII { | 
|  | 30 | enum { | 
|  | 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 Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 38 |  | 
| Chris Lattner | 51348c5 | 2006-03-12 09:13:49 +0000 | [diff] [blame] | 39 | /// 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 Lattner | 7579cfb | 2006-03-13 05:15:10 +0000 | [diff] [blame] | 43 | /// PPC970_Cracked - This instruction is cracked into two pieces, requiring | 
|  | 44 | /// two dispatch pipes to be available to issue. | 
|  | 45 | PPC970_Cracked = 0x4, | 
| Andrew Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 46 |  | 
| Chris Lattner | 51348c5 | 2006-03-12 09:13:49 +0000 | [diff] [blame] | 47 | /// PPC970_Mask/Shift - This is a bitmask that selects the pipeline type that | 
|  | 48 | /// an instruction is issued to. | 
| Chris Lattner | 7579cfb | 2006-03-13 05:15:10 +0000 | [diff] [blame] | 49 | PPC970_Shift = 3, | 
| Chris Lattner | aa237256 | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 50 | PPC970_Mask = 0x07 << PPC970_Shift | 
| Chris Lattner | 51348c5 | 2006-03-12 09:13:49 +0000 | [diff] [blame] | 51 | }; | 
|  | 52 | enum 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 Lattner | aa237256 | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 62 | PPC970_BRU    = 7 << PPC970_Shift    // Branch Unit | 
| Chris Lattner | 51348c5 | 2006-03-12 09:13:49 +0000 | [diff] [blame] | 63 | }; | 
| Nemanja Ivanovic | 11049f8 | 2016-10-04 06:59:23 +0000 | [diff] [blame] | 64 |  | 
|  | 65 | enum { | 
|  | 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 Pintilie | 26d4f92 | 2018-03-26 17:39:18 +0000 | [diff] [blame] | 71 | UseVSXReg = 0x1 << NewDef_Shift, | 
|  | 72 | /// This instruction is an X-Form memory operation. | 
|  | 73 | XFormMemOp = 0x1 << (NewDef_Shift+1) | 
| Nemanja Ivanovic | 11049f8 | 2016-10-04 06:59:23 +0000 | [diff] [blame] | 74 | }; | 
| Chris Lattner | df8e17d | 2010-11-14 23:42:06 +0000 | [diff] [blame] | 75 | } // end namespace PPCII | 
| Andrew Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 76 |  | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 77 | // 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. | 
|  | 81 | struct 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 Ivanovic | 4e1f5e0 | 2017-12-29 12:22:27 +0000 | [diff] [blame] | 102 | // The immediate should be truncated to N bits. | 
|  | 103 | uint64_t TruncateImmTo : 5; | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 104 | }; | 
|  | 105 |  | 
|  | 106 | // Information required to convert an instruction to just a materialized | 
|  | 107 | // immediate. | 
|  | 108 | struct LoadImmediateInfo { | 
|  | 109 | unsigned Imm : 16; | 
|  | 110 | unsigned Is64Bit : 1; | 
|  | 111 | unsigned SetCR : 1; | 
|  | 112 | }; | 
|  | 113 |  | 
| Eric Christopher | 234a1ec | 2015-03-12 06:07:16 +0000 | [diff] [blame] | 114 | class PPCSubtarget; | 
| Evan Cheng | 703a0fb | 2011-07-01 17:57:27 +0000 | [diff] [blame] | 115 | class PPCInstrInfo : public PPCGenInstrInfo { | 
| Eric Christopher | 1dcea73 | 2014-06-12 21:48:52 +0000 | [diff] [blame] | 116 | PPCSubtarget &Subtarget; | 
| Nate Begeman | 6cca84e | 2005-10-16 05:39:50 +0000 | [diff] [blame] | 117 | const PPCRegisterInfo RI; | 
| Bill Wendling | c6c48fc | 2008-03-10 22:49:16 +0000 | [diff] [blame] | 118 |  | 
| Stefan Pintilie | 26d4f92 | 2018-03-26 17:39:18 +0000 | [diff] [blame] | 119 | 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 Gohman | 3b46030 | 2008-07-07 23:14:23 +0000 | [diff] [blame] | 123 | unsigned DestReg, int FrameIdx, | 
| Bill Wendling | c6c48fc | 2008-03-10 22:49:16 +0000 | [diff] [blame] | 124 | const TargetRegisterClass *RC, | 
| Stefan Pintilie | 26d4f92 | 2018-03-26 17:39:18 +0000 | [diff] [blame] | 125 | SmallVectorImpl<MachineInstr *> &NewMIs) const; | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 126 | 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 Pintilie | 26d4f92 | 2018-03-26 17:39:18 +0000 | [diff] [blame] | 130 | const unsigned *getStoreOpcodesForSpillArray() const; | 
|  | 131 | const unsigned *getLoadOpcodesForSpillArray() const; | 
| Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 132 | virtual void anchor(); | 
| Andrew Kaylor | 16c4da0 | 2015-09-28 20:33:22 +0000 | [diff] [blame] | 133 |  | 
|  | 134 | protected: | 
|  | 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 Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 145 | MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI, | 
| Andrew Kaylor | 16c4da0 | 2015-09-28 20:33:22 +0000 | [diff] [blame] | 146 | unsigned OpIdx1, | 
|  | 147 | unsigned OpIdx2) const override; | 
|  | 148 |  | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 149 | public: | 
| Eric Christopher | 1dcea73 | 2014-06-12 21:48:52 +0000 | [diff] [blame] | 150 | explicit PPCInstrInfo(PPCSubtarget &STI); | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 151 |  | 
|  | 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 Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 156 | const PPCRegisterInfo &getRegisterInfo() const { return RI; } | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 157 |  | 
| Stefan Pintilie | 26d4f92 | 2018-03-26 17:39:18 +0000 | [diff] [blame] | 158 | bool isXFormMemOp(unsigned Opcode) const { | 
|  | 159 | return get(Opcode).TSFlags & PPCII::XFormMemOp; | 
|  | 160 | } | 
|  | 161 |  | 
| Andrew Trick | 10ffc2b | 2010-12-24 05:03:26 +0000 | [diff] [blame] | 162 | ScheduleHazardRecognizer * | 
| Eric Christopher | f047bfd | 2014-06-13 22:38:52 +0000 | [diff] [blame] | 163 | CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 164 | const ScheduleDAG *DAG) const override; | 
| Hal Finkel | 58ca360 | 2011-12-02 04:58:02 +0000 | [diff] [blame] | 165 | ScheduleHazardRecognizer * | 
|  | 166 | CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 167 | const ScheduleDAG *DAG) const override; | 
| Andrew Trick | 10ffc2b | 2010-12-24 05:03:26 +0000 | [diff] [blame] | 168 |  | 
| Hal Finkel | 8acae52 | 2015-07-14 20:02:02 +0000 | [diff] [blame] | 169 | unsigned getInstrLatency(const InstrItineraryData *ItinData, | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 170 | const MachineInstr &MI, | 
| Hal Finkel | 8acae52 | 2015-07-14 20:02:02 +0000 | [diff] [blame] | 171 | unsigned *PredCost = nullptr) const override; | 
|  | 172 |  | 
| Hal Finkel | ceb1f12 | 2013-12-12 00:19:11 +0000 | [diff] [blame] | 173 | int getOperandLatency(const InstrItineraryData *ItinData, | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 174 | const MachineInstr &DefMI, unsigned DefIdx, | 
|  | 175 | const MachineInstr &UseMI, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 176 | unsigned UseIdx) const override; | 
| Hal Finkel | ceb1f12 | 2013-12-12 00:19:11 +0000 | [diff] [blame] | 177 | int getOperandLatency(const InstrItineraryData *ItinData, | 
|  | 178 | SDNode *DefNode, unsigned DefIdx, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 179 | SDNode *UseNode, unsigned UseIdx) const override { | 
| Hal Finkel | ceb1f12 | 2013-12-12 00:19:11 +0000 | [diff] [blame] | 180 | return PPCGenInstrInfo::getOperandLatency(ItinData, DefNode, DefIdx, | 
|  | 181 | UseNode, UseIdx); | 
|  | 182 | } | 
|  | 183 |  | 
| Matthias Braun | 88e2131 | 2015-06-13 03:42:11 +0000 | [diff] [blame] | 184 | bool hasLowDefLatency(const TargetSchedModel &SchedModel, | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 185 | const MachineInstr &DefMI, | 
| Hal Finkel | 3c0952b0 | 2015-01-08 22:11:49 +0000 | [diff] [blame] | 186 | 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 Finkel | 5d36b23 | 2015-07-15 08:23:05 +0000 | [diff] [blame] | 193 | bool useMachineCombiner() const override { | 
|  | 194 | return true; | 
|  | 195 | } | 
| Chad Rosier | 03a4730 | 2015-09-21 15:09:11 +0000 | [diff] [blame] | 196 |  | 
| Hal Finkel | 5d36b23 | 2015-07-15 08:23:05 +0000 | [diff] [blame] | 197 | /// 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 Patel | 387e66e | 2015-11-05 19:34:57 +0000 | [diff] [blame] | 202 | SmallVectorImpl<MachineCombinerPattern> &P) const override; | 
| Chad Rosier | 03a4730 | 2015-09-21 15:09:11 +0000 | [diff] [blame] | 203 |  | 
|  | 204 | bool isAssociativeAndCommutative(const MachineInstr &Inst) const override; | 
| Hal Finkel | 5d36b23 | 2015-07-15 08:23:05 +0000 | [diff] [blame] | 205 |  | 
| Jakob Stoklund Olesen | 0f855e4 | 2012-06-19 21:14:34 +0000 | [diff] [blame] | 206 | bool isCoalescableExtInstr(const MachineInstr &MI, | 
|  | 207 | unsigned &SrcReg, unsigned &DstReg, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 208 | unsigned &SubIdx) const override; | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 209 | unsigned isLoadFromStackSlot(const MachineInstr &MI, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 210 | int &FrameIndex) const override; | 
| Lei Huang | 84dbbfd | 2017-06-21 17:17:56 +0000 | [diff] [blame] | 211 | bool isReallyTriviallyReMaterializable(const MachineInstr &MI, | 
|  | 212 | AliasAnalysis *AA) const override; | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 213 | unsigned isStoreToStackSlot(const MachineInstr &MI, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 214 | int &FrameIndex) const override; | 
| Chris Lattner | bb53acd | 2006-02-02 20:12:32 +0000 | [diff] [blame] | 215 |  | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 216 | bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 217 | unsigned &SrcOpIdx2) const override; | 
| Hal Finkel | 6c32ff3 | 2014-03-25 19:26:43 +0000 | [diff] [blame] | 218 |  | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 219 | void insertNoop(MachineBasicBlock &MBB, | 
|  | 220 | MachineBasicBlock::iterator MI) const override; | 
| Chris Lattner | ea79d9fd73 | 2006-03-05 23:49:55 +0000 | [diff] [blame] | 221 |  | 
| Chris Lattner | a47294ed | 2006-10-13 21:21:17 +0000 | [diff] [blame] | 222 |  | 
|  | 223 | // Branch analysis. | 
| Jacques Pienaar | 71c30a1 | 2016-07-15 14:41:04 +0000 | [diff] [blame] | 224 | bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 225 | MachineBasicBlock *&FBB, | 
|  | 226 | SmallVectorImpl<MachineOperand> &Cond, | 
|  | 227 | bool AllowModify) const override; | 
| Matt Arsenault | 1b9fc8e | 2016-09-14 20:43:16 +0000 | [diff] [blame] | 228 | unsigned removeBranch(MachineBasicBlock &MBB, | 
| Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame] | 229 | int *BytesRemoved = nullptr) const override; | 
| Matt Arsenault | e8e0f5c | 2016-09-14 17:24:15 +0000 | [diff] [blame] | 230 | unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, | 
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 231 | MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond, | 
| Matt Arsenault | a2b036e | 2016-09-14 17:23:48 +0000 | [diff] [blame] | 232 | const DebugLoc &DL, | 
|  | 233 | int *BytesAdded = nullptr) const override; | 
| Hal Finkel | ed6a285 | 2013-04-05 23:29:01 +0000 | [diff] [blame] | 234 |  | 
|  | 235 | // Select analysis. | 
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 236 | bool canInsertSelect(const MachineBasicBlock &, ArrayRef<MachineOperand> Cond, | 
|  | 237 | unsigned, unsigned, int &, int &, int &) const override; | 
|  | 238 | void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, | 
| Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 239 | const DebugLoc &DL, unsigned DstReg, | 
|  | 240 | ArrayRef<MachineOperand> Cond, unsigned TrueReg, | 
|  | 241 | unsigned FalseReg) const override; | 
| Hal Finkel | ed6a285 | 2013-04-05 23:29:01 +0000 | [diff] [blame] | 242 |  | 
| Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 243 | void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, | 
|  | 244 | const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 245 | bool KillSrc) const override; | 
| Andrew Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 246 |  | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 247 | 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 Anderson | eee1460 | 2008-01-01 21:11:32 +0000 | [diff] [blame] | 252 |  | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 253 | void loadRegFromStackSlot(MachineBasicBlock &MBB, | 
|  | 254 | MachineBasicBlock::iterator MBBI, | 
|  | 255 | unsigned DestReg, int FrameIndex, | 
|  | 256 | const TargetRegisterClass *RC, | 
|  | 257 | const TargetRegisterInfo *TRI) const override; | 
| Andrew Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 258 |  | 
| Stefan Pintilie | 26d4f92 | 2018-03-26 17:39:18 +0000 | [diff] [blame] | 259 | unsigned getStoreOpcodeForSpill(unsigned Reg, | 
|  | 260 | const TargetRegisterClass *RC = nullptr) const; | 
|  | 261 |  | 
|  | 262 | unsigned getLoadOpcodeForSpill(unsigned Reg, | 
|  | 263 | const TargetRegisterClass *RC = nullptr) const; | 
|  | 264 |  | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 265 | bool | 
| Matt Arsenault | 1b9fc8e | 2016-09-14 20:43:16 +0000 | [diff] [blame] | 266 | reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override; | 
| Andrew Trick | c416ba6 | 2010-12-24 04:28:06 +0000 | [diff] [blame] | 267 |  | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 268 | bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, | 
|  | 269 | MachineRegisterInfo *MRI) const override; | 
| Hal Finkel | d61d4f8 | 2013-04-06 19:30:30 +0000 | [diff] [blame] | 270 |  | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 271 | // 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 Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 274 | bool isProfitableToIfCvt(MachineBasicBlock &MBB, | 
|  | 275 | unsigned NumCycles, unsigned ExtraPredCycles, | 
| Cong Hou | c536bd9 | 2015-09-10 23:10:42 +0000 | [diff] [blame] | 276 | BranchProbability Probability) const override { | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 277 | return true; | 
|  | 278 | } | 
|  | 279 |  | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 280 | bool isProfitableToIfCvt(MachineBasicBlock &TMBB, | 
|  | 281 | unsigned NumT, unsigned ExtraT, | 
|  | 282 | MachineBasicBlock &FMBB, | 
|  | 283 | unsigned NumF, unsigned ExtraF, | 
| Cong Hou | c536bd9 | 2015-09-10 23:10:42 +0000 | [diff] [blame] | 284 | BranchProbability Probability) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 285 |  | 
| Cong Hou | c536bd9 | 2015-09-10 23:10:42 +0000 | [diff] [blame] | 286 | bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, | 
|  | 287 | BranchProbability Probability) const override { | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 288 | return true; | 
|  | 289 | } | 
|  | 290 |  | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 291 | bool isProfitableToUnpredicate(MachineBasicBlock &TMBB, | 
|  | 292 | MachineBasicBlock &FMBB) const override { | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 293 | return false; | 
|  | 294 | } | 
|  | 295 |  | 
|  | 296 | // Predication support. | 
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 297 | bool isPredicated(const MachineInstr &MI) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 298 |  | 
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 299 | bool isUnpredicatedTerminator(const MachineInstr &MI) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 300 |  | 
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 301 | bool PredicateInstruction(MachineInstr &MI, | 
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 302 | ArrayRef<MachineOperand> Pred) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 303 |  | 
| Ahmed Bougacha | c88bf54 | 2015-06-11 19:30:37 +0000 | [diff] [blame] | 304 | bool SubsumesPredicate(ArrayRef<MachineOperand> Pred1, | 
|  | 305 | ArrayRef<MachineOperand> Pred2) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 306 |  | 
| Duncan P. N. Exon Smith | 6307eb5 | 2016-02-23 02:46:52 +0000 | [diff] [blame] | 307 | bool DefinesPredicate(MachineInstr &MI, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 308 | std::vector<MachineOperand> &Pred) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 309 |  | 
| Krzysztof Parzyszek | cc31871 | 2017-03-03 18:30:54 +0000 | [diff] [blame] | 310 | bool isPredicable(const MachineInstr &MI) const override; | 
| Hal Finkel | 5711eca | 2013-04-09 22:58:37 +0000 | [diff] [blame] | 311 |  | 
| Hal Finkel | 82656cb | 2013-04-18 22:15:08 +0000 | [diff] [blame] | 312 | // Comparison optimization. | 
|  | 313 |  | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 314 | bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, | 
|  | 315 | unsigned &SrcReg2, int &Mask, int &Value) const override; | 
| Hal Finkel | 82656cb | 2013-04-18 22:15:08 +0000 | [diff] [blame] | 316 |  | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 317 | bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, | 
|  | 318 | unsigned SrcReg2, int Mask, int Value, | 
| Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 319 | const MachineRegisterInfo *MRI) const override; | 
| Hal Finkel | 82656cb | 2013-04-18 22:15:08 +0000 | [diff] [blame] | 320 |  | 
| Nicolas Geoffray | ae84bbd | 2008-04-16 20:10:13 +0000 | [diff] [blame] | 321 | /// GetInstSize - Return the number of bytes of code the specified | 
|  | 322 | /// instruction may be.  This returns the maximum number of bytes. | 
|  | 323 | /// | 
| Sjoerd Meijer | 0eb96ed | 2016-07-29 08:16:16 +0000 | [diff] [blame] | 324 | unsigned getInstSizeInBytes(const MachineInstr &MI) const override; | 
| Joerg Sonnenberger | 7ee0f31 | 2014-08-08 19:13:23 +0000 | [diff] [blame] | 325 |  | 
| Hans Wennborg | 9b9a535 | 2017-04-21 21:48:41 +0000 | [diff] [blame] | 326 | void getNoop(MCInst &NopInst) const override; | 
| Hal Finkel | 2d55698 | 2015-08-30 07:50:35 +0000 | [diff] [blame] | 327 |  | 
|  | 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 Shen | a1d8bc5 | 2016-04-19 20:14:52 +0000 | [diff] [blame] | 336 |  | 
| Tony Jiang | 438bf4a | 2017-11-20 14:38:30 +0000 | [diff] [blame] | 337 | // Expand VSX Memory Pseudo instruction to either a VSX or a FP instruction. | 
|  | 338 | bool expandVSXMemPseudo(MachineInstr &MI) const; | 
|  | 339 |  | 
| Tim Shen | a1d8bc5 | 2016-04-19 20:14:52 +0000 | [diff] [blame] | 340 | // Lower pseudo instructions after register allocation. | 
| Duncan P. N. Exon Smith | 9cfc75c | 2016-06-30 00:01:54 +0000 | [diff] [blame] | 341 | bool expandPostRAPseudo(MachineInstr &MI) const override; | 
| Nemanja Ivanovic | 11049f8 | 2016-10-04 06:59:23 +0000 | [diff] [blame] | 342 |  | 
|  | 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 Ivanovic | e597bd8 | 2017-05-31 05:40:25 +0000 | [diff] [blame] | 350 | static int getRecordFormOpcode(unsigned Opcode); | 
| Hiroshi Inoue | e3a3e3c | 2017-10-16 04:12:57 +0000 | [diff] [blame] | 351 |  | 
| Zaara Syeda | f94d58d | 2017-11-27 20:26:36 +0000 | [diff] [blame] | 352 | bool isTOCSaveMI(const MachineInstr &MI) const; | 
|  | 353 |  | 
| Hiroshi Inoue | e3a3e3c | 2017-10-16 04:12:57 +0000 | [diff] [blame] | 354 | 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 Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 368 |  | 
|  | 369 | bool convertToImmediateForm(MachineInstr &MI, | 
|  | 370 | MachineInstr **KilledDef = nullptr) const; | 
|  | 371 | void replaceInstrWithLI(MachineInstr &MI, const LoadImmediateInfo &LII) const; | 
|  | 372 |  | 
| Nemanja Ivanovic | 6995e5d | 2017-12-15 07:27:53 +0000 | [diff] [blame] | 373 | bool instrHasImmForm(const MachineInstr &MI, ImmInstrInfo &III) const; | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 374 | }; | 
|  | 375 |  | 
| Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 376 | } | 
| Misha Brukman | 116f927 | 2004-08-17 04:55:41 +0000 | [diff] [blame] | 377 |  | 
|  | 378 | #endif |