1 //===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file contains the declaration of the GlobalIFunc class, which
11 /// represents a single indirect function in the IR. Indirect function uses
12 /// ELF symbol type extension to mark that the address of a declaration should
13 /// be resolved at runtime by calling a resolver function.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_IR_GLOBALIFUNC_H
18 #define LLVM_IR_GLOBALIFUNC_H
20 #include "llvm/ADT/ilist_node.h"
21 #include "llvm/IR/GlobalIndirectSymbol.h"
22 #include "llvm/IR/Value.h"
29 // Traits class for using GlobalIFunc in symbol table in Module.
30 template <typename ValueSubClass
> class SymbolTableListTraits
;
32 class GlobalIFunc final
: public GlobalIndirectSymbol
,
33 public ilist_node
<GlobalIFunc
> {
34 friend class SymbolTableListTraits
<GlobalIFunc
>;
36 GlobalIFunc(Type
*Ty
, unsigned AddressSpace
, LinkageTypes Linkage
,
37 const Twine
&Name
, Constant
*Resolver
, Module
*Parent
);
40 GlobalIFunc(const GlobalIFunc
&) = delete;
41 GlobalIFunc
&operator=(const GlobalIFunc
&) = delete;
43 /// If a parent module is specified, the ifunc is automatically inserted into
44 /// the end of the specified module's ifunc list.
45 static GlobalIFunc
*create(Type
*Ty
, unsigned AddressSpace
,
46 LinkageTypes Linkage
, const Twine
&Name
,
47 Constant
*Resolver
, Module
*Parent
);
49 /// This method unlinks 'this' from the containing module, but does not
51 void removeFromParent();
53 /// This method unlinks 'this' from the containing module and deletes it.
54 void eraseFromParent();
56 /// These methods retrieve and set ifunc resolver function.
57 void setResolver(Constant
*Resolver
) {
58 setIndirectSymbol(Resolver
);
60 const Constant
*getResolver() const {
61 return getIndirectSymbol();
63 Constant
*getResolver() {
64 return getIndirectSymbol();
67 // Methods for support type inquiry through isa, cast, and dyn_cast:
68 static bool classof(const Value
*V
) {
69 return V
->getValueID() == Value::GlobalIFuncVal
;
73 } // end namespace llvm
75 #endif // LLVM_IR_GLOBALIFUNC_H