Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ARMMachineFunctionInfo.h - ARM machine function info ----*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file declares ARM-specific per-machine-function information.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_LIB_TARGET_ARM_ARMMACHINEFUNCTIONINFO_H
14
#define LLVM_LIB_TARGET_ARM_ARMMACHINEFUNCTIONINFO_H
15
16
#include "llvm/ADT/DenseMap.h"
17
#include "llvm/ADT/SmallPtrSet.h"
18
#include "llvm/CodeGen/MachineFunction.h"
19
#include "llvm/Support/ErrorHandling.h"
20
#include <utility>
21
22
namespace llvm {
23
24
/// ARMFunctionInfo - This class is derived from MachineFunctionInfo and
25
/// contains private ARM-specific information for each MachineFunction.
26
class ARMFunctionInfo : public MachineFunctionInfo {
27
  virtual void anchor();
28
29
  /// isThumb - True if this function is compiled under Thumb mode.
30
  /// Used to initialized Align, so must precede it.
31
  bool isThumb = false;
32
33
  /// hasThumb2 - True if the target architecture supports Thumb2. Do not use
34
  /// to determine if function is compiled under Thumb mode, for that use
35
  /// 'isThumb'.
36
  bool hasThumb2 = false;
37
38
  /// StByValParamsPadding - For parameter that is split between
39
  /// GPRs and memory; while recovering GPRs part, when
40
  /// StackAlignment > 4, and GPRs-part-size mod StackAlignment != 0,
41
  /// we need to insert gap before parameter start address. It allows to
42
  /// "attach" GPR-part to the part that was passed via stack.
43
  unsigned StByValParamsPadding = 0;
44
45
  /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
46
  ///
47
  unsigned ArgRegsSaveSize = 0;
48
49
  /// ReturnRegsCount - Number of registers used up in the return.
50
  unsigned ReturnRegsCount = 0;
51
52
  /// HasStackFrame - True if this function has a stack frame. Set by
53
  /// determineCalleeSaves().
54
  bool HasStackFrame = false;
55
56
  /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by
57
  /// emitPrologue.
58
  bool RestoreSPFromFP = false;
59
60
  /// LRSpilledForFarJump - True if the LR register has been for spilled to
61
  /// enable far jump.
62
  bool LRSpilledForFarJump = false;
63
64
  /// LRSpilled - True if the LR register has been for spilled for
65
  /// any reason, so it's legal to emit an ARM::tBfar (i.e. "bl").
66
  bool LRSpilled = false;
67
68
  /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
69
  /// spill stack offset.
70
  unsigned FramePtrSpillOffset = 0;
71
72
  /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
73
  /// register spills areas. For Mac OS X:
74
  ///
75
  /// GPR callee-saved (1) : r4, r5, r6, r7, lr
76
  /// --------------------------------------------
77
  /// GPR callee-saved (2) : r8, r10, r11
78
  /// --------------------------------------------
79
  /// DPR callee-saved : d8 - d15
80
  ///
81
  /// Also see AlignedDPRCSRegs below. Not all D-regs need to go in area 3.
82
  /// Some may be spilled after the stack has been realigned.
83
  unsigned GPRCS1Offset = 0;
84
  unsigned GPRCS2Offset = 0;
85
  unsigned DPRCSOffset = 0;
86
87
  /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
88
  /// areas.
89
  unsigned GPRCS1Size = 0;
90
  unsigned GPRCS2Size = 0;
91
  unsigned DPRCSAlignGapSize = 0;
92
  unsigned DPRCSSize = 0;
93
94
  /// NumAlignedDPRCS2Regs - The number of callee-saved DPRs that are saved in
95
  /// the aligned portion of the stack frame.  This is always a contiguous
96
  /// sequence of D-registers starting from d8.
97
  ///
98
  /// We do not keep track of the frame indices used for these registers - they
99
  /// behave like any other frame index in the aligned stack frame.  These
100
  /// registers also aren't included in DPRCSSize above.
101
  unsigned NumAlignedDPRCS2Regs = 0;
102
103
  unsigned PICLabelUId = 0;
104
105
  /// VarArgsFrameIndex - FrameIndex for start of varargs area.
106
  int VarArgsFrameIndex = 0;
107
108
  /// HasITBlocks - True if IT blocks have been inserted.
109
  bool HasITBlocks = false;
110
111
  /// CPEClones - Track constant pool entries clones created by Constant Island
112
  /// pass.
113
  DenseMap<unsigned, unsigned> CPEClones;
114
115
  /// ArgumentStackSize - amount of bytes on stack consumed by the arguments
116
  /// being passed on the stack
117
  unsigned ArgumentStackSize = 0;
118
119
  /// CoalescedWeights - mapping of basic blocks to the rolling counter of
120
  /// coalesced weights.
121
  DenseMap<const MachineBasicBlock*, unsigned> CoalescedWeights;
122
123
  /// True if this function has a subset of CSRs that is handled explicitly via
124
  /// copies.
125
  bool IsSplitCSR = false;
126
127
  /// Globals that have had their storage promoted into the constant pool.
128
  SmallPtrSet<const GlobalVariable*,2> PromotedGlobals;
129
130
  /// The amount the literal pool has been increasedby due to promoted globals.
131
  int PromotedGlobalsIncrease = 0;
132
133
  /// True if r0 will be preserved by a call to this function (e.g. C++
134
  /// con/destructors).
135
  bool PreservesR0 = false;
136
137
public:
138
  ARMFunctionInfo() = default;
139
140
  explicit ARMFunctionInfo(MachineFunction &MF);
141
142
1.69M
  bool isThumbFunction() const { return isThumb; }
143
429k
  bool isThumb1OnlyFunction() const { return isThumb && 
!hasThumb2315k
; }
144
1.29M
  bool isThumb2Function() const { return isThumb && 
hasThumb21.18M
; }
145
146
0
  unsigned getStoredByValParamsPadding() const { return StByValParamsPadding; }
147
0
  void setStoredByValParamsPadding(unsigned p) { StByValParamsPadding = p; }
148
149
108k
  unsigned getArgRegsSaveSize() const { return ArgRegsSaveSize; }
150
51.2k
  void setArgRegsSaveSize(unsigned s) { ArgRegsSaveSize = s; }
151
152
863
  unsigned getReturnRegsCount() const { return ReturnRegsCount; }
153
23.8k
  void setReturnRegsCount(unsigned s) { ReturnRegsCount = s; }
154
155
150k
  bool hasStackFrame() const { return HasStackFrame; }
156
19.2k
  void setHasStackFrame(bool s) { HasStackFrame = s; }
157
158
12.7k
  bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; }
159
741
  void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; }
160
161
1
  bool isLRSpilled() const { return LRSpilled; }
162
34.2k
  void setLRIsSpilled(bool s) { LRSpilled = s; }
163
164
17.5k
  bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; }
165
4
  void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; }
166
167
63.6k
  unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
168
7.52k
  void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
169
170
53.5k
  unsigned getNumAlignedDPRCS2Regs() const { return NumAlignedDPRCS2Regs; }
171
34.3k
  void setNumAlignedDPRCS2Regs(unsigned n) { NumAlignedDPRCS2Regs = n; }
172
173
0
  unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
174
0
  unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
175
0
  unsigned getDPRCalleeSavedAreaOffset()  const { return DPRCSOffset; }
176
177
11.7k
  void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
178
11.7k
  void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
179
11.7k
  void setDPRCalleeSavedAreaOffset(unsigned o)  { DPRCSOffset = o; }
180
181
24.6k
  unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
182
24.6k
  unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
183
23.7k
  unsigned getDPRCalleeSavedGapSize() const   { return DPRCSAlignGapSize; }
184
24.6k
  unsigned getDPRCalleeSavedAreaSize()  const { return DPRCSSize; }
185
186
11.7k
  void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
187
11.7k
  void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
188
10.8k
  void setDPRCalleeSavedGapSize(unsigned s)   { DPRCSAlignGapSize = s; }
189
11.7k
  void setDPRCalleeSavedAreaSize(unsigned s)  { DPRCSSize = s; }
190
191
56
  unsigned getArgumentStackSize() const { return ArgumentStackSize; }
192
25.6k
  void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }
193
194
26.5k
  void initPICLabelUId(unsigned UId) {
195
26.5k
    PICLabelUId = UId;
196
26.5k
  }
197
198
0
  unsigned getNumPICLabels() const {
199
0
    return PICLabelUId;
200
0
  }
201
202
29.0k
  unsigned createPICLabelUId() {
203
29.0k
    return PICLabelUId++;
204
29.0k
  }
205
206
98
  int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
207
98
  void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
208
209
4.87k
  bool hasITBlocks() const { return HasITBlocks; }
210
4.78k
  void setHasITBlocks(bool h) { HasITBlocks = h; }
211
212
387
  bool isSplitCSR() const { return IsSplitCSR; }
213
15
  void setIsSplitCSR(bool s) { IsSplitCSR = s; }
214
215
4.78k
  void recordCPEClone(unsigned CPIdx, unsigned CPCloneIdx) {
216
4.78k
    if (!CPEClones.insert(std::make_pair(CPCloneIdx, CPIdx)).second)
217
4.78k
      
llvm_unreachable0
("Duplicate entries!");
218
4.78k
  }
219
220
0
  unsigned getOriginalCPIdx(unsigned CloneIdx) const {
221
0
    DenseMap<unsigned, unsigned>::const_iterator I = CPEClones.find(CloneIdx);
222
0
    if (I != CPEClones.end())
223
0
      return I->second;
224
0
    else
225
0
      return -1U;
226
0
  }
227
228
  DenseMap<const MachineBasicBlock*, unsigned>::iterator getCoalescedWeight(
229
446
                                                  MachineBasicBlock* MBB) {
230
446
    auto It = CoalescedWeights.find(MBB);
231
446
    if (It == CoalescedWeights.end()) {
232
157
      It = CoalescedWeights.insert(std::make_pair(MBB, 0)).first;
233
157
    }
234
446
    return It;
235
446
  }
236
237
  /// Indicate to the backend that \c GV has had its storage changed to inside
238
  /// a constant pool. This means it no longer needs to be emitted as a
239
  /// global variable.
240
86
  void markGlobalAsPromotedToConstantPool(const GlobalVariable *GV) {
241
86
    PromotedGlobals.insert(GV);
242
86
  }
243
26.7k
  SmallPtrSet<const GlobalVariable*, 2>& getGlobalsPromotedToConstantPool() {
244
26.7k
    return PromotedGlobals;
245
26.7k
  }
246
158
  int getPromotedConstpoolIncrease() const {
247
158
    return PromotedGlobalsIncrease;
248
158
  }
249
86
  void setPromotedConstpoolIncrease(int Sz) {
250
86
    PromotedGlobalsIncrease = Sz;
251
86
  }
252
253
  DenseMap<unsigned, unsigned> EHPrologueRemappedRegs;
254
255
484
  void setPreservesR0() { PreservesR0 = true; }
256
34.2k
  bool getPreservesR0() const { return PreservesR0; }
257
};
258
259
} // end namespace llvm
260
261
#endif // LLVM_LIB_TARGET_ARM_ARMMACHINEFUNCTIONINFO_H