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