blob: e64876073ccf1dedbdc9c808065ca860e7b0c295 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86InstrInfo.h - X86 Instruction Information ------------*- C++ -*-===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00002//
John Criswell29265fe2003-10-21 15:17:13 +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 Brukmanc88330a2005-04-21 23:38:14 +00007//
John Criswell29265fe2003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Chris Lattnerd92fb002002-10-25 22:55:53 +00009//
Chris Lattnerb4d58d72003-01-14 22:00:31 +000010// This file contains the X86 implementation of the TargetInstrInfo class.
Chris Lattnerd92fb002002-10-25 22:55:53 +000011//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_X86_X86INSTRINFO_H
15#define LLVM_LIB_TARGET_X86_X86INSTRINFO_H
Chris Lattnerd92fb002002-10-25 22:55:53 +000016
Craig Topperc6d4efa2014-03-19 06:53:25 +000017#include "MCTargetDesc/X86BaseInfo.h"
Vyacheslav Klochkov6daefcf2016-08-11 22:07:33 +000018#include "X86InstrFMA3Info.h"
Chris Lattnerd92fb002002-10-25 22:55:53 +000019#include "X86RegisterInfo.h"
Dan Gohman906152a2009-01-05 17:59:02 +000020#include "llvm/ADT/DenseMap.h"
Craig Topperb25fda92012-03-17 18:46:09 +000021#include "llvm/Target/TargetInstrInfo.h"
Chris Lattnerd92fb002002-10-25 22:55:53 +000022
Evan Cheng703a0fb2011-07-01 17:57:27 +000023#define GET_INSTRINFO_HEADER
24#include "X86GenInstrInfo.inc"
25
Brian Gaeke960707c2003-11-11 22:41:34 +000026namespace llvm {
Hans Wennborg4ae51192016-03-25 01:10:56 +000027 class MachineInstrBuilder;
Evan Cheng11b0a5d2006-09-08 06:48:29 +000028 class X86RegisterInfo;
Eric Christopher6c786a12014-06-10 22:34:31 +000029 class X86Subtarget;
Brian Gaeke960707c2003-11-11 22:41:34 +000030
Chris Lattnerc0fb5672006-10-20 17:42:20 +000031namespace X86 {
32 // X86 specific condition code. These correspond to X86_*_COND in
33 // X86InstrInfo.td. They must be kept in synch.
Cong Hou94710842016-03-23 21:45:37 +000034enum CondCode {
35 COND_A = 0,
36 COND_AE = 1,
37 COND_B = 2,
38 COND_BE = 3,
39 COND_E = 4,
40 COND_G = 5,
41 COND_GE = 6,
42 COND_L = 7,
43 COND_LE = 8,
44 COND_NE = 9,
45 COND_NO = 10,
46 COND_NP = 11,
47 COND_NS = 12,
48 COND_O = 13,
49 COND_P = 14,
50 COND_S = 15,
51 LAST_VALID_COND = COND_S,
Dan Gohman97d95d62008-10-21 03:29:32 +000052
Cong Hou94710842016-03-23 21:45:37 +000053 // Artificial condition codes. These are used by AnalyzeBranch
54 // to indicate a block terminated with two conditional branches that together
55 // form a compound condition. They occur in code using FCMP_OEQ or FCMP_UNE,
56 // which can't be represented on x86 with a single condition. These
57 // are never used in MachineInstrs and are inverses of one another.
58 COND_NE_OR_P,
59 COND_E_AND_NP,
Dan Gohman97d95d62008-10-21 03:29:32 +000060
Cong Hou94710842016-03-23 21:45:37 +000061 COND_INVALID
62};
Andrew Trick27c079e2011-03-05 06:31:54 +000063
Cong Hou94710842016-03-23 21:45:37 +000064// Turn condition code into conditional branch opcode.
65unsigned GetCondBranchFromCond(CondCode CC);
Andrew Trick27c079e2011-03-05 06:31:54 +000066
Igor Bregerdb754552017-05-11 06:36:37 +000067/// \brief Return a pair of condition code for the given predicate and whether
68/// the instruction operands should be swaped to match the condition code.
69std::pair<CondCode, bool> getX86ConditionCode(CmpInst::Predicate Predicate);
70
Cong Hou94710842016-03-23 21:45:37 +000071/// \brief Return a set opcode for the given condition and whether it has
72/// a memory operand.
73unsigned getSETFromCond(CondCode CC, bool HasMemoryOperand = false);
Juergen Ributzka2da1bbc2014-06-16 23:58:24 +000074
Cong Hou94710842016-03-23 21:45:37 +000075/// \brief Return a cmov opcode for the given condition, register size in
76/// bytes, and operand type.
77unsigned getCMovFromCond(CondCode CC, unsigned RegBytes,
78 bool HasMemoryOperand = false);
Juergen Ributzka6ef06f92014-06-23 21:55:36 +000079
Cong Hou94710842016-03-23 21:45:37 +000080// Turn CMov opcode into condition code.
81CondCode getCondFromCMovOpc(unsigned Opc);
Michael Liao32376622012-09-20 03:06:15 +000082
Cong Hou94710842016-03-23 21:45:37 +000083/// GetOppositeBranchCondition - Return the inverse of the specified cond,
84/// e.g. turning COND_E to COND_NE.
85CondCode GetOppositeBranchCondition(CondCode CC);
Alexander Kornienkof00654e2015-06-23 09:49:53 +000086} // end namespace X86;
Chris Lattner3a897f32006-10-21 05:52:40 +000087
Chris Lattner377f1d52009-07-10 06:06:17 +000088
Chris Lattnerca9d7842009-07-10 06:29:59 +000089/// isGlobalStubReference - Return true if the specified TargetFlag operand is
Chris Lattner377f1d52009-07-10 06:06:17 +000090/// a reference to a stub for a global, not the global itself.
Chris Lattnerca9d7842009-07-10 06:29:59 +000091inline static bool isGlobalStubReference(unsigned char TargetFlag) {
92 switch (TargetFlag) {
Chris Lattner377f1d52009-07-10 06:06:17 +000093 case X86II::MO_DLLIMPORT: // dllimport stub.
94 case X86II::MO_GOTPCREL: // rip-relative GOT reference.
95 case X86II::MO_GOT: // normal GOT reference.
96 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Normal $non_lazy_ptr ref.
97 case X86II::MO_DARWIN_NONLAZY: // Normal $non_lazy_ptr ref.
Chris Lattner377f1d52009-07-10 06:06:17 +000098 return true;
99 default:
100 return false;
101 }
102}
Chris Lattnerd3f32c72009-07-10 07:33:30 +0000103
104/// isGlobalRelativeToPICBase - Return true if the specified global value
105/// reference is relative to a 32-bit PIC base (X86ISD::GlobalBaseReg). If this
106/// is true, the addressing mode has the PIC base register added in (e.g. EBX).
107inline static bool isGlobalRelativeToPICBase(unsigned char TargetFlag) {
108 switch (TargetFlag) {
109 case X86II::MO_GOTOFF: // isPICStyleGOT: local global.
110 case X86II::MO_GOT: // isPICStyleGOT: other global.
111 case X86II::MO_PIC_BASE_OFFSET: // Darwin local global.
112 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Darwin/32 external global.
Eric Christopherb0e1a452010-06-03 04:07:48 +0000113 case X86II::MO_TLVP: // ??? Pretty sure..
Chris Lattnerd3f32c72009-07-10 07:33:30 +0000114 return true;
115 default:
116 return false;
117 }
118}
Andrew Trick27c079e2011-03-05 06:31:54 +0000119
Anton Korobeynikov4e9dfe82008-06-28 11:07:54 +0000120inline static bool isScale(const MachineOperand &MO) {
Dan Gohman0d1e9a82008-10-03 15:45:36 +0000121 return MO.isImm() &&
Anton Korobeynikov4e9dfe82008-06-28 11:07:54 +0000122 (MO.getImm() == 1 || MO.getImm() == 2 ||
123 MO.getImm() == 4 || MO.getImm() == 8);
124}
125
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000126inline static bool isLeaMem(const MachineInstr &MI, unsigned Op) {
127 if (MI.getOperand(Op).isFI())
128 return true;
129 return Op + X86::AddrSegmentReg <= MI.getNumOperands() &&
130 MI.getOperand(Op + X86::AddrBaseReg).isReg() &&
131 isScale(MI.getOperand(Op + X86::AddrScaleAmt)) &&
132 MI.getOperand(Op + X86::AddrIndexReg).isReg() &&
133 (MI.getOperand(Op + X86::AddrDisp).isImm() ||
134 MI.getOperand(Op + X86::AddrDisp).isGlobal() ||
135 MI.getOperand(Op + X86::AddrDisp).isCPI() ||
136 MI.getOperand(Op + X86::AddrDisp).isJTI());
Anton Korobeynikov4e9dfe82008-06-28 11:07:54 +0000137}
138
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000139inline static bool isMem(const MachineInstr &MI, unsigned Op) {
140 if (MI.getOperand(Op).isFI())
141 return true;
142 return Op + X86::AddrNumOperands <= MI.getNumOperands() &&
143 MI.getOperand(Op + X86::AddrSegmentReg).isReg() && isLeaMem(MI, Op);
Rafael Espindola3b2df102009-04-08 21:14:34 +0000144}
145
Craig Topperec828472014-03-31 06:53:13 +0000146class X86InstrInfo final : public X86GenInstrInfo {
Eric Christopher6c786a12014-06-10 22:34:31 +0000147 X86Subtarget &Subtarget;
Chris Lattnerd92fb002002-10-25 22:55:53 +0000148 const X86RegisterInfo RI;
Andrew Trick27c079e2011-03-05 06:31:54 +0000149
Craig Topper9eadcfd2012-06-01 05:34:01 +0000150 /// RegOp2MemOpTable3Addr, RegOp2MemOpTable0, RegOp2MemOpTable1,
151 /// RegOp2MemOpTable2, RegOp2MemOpTable3 - Load / store folding opcode maps.
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000152 ///
Bruno Cardoso Lopes23eb5262011-09-08 18:35:57 +0000153 typedef DenseMap<unsigned,
Craig Toppere012ede2016-04-30 17:59:49 +0000154 std::pair<uint16_t, uint16_t> > RegOp2MemOpTableType;
Bruno Cardoso Lopes23eb5262011-09-08 18:35:57 +0000155 RegOp2MemOpTableType RegOp2MemOpTable2Addr;
156 RegOp2MemOpTableType RegOp2MemOpTable0;
157 RegOp2MemOpTableType RegOp2MemOpTable1;
158 RegOp2MemOpTableType RegOp2MemOpTable2;
Elena Demikhovsky602f3a22012-05-31 09:20:20 +0000159 RegOp2MemOpTableType RegOp2MemOpTable3;
Robert Khasanov79fb7292014-12-18 12:28:22 +0000160 RegOp2MemOpTableType RegOp2MemOpTable4;
Andrew Trick27c079e2011-03-05 06:31:54 +0000161
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000162 /// MemOp2RegOpTable - Load / store unfolding opcode map.
163 ///
Bruno Cardoso Lopes23eb5262011-09-08 18:35:57 +0000164 typedef DenseMap<unsigned,
Craig Toppere012ede2016-04-30 17:59:49 +0000165 std::pair<uint16_t, uint16_t> > MemOp2RegOpTableType;
Bruno Cardoso Lopes23eb5262011-09-08 18:35:57 +0000166 MemOp2RegOpTableType MemOp2RegOpTable;
167
Craig Topperd9c7d0d2012-06-23 04:58:41 +0000168 static void AddTableEntry(RegOp2MemOpTableType &R2MTable,
169 MemOp2RegOpTableType &M2RTable,
Craig Toppere012ede2016-04-30 17:59:49 +0000170 uint16_t RegOp, uint16_t MemOp, uint16_t Flags);
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +0000171
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +0000172 virtual void anchor();
173
Sanjoy Das6b34a462015-06-15 18:44:21 +0000174 bool AnalyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
175 MachineBasicBlock *&FBB,
176 SmallVectorImpl<MachineOperand> &Cond,
177 SmallVectorImpl<MachineInstr *> &CondBranches,
178 bool AllowModify) const;
179
Chris Lattnerd92fb002002-10-25 22:55:53 +0000180public:
Eric Christopher6c786a12014-06-10 22:34:31 +0000181 explicit X86InstrInfo(X86Subtarget &STI);
Chris Lattnerd92fb002002-10-25 22:55:53 +0000182
Chris Lattnerb4d58d72003-01-14 22:00:31 +0000183 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
Chris Lattnerd92fb002002-10-25 22:55:53 +0000184 /// such, whenever a client has an instance of instruction info, it should
185 /// always be able to get register info as well (through this method).
186 ///
Craig Topperf5e3b0b2014-03-09 07:58:15 +0000187 const X86RegisterInfo &getRegisterInfo() const { return RI; }
Chris Lattnerd92fb002002-10-25 22:55:53 +0000188
Serge Pavlov49acf9c2017-04-13 14:10:52 +0000189 /// Returns the stack pointer adjustment that happens inside the frame
190 /// setup..destroy sequence (e.g. by pushes, or inside the callee).
191 int64_t getFrameAdjustment(const MachineInstr &I) const {
192 assert(isFrameInstr(I));
Serge Pavlovd526b132017-05-09 13:35:13 +0000193 if (isFrameSetup(I))
194 return I.getOperand(2).getImm();
Serge Pavlov49acf9c2017-04-13 14:10:52 +0000195 return I.getOperand(1).getImm();
196 }
197
198 /// Sets the stack pointer adjustment made inside the frame made up by this
199 /// instruction.
200 void setFrameAdjustment(MachineInstr &I, int64_t V) const {
201 assert(isFrameInstr(I));
Serge Pavlovd526b132017-05-09 13:35:13 +0000202 if (isFrameSetup(I))
203 I.getOperand(2).setImm(V);
204 else
205 I.getOperand(1).setImm(V);
Serge Pavlov49acf9c2017-04-13 14:10:52 +0000206 }
207
Michael Kuperstein13fbd452015-02-01 16:56:04 +0000208 /// getSPAdjust - This returns the stack pointer adjustment made by
209 /// this instruction. For x86, we need to handle more complex call
210 /// sequences involving PUSHes.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000211 int getSPAdjust(const MachineInstr &MI) const override;
Michael Kuperstein13fbd452015-02-01 16:56:04 +0000212
Evan Cheng30bebff2010-01-13 00:30:23 +0000213 /// isCoalescableExtInstr - Return true if the instruction is a "coalescable"
214 /// extension instruction. That is, it's like a copy where it's legal for the
215 /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns
216 /// true, then it's expected the pre-extension value is available as a subreg
217 /// of the result register. This also returns the sub-register index in
218 /// SubIdx.
Craig Topper2d9361e2014-03-09 07:44:38 +0000219 bool isCoalescableExtInstr(const MachineInstr &MI,
220 unsigned &SrcReg, unsigned &DstReg,
221 unsigned &SubIdx) const override;
Evan Cheng42166152010-01-12 00:09:37 +0000222
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000223 unsigned isLoadFromStackSlot(const MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000224 int &FrameIndex) const override;
David Greene2f4c3742009-11-13 00:29:53 +0000225 /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination
226 /// stack locations as well. This uses a heuristic so it isn't
227 /// reliable for correctness.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000228 unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000229 int &FrameIndex) const override;
David Greene70fdd572009-11-12 20:55:29 +0000230
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000231 unsigned isStoreToStackSlot(const MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000232 int &FrameIndex) const override;
David Greene2f4c3742009-11-13 00:29:53 +0000233 /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
234 /// stack locations as well. This uses a heuristic so it isn't
235 /// reliable for correctness.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000236 unsigned isStoreToStackSlotPostFE(const MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000237 int &FrameIndex) const override;
Evan Chenged6e34f2008-03-31 20:40:39 +0000238
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000239 bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000240 AliasAnalysis *AA) const override;
Evan Chenged6e34f2008-03-31 20:40:39 +0000241 void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
Evan Cheng84517442009-07-16 09:20:10 +0000242 unsigned DestReg, unsigned SubIdx,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000243 const MachineInstr &Orig,
Craig Topper2d9361e2014-03-09 07:44:38 +0000244 const TargetRegisterInfo &TRI) const override;
Evan Chenged6e34f2008-03-31 20:40:39 +0000245
Tim Northover6833e3f2013-06-10 20:43:49 +0000246 /// Given an operand within a MachineInstr, insert preceding code to put it
247 /// into the right format for a particular kind of LEA instruction. This may
248 /// involve using an appropriate super-register instead (with an implicit use
249 /// of the original) or creating a new virtual register and inserting COPY
250 /// instructions to get the data into the right class.
251 ///
252 /// Reference parameters are set to indicate how caller should add this
253 /// operand to the LEA instruction.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000254 bool classifyLEAReg(MachineInstr &MI, const MachineOperand &Src,
255 unsigned LEAOpcode, bool AllowSP, unsigned &NewSrc,
256 bool &isKill, bool &isUndef,
Matthias Braun7313ca62016-08-09 01:47:26 +0000257 MachineOperand &ImplicitOp, LiveVariables *LV) const;
Tim Northover6833e3f2013-06-10 20:43:49 +0000258
Chris Lattnerb7782d72005-01-02 02:37:07 +0000259 /// convertToThreeAddress - This method must be implemented by targets that
260 /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target
261 /// may be able to convert a two-address instruction into a true
262 /// three-address instruction on demand. This allows the X86 target (for
263 /// example) to convert ADD and SHL instructions into LEA instructions if they
264 /// would require register copies due to two-addressness.
265 ///
266 /// This method returns a null pointer if the transformation cannot be
267 /// performed, otherwise it returns the new instruction.
268 ///
Craig Topper2d9361e2014-03-09 07:44:38 +0000269 MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000270 MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000271 LiveVariables *LV) const override;
Chris Lattnerb7782d72005-01-02 02:37:07 +0000272
Andrew Kaylor16c4da02015-09-28 20:33:22 +0000273 /// Returns true iff the routine could find two commutable operands in the
274 /// given machine instruction.
275 /// The 'SrcOpIdx1' and 'SrcOpIdx2' are INPUT and OUTPUT arguments. Their
276 /// input values can be re-defined in this method only if the input values
277 /// are not pre-defined, which is designated by the special value
278 /// 'CommuteAnyOperandIndex' assigned to it.
279 /// If both of indices are pre-defined and refer to some operands, then the
280 /// method simply returns true if the corresponding operands are commutable
281 /// and returns false otherwise.
Chris Lattner29478012005-01-19 07:11:01 +0000282 ///
Andrew Kaylor16c4da02015-09-28 20:33:22 +0000283 /// For example, calling this method this way:
284 /// unsigned Op1 = 1, Op2 = CommuteAnyOperandIndex;
285 /// findCommutedOpIndices(MI, Op1, Op2);
286 /// can be interpreted as a query asking to find an operand that would be
287 /// commutable with the operand#1.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000288 bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
Lang Hamesc59a2d02014-04-02 23:57:49 +0000289 unsigned &SrcOpIdx2) const override;
290
Andrew Kaylor4731bea2015-11-06 19:47:25 +0000291 /// Returns true if the routine could find two commutable operands
Vyacheslav Klochkov6daefcf2016-08-11 22:07:33 +0000292 /// in the given FMA instruction \p MI. Otherwise, returns false.
Andrew Kaylor4731bea2015-11-06 19:47:25 +0000293 ///
294 /// \p SrcOpIdx1 and \p SrcOpIdx2 are INPUT and OUTPUT arguments.
295 /// The output indices of the commuted operands are returned in these
296 /// arguments. Also, the input values of these arguments may be preset either
297 /// to indices of operands that must be commuted or be equal to a special
298 /// value 'CommuteAnyOperandIndex' which means that the corresponding
299 /// operand index is not set and this method is free to pick any of
300 /// available commutable operands.
Vyacheslav Klochkov6daefcf2016-08-11 22:07:33 +0000301 /// The parameter \p FMA3Group keeps the reference to the group of relative
302 /// FMA3 opcodes including register/memory forms of 132/213/231 opcodes.
Andrew Kaylor4731bea2015-11-06 19:47:25 +0000303 ///
304 /// For example, calling this method this way:
305 /// unsigned Idx1 = 1, Idx2 = CommuteAnyOperandIndex;
Vyacheslav Klochkov6daefcf2016-08-11 22:07:33 +0000306 /// findFMA3CommutedOpIndices(MI, Idx1, Idx2, FMA3Group);
Andrew Kaylor4731bea2015-11-06 19:47:25 +0000307 /// can be interpreted as a query asking if the operand #1 can be swapped
308 /// with any other available operand (e.g. operand #2, operand #3, etc.).
309 ///
310 /// The returned FMA opcode may differ from the opcode in the given MI.
311 /// For example, commuting the operands #1 and #3 in the following FMA
312 /// FMA213 #1, #2, #3
313 /// results into instruction with adjusted opcode:
314 /// FMA231 #3, #2, #1
Vyacheslav Klochkov6daefcf2016-08-11 22:07:33 +0000315 bool findFMA3CommutedOpIndices(const MachineInstr &MI,
Craig Topper6172b0b2016-07-23 07:16:53 +0000316 unsigned &SrcOpIdx1,
Vyacheslav Klochkov6daefcf2016-08-11 22:07:33 +0000317 unsigned &SrcOpIdx2,
318 const X86InstrFMA3Group &FMA3Group) const;
319
320 /// Returns an adjusted FMA opcode that must be used in FMA instruction that
321 /// performs the same computations as the given \p MI but which has the
322 /// operands \p SrcOpIdx1 and \p SrcOpIdx2 commuted.
323 /// It may return 0 if it is unsafe to commute the operands.
324 /// Note that a machine instruction (instead of its opcode) is passed as the
325 /// first parameter to make it possible to analyze the instruction's uses and
326 /// commute the first operand of FMA even when it seems unsafe when you look
327 /// at the opcode. For example, it is Ok to commute the first operand of
328 /// VFMADD*SD_Int, if ONLY the lowest 64-bit element of the result is used.
329 ///
330 /// The returned FMA opcode may differ from the opcode in the given \p MI.
331 /// For example, commuting the operands #1 and #3 in the following FMA
332 /// FMA213 #1, #2, #3
333 /// results into instruction with adjusted opcode:
334 /// FMA231 #3, #2, #1
335 unsigned getFMA3OpcodeToCommuteOperands(const MachineInstr &MI,
336 unsigned SrcOpIdx1,
337 unsigned SrcOpIdx2,
338 const X86InstrFMA3Group &FMA3Group) const;
Andrew Kaylor4731bea2015-11-06 19:47:25 +0000339
Chris Lattnerc0fb5672006-10-20 17:42:20 +0000340 // Branch analysis.
Duncan P. N. Exon Smith6307eb52016-02-23 02:46:52 +0000341 bool isUnpredicatedTerminator(const MachineInstr &MI) const override;
Hans Wennborga4686012017-02-16 00:04:05 +0000342 bool isUnconditionalTailCall(const MachineInstr &MI) const override;
343 bool canMakeTailCallConditional(SmallVectorImpl<MachineOperand> &Cond,
344 const MachineInstr &TailCall) const override;
345 void replaceBranchWithTailCall(MachineBasicBlock &MBB,
346 SmallVectorImpl<MachineOperand> &Cond,
347 const MachineInstr &TailCall) const override;
348
Jacques Pienaar71c30a12016-07-15 14:41:04 +0000349 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
Craig Topper2d9361e2014-03-09 07:44:38 +0000350 MachineBasicBlock *&FBB,
351 SmallVectorImpl<MachineOperand> &Cond,
352 bool AllowModify) const override;
Sanjoy Dasb666ea32015-06-15 18:44:14 +0000353
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000354 bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg,
Chad Rosierc27a18f2016-03-09 16:00:35 +0000355 int64_t &Offset,
Sanjoy Dasb666ea32015-06-15 18:44:14 +0000356 const TargetRegisterInfo *TRI) const override;
Jacques Pienaar71c30a12016-07-15 14:41:04 +0000357 bool analyzeBranchPredicate(MachineBasicBlock &MBB,
Sanjoy Das6b34a462015-06-15 18:44:21 +0000358 TargetInstrInfo::MachineBranchPredicate &MBP,
359 bool AllowModify = false) const override;
360
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000361 unsigned removeBranch(MachineBasicBlock &MBB,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000362 int *BytesRemoved = nullptr) const override;
Matt Arsenaulte8e0f5c2016-09-14 17:24:15 +0000363 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000364 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
Matt Arsenaulta2b036e2016-09-14 17:23:48 +0000365 const DebugLoc &DL,
366 int *BytesAdded = nullptr) const override;
Ahmed Bougachac88bf542015-06-11 19:30:37 +0000367 bool canInsertSelect(const MachineBasicBlock&, ArrayRef<MachineOperand> Cond,
Craig Topper2d9361e2014-03-09 07:44:38 +0000368 unsigned, unsigned, int&, int&, int&) const override;
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000369 void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
370 const DebugLoc &DL, unsigned DstReg,
371 ArrayRef<MachineOperand> Cond, unsigned TrueReg,
372 unsigned FalseReg) const override;
373 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
374 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
Craig Topper2d9361e2014-03-09 07:44:38 +0000375 bool KillSrc) const override;
376 void storeRegToStackSlot(MachineBasicBlock &MBB,
377 MachineBasicBlock::iterator MI,
378 unsigned SrcReg, bool isKill, int FrameIndex,
379 const TargetRegisterClass *RC,
380 const TargetRegisterInfo *TRI) const override;
Owen Andersoneee14602008-01-01 21:11:32 +0000381
Craig Topperf5e3b0b2014-03-09 07:58:15 +0000382 void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
383 SmallVectorImpl<MachineOperand> &Addr,
384 const TargetRegisterClass *RC,
385 MachineInstr::mmo_iterator MMOBegin,
386 MachineInstr::mmo_iterator MMOEnd,
387 SmallVectorImpl<MachineInstr*> &NewMIs) const;
Owen Andersoneee14602008-01-01 21:11:32 +0000388
Craig Topper2d9361e2014-03-09 07:44:38 +0000389 void loadRegFromStackSlot(MachineBasicBlock &MBB,
390 MachineBasicBlock::iterator MI,
391 unsigned DestReg, int FrameIndex,
392 const TargetRegisterClass *RC,
393 const TargetRegisterInfo *TRI) const override;
Owen Andersoneee14602008-01-01 21:11:32 +0000394
Craig Topperf5e3b0b2014-03-09 07:58:15 +0000395 void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
396 SmallVectorImpl<MachineOperand> &Addr,
397 const TargetRegisterClass *RC,
398 MachineInstr::mmo_iterator MMOBegin,
399 MachineInstr::mmo_iterator MMOEnd,
400 SmallVectorImpl<MachineInstr*> &NewMIs) const;
Jakob Stoklund Olesendd1904e2011-09-29 05:10:54 +0000401
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000402 bool expandPostRAPseudo(MachineInstr &MI) const override;
Jakob Stoklund Olesendd1904e2011-09-29 05:10:54 +0000403
Michael Kuperstein47eb85a2016-11-23 18:33:49 +0000404 /// Check whether the target can fold a load that feeds a subreg operand
405 /// (or a subreg operand that feeds a store).
406 bool isSubregFoldable() const override { return true; }
407
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000408 /// foldMemoryOperand - If this target supports it, fold a load or store of
409 /// the specified stack slot into the specified machine instruction for the
410 /// specified operand(s). If this is possible, the target should perform the
411 /// folding and return true, otherwise it should return false. If it folds
412 /// the instruction, it is likely that the MachineInstruction the iterator
413 /// references has been changed.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000414 MachineInstr *
415 foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI,
416 ArrayRef<unsigned> Ops,
417 MachineBasicBlock::iterator InsertPt, int FrameIndex,
418 LiveIntervals *LIS = nullptr) const override;
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000419
420 /// foldMemoryOperand - Same as the previous version except it allows folding
421 /// of any load and store from / to any address, not just from a specific
422 /// stack slot.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000423 MachineInstr *foldMemoryOperandImpl(
424 MachineFunction &MF, MachineInstr &MI, ArrayRef<unsigned> Ops,
425 MachineBasicBlock::iterator InsertPt, MachineInstr &LoadMI,
426 LiveIntervals *LIS = nullptr) const override;
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000427
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000428 /// unfoldMemoryOperand - Separate a single instruction which folded a load or
429 /// a store or a load and a store into two or more instruction. If this is
430 /// possible, returns true as well as the new instructions by reference.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000431 bool
432 unfoldMemoryOperand(MachineFunction &MF, MachineInstr &MI, unsigned Reg,
433 bool UnfoldLoad, bool UnfoldStore,
434 SmallVectorImpl<MachineInstr *> &NewMIs) const override;
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000435
Craig Topper2d9361e2014-03-09 07:44:38 +0000436 bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
437 SmallVectorImpl<SDNode*> &NewNodes) const override;
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000438
439 /// getOpcodeAfterMemoryUnfold - Returns the opcode of the would be new
440 /// instruction after load / store are unfolded from an instruction of the
441 /// specified opcode. It returns zero if the specified unfolding is not
Dan Gohman49fa51d2009-10-30 22:18:41 +0000442 /// possible. If LoadRegIndex is non-null, it is filled in with the operand
443 /// index of the operand which will hold the register holding the loaded
444 /// value.
Craig Topper2d9361e2014-03-09 07:44:38 +0000445 unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
446 bool UnfoldLoad, bool UnfoldStore,
Craig Toppere73658d2014-04-28 04:05:08 +0000447 unsigned *LoadRegIndex = nullptr) const override;
Andrew Trick27c079e2011-03-05 06:31:54 +0000448
Evan Cheng4f026f32010-01-22 03:34:51 +0000449 /// areLoadsFromSameBasePtr - This is used by the pre-regalloc scheduler
450 /// to determine if two loads are loading from the same base address. It
451 /// should only return true if the base pointers are the same and the
452 /// only differences between the two addresses are the offset. It also returns
453 /// the offsets by reference.
Craig Topper2d9361e2014-03-09 07:44:38 +0000454 bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1,
455 int64_t &Offset2) const override;
Evan Cheng4f026f32010-01-22 03:34:51 +0000456
457 /// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
Chris Lattner0ab5e2c2011-04-15 05:18:47 +0000458 /// determine (in conjunction with areLoadsFromSameBasePtr) if two loads should
Evan Cheng4f026f32010-01-22 03:34:51 +0000459 /// be scheduled togther. On some targets if two loads are loading from
460 /// addresses in the same cache line, it's better if they are scheduled
461 /// together. This function takes two integers that represent the load offsets
462 /// from the common base address. It returns true if it decides it's desirable
463 /// to schedule the two loads together. "NumLoads" is the number of loads that
464 /// have already been scheduled after Load1.
Craig Topper2d9361e2014-03-09 07:44:38 +0000465 bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
466 int64_t Offset1, int64_t Offset2,
467 unsigned NumLoads) const override;
Evan Cheng4f026f32010-01-22 03:34:51 +0000468
Hans Wennborg9b9a5352017-04-21 21:48:41 +0000469 void getNoop(MCInst &NopInst) const override;
Chris Lattner6a5e7062010-04-26 23:37:21 +0000470
Craig Topper2d9361e2014-03-09 07:44:38 +0000471 bool
Matt Arsenault1b9fc8e2016-09-14 20:43:16 +0000472 reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
Chris Lattner29478012005-01-19 07:11:01 +0000473
Evan Chengb5f0ec32009-02-06 17:17:30 +0000474 /// isSafeToMoveRegClassDefs - Return true if it's safe to move a machine
475 /// instruction that defines the specified register class.
Craig Topper2d9361e2014-03-09 07:44:38 +0000476 bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const override;
Evan Chengf7137222008-10-27 07:14:50 +0000477
Alexey Volkov6226de62014-05-20 08:55:50 +0000478 /// isSafeToClobberEFLAGS - Return true if it's safe insert an instruction tha
479 /// would clobber the EFLAGS condition register. Note the result may be
480 /// conservative. If it cannot definitely determine the safety after visiting
481 /// a few instructions in each direction it assumes it's not safe.
482 bool isSafeToClobberEFLAGS(MachineBasicBlock &MBB,
483 MachineBasicBlock::iterator I) const;
484
Andrew Kayloraf083d42015-08-26 20:36:52 +0000485 /// True if MI has a condition code def, e.g. EFLAGS, that is
486 /// not marked dead.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000487 bool hasLiveCondCodeDef(MachineInstr &MI) const;
Andrew Kayloraf083d42015-08-26 20:36:52 +0000488
Dan Gohman6ebe7342008-09-30 00:58:23 +0000489 /// getGlobalBaseReg - Return a virtual register initialized with the
490 /// the global base register value. Output instructions required to
491 /// initialize the register in the function entry block, if necessary.
Dan Gohman24300732008-09-23 18:22:58 +0000492 ///
Dan Gohman6ebe7342008-09-30 00:58:23 +0000493 unsigned getGlobalBaseReg(MachineFunction *MF) const;
Dan Gohman24300732008-09-23 18:22:58 +0000494
Jakob Stoklund Olesenb48c9942011-09-27 22:57:18 +0000495 std::pair<uint16_t, uint16_t>
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000496 getExecutionDomain(const MachineInstr &MI) const override;
Jakob Stoklund Olesenb551aa42010-03-29 23:24:21 +0000497
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000498 void setExecutionDomain(MachineInstr &MI, unsigned Domain) const override;
Jakob Stoklund Olesen49e121d2010-03-25 17:25:00 +0000499
Craig Topper2d9361e2014-03-09 07:44:38 +0000500 unsigned
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000501 getPartialRegUpdateClearance(const MachineInstr &MI, unsigned OpNum,
502 const TargetRegisterInfo *TRI) const override;
503 unsigned getUndefRegClearance(const MachineInstr &MI, unsigned &OpNum,
Craig Topper2d9361e2014-03-09 07:44:38 +0000504 const TargetRegisterInfo *TRI) const override;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000505 void breakPartialRegDependency(MachineInstr &MI, unsigned OpNum,
Craig Topper2d9361e2014-03-09 07:44:38 +0000506 const TargetRegisterInfo *TRI) const override;
Jakob Stoklund Olesenf8ad3362011-11-15 01:15:30 +0000507
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000508 MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI,
Chris Lattnereeba0c72010-09-05 02:18:34 +0000509 unsigned OpNum,
Benjamin Kramerf1362f62015-02-28 12:04:00 +0000510 ArrayRef<MachineOperand> MOs,
Keno Fischere70b31f2015-06-08 20:09:58 +0000511 MachineBasicBlock::iterator InsertPt,
Simon Pilgrim2f9548a2014-10-20 22:14:22 +0000512 unsigned Size, unsigned Alignment,
513 bool AllowCommute) const;
Evan Cheng63c76082010-10-19 18:58:51 +0000514
Craig Topper2d9361e2014-03-09 07:44:38 +0000515 bool isHighLatencyDef(int opc) const override;
Andrew Trick641e2d42011-03-05 08:00:22 +0000516
Matthias Braun88e21312015-06-13 03:42:11 +0000517 bool hasHighOperandLatency(const TargetSchedModel &SchedModel,
Evan Cheng63c76082010-10-19 18:58:51 +0000518 const MachineRegisterInfo *MRI,
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000519 const MachineInstr &DefMI, unsigned DefIdx,
520 const MachineInstr &UseMI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000521 unsigned UseIdx) const override;
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000522
Sanjay Patel08829ba2015-06-10 20:32:21 +0000523 bool useMachineCombiner() const override {
524 return true;
525 }
Chad Rosier03a47302015-09-21 15:09:11 +0000526
527 bool isAssociativeAndCommutative(const MachineInstr &Inst) const override;
528
529 bool hasReassociableOperands(const MachineInstr &Inst,
530 const MachineBasicBlock *MBB) const override;
531
532 void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2,
533 MachineInstr &NewMI1,
534 MachineInstr &NewMI2) const override;
Sanjay Patel08829ba2015-06-10 20:32:21 +0000535
Manman Renc9656732012-07-06 17:36:20 +0000536 /// analyzeCompare - For a comparison instruction, return the source registers
537 /// in SrcReg and SrcReg2 if having two register operands, and the value it
538 /// compares against in CmpValue. Return true if the comparison instruction
539 /// can be analyzed.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000540 bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg,
Craig Topper2d9361e2014-03-09 07:44:38 +0000541 unsigned &SrcReg2, int &CmpMask,
542 int &CmpValue) const override;
Manman Renc9656732012-07-06 17:36:20 +0000543
544 /// optimizeCompareInstr - Check if there exists an earlier instruction that
545 /// operates on the same source operands and sets flags in the same way as
546 /// Compare; remove Compare if possible.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000547 bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg,
Craig Topper2d9361e2014-03-09 07:44:38 +0000548 unsigned SrcReg2, int CmpMask, int CmpValue,
549 const MachineRegisterInfo *MRI) const override;
Manman Renc9656732012-07-06 17:36:20 +0000550
Manman Ren5759d012012-08-02 00:56:42 +0000551 /// optimizeLoadInstr - Try to remove the load by folding it to a register
552 /// operand at the use. We fold the load instructions if and only if the
Manman Renba8122c2012-08-02 19:37:32 +0000553 /// def and use are in the same BB. We only look at one load and see
554 /// whether it can be folded into MI. FoldAsLoadDefReg is the virtual register
555 /// defined by the load we are trying to fold. DefMI returns the machine
556 /// instruction that defines FoldAsLoadDefReg, and the function returns
557 /// the machine instruction generated due to folding.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000558 MachineInstr *optimizeLoadInstr(MachineInstr &MI,
Craig Topper2d9361e2014-03-09 07:44:38 +0000559 const MachineRegisterInfo *MRI,
560 unsigned &FoldAsLoadDefReg,
561 MachineInstr *&DefMI) const override;
Manman Ren5759d012012-08-02 00:56:42 +0000562
Alex Lorenz49873a82015-08-06 00:44:07 +0000563 std::pair<unsigned, unsigned>
564 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
565
566 ArrayRef<std::pair<unsigned, const char *>>
567 getSerializableDirectMachineOperandTargetFlags() const override;
568
Jessica Paquette596f4832017-03-06 21:31:18 +0000569 unsigned getOutliningBenefit(size_t SequenceSize,
Jessica Paquettec984e212017-03-13 18:39:33 +0000570 size_t Occurrences,
571 bool CanBeTailCall) const override;
Jessica Paquette596f4832017-03-06 21:31:18 +0000572
573 bool isFunctionSafeToOutlineFrom(MachineFunction &MF) const override;
574
575 llvm::X86GenInstrInfo::MachineOutlinerInstrType
576 getOutliningType(MachineInstr &MI) const override;
577
578 void insertOutlinerEpilogue(MachineBasicBlock &MBB,
Jessica Paquettec984e212017-03-13 18:39:33 +0000579 MachineFunction &MF,
580 bool IsTailCall) const override;
Jessica Paquette596f4832017-03-06 21:31:18 +0000581
582 void insertOutlinerPrologue(MachineBasicBlock &MBB,
Jessica Paquettec984e212017-03-13 18:39:33 +0000583 MachineFunction &MF,
584 bool isTailCall) const override;
Jessica Paquette596f4832017-03-06 21:31:18 +0000585
586 MachineBasicBlock::iterator
587 insertOutlinedCall(Module &M, MachineBasicBlock &MBB,
588 MachineBasicBlock::iterator &It,
Jessica Paquettec984e212017-03-13 18:39:33 +0000589 MachineFunction &MF,
590 bool IsTailCall) const override;
Andrew Kaylor16c4da02015-09-28 20:33:22 +0000591protected:
592 /// Commutes the operands in the given instruction by changing the operands
593 /// order and/or changing the instruction's opcode and/or the immediate value
594 /// operand.
595 ///
596 /// The arguments 'CommuteOpIdx1' and 'CommuteOpIdx2' specify the operands
597 /// to be commuted.
598 ///
599 /// Do not call this method for a non-commutable instruction or
600 /// non-commutable operands.
601 /// Even though the instruction is commutable, the method may still
602 /// fail to commute the operands, null pointer is returned in such cases.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000603 MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
Andrew Kaylor16c4da02015-09-28 20:33:22 +0000604 unsigned CommuteOpIdx1,
605 unsigned CommuteOpIdx2) const override;
606
Owen Anderson2a3be7b2008-01-07 01:35:02 +0000607private:
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000608 MachineInstr *convertToThreeAddressWithLEA(unsigned MIOpc,
609 MachineFunction::iterator &MFI,
610 MachineInstr &MI,
611 LiveVariables *LV) const;
Evan Cheng766a73f2009-12-11 06:01:48 +0000612
Simon Pilgrim7e6606f2015-11-04 20:48:09 +0000613 /// Handles memory folding for special case instructions, for instance those
614 /// requiring custom manipulation of the address.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000615 MachineInstr *foldMemoryOperandCustom(MachineFunction &MF, MachineInstr &MI,
Simon Pilgrim7e6606f2015-11-04 20:48:09 +0000616 unsigned OpNum,
617 ArrayRef<MachineOperand> MOs,
618 MachineBasicBlock::iterator InsertPt,
619 unsigned Size, unsigned Align) const;
620
David Greene70fdd572009-11-12 20:55:29 +0000621 /// isFrameOperand - Return true and the FrameIndex if the specified
622 /// operand and follow operands form a reference to the stack frame.
Duncan P. N. Exon Smith9cfc75c2016-06-30 00:01:54 +0000623 bool isFrameOperand(const MachineInstr &MI, unsigned int Op,
David Greene70fdd572009-11-12 20:55:29 +0000624 int &FrameIndex) const;
Craig Topper202b4532016-09-22 03:00:50 +0000625
626 /// Returns true iff the routine could find two commutable operands in the
627 /// given machine instruction with 3 vector inputs.
628 /// The 'SrcOpIdx1' and 'SrcOpIdx2' are INPUT and OUTPUT arguments. Their
629 /// input values can be re-defined in this method only if the input values
630 /// are not pre-defined, which is designated by the special value
631 /// 'CommuteAnyOperandIndex' assigned to it.
632 /// If both of indices are pre-defined and refer to some operands, then the
633 /// method simply returns true if the corresponding operands are commutable
634 /// and returns false otherwise.
635 ///
636 /// For example, calling this method this way:
637 /// unsigned Op1 = 1, Op2 = CommuteAnyOperandIndex;
638 /// findThreeSrcCommutedOpIndices(MI, Op1, Op2);
639 /// can be interpreted as a query asking to find an operand that would be
640 /// commutable with the operand#1.
641 bool findThreeSrcCommutedOpIndices(const MachineInstr &MI,
642 unsigned &SrcOpIdx1,
643 unsigned &SrcOpIdx2) const;
Chris Lattnerd92fb002002-10-25 22:55:53 +0000644};
645
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000646} // End llvm namespace
Brian Gaeke960707c2003-11-11 22:41:34 +0000647
Chris Lattnerd92fb002002-10-25 22:55:53 +0000648#endif