1 //===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file contains the declaration of the GlobalIFunc class, which
12 /// represents a single indirect function in the IR. Indirect function uses
13 /// ELF symbol type extension to mark that the address of a declaration should
14 /// be resolved at runtime by calling a resolver function.
16 //===----------------------------------------------------------------------===//
18 #ifndef LLVM_IR_GLOBALIFUNC_H
19 #define LLVM_IR_GLOBALIFUNC_H
21 #include "llvm/ADT/ilist_node.h"
22 #include "llvm/IR/GlobalIndirectSymbol.h"
23 #include "llvm/IR/Value.h"
30 // Traits class for using GlobalIFunc in symbol table in Module.
31 template <typename ValueSubClass> class SymbolTableListTraits;
33 class GlobalIFunc final : public GlobalIndirectSymbol,
34 public ilist_node<GlobalIFunc> {
35 friend class SymbolTableListTraits<GlobalIFunc>;
37 GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
38 const Twine &Name, Constant *Resolver, Module *Parent);
41 GlobalIFunc(const GlobalIFunc &) = delete;
42 GlobalIFunc &operator=(const GlobalIFunc &) = delete;
44 /// If a parent module is specified, the ifunc is automatically inserted into
45 /// the end of the specified module's ifunc list.
46 static GlobalIFunc *create(Type *Ty, unsigned AddressSpace,
47 LinkageTypes Linkage, const Twine &Name,
48 Constant *Resolver, Module *Parent);
50 void copyAttributesFrom(const GlobalIFunc *Src) {
51 GlobalValue::copyAttributesFrom(Src);
54 /// This method unlinks 'this' from the containing module, but does not
56 void removeFromParent();
58 /// This method unlinks 'this' from the containing module and deletes it.
59 void eraseFromParent();
61 /// These methods retrieve and set ifunc resolver function.
62 void setResolver(Constant *Resolver) {
63 setIndirectSymbol(Resolver);
65 const Constant *getResolver() const {
66 return getIndirectSymbol();
68 Constant *getResolver() {
69 return getIndirectSymbol();
72 // Methods for support type inquiry through isa, cast, and dyn_cast:
73 static bool classof(const Value *V) {
74 return V->getValueID() == Value::GlobalIFuncVal;
78 } // end namespace llvm
80 #endif // LLVM_IR_GLOBALIFUNC_H