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"
24 struct StructTypeKeyInfo {
26 ArrayRef<Type *> ETypes;
28 KeyTy(ArrayRef<Type *> E, bool P);
29 KeyTy(const StructType *ST);
30 bool operator==(const KeyTy &that) const;
31 bool operator!=(const KeyTy &that) const;
33 static StructType *getEmptyKey();
34 static StructType *getTombstoneKey();
35 static unsigned getHashValue(const KeyTy &Key);
36 static unsigned getHashValue(const StructType *ST);
37 static bool isEqual(const KeyTy &LHS, const StructType *RHS);
38 static bool isEqual(const StructType *LHS, const StructType *RHS);
42 class IdentifiedStructTypeSet {
43 // The set of opaque types is the composite module.
44 DenseSet<StructType *> OpaqueStructTypes;
46 // The set of identified but non opaque structures in the composite module.
47 DenseSet<StructType *, StructTypeKeyInfo> NonOpaqueStructTypes;
50 void addNonOpaque(StructType *Ty);
51 void switchToNonOpaque(StructType *Ty);
52 void addOpaque(StructType *Ty);
53 StructType *findNonOpaque(ArrayRef<Type *> ETypes, bool IsPacked);
54 bool hasType(StructType *Ty);
59 typedef std::function<void(GlobalValue &)> ValueAdder;
60 /// Move in the provide values. The source is destroyed.
61 /// Returns true on error.
62 bool move(Module &Src, ArrayRef<GlobalValue *> ValuesToLink,
63 std::function<void(GlobalValue &GV, ValueAdder Add)> AddLazyFor);
64 Module &getModule() { return Composite; }
68 IdentifiedStructTypeSet IdentifiedStructTypes;
71 } // End llvm namespace