2016-04-07 14:32:19 +02:00
|
|
|
//===-------- llvm/GlobalIFunc.h - GlobalIFunc class ------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-04-07 14:32:19 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \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);
|
|
|
|
|
|
|
|
/// 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
|