Coverage Report

Created: 2020-10-24 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/TargetBuiltins.h
Line
Count
Source (jump to first uncovered line)
1
//===--- TargetBuiltins.h - Target specific builtin IDs ---------*- 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
/// \file
10
/// Enumerates target-specific builtins in their own namespaces within
11
/// namespace ::clang.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_BASIC_TARGETBUILTINS_H
16
#define LLVM_CLANG_BASIC_TARGETBUILTINS_H
17
18
#include <algorithm>
19
#include <stdint.h>
20
#include "clang/Basic/Builtins.h"
21
#include "llvm/Support/MathExtras.h"
22
#undef PPC
23
24
namespace clang {
25
26
  namespace NEON {
27
  enum {
28
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
29
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
30
#include "clang/Basic/BuiltinsNEON.def"
31
    FirstTSBuiltin
32
  };
33
  }
34
35
  /// ARM builtins
36
  namespace ARM {
37
    enum {
38
      LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
39
      LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
40
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
41
#include "clang/Basic/BuiltinsARM.def"
42
      LastTSBuiltin
43
    };
44
  }
45
46
  namespace SVE {
47
  enum {
48
    LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
49
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
50
#include "clang/Basic/BuiltinsSVE.def"
51
    FirstTSBuiltin,
52
  };
53
  }
54
55
  /// AArch64 builtins
56
  namespace AArch64 {
57
  enum {
58
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
59
    LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
60
    FirstSVEBuiltin = NEON::FirstTSBuiltin,
61
    LastSVEBuiltin = SVE::FirstTSBuiltin - 1,
62
  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
63
  #include "clang/Basic/BuiltinsAArch64.def"
64
    LastTSBuiltin
65
  };
66
  }
67
68
  /// BPF builtins
69
  namespace BPF {
70
  enum {
71
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
72
  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
73
  #include "clang/Basic/BuiltinsBPF.def"
74
    LastTSBuiltin
75
  };
76
  }
77
78
  /// PPC builtins
79
  namespace PPC {
80
    enum {
81
        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
82
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
83
#include "clang/Basic/BuiltinsPPC.def"
84
        LastTSBuiltin
85
    };
86
  }
87
88
  /// NVPTX builtins
89
  namespace NVPTX {
90
    enum {
91
        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
92
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
93
#include "clang/Basic/BuiltinsNVPTX.def"
94
        LastTSBuiltin
95
    };
96
  }
97
98
  /// AMDGPU builtins
99
  namespace AMDGPU {
100
  enum {
101
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
102
  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
103
  #include "clang/Basic/BuiltinsAMDGPU.def"
104
    LastTSBuiltin
105
  };
106
  }
107
108
  /// X86 builtins
109
  namespace X86 {
110
  enum {
111
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
112
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
113
#include "clang/Basic/BuiltinsX86.def"
114
    FirstX86_64Builtin,
115
    LastX86CommonBuiltin = FirstX86_64Builtin - 1,
116
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
117
#include "clang/Basic/BuiltinsX86_64.def"
118
    LastTSBuiltin
119
  };
120
  }
121
122
  /// VE builtins
123
  namespace VE {
124
  enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, LastTSBuiltin };
125
  }
126
127
  /// Flags to identify the types for overloaded Neon builtins.
128
  ///
129
  /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h.
130
  class NeonTypeFlags {
131
    enum {
132
      EltTypeMask = 0xf,
133
      UnsignedFlag = 0x10,
134
      QuadFlag = 0x20
135
    };
136
    uint32_t Flags;
137
138
  public:
139
    enum EltType {
140
      Int8,
141
      Int16,
142
      Int32,
143
      Int64,
144
      Poly8,
145
      Poly16,
146
      Poly64,
147
      Poly128,
148
      Float16,
149
      Float32,
150
      Float64,
151
      BFloat16
152
    };
153
154
15.2k
    NeonTypeFlags(unsigned F) : Flags(F) {}
155
69
    NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
156
69
      if (IsUnsigned)
157
0
        Flags |= UnsignedFlag;
158
69
      if (IsQuad)
159
39
        Flags |= QuadFlag;
160
69
    }
161
162
11.7k
    EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
163
18
    bool isPoly() const {
164
18
      EltType ET = getEltType();
165
18
      return ET == Poly8 || ET == Poly16 || 
ET == Poly6416
;
166
18
    }
167
8.67k
    bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
168
16.0k
    bool isQuad() const { return (Flags & QuadFlag) != 0; }
169
  };
170
171
  /// Flags to identify the types for overloaded SVE builtins.
172
  class SVETypeFlags {
173
    uint64_t Flags;
174
    unsigned EltTypeShift;
175
    unsigned MemEltTypeShift;
176
    unsigned MergeTypeShift;
177
    unsigned SplatOperandMaskShift;
178
179
  public:
180
#define LLVM_GET_SVE_TYPEFLAGS
181
#include "clang/Basic/arm_sve_typeflags.inc"
182
#undef LLVM_GET_SVE_TYPEFLAGS
183
184
    enum EltType {
185
#define LLVM_GET_SVE_ELTTYPES
186
#include "clang/Basic/arm_sve_typeflags.inc"
187
#undef LLVM_GET_SVE_ELTTYPES
188
    };
189
190
    enum MemEltType {
191
#define LLVM_GET_SVE_MEMELTTYPES
192
#include "clang/Basic/arm_sve_typeflags.inc"
193
#undef LLVM_GET_SVE_MEMELTTYPES
194
    };
195
196
    enum MergeType {
197
#define LLVM_GET_SVE_MERGETYPES
198
#include "clang/Basic/arm_sve_typeflags.inc"
199
#undef LLVM_GET_SVE_MERGETYPES
200
    };
201
202
    enum ImmCheckType {
203
#define LLVM_GET_SVE_IMMCHECKTYPES
204
#include "clang/Basic/arm_sve_typeflags.inc"
205
#undef LLVM_GET_SVE_IMMCHECKTYPES
206
    };
207
208
16.2k
    SVETypeFlags(uint64_t F) : Flags(F) {
209
16.2k
      EltTypeShift = llvm::countTrailingZeros(EltTypeMask);
210
16.2k
      MemEltTypeShift = llvm::countTrailingZeros(MemEltTypeMask);
211
16.2k
      MergeTypeShift = llvm::countTrailingZeros(MergeTypeMask);
212
16.2k
      SplatOperandMaskShift = llvm::countTrailingZeros(SplatOperandMask);
213
16.2k
    }
214
215
23.6k
    EltType getEltType() const {
216
23.6k
      return (EltType)((Flags & EltTypeMask) >> EltTypeShift);
217
23.6k
    }
218
219
1.86k
    MemEltType getMemEltType() const {
220
1.86k
      return (MemEltType)((Flags & MemEltTypeMask) >> MemEltTypeShift);
221
1.86k
    }
222
223
38.2k
    MergeType getMergeType() const {
224
38.2k
      return (MergeType)((Flags & MergeTypeMask) >> MergeTypeShift);
225
38.2k
    }
226
227
3.48k
    unsigned getSplatOperand() const {
228
3.48k
      return ((Flags & SplatOperandMask) >> SplatOperandMaskShift) - 1;
229
3.48k
    }
230
231
12.7k
    bool hasSplatOperand() const {
232
12.7k
      return Flags & SplatOperandMask;
233
12.7k
    }
234
235
16.1k
    bool isLoad() const { return Flags & IsLoad; }
236
15.4k
    bool isStore() const { return Flags & IsStore; }
237
15.2k
    bool isGatherLoad() const { return Flags & IsGatherLoad; }
238
14.0k
    bool isScatterStore() const { return Flags & IsScatterStore; }
239
13.3k
    bool isStructLoad() const { return Flags & IsStructLoad; }
240
13.2k
    bool isStructStore() const { return Flags & IsStructStore; }
241
1.87k
    bool isZExtReturn() const { return Flags & IsZExtReturn; }
242
1.68k
    bool isByteIndexed() const { return Flags & IsByteIndexed; }
243
12.7k
    bool isOverloadNone() const { return Flags & IsOverloadNone; }
244
12.1k
    bool isOverloadWhile() const { return Flags & IsOverloadWhile; }
245
11.5k
    bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
246
11.9k
    bool isOverloadWhileRW() const { return Flags & IsOverloadWhileRW; }
247
11.9k
    bool isOverloadCvt() const { return Flags & IsOverloadCvt; }
248
13.5k
    bool isPrefetch() const { return Flags & IsPrefetch; }
249
12.7k
    bool isReverseCompare() const { return Flags & ReverseCompare; }
250
12.7k
    bool isAppendSVALL() const { return Flags & IsAppendSVALL; }
251
12.7k
    bool isInsertOp1SVALL() const { return Flags & IsInsertOp1SVALL; }
252
13.4k
    bool isGatherPrefetch() const { return Flags & IsGatherPrefetch; }
253
12.7k
    bool isReverseUSDOT() const { return Flags & ReverseUSDOT; }
254
12.9k
    bool isUndef() const { return Flags & IsUndef; }
255
11.7k
    bool isTupleCreate() const { return Flags & IsTupleCreate; }
256
11.6k
    bool isTupleGet() const { return Flags & IsTupleGet; }
257
11.8k
    bool isTupleSet() const { return Flags & IsTupleSet; }
258
259
0
    uint64_t getBits() const { return Flags; }
260
0
    bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }
261
  };
262
263
  /// Hexagon builtins
264
  namespace Hexagon {
265
    enum {
266
        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
267
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
268
#include "clang/Basic/BuiltinsHexagon.def"
269
        LastTSBuiltin
270
    };
271
  }
272
273
  /// MIPS builtins
274
  namespace Mips {
275
    enum {
276
        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
277
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
278
#include "clang/Basic/BuiltinsMips.def"
279
        LastTSBuiltin
280
    };
281
  }
282
283
  /// XCore builtins
284
  namespace XCore {
285
    enum {
286
        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
287
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
288
#include "clang/Basic/BuiltinsXCore.def"
289
        LastTSBuiltin
290
    };
291
  }
292
293
  /// Le64 builtins
294
  namespace Le64 {
295
  enum {
296
    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
297
  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
298
  #include "clang/Basic/BuiltinsLe64.def"
299
    LastTSBuiltin
300
  };
301
  }
302
303
  /// SystemZ builtins
304
  namespace SystemZ {
305
    enum {
306
        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
307
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
308
#include "clang/Basic/BuiltinsSystemZ.def"
309
        LastTSBuiltin
310
    };
311
  }
312
313
  /// WebAssembly builtins
314
  namespace WebAssembly {
315
    enum {
316
      LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
317
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
318
#include "clang/Basic/BuiltinsWebAssembly.def"
319
      LastTSBuiltin
320
    };
321
  }
322
323
  static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
324
      {NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin,
325
       AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin,
326
       NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin,
327
       Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin,
328
       Le64::LastTSBuiltin, SystemZ::LastTSBuiltin,
329
       WebAssembly::LastTSBuiltin});
330
331
} // end namespace clang.
332
333
#endif