| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef LLVM_IR_GLOBALIFUNC_H |
| 18 |
#define LLVM_IR_GLOBALIFUNC_H |
| 19 |
|
| 20 |
#include "llvm/ADT/ilist_node.h" |
| 21 |
#include "llvm/IR/Constant.h" |
| 22 |
#include "llvm/IR/GlobalObject.h" |
| 23 |
#include "llvm/IR/OperandTraits.h" |
| 24 |
#include "llvm/IR/Value.h" |
| 25 |
|
| 26 |
namespace llvm { |
| 27 |
|
| 28 |
class Twine; |
| 29 |
class Module; |
| 30 |
|
| 31 |
|
| 32 |
template <typename ValueSubClass> class SymbolTableListTraits; |
| 33 |
|
| 34 |
class GlobalIFunc final : public GlobalObject, public ilist_node<GlobalIFunc> { |
| 35 |
friend class SymbolTableListTraits<GlobalIFunc>; |
| 36 |
|
| 37 |
GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, |
| 38 |
const Twine &Name, Constant *Resolver, Module *Parent); |
| 39 |
|
| 40 |
public: |
| 41 |
GlobalIFunc(const GlobalIFunc &) = delete; |
| 42 |
GlobalIFunc &operator=(const GlobalIFunc &) = delete; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
static GlobalIFunc *create(Type *Ty, unsigned AddressSpace, |
| 47 |
LinkageTypes Linkage, const Twine &Name, |
| 48 |
Constant *Resolver, Module *Parent); |
| 49 |
|
| 50 |
|
| 51 |
void *operator new(size_t S) { return User::operator new(S, 1); } |
| 52 |
void operator delete(void *Ptr) { User::operator delete(Ptr); } |
| 53 |
|
| 54 |
|
| 55 |
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); |
| 56 |
|
| 57 |
void copyAttributesFrom(const GlobalIFunc *Src) { |
| 58 |
GlobalObject::copyAttributesFrom(Src); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
void removeFromParent(); |
| 64 |
|
| 65 |
|
| 66 |
void eraseFromParent(); |
| 67 |
|
| 68 |
|
| 69 |
void setResolver(Constant *Resolver) { Op<0>().set(Resolver); } |
| 70 |
const Constant *getResolver() const { |
| 71 |
return static_cast<Constant *>(Op<0>().get()); |
| 72 |
} |
| 73 |
Constant *getResolver() { return static_cast<Constant *>(Op<0>().get()); } |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
const Function *getResolverFunction() const; |
| 78 |
Function *getResolverFunction() { |
| 79 |
return const_cast<Function *>( |
| 80 |
static_cast<const GlobalIFunc *>(this)->getResolverFunction()); |
| 81 |
} |
| 82 |
|
| 83 |
static FunctionType *getResolverFunctionType(Type *IFuncValTy) { |
| 84 |
return FunctionType::get(IFuncValTy->getPointerTo(), false); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
static bool classof(const Value *V) { |
| 89 |
return V->getValueID() == Value::GlobalIFuncVal; |
| 90 |
} |
| 91 |
}; |
| 92 |
|
| 93 |
template <> |
| 94 |
struct OperandTraits<GlobalIFunc> |
| 95 |
: public FixedNumOperandTraits<GlobalIFunc, 1> {}; |
| 96 |
|
| 97 |
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalIFunc, Constant) |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
#endif |