+
+class ConstantFwdRefs: public NonCopyable {
+ Module* TheModule;
+
+ // GlobalRefs - This maintains a mapping between <Type, Slot #>'s and forward
+ // references to global values or constants. Such values may be referenced
+ // before they are defined, and if so, the temporary object that they
+ // represent is held here.
+ //
+ typedef std::map<std::pair<const Type *, unsigned>,
+ Value*> GlobalRefsType;
+ GlobalRefsType GlobalRefs;
+
+ Value* find (const Type* Ty, unsigned Slot);
+ void insert (const Type* Ty, unsigned Slot, Value* V);
+ void erase (const Type* Ty, unsigned Slot);
+
+public:
+ // sets the current module pointer: needed to insert placeholder globals
+ void VisitingModule (Module* M) { TheModule = M; }
+
+ // get a forward reference to a global or a constant
+ GlobalValue* GetFwdRefToGlobal (const PointerType* PT, unsigned Slot);
+ Constant* GetFwdRefToConstant (const Type* Ty, unsigned Slot);
+
+ // resolve all references to the placeholder (if any) for the given value
+ void ResolveRefsToValue (Value* val, unsigned Slot);
+};
+
+