clang 20.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>
21#include "llvm/Support/MathExtras.h"
22#undef PPC
23
24namespace clang {
25
26 namespace NEON {
27 enum {
29#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
30#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
31#include "clang/Basic/BuiltinsNEON.def"
33 };
34 }
35
36 /// ARM builtins
37 namespace ARM {
38 enum {
41#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
42#include "clang/Basic/BuiltinsARM.def"
44 };
45 }
46
47 namespace SVE {
48 enum {
50#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
51#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
52#include "clang/Basic/BuiltinsSVE.def"
54 };
55 }
56
57 namespace SME {
58 enum {
60#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
61#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
62#include "clang/Basic/BuiltinsSME.def"
64 };
65 }
66
67 /// AArch64 builtins
68 namespace AArch64 {
69 enum {
76 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
77 #include "clang/Basic/BuiltinsAArch64.def"
79 };
80 }
81
82 /// BPF builtins
83 namespace BPF {
84 enum {
86 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
87 #include "clang/Basic/BuiltinsBPF.inc"
89 };
90 }
91
92 /// PPC builtins
93 namespace PPC {
94 enum {
96#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
97#include "clang/Basic/BuiltinsPPC.def"
99 };
100 }
101
102 /// NVPTX builtins
103 namespace NVPTX {
104 enum {
106#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
107#include "clang/Basic/BuiltinsNVPTX.def"
109 };
110 }
111
112 /// AMDGPU builtins
113 namespace AMDGPU {
114 enum {
116 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
117 #include "clang/Basic/BuiltinsAMDGPU.def"
119 };
120 }
121
122 /// X86 builtins
123 namespace X86 {
124 enum {
126#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
127#include "clang/Basic/BuiltinsX86.def"
128#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
129#include "clang/Basic/BuiltinsX86.inc"
132#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
133#include "clang/Basic/BuiltinsX86_64.def"
135 };
136 }
137
138 /// VE builtins
139 namespace VE {
140 enum {
142#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
143#include "clang/Basic/BuiltinsVE.def"
145 };
146 }
147
148 namespace RISCVVector {
149 enum {
151#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
152#include "clang/Basic/BuiltinsRISCVVector.def"
154 };
155 }
156
157 /// RISCV builtins
158 namespace RISCV {
159 enum {
163#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
164#include "clang/Basic/BuiltinsRISCV.inc"
166 };
167 } // namespace RISCV
168
169 /// LoongArch builtins
170 namespace LoongArch {
171 enum {
173#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
174#include "clang/Basic/BuiltinsLoongArch.def"
176 };
177 } // namespace LoongArch
178
179 /// Flags to identify the types for overloaded Neon builtins.
180 ///
181 /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h.
183 enum {
184 EltTypeMask = 0xf,
185 UnsignedFlag = 0x10,
186 QuadFlag = 0x20
187 };
188 uint32_t Flags;
189
190 public:
191 enum EltType {
204 };
205
206 NeonTypeFlags(unsigned F) : Flags(F) {}
207 NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
208 if (IsUnsigned)
209 Flags |= UnsignedFlag;
210 if (IsQuad)
211 Flags |= QuadFlag;
212 }
213
214 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
215 bool isPoly() const {
216 EltType ET = getEltType();
217 return ET == Poly8 || ET == Poly16 || ET == Poly64;
218 }
219 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
220 bool isQuad() const { return (Flags & QuadFlag) != 0; }
221 unsigned getEltSizeInBits() const {
222 switch (getEltType()) {
223 case Int8:
224 case Poly8:
225 return 8;
226 case Int16:
227 case Float16:
228 case Poly16:
229 case BFloat16:
230 return 16;
231 case Int32:
232 case Float32:
233 return 32;
234 case Int64:
235 case Float64:
236 case Poly64:
237 return 64;
238 case Poly128:
239 return 128;
240 }
241 llvm_unreachable("Invalid NeonTypeFlag!");
242 }
243 };
244
245 // Shared between SVE/SME and NEON
247#define LLVM_GET_ARM_INTRIN_IMMCHECKTYPES
248#include "clang/Basic/arm_immcheck_types.inc"
249#undef LLVM_GET_ARM_INTRIN_IMMCHECKTYPES
250 };
251
252 /// Flags to identify the types for overloaded SVE builtins.
254 uint64_t Flags;
255 unsigned EltTypeShift;
256 unsigned MemEltTypeShift;
257 unsigned MergeTypeShift;
258 unsigned SplatOperandMaskShift;
259
260 public:
261#define LLVM_GET_SVE_TYPEFLAGS
262#include "clang/Basic/arm_sve_typeflags.inc"
263#undef LLVM_GET_SVE_TYPEFLAGS
264
265 enum EltType {
266#define LLVM_GET_SVE_ELTTYPES
267#include "clang/Basic/arm_sve_typeflags.inc"
268#undef LLVM_GET_SVE_ELTTYPES
269 };
270
272#define LLVM_GET_SVE_MEMELTTYPES
273#include "clang/Basic/arm_sve_typeflags.inc"
274#undef LLVM_GET_SVE_MEMELTTYPES
275 };
276
278#define LLVM_GET_SVE_MERGETYPES
279#include "clang/Basic/arm_sve_typeflags.inc"
280#undef LLVM_GET_SVE_MERGETYPES
281 };
282
283 SVETypeFlags(uint64_t F) : Flags(F) {
284 EltTypeShift = llvm::countr_zero(EltTypeMask);
285 MemEltTypeShift = llvm::countr_zero(MemEltTypeMask);
286 MergeTypeShift = llvm::countr_zero(MergeTypeMask);
287 SplatOperandMaskShift = llvm::countr_zero(SplatOperandMask);
288 }
289
291 return (EltType)((Flags & EltTypeMask) >> EltTypeShift);
292 }
293
295 return (MemEltType)((Flags & MemEltTypeMask) >> MemEltTypeShift);
296 }
297
299 return (MergeType)((Flags & MergeTypeMask) >> MergeTypeShift);
300 }
301
302 unsigned getSplatOperand() const {
303 return ((Flags & SplatOperandMask) >> SplatOperandMaskShift) - 1;
304 }
305
306 bool hasSplatOperand() const {
307 return Flags & SplatOperandMask;
308 }
309
310 bool isLoad() const { return Flags & IsLoad; }
311 bool isStore() const { return Flags & IsStore; }
312 bool isGatherLoad() const { return Flags & IsGatherLoad; }
313 bool isScatterStore() const { return Flags & IsScatterStore; }
314 bool isStructLoad() const { return Flags & IsStructLoad; }
315 bool isStructStore() const { return Flags & IsStructStore; }
316 bool isZExtReturn() const { return Flags & IsZExtReturn; }
317 bool isByteIndexed() const { return Flags & IsByteIndexed; }
318 bool isOverloadNone() const { return Flags & IsOverloadNone; }
320 return Flags & IsOverloadWhileOrMultiVecCvt;
321 }
322 bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
323 bool isOverloadWhileRW() const { return Flags & IsOverloadWhileRW; }
324 bool isOverloadCvt() const { return Flags & IsOverloadCvt; }
325 bool isPrefetch() const { return Flags & IsPrefetch; }
326 bool isReverseCompare() const { return Flags & ReverseCompare; }
327 bool isAppendSVALL() const { return Flags & IsAppendSVALL; }
328 bool isInsertOp1SVALL() const { return Flags & IsInsertOp1SVALL; }
329 bool isGatherPrefetch() const { return Flags & IsGatherPrefetch; }
330 bool isReverseUSDOT() const { return Flags & ReverseUSDOT; }
331 bool isReverseMergeAnyBinOp() const { return Flags & ReverseMergeAnyBinOp; }
332 bool isReverseMergeAnyAccOp() const { return Flags & ReverseMergeAnyAccOp; }
333 bool isUndef() const { return Flags & IsUndef; }
334 bool isTupleCreate() const { return Flags & IsTupleCreate; }
335 bool isTupleGet() const { return Flags & IsTupleGet; }
336 bool isTupleSet() const { return Flags & IsTupleSet; }
337 bool isReadZA() const { return Flags & IsReadZA; }
338 bool isWriteZA() const { return Flags & IsWriteZA; }
339 bool setsFPMR() const { return Flags & SetsFPMR; }
340 bool isReductionQV() const { return Flags & IsReductionQV; }
341 uint64_t getBits() const { return Flags; }
342 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }
343 };
344
345 /// Hexagon builtins
346 namespace Hexagon {
347 enum {
349#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
350#include "clang/Basic/BuiltinsHexagon.def"
352 };
353 }
354
355 /// MIPS builtins
356 namespace Mips {
357 enum {
359#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
360#include "clang/Basic/BuiltinsMips.def"
362 };
363 }
364
365 /// XCore builtins
366 namespace XCore {
367 enum {
369#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
370#include "clang/Basic/BuiltinsXCore.def"
372 };
373 }
374
375 /// SystemZ builtins
376 namespace SystemZ {
377 enum {
379#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
380#include "clang/Basic/BuiltinsSystemZ.def"
382 };
383 }
384
385 /// WebAssembly builtins
386 namespace WebAssembly {
387 enum {
389#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
390#include "clang/Basic/BuiltinsWebAssembly.def"
392 };
393 }
394
395 static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
401
402} // end namespace clang.
403
404#endif
Defines enum values for all the target-independent builtin functions.
Flags to identify the types for overloaded Neon builtins.
bool isUnsigned() const
NeonTypeFlags(unsigned F)
unsigned getEltSizeInBits() const
EltType getEltType() const
NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad)
Flags to identify the types for overloaded SVE builtins.
bool isZExtReturn() const
bool isReverseUSDOT() const
bool isOverloadNone() const
bool isUndef() const
MemEltType getMemEltType() const
bool isWriteZA() const
uint64_t getBits() const
bool isGatherLoad() const
bool isOverloadCvt() const
EltType getEltType() const
bool isOverloadDefault() const
bool isPrefetch() const
bool isOverloadWhileRW() const
bool isReadZA() const
bool isTupleSet() const
bool isReverseMergeAnyAccOp() const
bool isReductionQV() const
bool isTupleGet() const
bool isFlagSet(uint64_t Flag) const
bool isInsertOp1SVALL() const
bool isAppendSVALL() const
bool isReverseMergeAnyBinOp() const
bool isStructStore() const
bool isTupleCreate() const
bool isGatherPrefetch() const
SVETypeFlags(uint64_t F)
bool hasSplatOperand() const
MergeType getMergeType() const
bool isByteIndexed() const
bool isStructLoad() const
bool setsFPMR() const
bool isOverloadWhileOrMultiVecCvt() const
unsigned getSplatOperand() const
bool isStore() const
bool isScatterStore() const
bool isReverseCompare() const
The JSON file list parser is used to communicate input to InstallAPI.
static constexpr uint64_t LargestBuiltinID