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"
130#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
131#include "clang/Basic/BuiltinsX86_64.def"
133 };
134 }
135
136 /// VE builtins
137 namespace VE {
138 enum {
140#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
141#include "clang/Basic/BuiltinsVE.def"
143 };
144 }
145
146 namespace RISCVVector {
147 enum {
149#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
150#include "clang/Basic/BuiltinsRISCVVector.def"
152 };
153 }
154
155 /// RISCV builtins
156 namespace RISCV {
157 enum {
161#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
162#include "clang/Basic/BuiltinsRISCV.inc"
164 };
165 } // namespace RISCV
166
167 /// LoongArch builtins
168 namespace LoongArch {
169 enum {
171#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
172#include "clang/Basic/BuiltinsLoongArch.def"
174 };
175 } // namespace LoongArch
176
177 /// Flags to identify the types for overloaded Neon builtins.
178 ///
179 /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h.
181 enum {
182 EltTypeMask = 0xf,
183 UnsignedFlag = 0x10,
184 QuadFlag = 0x20
185 };
186 uint32_t Flags;
187
188 public:
189 enum EltType {
202 };
203
204 NeonTypeFlags(unsigned F) : Flags(F) {}
205 NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
206 if (IsUnsigned)
207 Flags |= UnsignedFlag;
208 if (IsQuad)
209 Flags |= QuadFlag;
210 }
211
212 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
213 bool isPoly() const {
214 EltType ET = getEltType();
215 return ET == Poly8 || ET == Poly16 || ET == Poly64;
216 }
217 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
218 bool isQuad() const { return (Flags & QuadFlag) != 0; }
219 };
220
221 /// Flags to identify the types for overloaded SVE builtins.
223 uint64_t Flags;
224 unsigned EltTypeShift;
225 unsigned MemEltTypeShift;
226 unsigned MergeTypeShift;
227 unsigned SplatOperandMaskShift;
228
229 public:
230#define LLVM_GET_SVE_TYPEFLAGS
231#include "clang/Basic/arm_sve_typeflags.inc"
232#undef LLVM_GET_SVE_TYPEFLAGS
233
234 enum EltType {
235#define LLVM_GET_SVE_ELTTYPES
236#include "clang/Basic/arm_sve_typeflags.inc"
237#undef LLVM_GET_SVE_ELTTYPES
238 };
239
241#define LLVM_GET_SVE_MEMELTTYPES
242#include "clang/Basic/arm_sve_typeflags.inc"
243#undef LLVM_GET_SVE_MEMELTTYPES
244 };
245
247#define LLVM_GET_SVE_MERGETYPES
248#include "clang/Basic/arm_sve_typeflags.inc"
249#undef LLVM_GET_SVE_MERGETYPES
250 };
251
253#define LLVM_GET_SVE_IMMCHECKTYPES
254#include "clang/Basic/arm_sve_typeflags.inc"
255#undef LLVM_GET_SVE_IMMCHECKTYPES
256 };
257
258 SVETypeFlags(uint64_t F) : Flags(F) {
259 EltTypeShift = llvm::countr_zero(EltTypeMask);
260 MemEltTypeShift = llvm::countr_zero(MemEltTypeMask);
261 MergeTypeShift = llvm::countr_zero(MergeTypeMask);
262 SplatOperandMaskShift = llvm::countr_zero(SplatOperandMask);
263 }
264
266 return (EltType)((Flags & EltTypeMask) >> EltTypeShift);
267 }
268
270 return (MemEltType)((Flags & MemEltTypeMask) >> MemEltTypeShift);
271 }
272
274 return (MergeType)((Flags & MergeTypeMask) >> MergeTypeShift);
275 }
276
277 unsigned getSplatOperand() const {
278 return ((Flags & SplatOperandMask) >> SplatOperandMaskShift) - 1;
279 }
280
281 bool hasSplatOperand() const {
282 return Flags & SplatOperandMask;
283 }
284
285 bool isLoad() const { return Flags & IsLoad; }
286 bool isStore() const { return Flags & IsStore; }
287 bool isGatherLoad() const { return Flags & IsGatherLoad; }
288 bool isScatterStore() const { return Flags & IsScatterStore; }
289 bool isStructLoad() const { return Flags & IsStructLoad; }
290 bool isStructStore() const { return Flags & IsStructStore; }
291 bool isZExtReturn() const { return Flags & IsZExtReturn; }
292 bool isByteIndexed() const { return Flags & IsByteIndexed; }
293 bool isOverloadNone() const { return Flags & IsOverloadNone; }
295 return Flags & IsOverloadWhileOrMultiVecCvt;
296 }
297 bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
298 bool isOverloadWhileRW() const { return Flags & IsOverloadWhileRW; }
299 bool isOverloadCvt() const { return Flags & IsOverloadCvt; }
300 bool isPrefetch() const { return Flags & IsPrefetch; }
301 bool isReverseCompare() const { return Flags & ReverseCompare; }
302 bool isAppendSVALL() const { return Flags & IsAppendSVALL; }
303 bool isInsertOp1SVALL() const { return Flags & IsInsertOp1SVALL; }
304 bool isGatherPrefetch() const { return Flags & IsGatherPrefetch; }
305 bool isReverseUSDOT() const { return Flags & ReverseUSDOT; }
306 bool isReverseMergeAnyBinOp() const { return Flags & ReverseMergeAnyBinOp; }
307 bool isReverseMergeAnyAccOp() const { return Flags & ReverseMergeAnyAccOp; }
308 bool isUndef() const { return Flags & IsUndef; }
309 bool isTupleCreate() const { return Flags & IsTupleCreate; }
310 bool isTupleGet() const { return Flags & IsTupleGet; }
311 bool isTupleSet() const { return Flags & IsTupleSet; }
312 bool isReadZA() const { return Flags & IsReadZA; }
313 bool isWriteZA() const { return Flags & IsWriteZA; }
314 bool isReductionQV() const { return Flags & IsReductionQV; }
315 uint64_t getBits() const { return Flags; }
316 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }
317 };
318
319 /// Hexagon builtins
320 namespace Hexagon {
321 enum {
323#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
324#include "clang/Basic/BuiltinsHexagon.def"
326 };
327 }
328
329 /// MIPS builtins
330 namespace Mips {
331 enum {
333#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
334#include "clang/Basic/BuiltinsMips.def"
336 };
337 }
338
339 /// XCore builtins
340 namespace XCore {
341 enum {
343#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
344#include "clang/Basic/BuiltinsXCore.def"
346 };
347 }
348
349 /// SystemZ builtins
350 namespace SystemZ {
351 enum {
353#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
354#include "clang/Basic/BuiltinsSystemZ.def"
356 };
357 }
358
359 /// WebAssembly builtins
360 namespace WebAssembly {
361 enum {
363#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
364#include "clang/Basic/BuiltinsWebAssembly.def"
366 };
367 }
368
369 static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
375
376} // end namespace clang.
377
378#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
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 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