Coverage Report

Created: 2018-11-16 02:38

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/SectionKind.h
Line
Count
Source
1
//===-- llvm/MC/SectionKind.h - Classification of sections ------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_MC_SECTIONKIND_H
11
#define LLVM_MC_SECTIONKIND_H
12
13
namespace llvm {
14
15
/// SectionKind - This is a simple POD value that classifies the properties of
16
/// a section.  A section is classified into the deepest possible
17
/// classification, and then the target maps them onto their sections based on
18
/// what capabilities they have.
19
///
20
/// The comments below describe these as if they were an inheritance hierarchy
21
/// in order to explain the predicates below.
22
///
23
class SectionKind {
24
  enum Kind {
25
    /// Metadata - Debug info sections or other metadata.
26
    Metadata,
27
28
    /// Text - Text section, used for functions and other executable code.
29
    Text,
30
31
           /// ExecuteOnly, Text section that is not readable.
32
           ExecuteOnly,
33
34
    /// ReadOnly - Data that is never written to at program runtime by the
35
    /// program or the dynamic linker.  Things in the top-level readonly
36
    /// SectionKind are not mergeable.
37
    ReadOnly,
38
39
        /// MergableCString - Any null-terminated string which allows merging.
40
        /// These values are known to end in a nul value of the specified size,
41
        /// not otherwise contain a nul value, and be mergable.  This allows the
42
        /// linker to unique the strings if it so desires.
43
44
           /// Mergeable1ByteCString - 1 byte mergable, null terminated, string.
45
           Mergeable1ByteCString,
46
47
           /// Mergeable2ByteCString - 2 byte mergable, null terminated, string.
48
           Mergeable2ByteCString,
49
50
           /// Mergeable4ByteCString - 4 byte mergable, null terminated, string.
51
           Mergeable4ByteCString,
52
53
        /// MergeableConst - These are sections for merging fixed-length
54
        /// constants together.  For example, this can be used to unique
55
        /// constant pool entries etc.
56
57
            /// MergeableConst4 - This is a section used by 4-byte constants,
58
            /// for example, floats.
59
            MergeableConst4,
60
61
            /// MergeableConst8 - This is a section used by 8-byte constants,
62
            /// for example, doubles.
63
            MergeableConst8,
64
65
            /// MergeableConst16 - This is a section used by 16-byte constants,
66
            /// for example, vectors.
67
            MergeableConst16,
68
69
            /// MergeableConst32 - This is a section used by 32-byte constants,
70
            /// for example, vectors.
71
            MergeableConst32,
72
73
    /// Writeable - This is the base of all segments that need to be written
74
    /// to during program runtime.
75
76
       /// ThreadLocal - This is the base of all TLS segments.  All TLS
77
       /// objects must be writeable, otherwise there is no reason for them to
78
       /// be thread local!
79
80
           /// ThreadBSS - Zero-initialized TLS data objects.
81
           ThreadBSS,
82
83
           /// ThreadData - Initialized TLS data objects.
84
           ThreadData,
85
86
       /// GlobalWriteableData - Writeable data that is global (not thread
87
       /// local).
88
89
           /// BSS - Zero initialized writeable data.
90
           BSS,
91
92
               /// BSSLocal - This is BSS (zero initialized and writable) data
93
               /// which has local linkage.
94
               BSSLocal,
95
96
               /// BSSExtern - This is BSS data with normal external linkage.
97
               BSSExtern,
98
99
           /// Common - Data with common linkage.  These represent tentative
100
           /// definitions, which always have a zero initializer and are never
101
           /// marked 'constant'.
102
           Common,
103
104
           /// This is writeable data that has a non-zero initializer.
105
           Data,
106
107
           /// ReadOnlyWithRel - These are global variables that are never
108
           /// written to by the program, but that have relocations, so they
109
           /// must be stuck in a writeable section so that the dynamic linker
110
           /// can write to them.  If it chooses to, the dynamic linker can
111
           /// mark the pages these globals end up on as read-only after it is
112
           /// done with its relocation phase.
113
           ReadOnlyWithRel
114
  } K : 8;
115
public:
116
117
183k
  bool isMetadata() const { return K == Metadata; }
118
119
2.07M
  bool isText() const { return K == Text || 
K == ExecuteOnly752k
; }
120
121
367k
  bool isExecuteOnly() const { return K == ExecuteOnly; }
122
123
197k
  bool isReadOnly() const {
124
197k
    return K == ReadOnly || 
isMergeableCString()127k
||
125
197k
           
isMergeableConst()127k
;
126
197k
  }
127
128
675k
  bool isMergeableCString() const {
129
675k
    return K == Mergeable1ByteCString || 
K == Mergeable2ByteCString673k
||
130
675k
           
K == Mergeable4ByteCString673k
;
131
675k
  }
132
688k
  bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; }
133
278k
  bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; }
134
182k
  bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; }
135
136
564k
  bool isMergeableConst() const {
137
564k
    return K == MergeableConst4 || 
K == MergeableConst8564k
||
138
564k
           
K == MergeableConst16563k
||
K == MergeableConst32563k
;
139
564k
  }
140
239k
  bool isMergeableConst4() const { return K == MergeableConst4; }
141
233k
  bool isMergeableConst8() const { return K == MergeableConst8; }
142
220k
  bool isMergeableConst16() const { return K == MergeableConst16; }
143
188k
  bool isMergeableConst32() const { return K == MergeableConst32; }
144
145
183k
  bool isWriteable() const {
146
183k
    return isThreadLocal() || 
isGlobalWriteableData()182k
;
147
183k
  }
148
149
776k
  bool isThreadLocal() const {
150
776k
    return K == ThreadData || 
K == ThreadBSS775k
;
151
776k
  }
152
153
1.02M
  bool isThreadBSS() const { return K == ThreadBSS; }
154
846k
  bool isThreadData() const { return K == ThreadData; }
155
156
183k
  bool isGlobalWriteableData() const {
157
183k
    return isBSS() || 
isCommon()180k
||
isData()180k
||
isReadOnlyWithRel()176k
;
158
183k
  }
159
160
822k
  bool isBSS() const { return K == BSS || 
K == BSSLocal798k
||
K == BSSExtern785k
; }
161
426k
  bool isBSSLocal() const { return K == BSSLocal; }
162
18.6k
  bool isBSSExtern() const { return K == BSSExtern; }
163
164
801k
  bool isCommon() const { return K == Common; }
165
166
236k
  bool isData() const { return K == Data; }
167
168
281k
  bool isReadOnlyWithRel() const {
169
281k
    return K == ReadOnlyWithRel;
170
281k
  }
171
private:
172
3.84M
  static SectionKind get(Kind K) {
173
3.84M
    SectionKind Res;
174
3.84M
    Res.K = K;
175
3.84M
    return Res;
176
3.84M
  }
177
public:
178
179
590k
  static SectionKind getMetadata() { return get(Metadata); }
180
539k
  static SectionKind getText() { return get(Text); }
181
545
  static SectionKind getExecuteOnly() { return get(ExecuteOnly); }
182
1.85M
  static SectionKind getReadOnly() { return get(ReadOnly); }
183
428k
  static SectionKind getMergeable1ByteCString() {
184
428k
    return get(Mergeable1ByteCString);
185
428k
  }
186
17.0k
  static SectionKind getMergeable2ByteCString() {
187
17.0k
    return get(Mergeable2ByteCString);
188
17.0k
  }
189
246
  static SectionKind getMergeable4ByteCString() {
190
246
    return get(Mergeable4ByteCString);
191
246
  }
192
23.0k
  static SectionKind getMergeableConst4() { return get(MergeableConst4); }
193
31.0k
  static SectionKind getMergeableConst8() { return get(MergeableConst8); }
194
46.9k
  static SectionKind getMergeableConst16() { return get(MergeableConst16); }
195
4.95k
  static SectionKind getMergeableConst32() { return get(MergeableConst32); }
196
17.2k
  static SectionKind getThreadBSS() { return get(ThreadBSS); }
197
140
  static SectionKind getThreadData() { return get(ThreadData); }
198
59.1k
  static SectionKind getBSS() { return get(BSS); }
199
11.3k
  static SectionKind getBSSLocal() { return get(BSSLocal); }
200
6.77k
  static SectionKind getBSSExtern() { return get(BSSExtern); }
201
14.0k
  static SectionKind getCommon() { return get(Common); }
202
146k
  static SectionKind getData() { return get(Data); }
203
53.2k
  static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
204
};
205
206
} // end namespace llvm
207
208
#endif