1 //===--- TargetBuiltins.h - Target specific builtin IDs ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Enumerates target-specific builtins in their own namespaces within
12 /// namespace ::clang.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_BASIC_TARGETBUILTINS_H
17 #define LLVM_CLANG_BASIC_TARGETBUILTINS_H
18 
19 #include "clang/Basic/Builtins.h"
20 #undef PPC
21 
22 namespace clang {
23 
24   namespace NEON {
25   enum {
26     LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
27 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
28 #include "clang/Basic/BuiltinsNEON.def"
29     FirstTSBuiltin
30   };
31   }
32 
33   /// \brief ARM builtins
34   namespace ARM {
35     enum {
36       LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
37       LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
38 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
39 #include "clang/Basic/BuiltinsARM.def"
40       LastTSBuiltin
41     };
42   }
43 
44   /// \brief AArch64 builtins
45   namespace AArch64 {
46   enum {
47     LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
48     LastNEONBuiltin = NEON::FirstTSBuiltin - 1,
49   #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
50   #include "clang/Basic/BuiltinsAArch64.def"
51     LastTSBuiltin
52   };
53   }
54 
55   /// \brief PPC builtins
56   namespace PPC {
57     enum {
58         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
59 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
60 #include "clang/Basic/BuiltinsPPC.def"
61         LastTSBuiltin
62     };
63   }
64 
65   /// \brief NVPTX builtins
66   namespace NVPTX {
67     enum {
68         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
69 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
70 #include "clang/Basic/BuiltinsNVPTX.def"
71         LastTSBuiltin
72     };
73   }
74 
75   /// \brief R600 builtins
76   namespace R600 {
77   enum {
78     LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
79   #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
80   #include "clang/Basic/BuiltinsR600.def"
81     LastTSBuiltin
82   };
83   }
84 
85   /// \brief X86 builtins
86   namespace X86 {
87     enum {
88         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
89 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
90 #include "clang/Basic/BuiltinsX86.def"
91         LastTSBuiltin
92     };
93   }
94 
95   /// \brief Flags to identify the types for overloaded Neon builtins.
96   ///
97   /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h.
98   class NeonTypeFlags {
99     enum {
100       EltTypeMask = 0xf,
101       UnsignedFlag = 0x10,
102       QuadFlag = 0x20
103     };
104     uint32_t Flags;
105 
106   public:
107     enum EltType {
108       Int8,
109       Int16,
110       Int32,
111       Int64,
112       Poly8,
113       Poly16,
114       Poly64,
115       Poly128,
116       Float16,
117       Float32,
118       Float64
119     };
120 
NeonTypeFlags(unsigned F)121     NeonTypeFlags(unsigned F) : Flags(F) {}
NeonTypeFlags(EltType ET,bool IsUnsigned,bool IsQuad)122     NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) {
123       if (IsUnsigned)
124         Flags |= UnsignedFlag;
125       if (IsQuad)
126         Flags |= QuadFlag;
127     }
128 
getEltType()129     EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
isPoly()130     bool isPoly() const {
131       EltType ET = getEltType();
132       return ET == Poly8 || ET == Poly16;
133     }
isUnsigned()134     bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
isQuad()135     bool isQuad() const { return (Flags & QuadFlag) != 0; }
136   };
137 
138   /// \brief Hexagon builtins
139   namespace Hexagon {
140     enum {
141         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
142 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
143 #include "clang/Basic/BuiltinsHexagon.def"
144         LastTSBuiltin
145     };
146   }
147 
148   /// \brief MIPS builtins
149   namespace Mips {
150     enum {
151         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
152 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
153 #include "clang/Basic/BuiltinsMips.def"
154         LastTSBuiltin
155     };
156   }
157 
158   /// \brief XCore builtins
159   namespace XCore {
160     enum {
161         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
162 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
163 #include "clang/Basic/BuiltinsXCore.def"
164         LastTSBuiltin
165     };
166   }
167 
168   /// \brief Le64 builtins
169   namespace Le64 {
170   enum {
171     LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
172   #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
173   #include "clang/Basic/BuiltinsLe64.def"
174     LastTSBuiltin
175   };
176   }
177 
178   /// \brief SystemZ builtins
179   namespace SystemZ {
180     enum {
181         LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
182 #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
183 #include "clang/Basic/BuiltinsSystemZ.def"
184         LastTSBuiltin
185     };
186   }
187 } // end namespace clang.
188 
189 #endif
190