File indexing completed on 2026-05-10 08:44:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef LLVM_IR_GLOBALIFUNC_H
0018 #define LLVM_IR_GLOBALIFUNC_H
0019
0020 #include "llvm/ADT/ilist_node.h"
0021 #include "llvm/IR/Constant.h"
0022 #include "llvm/IR/GlobalObject.h"
0023 #include "llvm/IR/OperandTraits.h"
0024 #include "llvm/IR/Value.h"
0025
0026 namespace llvm {
0027
0028 class Twine;
0029 class Module;
0030
0031
0032 template <typename ValueSubClass, typename... Args> class SymbolTableListTraits;
0033
0034 class GlobalIFunc final : public GlobalObject, public ilist_node<GlobalIFunc> {
0035 friend class SymbolTableListTraits<GlobalIFunc>;
0036
0037 constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
0038
0039 GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
0040 const Twine &Name, Constant *Resolver, Module *Parent);
0041
0042 public:
0043 GlobalIFunc(const GlobalIFunc &) = delete;
0044 GlobalIFunc &operator=(const GlobalIFunc &) = delete;
0045
0046
0047
0048 static GlobalIFunc *create(Type *Ty, unsigned AddressSpace,
0049 LinkageTypes Linkage, const Twine &Name,
0050 Constant *Resolver, Module *Parent);
0051
0052
0053 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
0054 void operator delete(void *Ptr) { User::operator delete(Ptr); }
0055
0056
0057 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
0058
0059 void copyAttributesFrom(const GlobalIFunc *Src) {
0060 GlobalObject::copyAttributesFrom(Src);
0061 }
0062
0063
0064
0065 void removeFromParent();
0066
0067
0068 void eraseFromParent();
0069
0070
0071 void setResolver(Constant *Resolver) { Op<0>().set(Resolver); }
0072 const Constant *getResolver() const {
0073 return static_cast<Constant *>(Op<0>().get());
0074 }
0075 Constant *getResolver() { return static_cast<Constant *>(Op<0>().get()); }
0076
0077
0078
0079 const Function *getResolverFunction() const;
0080 Function *getResolverFunction() {
0081 return const_cast<Function *>(
0082 static_cast<const GlobalIFunc *>(this)->getResolverFunction());
0083 }
0084
0085 static bool isValidLinkage(LinkageTypes L) {
0086 return isExternalLinkage(L) || isLocalLinkage(L) || isWeakLinkage(L) ||
0087 isLinkOnceLinkage(L);
0088 }
0089
0090
0091 static bool classof(const Value *V) {
0092 return V->getValueID() == Value::GlobalIFuncVal;
0093 }
0094
0095
0096
0097
0098
0099 void applyAlongResolverPath(function_ref<void(const GlobalValue &)> Op) const;
0100 };
0101
0102 template <>
0103 struct OperandTraits<GlobalIFunc>
0104 : public FixedNumOperandTraits<GlobalIFunc, 1> {};
0105
0106 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalIFunc, Constant)
0107
0108 }
0109
0110 #endif