2016-04-07 14:32:19 +02:00
|
|
|
//===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \brief
|
|
|
|
/// This file contains the declaration of the GlobalIFunc class, which
|
|
|
|
/// represents a single indirect function in the IR. Indirect function uses
|
|
|
|
/// ELF symbol type extension to mark that the address of a declaration should
|
|
|
|
/// be resolved at runtime by calling a resolver function.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_IR_GLOBALIFUNC_H
|
|
|
|
#define LLVM_IR_GLOBALIFUNC_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/ilist_node.h"
|
|
|
|
#include "llvm/IR/GlobalIndirectSymbol.h"
|
2016-12-05 22:55:02 +01:00
|
|
|
#include "llvm/IR/Value.h"
|
2016-04-07 14:32:19 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2016-04-16 09:51:28 +02:00
|
|
|
class Twine;
|
2016-04-07 14:32:19 +02:00
|
|
|
class Module;
|
|
|
|
|
|
|
|
// Traits class for using GlobalIFunc in symbol table in Module.
|
|
|
|
template <typename ValueSubClass> class SymbolTableListTraits;
|
|
|
|
|
|
|
|
class GlobalIFunc final : public GlobalIndirectSymbol,
|
|
|
|
public ilist_node<GlobalIFunc> {
|
|
|
|
friend class SymbolTableListTraits<GlobalIFunc>;
|
|
|
|
|
|
|
|
GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
|
|
|
|
const Twine &Name, Constant *Resolver, Module *Parent);
|
|
|
|
|
|
|
|
public:
|
2016-12-05 22:55:02 +01:00
|
|
|
GlobalIFunc(const GlobalIFunc &) = delete;
|
|
|
|
GlobalIFunc &operator=(const GlobalIFunc &) = delete;
|
|
|
|
|
2016-04-07 14:32:19 +02:00
|
|
|
/// If a parent module is specified, the ifunc is automatically inserted into
|
|
|
|
/// the end of the specified module's ifunc list.
|
|
|
|
static GlobalIFunc *create(Type *Ty, unsigned AddressSpace,
|
|
|
|
LinkageTypes Linkage, const Twine &Name,
|
|
|
|
Constant *Resolver, Module *Parent);
|
|
|
|
|
2017-05-11 23:14:29 +02:00
|
|
|
void copyAttributesFrom(const GlobalIFunc *Src) {
|
|
|
|
GlobalValue::copyAttributesFrom(Src);
|
|
|
|
}
|
|
|
|
|
2016-04-07 14:32:19 +02:00
|
|
|
/// This method unlinks 'this' from the containing module, but does not
|
|
|
|
/// delete it.
|
2017-05-11 23:14:29 +02:00
|
|
|
void removeFromParent();
|
2016-04-07 14:32:19 +02:00
|
|
|
|
|
|
|
/// This method unlinks 'this' from the containing module and deletes it.
|
2017-05-11 23:14:29 +02:00
|
|
|
void eraseFromParent();
|
2016-04-07 14:32:19 +02:00
|
|
|
|
|
|
|
/// These methods retrieve and set ifunc resolver function.
|
|
|
|
void setResolver(Constant *Resolver) {
|
|
|
|
setIndirectSymbol(Resolver);
|
|
|
|
}
|
|
|
|
const Constant *getResolver() const {
|
|
|
|
return getIndirectSymbol();
|
|
|
|
}
|
|
|
|
Constant *getResolver() {
|
|
|
|
return getIndirectSymbol();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2017-06-29 21:35:17 +02:00
|
|
|
static bool classof(const Value *V) {
|
2016-04-07 14:32:19 +02:00
|
|
|
return V->getValueID() == Value::GlobalIFuncVal;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-12-05 22:55:02 +01:00
|
|
|
} // end namespace llvm
|
2016-04-07 14:32:19 +02:00
|
|
|
|
2016-12-05 22:55:02 +01:00
|
|
|
#endif // LLVM_IR_GLOBALIFUNC_H
|