Coverage Report

Created: 2019-07-24 05:18

/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
// 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
#ifndef LLVM_MC_SECTIONKIND_H
10
#define LLVM_MC_SECTIONKIND_H
11
12
namespace llvm {
13
14
/// SectionKind - This is a simple POD value that classifies the properties of
15
/// a section.  A section is classified into the deepest possible
16
/// classification, and then the target maps them onto their sections based on
17
/// what capabilities they have.
18
///
19
/// The comments below describe these as if they were an inheritance hierarchy
20
/// in order to explain the predicates below.
21
///
22
class SectionKind {
23
  enum Kind {
24
    /// Metadata - Debug info sections or other metadata.
25
    Metadata,
26
27
    /// Text - Text section, used for functions and other executable code.
28
    Text,
29
30
           /// ExecuteOnly, Text section that is not readable.
31
           ExecuteOnly,
32
33
    /// ReadOnly - Data that is never written to at program runtime by the
34
    /// program or the dynamic linker.  Things in the top-level readonly
35
    /// SectionKind are not mergeable.
36
    ReadOnly,
37
38
        /// MergableCString - Any null-terminated string which allows merging.
39
        /// These values are known to end in a nul value of the specified size,
40
        /// not otherwise contain a nul value, and be mergable.  This allows the
41
        /// linker to unique the strings if it so desires.
42
43
           /// Mergeable1ByteCString - 1 byte mergable, null terminated, string.
44
           Mergeable1ByteCString,
45
46
           /// Mergeable2ByteCString - 2 byte mergable, null terminated, string.
47
           Mergeable2ByteCString,
48
49
           /// Mergeable4ByteCString - 4 byte mergable, null terminated, string.
50
           Mergeable4ByteCString,
51
52
        /// MergeableConst - These are sections for merging fixed-length
53
        /// constants together.  For example, this can be used to unique
54
        /// constant pool entries etc.
55
56
            /// MergeableConst4 - This is a section used by 4-byte constants,
57
            /// for example, floats.
58
            MergeableConst4,
59
60
            /// MergeableConst8 - This is a section used by 8-byte constants,
61
            /// for example, doubles.
62
            MergeableConst8,
63
64
            /// MergeableConst16 - This is a section used by 16-byte constants,
65
            /// for example, vectors.
66
            MergeableConst16,
67
68
            /// MergeableConst32 - This is a section used by 32-byte constants,
69
            /// for example, vectors.
70
            MergeableConst32,
71
72
    /// Writeable - This is the base of all segments that need to be written
73
    /// to during program runtime.
74
75
       /// ThreadLocal - This is the base of all TLS segments.  All TLS
76
       /// objects must be writeable, otherwise there is no reason for them to
77
       /// be thread local!
78
79
           /// ThreadBSS - Zero-initialized TLS data objects.
80
           ThreadBSS,
81
82
           /// ThreadData - Initialized TLS data objects.
83
           ThreadData,
84
85
       /// GlobalWriteableData - Writeable data that is global (not thread
86
       /// local).
87
88
           /// BSS - Zero initialized writeable data.
89
           BSS,
90
91
               /// BSSLocal - This is BSS (zero initialized and writable) data
92
               /// which has local linkage.
93
               BSSLocal,
94
95
               /// BSSExtern - This is BSS data with normal external linkage.
96
               BSSExtern,
97
98
           /// Common - Data with common linkage.  These represent tentative
99
           /// definitions, which always have a zero initializer and are never
100
           /// marked 'constant'.
101
           Common,
102
103
           /// This is writeable data that has a non-zero initializer.
104
           Data,
105
106
           /// ReadOnlyWithRel - These are global variables that are never
107
           /// written to by the program, but that have relocations, so they
108
           /// must be stuck in a writeable section so that the dynamic linker
109
           /// can write to them.  If it chooses to, the dynamic linker can
110
           /// mark the pages these globals end up on as read-only after it is
111
           /// done with its relocation phase.
112
           ReadOnlyWithRel
113
  } K : 8;
114
public:
115
116
203k
  bool isMetadata() const { return K == Metadata; }
117
118
2.16M
  bool isText() const { return K == Text || 
K == ExecuteOnly754k
; }
119
120
407k
  bool isExecuteOnly() const { return K == ExecuteOnly; }
121
122
205k
  bool isReadOnly() const {
123
205k
    return K == ReadOnly || 
isMergeableCString()135k
||
124
205k
           
isMergeableConst()134k
;
125
205k
  }
126
127
744k
  bool isMergeableCString() const {
128
744k
    return K == Mergeable1ByteCString || 
K == Mergeable2ByteCString742k
||
129
744k
           
K == Mergeable4ByteCString742k
;
130
744k
  }
131
696k
  bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; }
132
298k
  bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; }
133
202k
  bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; }
134
135
612k
  bool isMergeableConst() const {
136
612k
    return K == MergeableConst4 || 
K == MergeableConst8612k
||
137
612k
           
K == MergeableConst16612k
||
K == MergeableConst32611k
;
138
612k
  }
139
252k
  bool isMergeableConst4() const { return K == MergeableConst4; }
140
247k
  bool isMergeableConst8() const { return K == MergeableConst8; }
141
241k
  bool isMergeableConst16() const { return K == MergeableConst16; }
142
209k
  bool isMergeableConst32() const { return K == MergeableConst32; }
143
144
203k
  bool isWriteable() const {
145
203k
    return isThreadLocal() || 
isGlobalWriteableData()203k
;
146
203k
  }
147
148
815k
  bool isThreadLocal() const {
149
815k
    return K == ThreadData || 
K == ThreadBSS815k
;
150
815k
  }
151
152
1.03M
  bool isThreadBSS() const { return K == ThreadBSS; }
153
833k
  bool isThreadData() const { return K == ThreadData; }
154
155
204k
  bool isGlobalWriteableData() const {
156
204k
    return isBSS() || 
isCommon()200k
||
isData()200k
||
isReadOnlyWithRel()196k
;
157
204k
  }
158
159
866k
  bool isBSS() const { return K == BSS || 
K == BSSLocal842k
||
K == BSSExtern829k
; }
160
424k
  bool isBSSLocal() const { return K == BSSLocal; }
161
18.3k
  bool isBSSExtern() const { return K == BSSExtern; }
162
163
841k
  bool isCommon() const { return K == Common; }
164
165
243k
  bool isData() const { return K == Data; }
166
167
283k
  bool isReadOnlyWithRel() const {
168
283k
    return K == ReadOnlyWithRel;
169
283k
  }
170
private:
171
4.26M
  static SectionKind get(Kind K) {
172
4.26M
    SectionKind Res;
173
4.26M
    Res.K = K;
174
4.26M
    return Res;
175
4.26M
  }
176
public:
177
178
612k
  static SectionKind getMetadata() { return get(Metadata); }
179
565k
  static SectionKind getText() { return get(Text); }
180
551
  static SectionKind getExecuteOnly() { return get(ExecuteOnly); }
181
2.24M
  static SectionKind getReadOnly() { return get(ReadOnly); }
182
416k
  static SectionKind getMergeable1ByteCString() {
183
416k
    return get(Mergeable1ByteCString);
184
416k
  }
185
16.9k
  static SectionKind getMergeable2ByteCString() {
186
16.9k
    return get(Mergeable2ByteCString);
187
16.9k
  }
188
246
  static SectionKind getMergeable4ByteCString() {
189
246
    return get(Mergeable4ByteCString);
190
246
  }
191
21.4k
  static SectionKind getMergeableConst4() { return get(MergeableConst4); }
192
23.0k
  static SectionKind getMergeableConst8() { return get(MergeableConst8); }
193
46.8k
  static SectionKind getMergeableConst16() { return get(MergeableConst16); }
194
5.93k
  static SectionKind getMergeableConst32() { return get(MergeableConst32); }
195
17.1k
  static SectionKind getThreadBSS() { return get(ThreadBSS); }
196
165
  static SectionKind getThreadData() { return get(ThreadData); }
197
59.1k
  static SectionKind getBSS() { return get(BSS); }
198
11.3k
  static SectionKind getBSSLocal() { return get(BSSLocal); }
199
7.39k
  static SectionKind getBSSExtern() { return get(BSSExtern); }
200
14.3k
  static SectionKind getCommon() { return get(Common); }
201
146k
  static SectionKind getData() { return get(Data); }
202
53.2k
  static SectionKind getReadOnlyWithRel() { return get(ReadOnlyWithRel); }
203
};
204
205
} // end namespace llvm
206
207
#endif