clang 24.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 GET_NEON_BUILTIN_ENUMERATORS
30#include "clang/Basic/arm_neon.inc"
33#include "clang/Basic/arm_fp16.inc"
34#undef GET_NEON_BUILTIN_ENUMERATORS
36 };
37 }
38
39 /// ARM builtins
40 namespace ARM {
41 enum {
44#define GET_MVE_BUILTIN_ENUMERATORS
45#include "clang/Basic/arm_mve_builtins.inc"
46#undef GET_MVE_BUILTIN_ENUMERATORS
49#define GET_CDE_BUILTIN_ENUMERATORS
50#include "clang/Basic/arm_cde_builtins.inc"
51#undef GET_CDE_BUILTIN_ENUMERATORS
54#define GET_BUILTIN_ENUMERATORS
55#include "clang/Basic/BuiltinsARM.inc"
56#undef GET_BUILTIN_ENUMERATORS
58 };
59 }
60
61 namespace SVE {
62 enum {
64#define GET_SVE_BUILTIN_ENUMERATORS
65#include "clang/Basic/arm_sve_builtins.inc"
66#undef GET_SVE_BUILTIN_ENUMERATORS
69#define GET_SVE_BUILTINS
70#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
71#include "clang/Basic/BuiltinsAArch64NeonSVEBridge.def"
72#undef TARGET_BUILTIN
73#undef GET_SVE_BUILTINS
75 };
76 }
77
78 namespace SME {
79 enum {
81#define GET_SME_BUILTIN_ENUMERATORS
82#include "clang/Basic/arm_sme_builtins.inc"
83#undef GET_SME_BUILTIN_ENUMERATORS
85 };
86 }
87
88 namespace AArch64 {
89 enum {
96#define GET_BUILTIN_ENUMERATORS
97#include "clang/Basic/BuiltinsAArch64.inc"
98#undef GET_BUILTIN_ENUMERATORS
100 };
101 }
102
103 /// BPF builtins
104 namespace BPF {
105 enum {
107#define GET_BUILTIN_ENUMERATORS
108#include "clang/Basic/BuiltinsBPF.inc"
109#undef GET_BUILTIN_ENUMERATORS
111 };
112 }
113
114 /// PPC builtins
115 namespace PPC {
116 enum {
118#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
119#include "clang/Basic/BuiltinsPPC.def"
121 };
122 }
123
124 /// NVPTX builtins
125 namespace NVPTX {
126 enum {
128#define GET_BUILTIN_ENUMERATORS
129#include "clang/Basic/BuiltinsNVPTX.inc"
130#undef GET_BUILTIN_ENUMERATORS
132 };
133 }
134
135 /// AMDGPU builtins
136 namespace AMDGPU {
137 enum {
139#define GET_BUILTIN_ENUMERATORS
140#include "clang/Basic/BuiltinsAMDGPU.inc"
141#undef GET_BUILTIN_ENUMERATORS
143 };
144 }
145
146 /// DirectX builtins
147 namespace DirectX {
148 enum {
150#define GET_BUILTIN_ENUMERATORS
151#include "clang/Basic/BuiltinsDirectX.inc"
152#undef GET_BUILTIN_ENUMERATORS
154 };
155 } // namespace DirectX
156
157 /// SPIRV builtins
158 namespace SPIRV {
159 enum {
161#define GET_BUILTIN_ENUMERATORS
162#include "clang/Basic/BuiltinsSPIRVCommon.inc"
163#undef GET_BUILTIN_ENUMERATORS
166#define GET_BUILTIN_ENUMERATORS
167#include "clang/Basic/BuiltinsSPIRVVK.inc"
168#undef GET_BUILTIN_ENUMERATORS
171#define GET_BUILTIN_ENUMERATORS
172#include "clang/Basic/BuiltinsSPIRVCL.inc"
173#undef GET_BUILTIN_ENUMERATORS
175 };
176 } // namespace SPIRV
177
178 /// X86 builtins
179 namespace X86 {
180 enum {
182#define GET_BUILTIN_ENUMERATORS
183#include "clang/Basic/BuiltinsX86.inc"
184#undef GET_BUILTIN_ENUMERATORS
187#define GET_BUILTIN_ENUMERATORS
188#include "clang/Basic/BuiltinsX86_64.inc"
189#undef GET_BUILTIN_ENUMERATORS
191 };
192 }
193
194 /// VE builtins
195 namespace VE {
196 enum {
198#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
199#include "clang/Basic/BuiltinsVE.def"
201 };
202 }
203
204 namespace RISCVVector {
205 enum {
207#define GET_RISCVV_BUILTIN_ENUMERATORS
208#include "clang/Basic/riscv_vector_builtins.inc"
211#include "clang/Basic/riscv_sifive_vector_builtins.inc"
214#include "clang/Basic/riscv_andes_vector_builtins.inc"
215#undef GET_RISCVV_BUILTIN_ENUMERATORS
217 };
218 }
219
220 /// RISCV builtins
221 namespace RISCV {
222 enum {
226#define GET_BUILTIN_ENUMERATORS
227#include "clang/Basic/BuiltinsRISCV.inc"
228#undef GET_BUILTIN_ENUMERATORS
230 };
231 } // namespace RISCV
232
233 /// LoongArch builtins
234 namespace LoongArch {
235 enum {
237#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
238#include "clang/Basic/BuiltinsLoongArchBase.def"
241#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
242#include "clang/Basic/BuiltinsLoongArchLSX.def"
245#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BI##ID,
246#include "clang/Basic/BuiltinsLoongArchLASX.def"
248 };
249 } // namespace LoongArch
250
251 /// Flags to identify the types for overloaded Neon builtins.
252 ///
253 /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h.
255 enum {
256 EltTypeMask = 0xf,
257 UnsignedFlag = 0x10,
258 QuadFlag = 0x20
259 };
260 uint32_t Flags;
261
262 public:
278
279 NeonTypeFlags(unsigned F) : Flags(F) {}
280 NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
281 if (IsUnsigned)
282 Flags |= UnsignedFlag;
283 if (IsQuad)
284 Flags |= QuadFlag;
285 }
286
287 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
288 bool isPoly() const {
289 EltType ET = getEltType();
290 return ET == Poly8 || ET == Poly16 || ET == Poly64;
291 }
292 bool isFloatingPoint() const {
293 EltType ET = getEltType();
294 return ET == Float16 || ET == Float32 || ET == Float64 || ET == BFloat16;
295 }
296 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
297 bool isQuad() const { return (Flags & QuadFlag) != 0; }
298 unsigned getEltSizeInBits() const {
299 switch (getEltType()) {
300 case Int8:
301 case Poly8:
302 case MFloat8:
303 return 8;
304 case Int16:
305 case Float16:
306 case Poly16:
307 case BFloat16:
308 return 16;
309 case Int32:
310 case Float32:
311 return 32;
312 case Int64:
313 case Float64:
314 case Poly64:
315 return 64;
316 case Poly128:
317 return 128;
318 }
319 llvm_unreachable("Invalid NeonTypeFlag!");
320 }
321 };
322
323 // Shared between SVE/SME and NEON
325#define LLVM_GET_ARM_INTRIN_IMMCHECKTYPES
326#include "clang/Basic/arm_immcheck_types.inc"
327#undef LLVM_GET_ARM_INTRIN_IMMCHECKTYPES
328 };
329
330 /// Flags to identify the types for overloaded SVE builtins.
332 uint64_t Flags;
333 unsigned EltTypeShift;
334 unsigned MemEltTypeShift;
335 unsigned MergeTypeShift;
336 unsigned SplatOperandMaskShift;
337
338 public:
339#define LLVM_GET_SVE_TYPEFLAGS
340#include "clang/Basic/arm_sve_typeflags.inc"
341#undef LLVM_GET_SVE_TYPEFLAGS
342
343 enum EltType {
344#define LLVM_GET_SVE_ELTTYPES
345#include "clang/Basic/arm_sve_typeflags.inc"
346#undef LLVM_GET_SVE_ELTTYPES
347 };
348
350#define LLVM_GET_SVE_MEMELTTYPES
351#include "clang/Basic/arm_sve_typeflags.inc"
352#undef LLVM_GET_SVE_MEMELTTYPES
353 };
354
356#define LLVM_GET_SVE_MERGETYPES
357#include "clang/Basic/arm_sve_typeflags.inc"
358#undef LLVM_GET_SVE_MERGETYPES
359 };
360
361 SVETypeFlags(uint64_t F) : Flags(F) {
362 EltTypeShift = llvm::countr_zero(EltTypeMask);
363 MemEltTypeShift = llvm::countr_zero(MemEltTypeMask);
364 MergeTypeShift = llvm::countr_zero(MergeTypeMask);
365 SplatOperandMaskShift = llvm::countr_zero(SplatOperandMask);
366 }
367
369 return (EltType)((Flags & EltTypeMask) >> EltTypeShift);
370 }
371
373 return (MemEltType)((Flags & MemEltTypeMask) >> MemEltTypeShift);
374 }
375
377 return (MergeType)((Flags & MergeTypeMask) >> MergeTypeShift);
378 }
379
380 unsigned getSplatOperand() const {
381 return ((Flags & SplatOperandMask) >> SplatOperandMaskShift) - 1;
382 }
383
384 bool hasSplatOperand() const {
385 return Flags & SplatOperandMask;
386 }
387
388 bool isLoad() const { return Flags & IsLoad; }
389 bool isStore() const { return Flags & IsStore; }
390 bool isGatherLoad() const { return Flags & IsGatherLoad; }
391 bool isScatterStore() const { return Flags & IsScatterStore; }
392 bool isStructLoad() const { return Flags & IsStructLoad; }
393 bool isStructStore() const { return Flags & IsStructStore; }
394 bool isZExtReturn() const { return Flags & IsZExtReturn; }
395 bool isByteIndexed() const { return Flags & IsByteIndexed; }
396 bool isOverloadNone() const { return Flags & IsOverloadNone; }
398 return Flags & IsOverloadWhileOrMultiVecCvt;
399 }
400 bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
401 bool isOverloadWhileRW() const { return Flags & IsOverloadWhileRW; }
403 return Flags & IsOverloadFirstandLast;
404 }
406 return Flags & IsOverloadDefaultAndOp0;
407 }
408 bool isPrefetch() const { return Flags & IsPrefetch; }
409 bool isReverseCompare() const { return Flags & ReverseCompare; }
410 bool isAppendSVALL() const { return Flags & IsAppendSVALL; }
411 bool isInsertOp1SVALL() const { return Flags & IsInsertOp1SVALL; }
412 bool isGatherPrefetch() const { return Flags & IsGatherPrefetch; }
413 bool isReverseUSDOT() const { return Flags & ReverseUSDOT; }
414 bool isReverseMergeAnyBinOp() const { return Flags & ReverseMergeAnyBinOp; }
415 bool isReverseMergeAnyAccOp() const { return Flags & ReverseMergeAnyAccOp; }
416 bool isUndef() const { return Flags & IsUndef; }
417 bool isTupleCreate() const { return Flags & IsTupleCreate; }
418 bool isTupleGet() const { return Flags & IsTupleGet; }
419 bool isTupleSet() const { return Flags & IsTupleSet; }
420 bool isReadZA() const { return Flags & IsReadZA; }
421 bool isWriteZA() const { return Flags & IsWriteZA; }
422 bool setsFPMR() const { return Flags & SetsFPMR; }
423 bool isReductionQV() const { return Flags & IsReductionQV; }
424 uint64_t getBits() const { return Flags; }
425 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }
426 };
427
428 /// Hexagon builtins
429 namespace Hexagon {
430 enum {
432#define GET_BUILTIN_ENUMERATORS
433#include "clang/Basic/BuiltinsHexagon.inc"
434#undef GET_BUILTIN_ENUMERATORS
436 };
437 }
438
439 /// MIPS builtins
440 namespace Mips {
441 enum {
443#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
444#include "clang/Basic/BuiltinsMips.def"
446 };
447 }
448
449 /// XCore builtins
450 namespace XCore {
451 enum {
453#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
454#include "clang/Basic/BuiltinsXCore.def"
456 };
457 }
458
459 /// SystemZ builtins
460 namespace SystemZ {
461 enum {
463#define GET_BUILTIN_ENUMERATORS
464#include "clang/Basic/BuiltinsSystemZ.inc"
465#undef GET_BUILTIN_ENUMERATORS
468#define GET_BUILTIN_ENUMERATORS
469#include "clang/Basic/BuiltinsZOS.inc"
470#undef GET_BUILTIN_ENUMERATORS
472 };
473 }
474
475 /// WebAssembly builtins
476 namespace WebAssembly {
477 enum {
479#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
480#include "clang/Basic/BuiltinsWebAssembly.def"
482 };
483 }
484
485 /// AVR builtins
486 namespace AVR {
487 enum {
489#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
490#include "clang/Basic/BuiltinsAVR.def"
492 };
493 } // namespace AVR
494
495 static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
501
502} // end namespace clang.
503
504#endif
Defines enum values for all the target-independent builtin functions.
bool isFloatingPoint() const
unsigned getEltSizeInBits() const
EltType getEltType() const
NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad)
bool isZExtReturn() const
bool isReverseUSDOT() const
bool isOverloadNone() const
MemEltType getMemEltType() const
uint64_t getBits() const
bool isGatherLoad() const
EltType getEltType() const
bool isOverloadFirstandLast() const
bool isOverloadDefault() const
bool isPrefetch() const
bool isOverloadWhileRW() 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 isOverloadDefaultAndOp0() const
bool isTupleCreate() const
bool isGatherPrefetch() const
bool hasSplatOperand() const
MergeType getMergeType() const
bool isByteIndexed() const
bool isStructLoad() const
bool isOverloadWhileOrMultiVecCvt() const
unsigned getSplatOperand() const
bool isScatterStore() const
bool isReverseCompare() const
ARM builtins.
AVR builtins.
BPF builtins.
DirectX builtins.
Hexagon builtins.
LoongArch builtins.
MIPS builtins.
PPC builtins.
RISCV builtins.
SPIRV builtins.
SystemZ builtins.
VE builtins.
WebAssembly builtins.
X86 builtins.
XCore builtins.
Top level wrappers for InstallAPI frontend operations.
static constexpr uint64_t LargestBuiltinID
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t