LLVM  6.0.0svn
GlobalIFunc.h
Go to the documentation of this file.
1 //===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- 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 /// \brief
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.
15 ///
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_IR_GLOBALIFUNC_H
19 #define LLVM_IR_GLOBALIFUNC_H
20 
21 #include "llvm/ADT/ilist_node.h"
23 #include "llvm/IR/Value.h"
24 
25 namespace llvm {
26 
27 class Twine;
28 class Module;
29 
30 // Traits class for using GlobalIFunc in symbol table in Module.
31 template <typename ValueSubClass> class SymbolTableListTraits;
32 
33 class GlobalIFunc final : public GlobalIndirectSymbol,
34  public ilist_node<GlobalIFunc> {
36 
38  const Twine &Name, Constant *Resolver, Module *Parent);
39 
40 public:
41  GlobalIFunc(const GlobalIFunc &) = delete;
42  GlobalIFunc &operator=(const GlobalIFunc &) = delete;
43 
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,
48  Constant *Resolver, Module *Parent);
49 
50  void copyAttributesFrom(const GlobalIFunc *Src) {
52  }
53 
54  /// This method unlinks 'this' from the containing module, but does not
55  /// delete it.
56  void removeFromParent();
57 
58  /// This method unlinks 'this' from the containing module and deletes it.
59  void eraseFromParent();
60 
61  /// These methods retrieve and set ifunc resolver function.
62  void setResolver(Constant *Resolver) {
63  setIndirectSymbol(Resolver);
64  }
65  const Constant *getResolver() const {
66  return getIndirectSymbol();
67  }
69  return getIndirectSymbol();
70  }
71 
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;
75  }
76 };
77 
78 } // end namespace llvm
79 
80 #endif // LLVM_IR_GLOBALIFUNC_H
static bool classof(const Value *V)
Definition: GlobalIFunc.h:73
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:66
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:465
void setResolver(Constant *Resolver)
These methods retrieve and set ifunc resolver function.
Definition: GlobalIFunc.h:62
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
static GlobalIFunc * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent)
If a parent module is specified, the ifunc is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:456
const Constant * getResolver() const
Definition: GlobalIFunc.h:65
void eraseFromParent()
This method unlinks &#39;this&#39; from the containing module and deletes it.
Definition: Globals.cpp:466
Constant * getResolver()
Definition: GlobalIFunc.h:68
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:42
AddressSpace
Definition: NVPTXBaseInfo.h:22
void copyAttributesFrom(const GlobalIFunc *Src)
Definition: GlobalIFunc.h:50
unsigned Linkage
Definition: GlobalValue.h:94
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
GlobalIFunc & operator=(const GlobalIFunc &)=delete
void removeFromParent()
This method unlinks &#39;this&#39; from the containing module, but does not delete it.
Definition: Globals.cpp:462
const Constant * getIndirectSymbol() const
LLVM Value Representation.
Definition: Value.h:73