| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef LLVM_IR_INTRINSICS_H |
| 16 |
#define LLVM_IR_INTRINSICS_H |
| 17 |
|
| 18 |
#include "llvm/ADT/ArrayRef.h" |
| 19 |
#include "llvm/ADT/None.h" |
| 20 |
#include "llvm/ADT/Optional.h" |
| 21 |
#include "llvm/Support/TypeSize.h" |
| 22 |
#include <string> |
| 23 |
|
| 24 |
namespace llvm { |
| 25 |
|
| 26 |
class Type; |
| 27 |
class FunctionType; |
| 28 |
class Function; |
| 29 |
class LLVMContext; |
| 30 |
class Module; |
| 31 |
class AttributeList; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
namespace Intrinsic { |
| 37 |
|
| 38 |
static const int NoAliasScopeDeclScopeArg = 0; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
typedef unsigned ID; |
| 43 |
|
| 44 |
enum IndependentIntrinsics : unsigned { |
| 45 |
not_intrinsic = 0, |
| 46 |
|
| 47 |
|
| 48 |
#define GET_INTRINSIC_ENUM_VALUES |
| 49 |
#include "llvm/IR/IntrinsicEnums.inc" |
| 50 |
#undef GET_INTRINSIC_ENUM_VALUES |
| 51 |
}; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
StringRef getName(ID id); |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
StringRef getBaseName(ID id); |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
std::string getName(ID Id, ArrayRef<Type *> Tys, Module *M, |
| 69 |
FunctionType *FT = nullptr); |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
std::string getNameNoUnnamedTypes(ID Id, ArrayRef<Type *> Tys); |
| 75 |
|
| 76 |
|
| 77 |
FunctionType *getType(LLVMContext &Context, ID id, |
| 78 |
ArrayRef<Type*> Tys = None); |
| 79 |
|
| 80 |
|
| 81 |
bool isOverloaded(ID id); |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
bool isLeaf(ID id); |
| 87 |
|
| 88 |
|
| 89 |
AttributeList getAttributes(LLVMContext &C, ID id); |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
Function *getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys = None); |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
int lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable, |
| 105 |
StringRef Name); |
| 106 |
|
| 107 |
|
| 108 |
ID getIntrinsicForGCCBuiltin(const char *Prefix, StringRef BuiltinName); |
| 109 |
|
| 110 |
|
| 111 |
ID getIntrinsicForMSBuiltin(const char *Prefix, StringRef BuiltinName); |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
struct IITDescriptor { |
| 116 |
enum IITDescriptorKind { |
| 117 |
Void, |
| 118 |
VarArg, |
| 119 |
MMX, |
| 120 |
Token, |
| 121 |
Metadata, |
| 122 |
Half, |
| 123 |
BFloat, |
| 124 |
Float, |
| 125 |
Double, |
| 126 |
Quad, |
| 127 |
Integer, |
| 128 |
Vector, |
| 129 |
Pointer, |
| 130 |
Struct, |
| 131 |
Argument, |
| 132 |
ExtendArgument, |
| 133 |
TruncArgument, |
| 134 |
HalfVecArgument, |
| 135 |
SameVecWidthArgument, |
| 136 |
PtrToArgument, |
| 137 |
PtrToElt, |
| 138 |
VecOfAnyPtrsToElt, |
| 139 |
VecElementArgument, |
| 140 |
Subdivide2Argument, |
| 141 |
Subdivide4Argument, |
| 142 |
VecOfBitcastsToInt, |
| 143 |
AMX, |
| 144 |
PPCQuad, |
| 145 |
} Kind; |
| 146 |
|
| 147 |
union { |
| 148 |
unsigned Integer_Width; |
| 149 |
unsigned Float_Width; |
| 150 |
unsigned Pointer_AddressSpace; |
| 151 |
unsigned Struct_NumElements; |
| 152 |
unsigned Argument_Info; |
| 153 |
ElementCount Vector_Width; |
| 154 |
}; |
| 155 |
|
| 156 |
enum ArgKind { |
| 157 |
AK_Any, |
| 158 |
AK_AnyInteger, |
| 159 |
AK_AnyFloat, |
| 160 |
AK_AnyVector, |
| 161 |
AK_AnyPointer, |
| 162 |
AK_MatchType = 7 |
| 163 |
}; |
| 164 |
|
| 165 |
unsigned getArgumentNumber() const { |
| 166 |
assert(Kind == Argument || Kind == ExtendArgument || |
| 167 |
Kind == TruncArgument || Kind == HalfVecArgument || |
| 168 |
Kind == SameVecWidthArgument || Kind == PtrToArgument || |
| 169 |
Kind == PtrToElt || Kind == VecElementArgument || |
| 170 |
Kind == Subdivide2Argument || Kind == Subdivide4Argument || |
| 171 |
Kind == VecOfBitcastsToInt); |
| 172 |
return Argument_Info >> 3; |
| 173 |
} |
| 174 |
ArgKind getArgumentKind() const { |
| 175 |
assert(Kind == Argument || Kind == ExtendArgument || |
| 176 |
Kind == TruncArgument || Kind == HalfVecArgument || |
| 177 |
Kind == SameVecWidthArgument || Kind == PtrToArgument || |
| 178 |
Kind == VecElementArgument || Kind == Subdivide2Argument || |
| 179 |
Kind == Subdivide4Argument || Kind == VecOfBitcastsToInt); |
| 180 |
return (ArgKind)(Argument_Info & 7); |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
unsigned getOverloadArgNumber() const { |
| 186 |
assert(Kind == VecOfAnyPtrsToElt); |
| 187 |
return Argument_Info >> 16; |
| 188 |
} |
| 189 |
unsigned getRefArgNumber() const { |
| 190 |
assert(Kind == VecOfAnyPtrsToElt); |
| 191 |
return Argument_Info & 0xFFFF; |
| 192 |
} |
| 193 |
|
| 194 |
static IITDescriptor get(IITDescriptorKind K, unsigned Field) { |
| 195 |
IITDescriptor Result = { K, { Field } }; |
| 196 |
return Result; |
| 197 |
} |
| 198 |
|
| 199 |
static IITDescriptor get(IITDescriptorKind K, unsigned short Hi, |
| 200 |
unsigned short Lo) { |
| 201 |
unsigned Field = Hi << 16 | Lo; |
| 202 |
IITDescriptor Result = {K, {Field}}; |
| 203 |
return Result; |
| 204 |
} |
| 205 |
|
| 206 |
static IITDescriptor getVector(unsigned Width, bool IsScalable) { |
| 207 |
IITDescriptor Result = {Vector, {0}}; |
| 208 |
Result.Vector_Width = ElementCount::get(Width, IsScalable); |
| 209 |
return Result; |
| 210 |
} |
| 211 |
}; |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T); |
| 216 |
|
| 217 |
enum MatchIntrinsicTypesResult { |
| 218 |
MatchIntrinsicTypes_Match = 0, |
| 219 |
MatchIntrinsicTypes_NoMatchRet = 1, |
| 220 |
MatchIntrinsicTypes_NoMatchArg = 2, |
| 221 |
}; |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
MatchIntrinsicTypesResult |
| 230 |
matchIntrinsicSignature(FunctionType *FTy, ArrayRef<IITDescriptor> &Infos, |
| 231 |
SmallVectorImpl<Type *> &ArgTys); |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef<IITDescriptor> &Infos); |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
bool getIntrinsicSignature(Function *F, SmallVectorImpl<Type *> &ArgTys); |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
llvm::Optional<Function*> remangleIntrinsicFunction(Function *F); |
| 251 |
|
| 252 |
} |
| 253 |
|
| 254 |
} |
| 255 |
|
| 256 |
#endif |