#ifndef LLVM_LINKER_IRMOVER_H
#define LLVM_LINKER_IRMOVER_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
#include <functional>
namespace llvm {
class GlobalValue;
class Metadata;
class Module;
class StructType;
class TrackingMDRef;
class Type;
class IRMover {
struct StructTypeKeyInfo {
struct KeyTy {
ArrayRef<Type *> ETypes;
bool IsPacked;
KeyTy(ArrayRef<Type *> E, bool P);
KeyTy(const StructType *ST);
bool operator==(const KeyTy &that) const;
bool operator!=(const KeyTy &that) const;
};
static StructType *getEmptyKey();
static StructType *getTombstoneKey();
static unsigned getHashValue(const KeyTy &Key);
static unsigned getHashValue(const StructType *ST);
static bool isEqual(const KeyTy &LHS, const StructType *RHS);
static bool isEqual(const StructType *LHS, const StructType *RHS);
};
typedef DenseMap<const Metadata *, TrackingMDRef> MDMapT;
public:
class IdentifiedStructTypeSet {
DenseSet<StructType *> OpaqueStructTypes;
DenseSet<StructType *, StructTypeKeyInfo> NonOpaqueStructTypes;
public:
void addNonOpaque(StructType *Ty);
void switchToNonOpaque(StructType *Ty);
void addOpaque(StructType *Ty);
StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
bool hasType(StructType *Ty);
};
IRMover(Module &M);
typedef std::function<void(GlobalValue &)> ValueAdder;
bool move(std::unique_ptr<Module> Src, ArrayRef<GlobalValue *> ValuesToLink,
std::function<void(GlobalValue &GV, ValueAdder Add)> AddLazyFor);
Module &getModule() { return Composite; }
private:
Module &Composite;
IdentifiedStructTypeSet IdentifiedStructTypes;
MDMapT SharedMDs; };
}
#endif