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 <stdint.h> 20 #include "clang/Basic/Builtins.h" 21 #undef PPC 22 23 namespace clang { 24 25 namespace NEON { 26 enum { 27 LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 28 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 29 #include "clang/Basic/BuiltinsNEON.def" 30 FirstTSBuiltin 31 }; 32 } 33 34 /// \brief ARM builtins 35 namespace ARM { 36 enum { 37 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 38 LastNEONBuiltin = NEON::FirstTSBuiltin - 1, 39 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 40 #include "clang/Basic/BuiltinsARM.def" 41 LastTSBuiltin 42 }; 43 } 44 45 /// \brief AArch64 builtins 46 namespace AArch64 { 47 enum { 48 LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 49 LastNEONBuiltin = NEON::FirstTSBuiltin - 1, 50 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 51 #include "clang/Basic/BuiltinsAArch64.def" 52 LastTSBuiltin 53 }; 54 } 55 56 /// \brief PPC builtins 57 namespace PPC { 58 enum { 59 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 60 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 61 #include "clang/Basic/BuiltinsPPC.def" 62 LastTSBuiltin 63 }; 64 } 65 66 /// \brief NVPTX builtins 67 namespace NVPTX { 68 enum { 69 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 70 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 71 #include "clang/Basic/BuiltinsNVPTX.def" 72 LastTSBuiltin 73 }; 74 } 75 76 /// \brief AMDGPU builtins 77 namespace AMDGPU { 78 enum { 79 LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 80 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 81 #include "clang/Basic/BuiltinsAMDGPU.def" 82 LastTSBuiltin 83 }; 84 } 85 86 /// \brief X86 builtins 87 namespace X86 { 88 enum { 89 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 90 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 91 #include "clang/Basic/BuiltinsX86.def" 92 LastTSBuiltin 93 }; 94 } 95 96 /// \brief Flags to identify the types for overloaded Neon builtins. 97 /// 98 /// These must be kept in sync with the flags in utils/TableGen/NeonEmitter.h. 99 class NeonTypeFlags { 100 enum { 101 EltTypeMask = 0xf, 102 UnsignedFlag = 0x10, 103 QuadFlag = 0x20 104 }; 105 uint32_t Flags; 106 107 public: 108 enum EltType { 109 Int8, 110 Int16, 111 Int32, 112 Int64, 113 Poly8, 114 Poly16, 115 Poly64, 116 Poly128, 117 Float16, 118 Float32, 119 Float64 120 }; 121 NeonTypeFlags(unsigned F)122 NeonTypeFlags(unsigned F) : Flags(F) {} NeonTypeFlags(EltType ET,bool IsUnsigned,bool IsQuad)123 NeonTypeFlags(EltType ET, bool IsUnsigned, bool IsQuad) : Flags(ET) { 124 if (IsUnsigned) 125 Flags |= UnsignedFlag; 126 if (IsQuad) 127 Flags |= QuadFlag; 128 } 129 getEltType()130 EltType getEltType() const { return (EltType)(Flags & EltTypeMask); } isPoly()131 bool isPoly() const { 132 EltType ET = getEltType(); 133 return ET == Poly8 || ET == Poly16; 134 } isUnsigned()135 bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; } isQuad()136 bool isQuad() const { return (Flags & QuadFlag) != 0; } 137 }; 138 139 /// \brief Hexagon builtins 140 namespace Hexagon { 141 enum { 142 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 143 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 144 #include "clang/Basic/BuiltinsHexagon.def" 145 LastTSBuiltin 146 }; 147 } 148 149 /// \brief MIPS builtins 150 namespace Mips { 151 enum { 152 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 153 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 154 #include "clang/Basic/BuiltinsMips.def" 155 LastTSBuiltin 156 }; 157 } 158 159 /// \brief XCore builtins 160 namespace XCore { 161 enum { 162 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 163 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 164 #include "clang/Basic/BuiltinsXCore.def" 165 LastTSBuiltin 166 }; 167 } 168 169 /// \brief Le64 builtins 170 namespace Le64 { 171 enum { 172 LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, 173 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 174 #include "clang/Basic/BuiltinsLe64.def" 175 LastTSBuiltin 176 }; 177 } 178 179 /// \brief SystemZ builtins 180 namespace SystemZ { 181 enum { 182 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 183 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 184 #include "clang/Basic/BuiltinsSystemZ.def" 185 LastTSBuiltin 186 }; 187 } 188 189 /// \brief WebAssembly builtins 190 namespace WebAssembly { 191 enum { 192 LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1, 193 #define BUILTIN(ID, TYPE, ATTRS) BI##ID, 194 #include "clang/Basic/BuiltinsWebAssembly.def" 195 LastTSBuiltin 196 }; 197 } 198 199 } // end namespace clang. 200 201 #endif 202