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