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