annotate lib/Target/X86/X86InstrInfo.h @ 128:c347d3398279 default tip

fix
author mir3636
date Wed, 06 Dec 2017 14:37:17 +0900
parents 803732b1fca8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 //===-- X86InstrInfo.h - X86 Instruction Information ------------*- C++ -*-===//
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // The LLVM Compiler Infrastructure
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // This file is distributed under the University of Illinois Open Source
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 // License. See LICENSE.TXT for details.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 //===----------------------------------------------------------------------===//
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 // This file contains the X86 implementation of the TargetInstrInfo class.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 //===----------------------------------------------------------------------===//
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
14 #ifndef LLVM_LIB_TARGET_X86_X86INSTRINFO_H
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15 #define LLVM_LIB_TARGET_X86_X86INSTRINFO_H
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
17 #include "MCTargetDesc/X86BaseInfo.h"
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
18 #include "X86InstrFMA3Info.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #include "X86RegisterInfo.h"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #include "llvm/ADT/DenseMap.h"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "llvm/Target/TargetInstrInfo.h"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define GET_INSTRINFO_HEADER
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "X86GenInstrInfo.inc"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 namespace llvm {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
27 class MachineInstrBuilder;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
28 class X86RegisterInfo;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
29 class X86Subtarget;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 namespace X86 {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
32 // X86 specific condition code. These correspond to X86_*_COND in
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
33 // X86InstrInfo.td. They must be kept in synch.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
34 enum CondCode {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
35 COND_A = 0,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
36 COND_AE = 1,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
37 COND_B = 2,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
38 COND_BE = 3,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
39 COND_E = 4,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
40 COND_G = 5,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
41 COND_GE = 6,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
42 COND_L = 7,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
43 COND_LE = 8,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
44 COND_NE = 9,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
45 COND_NO = 10,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
46 COND_NP = 11,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
47 COND_NS = 12,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
48 COND_O = 13,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
49 COND_P = 14,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
50 COND_S = 15,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
51 LAST_VALID_COND = COND_S,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
53 // Artificial condition codes. These are used by AnalyzeBranch
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
54 // to indicate a block terminated with two conditional branches that together
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
55 // form a compound condition. They occur in code using FCMP_OEQ or FCMP_UNE,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
56 // which can't be represented on x86 with a single condition. These
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
57 // are never used in MachineInstrs and are inverses of one another.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
58 COND_NE_OR_P,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
59 COND_E_AND_NP,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
61 COND_INVALID
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
62 };
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
64 // Turn condition code into conditional branch opcode.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
65 unsigned GetCondBranchFromCond(CondCode CC);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
67 /// \brief Return a pair of condition code for the given predicate and whether
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
68 /// the instruction operands should be swaped to match the condition code.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
69 std::pair<CondCode, bool> getX86ConditionCode(CmpInst::Predicate Predicate);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
70
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
71 /// \brief Return a set opcode for the given condition and whether it has
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
72 /// a memory operand.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
73 unsigned getSETFromCond(CondCode CC, bool HasMemoryOperand = false);
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
74
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
75 /// \brief Return a cmov opcode for the given condition, register size in
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
76 /// bytes, and operand type.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
77 unsigned getCMovFromCond(CondCode CC, unsigned RegBytes,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
78 bool HasMemoryOperand = false);
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
79
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
80 // Turn CMov opcode into condition code.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
81 CondCode getCondFromCMovOpc(unsigned Opc);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
83 /// GetOppositeBranchCondition - Return the inverse of the specified cond,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
84 /// e.g. turning COND_E to COND_NE.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
85 CondCode GetOppositeBranchCondition(CondCode CC);
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
86 } // namespace X86
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 /// isGlobalStubReference - Return true if the specified TargetFlag operand is
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 /// a reference to a stub for a global, not the global itself.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 inline static bool isGlobalStubReference(unsigned char TargetFlag) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 switch (TargetFlag) {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
92 case X86II::MO_DLLIMPORT: // dllimport stub.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
93 case X86II::MO_GOTPCREL: // rip-relative GOT reference.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
94 case X86II::MO_GOT: // normal GOT reference.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
95 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Normal $non_lazy_ptr ref.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
96 case X86II::MO_DARWIN_NONLAZY: // Normal $non_lazy_ptr ref.
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 return true;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 default:
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 return false;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 /// isGlobalRelativeToPICBase - Return true if the specified global value
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 /// reference is relative to a 32-bit PIC base (X86ISD::GlobalBaseReg). If this
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 /// is true, the addressing mode has the PIC base register added in (e.g. EBX).
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 inline static bool isGlobalRelativeToPICBase(unsigned char TargetFlag) {
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 switch (TargetFlag) {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
108 case X86II::MO_GOTOFF: // isPICStyleGOT: local global.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
109 case X86II::MO_GOT: // isPICStyleGOT: other global.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
110 case X86II::MO_PIC_BASE_OFFSET: // Darwin local global.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
111 case X86II::MO_DARWIN_NONLAZY_PIC_BASE: // Darwin/32 external global.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
112 case X86II::MO_TLVP: // ??? Pretty sure..
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 return true;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 default:
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 return false;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 inline static bool isScale(const MachineOperand &MO) {
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
120 return MO.isImm() && (MO.getImm() == 1 || MO.getImm() == 2 ||
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
121 MO.getImm() == 4 || MO.getImm() == 8);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
124 inline static bool isLeaMem(const MachineInstr &MI, unsigned Op) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
125 if (MI.getOperand(Op).isFI())
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
126 return true;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
127 return Op + X86::AddrSegmentReg <= MI.getNumOperands() &&
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
128 MI.getOperand(Op + X86::AddrBaseReg).isReg() &&
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
129 isScale(MI.getOperand(Op + X86::AddrScaleAmt)) &&
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
130 MI.getOperand(Op + X86::AddrIndexReg).isReg() &&
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
131 (MI.getOperand(Op + X86::AddrDisp).isImm() ||
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
132 MI.getOperand(Op + X86::AddrDisp).isGlobal() ||
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
133 MI.getOperand(Op + X86::AddrDisp).isCPI() ||
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
134 MI.getOperand(Op + X86::AddrDisp).isJTI());
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
137 inline static bool isMem(const MachineInstr &MI, unsigned Op) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
138 if (MI.getOperand(Op).isFI())
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
139 return true;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
140 return Op + X86::AddrNumOperands <= MI.getNumOperands() &&
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
141 MI.getOperand(Op + X86::AddrSegmentReg).isReg() && isLeaMem(MI, Op);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
144 class X86InstrInfo final : public X86GenInstrInfo {
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
145 X86Subtarget &Subtarget;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 const X86RegisterInfo RI;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 /// RegOp2MemOpTable3Addr, RegOp2MemOpTable0, RegOp2MemOpTable1,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 /// RegOp2MemOpTable2, RegOp2MemOpTable3 - Load / store folding opcode maps.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 ///
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
151 typedef DenseMap<unsigned, std::pair<uint16_t, uint16_t>>
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
152 RegOp2MemOpTableType;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 RegOp2MemOpTableType RegOp2MemOpTable2Addr;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 RegOp2MemOpTableType RegOp2MemOpTable0;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 RegOp2MemOpTableType RegOp2MemOpTable1;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 RegOp2MemOpTableType RegOp2MemOpTable2;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 RegOp2MemOpTableType RegOp2MemOpTable3;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
158 RegOp2MemOpTableType RegOp2MemOpTable4;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 /// MemOp2RegOpTable - Load / store unfolding opcode map.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 ///
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
162 typedef DenseMap<unsigned, std::pair<uint16_t, uint16_t>>
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
163 MemOp2RegOpTableType;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 MemOp2RegOpTableType MemOp2RegOpTable;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 static void AddTableEntry(RegOp2MemOpTableType &R2MTable,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
167 MemOp2RegOpTableType &M2RTable, uint16_t RegOp,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
168 uint16_t MemOp, uint16_t Flags);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 virtual void anchor();
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
172 bool AnalyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
173 MachineBasicBlock *&FBB,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
174 SmallVectorImpl<MachineOperand> &Cond,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
175 SmallVectorImpl<MachineInstr *> &CondBranches,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
176 bool AllowModify) const;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
177
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 public:
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
179 explicit X86InstrInfo(X86Subtarget &STI);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 /// such, whenever a client has an instance of instruction info, it should
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 /// always be able to get register info as well (through this method).
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 ///
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
185 const X86RegisterInfo &getRegisterInfo() const { return RI; }
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
187 /// Returns the stack pointer adjustment that happens inside the frame
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
188 /// setup..destroy sequence (e.g. by pushes, or inside the callee).
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
189 int64_t getFrameAdjustment(const MachineInstr &I) const {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
190 assert(isFrameInstr(I));
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
191 if (isFrameSetup(I))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
192 return I.getOperand(2).getImm();
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
193 return I.getOperand(1).getImm();
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
194 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
195
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
196 /// Sets the stack pointer adjustment made inside the frame made up by this
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
197 /// instruction.
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
198 void setFrameAdjustment(MachineInstr &I, int64_t V) const {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
199 assert(isFrameInstr(I));
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
200 if (isFrameSetup(I))
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
201 I.getOperand(2).setImm(V);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
202 else
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
203 I.getOperand(1).setImm(V);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
204 }
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
205
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
206 /// getSPAdjust - This returns the stack pointer adjustment made by
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
207 /// this instruction. For x86, we need to handle more complex call
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
208 /// sequences involving PUSHes.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
209 int getSPAdjust(const MachineInstr &MI) const override;
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
210
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 /// isCoalescableExtInstr - Return true if the instruction is a "coalescable"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 /// extension instruction. That is, it's like a copy where it's legal for the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 /// source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 /// true, then it's expected the pre-extension value is available as a subreg
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 /// of the result register. This also returns the sub-register index in
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 /// SubIdx.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
217 bool isCoalescableExtInstr(const MachineInstr &MI, unsigned &SrcReg,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
218 unsigned &DstReg, unsigned &SubIdx) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
220 unsigned isLoadFromStackSlot(const MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
221 int &FrameIndex) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 /// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 /// stack locations as well. This uses a heuristic so it isn't
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 /// reliable for correctness.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
225 unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
226 int &FrameIndex) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
228 unsigned isStoreToStackSlot(const MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
229 int &FrameIndex) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 /// stack locations as well. This uses a heuristic so it isn't
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 /// reliable for correctness.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
233 unsigned isStoreToStackSlotPostFE(const MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
234 int &FrameIndex) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
236 bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
237 AliasAnalysis *AA) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 unsigned DestReg, unsigned SubIdx,
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
240 const MachineInstr &Orig,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
241 const TargetRegisterInfo &TRI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 /// Given an operand within a MachineInstr, insert preceding code to put it
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 /// into the right format for a particular kind of LEA instruction. This may
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 /// involve using an appropriate super-register instead (with an implicit use
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 /// of the original) or creating a new virtual register and inserting COPY
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 /// instructions to get the data into the right class.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 ///
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 /// Reference parameters are set to indicate how caller should add this
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 /// operand to the LEA instruction.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
251 bool classifyLEAReg(MachineInstr &MI, const MachineOperand &Src,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
252 unsigned LEAOpcode, bool AllowSP, unsigned &NewSrc,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
253 bool &isKill, bool &isUndef, MachineOperand &ImplicitOp,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
254 LiveVariables *LV) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 /// convertToThreeAddress - This method must be implemented by targets that
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 /// may be able to convert a two-address instruction into a true
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 /// three-address instruction on demand. This allows the X86 target (for
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 /// example) to convert ADD and SHL instructions into LEA instructions if they
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 /// would require register copies due to two-addressness.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 ///
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 /// This method returns a null pointer if the transformation cannot be
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 /// performed, otherwise it returns the new instruction.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 ///
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
266 MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI,
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
267 MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
268 LiveVariables *LV) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
270 /// Returns true iff the routine could find two commutable operands in the
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
271 /// given machine instruction.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
272 /// The 'SrcOpIdx1' and 'SrcOpIdx2' are INPUT and OUTPUT arguments. Their
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
273 /// input values can be re-defined in this method only if the input values
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
274 /// are not pre-defined, which is designated by the special value
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
275 /// 'CommuteAnyOperandIndex' assigned to it.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
276 /// If both of indices are pre-defined and refer to some operands, then the
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
277 /// method simply returns true if the corresponding operands are commutable
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
278 /// and returns false otherwise.
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 ///
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
280 /// For example, calling this method this way:
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
281 /// unsigned Op1 = 1, Op2 = CommuteAnyOperandIndex;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
282 /// findCommutedOpIndices(MI, Op1, Op2);
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
283 /// can be interpreted as a query asking to find an operand that would be
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
284 /// commutable with the operand#1.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
285 bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
286 unsigned &SrcOpIdx2) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
288 /// Returns true if the routine could find two commutable operands
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
289 /// in the given FMA instruction \p MI. Otherwise, returns false.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
290 ///
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
291 /// \p SrcOpIdx1 and \p SrcOpIdx2 are INPUT and OUTPUT arguments.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
292 /// The output indices of the commuted operands are returned in these
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
293 /// arguments. Also, the input values of these arguments may be preset either
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
294 /// to indices of operands that must be commuted or be equal to a special
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
295 /// value 'CommuteAnyOperandIndex' which means that the corresponding
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
296 /// operand index is not set and this method is free to pick any of
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
297 /// available commutable operands.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
298 /// The parameter \p FMA3Group keeps the reference to the group of relative
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
299 /// FMA3 opcodes including register/memory forms of 132/213/231 opcodes.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
300 ///
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
301 /// For example, calling this method this way:
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
302 /// unsigned Idx1 = 1, Idx2 = CommuteAnyOperandIndex;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
303 /// findFMA3CommutedOpIndices(MI, Idx1, Idx2, FMA3Group);
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
304 /// can be interpreted as a query asking if the operand #1 can be swapped
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
305 /// with any other available operand (e.g. operand #2, operand #3, etc.).
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
306 ///
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
307 /// The returned FMA opcode may differ from the opcode in the given MI.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
308 /// For example, commuting the operands #1 and #3 in the following FMA
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
309 /// FMA213 #1, #2, #3
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
310 /// results into instruction with adjusted opcode:
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
311 /// FMA231 #3, #2, #1
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
312 bool findFMA3CommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1,
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
313 unsigned &SrcOpIdx2,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
314 const X86InstrFMA3Group &FMA3Group) const;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
315
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
316 /// Returns an adjusted FMA opcode that must be used in FMA instruction that
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
317 /// performs the same computations as the given \p MI but which has the
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
318 /// operands \p SrcOpIdx1 and \p SrcOpIdx2 commuted.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
319 /// It may return 0 if it is unsafe to commute the operands.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
320 /// Note that a machine instruction (instead of its opcode) is passed as the
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
321 /// first parameter to make it possible to analyze the instruction's uses and
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
322 /// commute the first operand of FMA even when it seems unsafe when you look
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
323 /// at the opcode. For example, it is Ok to commute the first operand of
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
324 /// VFMADD*SD_Int, if ONLY the lowest 64-bit element of the result is used.
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
325 ///
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
326 /// The returned FMA opcode may differ from the opcode in the given \p MI.
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
327 /// For example, commuting the operands #1 and #3 in the following FMA
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
328 /// FMA213 #1, #2, #3
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
329 /// results into instruction with adjusted opcode:
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
330 /// FMA231 #3, #2, #1
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
331 unsigned
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
332 getFMA3OpcodeToCommuteOperands(const MachineInstr &MI, unsigned SrcOpIdx1,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
333 unsigned SrcOpIdx2,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
334 const X86InstrFMA3Group &FMA3Group) const;
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
335
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 // Branch analysis.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
337 bool isUnpredicatedTerminator(const MachineInstr &MI) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
338 bool isUnconditionalTailCall(const MachineInstr &MI) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
339 bool canMakeTailCallConditional(SmallVectorImpl<MachineOperand> &Cond,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
340 const MachineInstr &TailCall) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
341 void replaceBranchWithTailCall(MachineBasicBlock &MBB,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
342 SmallVectorImpl<MachineOperand> &Cond,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
343 const MachineInstr &TailCall) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
344
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
345 bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
346 MachineBasicBlock *&FBB,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
347 SmallVectorImpl<MachineOperand> &Cond,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
348 bool AllowModify) const override;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
349
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
350 bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
351 int64_t &Offset,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
352 const TargetRegisterInfo *TRI) const override;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
353 bool analyzeBranchPredicate(MachineBasicBlock &MBB,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
354 TargetInstrInfo::MachineBranchPredicate &MBP,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
355 bool AllowModify = false) const override;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
356
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
357 unsigned removeBranch(MachineBasicBlock &MBB,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
358 int *BytesRemoved = nullptr) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
359 unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
360 MachineBasicBlock *FBB, ArrayRef<MachineOperand> Cond,
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
361 const DebugLoc &DL,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
362 int *BytesAdded = nullptr) const override;
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
363 bool canInsertSelect(const MachineBasicBlock &, ArrayRef<MachineOperand> Cond,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
364 unsigned, unsigned, int &, int &, int &) const override;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
365 void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
366 const DebugLoc &DL, unsigned DstReg,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
367 ArrayRef<MachineOperand> Cond, unsigned TrueReg,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
368 unsigned FalseReg) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
369 void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
370 const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
371 bool KillSrc) const override;
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
372 void storeRegToStackSlot(MachineBasicBlock &MBB,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
373 MachineBasicBlock::iterator MI, unsigned SrcReg,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
374 bool isKill, int FrameIndex,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
375 const TargetRegisterClass *RC,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
376 const TargetRegisterInfo *TRI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
378 void storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
379 SmallVectorImpl<MachineOperand> &Addr,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
380 const TargetRegisterClass *RC,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
381 MachineInstr::mmo_iterator MMOBegin,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
382 MachineInstr::mmo_iterator MMOEnd,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
383 SmallVectorImpl<MachineInstr *> &NewMIs) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
385 void loadRegFromStackSlot(MachineBasicBlock &MBB,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
386 MachineBasicBlock::iterator MI, unsigned DestReg,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
387 int FrameIndex, const TargetRegisterClass *RC,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
388 const TargetRegisterInfo *TRI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
390 void loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
391 SmallVectorImpl<MachineOperand> &Addr,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
392 const TargetRegisterClass *RC,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
393 MachineInstr::mmo_iterator MMOBegin,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
394 MachineInstr::mmo_iterator MMOEnd,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
395 SmallVectorImpl<MachineInstr *> &NewMIs) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
397 bool expandPostRAPseudo(MachineInstr &MI) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
398
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
399 /// Check whether the target can fold a load that feeds a subreg operand
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
400 /// (or a subreg operand that feeds a store).
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
401 bool isSubregFoldable() const override { return true; }
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 /// foldMemoryOperand - If this target supports it, fold a load or store of
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 /// the specified stack slot into the specified machine instruction for the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 /// specified operand(s). If this is possible, the target should perform the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 /// folding and return true, otherwise it should return false. If it folds
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 /// the instruction, it is likely that the MachineInstruction the iterator
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 /// references has been changed.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
409 MachineInstr *
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
410 foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
411 ArrayRef<unsigned> Ops,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
412 MachineBasicBlock::iterator InsertPt, int FrameIndex,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
413 LiveIntervals *LIS = nullptr) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 /// foldMemoryOperand - Same as the previous version except it allows folding
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 /// of any load and store from / to any address, not just from a specific
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 /// stack slot.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
418 MachineInstr *foldMemoryOperandImpl(
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
419 MachineFunction &MF, MachineInstr &MI, ArrayRef<unsigned> Ops,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
420 MachineBasicBlock::iterator InsertPt, MachineInstr &LoadMI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
421 LiveIntervals *LIS = nullptr) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 /// unfoldMemoryOperand - Separate a single instruction which folded a load or
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 /// a store or a load and a store into two or more instruction. If this is
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 /// possible, returns true as well as the new instructions by reference.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
426 bool
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
427 unfoldMemoryOperand(MachineFunction &MF, MachineInstr &MI, unsigned Reg,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
428 bool UnfoldLoad, bool UnfoldStore,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
429 SmallVectorImpl<MachineInstr *> &NewMIs) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
431 bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
432 SmallVectorImpl<SDNode *> &NewNodes) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 /// getOpcodeAfterMemoryUnfold - Returns the opcode of the would be new
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 /// instruction after load / store are unfolded from an instruction of the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 /// specified opcode. It returns zero if the specified unfolding is not
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 /// possible. If LoadRegIndex is non-null, it is filled in with the operand
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 /// index of the operand which will hold the register holding the loaded
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 /// value.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
440 unsigned
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
441 getOpcodeAfterMemoryUnfold(unsigned Opc, bool UnfoldLoad, bool UnfoldStore,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
442 unsigned *LoadRegIndex = nullptr) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 /// areLoadsFromSameBasePtr - This is used by the pre-regalloc scheduler
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 /// to determine if two loads are loading from the same base address. It
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 /// should only return true if the base pointers are the same and the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 /// only differences between the two addresses are the offset. It also returns
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 /// the offsets by reference.
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
449 bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
450 int64_t &Offset2) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 /// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
453 /// determine (in conjunction with areLoadsFromSameBasePtr) if two loads
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
454 /// should be scheduled togther. On some targets if two loads are loading from
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 /// addresses in the same cache line, it's better if they are scheduled
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 /// together. This function takes two integers that represent the load offsets
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 /// from the common base address. It returns true if it decides it's desirable
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 /// to schedule the two loads together. "NumLoads" is the number of loads that
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 /// have already been scheduled after Load1.
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
460 bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2, int64_t Offset1,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
461 int64_t Offset2,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
462 unsigned NumLoads) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
463
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
464 void getNoop(MCInst &NopInst) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
466 bool
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
467 reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 /// isSafeToMoveRegClassDefs - Return true if it's safe to move a machine
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 /// instruction that defines the specified register class.
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
471 bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const override;
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
472
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
473 /// isSafeToClobberEFLAGS - Return true if it's safe insert an instruction tha
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
474 /// would clobber the EFLAGS condition register. Note the result may be
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
475 /// conservative. If it cannot definitely determine the safety after visiting
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
476 /// a few instructions in each direction it assumes it's not safe.
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
477 bool isSafeToClobberEFLAGS(MachineBasicBlock &MBB,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
478 MachineBasicBlock::iterator I) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
480 /// True if MI has a condition code def, e.g. EFLAGS, that is
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
481 /// not marked dead.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
482 bool hasLiveCondCodeDef(MachineInstr &MI) const;
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
483
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 /// getGlobalBaseReg - Return a virtual register initialized with the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 /// the global base register value. Output instructions required to
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 /// initialize the register in the function entry block, if necessary.
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 ///
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 unsigned getGlobalBaseReg(MachineFunction *MF) const;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
489
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 std::pair<uint16_t, uint16_t>
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
491 getExecutionDomain(const MachineInstr &MI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
493 void setExecutionDomain(MachineInstr &MI, unsigned Domain) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
494
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
495 unsigned
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
496 getPartialRegUpdateClearance(const MachineInstr &MI, unsigned OpNum,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
497 const TargetRegisterInfo *TRI) const override;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
498 unsigned getUndefRegClearance(const MachineInstr &MI, unsigned &OpNum,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
499 const TargetRegisterInfo *TRI) const override;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
500 void breakPartialRegDependency(MachineInstr &MI, unsigned OpNum,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
501 const TargetRegisterInfo *TRI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
503 MachineInstr *foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 unsigned OpNum,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
505 ArrayRef<MachineOperand> MOs,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
506 MachineBasicBlock::iterator InsertPt,
83
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
507 unsigned Size, unsigned Alignment,
60c9769439b8 LLVM 3.7
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
508 bool AllowCommute) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
509
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
510 bool isHighLatencyDef(int opc) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
512 bool hasHighOperandLatency(const TargetSchedModel &SchedModel,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 const MachineRegisterInfo *MRI,
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
514 const MachineInstr &DefMI, unsigned DefIdx,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
515 const MachineInstr &UseMI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
516 unsigned UseIdx) const override;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
517
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
518 bool useMachineCombiner() const override { return true; }
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
519
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
520 bool isAssociativeAndCommutative(const MachineInstr &Inst) const override;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
521
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
522 bool hasReassociableOperands(const MachineInstr &Inst,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
523 const MachineBasicBlock *MBB) const override;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
524
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
525 void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
526 MachineInstr &NewMI1,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
527 MachineInstr &NewMI2) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
528
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 /// analyzeCompare - For a comparison instruction, return the source registers
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 /// in SrcReg and SrcReg2 if having two register operands, and the value it
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 /// compares against in CmpValue. Return true if the comparison instruction
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 /// can be analyzed.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
533 bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
534 unsigned &SrcReg2, int &CmpMask,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
535 int &CmpValue) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
536
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 /// optimizeCompareInstr - Check if there exists an earlier instruction that
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 /// operates on the same source operands and sets flags in the same way as
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 /// Compare; remove Compare if possible.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
540 bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
541 unsigned SrcReg2, int CmpMask, int CmpValue,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
542 const MachineRegisterInfo *MRI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 /// optimizeLoadInstr - Try to remove the load by folding it to a register
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 /// operand at the use. We fold the load instructions if and only if the
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 /// def and use are in the same BB. We only look at one load and see
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 /// whether it can be folded into MI. FoldAsLoadDefReg is the virtual register
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 /// defined by the load we are trying to fold. DefMI returns the machine
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 /// instruction that defines FoldAsLoadDefReg, and the function returns
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 /// the machine instruction generated due to folding.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
551 MachineInstr *optimizeLoadInstr(MachineInstr &MI,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
552 const MachineRegisterInfo *MRI,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
553 unsigned &FoldAsLoadDefReg,
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
554 MachineInstr *&DefMI) const override;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
556 std::pair<unsigned, unsigned>
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
557 decomposeMachineOperandsTargetFlags(unsigned TF) const override;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
558
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
559 ArrayRef<std::pair<unsigned, const char *>>
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
560 getSerializableDirectMachineOperandTargetFlags() const override;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
561
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
562 virtual MachineOutlinerInfo getOutlininingCandidateInfo(
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
563 std::vector<
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
564 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
565 &RepeatedSequenceLocs) const override;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
566
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
567 bool isFunctionSafeToOutlineFrom(MachineFunction &MF,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
568 bool OutlineFromLinkOnceODRs) const override;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
569
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
570 llvm::X86GenInstrInfo::MachineOutlinerInstrType
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
571 getOutliningType(MachineInstr &MI) const override;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
572
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
573 void insertOutlinerEpilogue(MachineBasicBlock &MBB, MachineFunction &MF,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
574 const MachineOutlinerInfo &MInfo) const override;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
575
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
576 void insertOutlinerPrologue(MachineBasicBlock &MBB, MachineFunction &MF,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
577 const MachineOutlinerInfo &MInfo) const override;
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
578
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
579 MachineBasicBlock::iterator
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
580 insertOutlinedCall(Module &M, MachineBasicBlock &MBB,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
581 MachineBasicBlock::iterator &It, MachineFunction &MF,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
582 const MachineOutlinerInfo &MInfo) const override;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
583
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
584 protected:
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
585 /// Commutes the operands in the given instruction by changing the operands
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
586 /// order and/or changing the instruction's opcode and/or the immediate value
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
587 /// operand.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
588 ///
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
589 /// The arguments 'CommuteOpIdx1' and 'CommuteOpIdx2' specify the operands
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
590 /// to be commuted.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
591 ///
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
592 /// Do not call this method for a non-commutable instruction or
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
593 /// non-commutable operands.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
594 /// Even though the instruction is commutable, the method may still
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
595 /// fail to commute the operands, null pointer is returned in such cases.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
596 MachineInstr *commuteInstructionImpl(MachineInstr &MI, bool NewMI,
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
597 unsigned CommuteOpIdx1,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
598 unsigned CommuteOpIdx2) const override;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 83
diff changeset
599
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 private:
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
601 MachineInstr *convertToThreeAddressWithLEA(unsigned MIOpc,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
602 MachineFunction::iterator &MFI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
603 MachineInstr &MI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
604 LiveVariables *LV) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
606 /// Handles memory folding for special case instructions, for instance those
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
607 /// requiring custom manipulation of the address.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
608 MachineInstr *foldMemoryOperandCustom(MachineFunction &MF, MachineInstr &MI,
100
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
609 unsigned OpNum,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
610 ArrayRef<MachineOperand> MOs,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
611 MachineBasicBlock::iterator InsertPt,
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
612 unsigned Size, unsigned Align) const;
7d135dc70f03 LLVM 3.9
Miyagi Mitsuki <e135756@ie.u-ryukyu.ac.jp>
parents: 95
diff changeset
613
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 /// isFrameOperand - Return true and the FrameIndex if the specified
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 /// operand and follow operands form a reference to the stack frame.
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
616 bool isFrameOperand(const MachineInstr &MI, unsigned int Op,
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 int &FrameIndex) const;
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
618
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
619 /// Returns true iff the routine could find two commutable operands in the
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
620 /// given machine instruction with 3 vector inputs.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
621 /// The 'SrcOpIdx1' and 'SrcOpIdx2' are INPUT and OUTPUT arguments. Their
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
622 /// input values can be re-defined in this method only if the input values
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
623 /// are not pre-defined, which is designated by the special value
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
624 /// 'CommuteAnyOperandIndex' assigned to it.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
625 /// If both of indices are pre-defined and refer to some operands, then the
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
626 /// method simply returns true if the corresponding operands are commutable
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
627 /// and returns false otherwise.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
628 ///
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
629 /// For example, calling this method this way:
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
630 /// unsigned Op1 = 1, Op2 = CommuteAnyOperandIndex;
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
631 /// findThreeSrcCommutedOpIndices(MI, Op1, Op2);
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
632 /// can be interpreted as a query asking to find an operand that would be
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
633 /// commutable with the operand#1.
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
634 bool findThreeSrcCommutedOpIndices(const MachineInstr &MI,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
635 unsigned &SrcOpIdx1,
1172e4bd9c6f update 4.0.0
mir3636
parents: 100
diff changeset
636 unsigned &SrcOpIdx2) const;
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 };
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
639 } // namespace llvm
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 #endif