clang 17.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#include "clang/Basic/BuiltinsSVE.def"
53 };
54 }
55
56 /// AArch64 builtins
57 namespace AArch64 {
58 enum {
63 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
64 #include "clang/Basic/BuiltinsAArch64.def"
66 };
67 }
68
69 /// BPF builtins
70 namespace BPF {
71 enum {
73 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
74 #include "clang/Basic/BuiltinsBPF.def"
76 };
77 }
78
79 /// PPC builtins
80 namespace PPC {
81 enum {
83#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
84#include "clang/Basic/BuiltinsPPC.def"
86 };
87 }
88
89 /// NVPTX builtins
90 namespace NVPTX {
91 enum {
93#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
94#include "clang/Basic/BuiltinsNVPTX.def"
96 };
97 }
98
99 /// AMDGPU builtins
100 namespace AMDGPU {
101 enum {
103 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
104 #include "clang/Basic/BuiltinsAMDGPU.def"
106 };
107 }
108
109 /// X86 builtins
110 namespace X86 {
111 enum {
113#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
114#include "clang/Basic/BuiltinsX86.def"
117#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
118#include "clang/Basic/BuiltinsX86_64.def"
120 };
121 }
122
123 /// VE builtins
124 namespace VE {
125 enum {
127#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
128#include "clang/Basic/BuiltinsVE.def"
130 };
131 }
132
133 namespace RISCVVector {
134 enum {
136#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
137#include "clang/Basic/BuiltinsRISCVVector.def"
139 };
140 }
141
142 /// RISCV builtins
143 namespace RISCV {
144 enum {
148#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
149#include "clang/Basic/BuiltinsRISCV.def"
151 };
152 } // namespace RISCV
153
154 /// LoongArch builtins
155 namespace LoongArch {
156 enum {
158#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
159#include "clang/Basic/BuiltinsLoongArch.def"
161 };
162 } // namespace LoongArch
163
164 /// Flags to identify the types for overloaded Neon builtins.
165 ///
166 /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h.
168 enum {
169 EltTypeMask = 0xf,
170 UnsignedFlag = 0x10,
171 QuadFlag = 0x20
172 };
173 uint32_t Flags;
174
175 public:
176 enum EltType {
189 };
190
191 NeonTypeFlags(unsigned F) : Flags(F) {}
192 NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
193 if (IsUnsigned)
194 Flags |= UnsignedFlag;
195 if (IsQuad)
196 Flags |= QuadFlag;
197 }
198
199 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
200 bool isPoly() const {
201 EltType ET = getEltType();
202 return ET == Poly8 || ET == Poly16 || ET == Poly64;
203 }
204 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
205 bool isQuad() const { return (Flags & QuadFlag) != 0; }
206 };
207
208 /// Flags to identify the types for overloaded SVE builtins.
210 uint64_t Flags;
211 unsigned EltTypeShift;
212 unsigned MemEltTypeShift;
213 unsigned MergeTypeShift;
214 unsigned SplatOperandMaskShift;
215
216 public:
217#define LLVM_GET_SVE_TYPEFLAGS
218#include "clang/Basic/arm_sve_typeflags.inc"
219#undef LLVM_GET_SVE_TYPEFLAGS
220
221 enum EltType {
222#define LLVM_GET_SVE_ELTTYPES
223#include "clang/Basic/arm_sve_typeflags.inc"
224#undef LLVM_GET_SVE_ELTTYPES
225 };
226
228#define LLVM_GET_SVE_MEMELTTYPES
229#include "clang/Basic/arm_sve_typeflags.inc"
230#undef LLVM_GET_SVE_MEMELTTYPES
231 };
232
234#define LLVM_GET_SVE_MERGETYPES
235#include "clang/Basic/arm_sve_typeflags.inc"
236#undef LLVM_GET_SVE_MERGETYPES
237 };
238
240#define LLVM_GET_SVE_IMMCHECKTYPES
241#include "clang/Basic/arm_sve_typeflags.inc"
242#undef LLVM_GET_SVE_IMMCHECKTYPES
243 };
244
245 SVETypeFlags(uint64_t F) : Flags(F) {
246 EltTypeShift = llvm::countr_zero(EltTypeMask);
247 MemEltTypeShift = llvm::countr_zero(MemEltTypeMask);
248 MergeTypeShift = llvm::countr_zero(MergeTypeMask);
249 SplatOperandMaskShift = llvm::countr_zero(SplatOperandMask);
250 }
251
253 return (EltType)((Flags & EltTypeMask) >> EltTypeShift);
254 }
255
257 return (MemEltType)((Flags & MemEltTypeMask) >> MemEltTypeShift);
258 }
259
261 return (MergeType)((Flags & MergeTypeMask) >> MergeTypeShift);
262 }
263
264 unsigned getSplatOperand() const {
265 return ((Flags & SplatOperandMask) >> SplatOperandMaskShift) - 1;
266 }
267
268 bool hasSplatOperand() const {
269 return Flags & SplatOperandMask;
270 }
271
272 bool isLoad() const { return Flags & IsLoad; }
273 bool isStore() const { return Flags & IsStore; }
274 bool isGatherLoad() const { return Flags & IsGatherLoad; }
275 bool isScatterStore() const { return Flags & IsScatterStore; }
276 bool isStructLoad() const { return Flags & IsStructLoad; }
277 bool isStructStore() const { return Flags & IsStructStore; }
278 bool isZExtReturn() const { return Flags & IsZExtReturn; }
279 bool isByteIndexed() const { return Flags & IsByteIndexed; }
280 bool isOverloadNone() const { return Flags & IsOverloadNone; }
281 bool isOverloadWhile() const { return Flags & IsOverloadWhile; }
282 bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
283 bool isOverloadWhileRW() const { return Flags & IsOverloadWhileRW; }
284 bool isOverloadCvt() const { return Flags & IsOverloadCvt; }
285 bool isPrefetch() const { return Flags & IsPrefetch; }
286 bool isReverseCompare() const { return Flags & ReverseCompare; }
287 bool isAppendSVALL() const { return Flags & IsAppendSVALL; }
288 bool isInsertOp1SVALL() const { return Flags & IsInsertOp1SVALL; }
289 bool isGatherPrefetch() const { return Flags & IsGatherPrefetch; }
290 bool isReverseUSDOT() const { return Flags & ReverseUSDOT; }
291 bool isReverseMergeAnyBinOp() const { return Flags & ReverseMergeAnyBinOp; }
292 bool isUndef() const { return Flags & IsUndef; }
293 bool isTupleCreate() const { return Flags & IsTupleCreate; }
294 bool isTupleGet() const { return Flags & IsTupleGet; }
295 bool isTupleSet() const { return Flags & IsTupleSet; }
296
297 uint64_t getBits() const { return Flags; }
298 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }
299 };
300
301 /// Hexagon builtins
302 namespace Hexagon {
303 enum {
305#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
306#include "clang/Basic/BuiltinsHexagon.def"
308 };
309 }
310
311 /// MIPS builtins
312 namespace Mips {
313 enum {
315#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
316#include "clang/Basic/BuiltinsMips.def"
318 };
319 }
320
321 /// XCore builtins
322 namespace XCore {
323 enum {
325#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
326#include "clang/Basic/BuiltinsXCore.def"
328 };
329 }
330
331 /// SystemZ builtins
332 namespace SystemZ {
333 enum {
335#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
336#include "clang/Basic/BuiltinsSystemZ.def"
338 };
339 }
340
341 /// WebAssembly builtins
342 namespace WebAssembly {
343 enum {
345#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
346#include "clang/Basic/BuiltinsWebAssembly.def"
348 };
349 }
350
351 static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
357
358} // end namespace clang.
359
360#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)
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
uint64_t getBits() const
bool isGatherLoad() const
bool isOverloadCvt() const
EltType getEltType() const
bool isOverloadDefault() const
bool isPrefetch() const
bool isOverloadWhileRW() const
bool isTupleSet() const
bool isTupleGet() const
bool isFlagSet(uint64_t Flag) const
bool isInsertOp1SVALL() const
bool isOverloadWhile() 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
unsigned getSplatOperand() const
bool isStore() const
bool isScatterStore() const
bool isReverseCompare() const
static constexpr uint64_t LargestBuiltinID