1 //===- IRMover.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LINKER_IRMOVER_H
11 #define LLVM_LINKER_IRMOVER_H
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/DenseSet.h"
25 struct StructTypeKeyInfo {
27 ArrayRef<Type *> ETypes;
29 KeyTy(ArrayRef<Type *> E, bool P);
30 KeyTy(const StructType *ST);
31 bool operator==(const KeyTy &that) const;
32 bool operator!=(const KeyTy &that) const;
34 static StructType *getEmptyKey();
35 static StructType *getTombstoneKey();
36 static unsigned getHashValue(const KeyTy &Key);
37 static unsigned getHashValue(const StructType *ST);
38 static bool isEqual(const KeyTy &LHS, const StructType *RHS);
39 static bool isEqual(const StructType *LHS, const StructType *RHS);
43 class IdentifiedStructTypeSet {
44 // The set of opaque types is the composite module.
45 DenseSet<StructType *> OpaqueStructTypes;
47 // The set of identified but non opaque structures in the composite module.
48 DenseSet<StructType *, StructTypeKeyInfo> NonOpaqueStructTypes;
51 void addNonOpaque(StructType *Ty);
52 void switchToNonOpaque(StructType *Ty);
53 void addOpaque(StructType *Ty);
54 StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
55 bool hasType(StructType *Ty);
60 typedef std::function<void(GlobalValue &)> ValueAdder;
61 /// Move in the provide values. The source is destroyed.
62 /// Returns true on error.
63 bool move(Module &Src, ArrayRef<GlobalValue *> ValuesToLink,
64 std::function<void(GlobalValue &GV, ValueAdder Add)> AddLazyFor,
65 DenseMap<unsigned, MDNode *> *ValIDToTempMDMap = nullptr,
66 bool IsMetadataLinkingPostpass = false);
67 Module &getModule() { return Composite; }
71 IdentifiedStructTypeSet IdentifiedStructTypes;
74 } // End llvm namespace