diff options
author | James Molloy <james.molloy@arm.com> | 2013-05-28 15:17:05 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2013-05-28 15:17:05 +0000 |
commit | a84a83bbcdfaecadfc6574094272fd3edc429a23 (patch) | |
tree | ca87000d15263653ac635164ab194745b87f46e6 /include/llvm/Transforms/Utils/ValueMapper.h | |
parent | 9903f75bf6ec4136bd752595c689db845eedad3d (diff) | |
download | external_llvm-a84a83bbcdfaecadfc6574094272fd3edc429a23.zip external_llvm-a84a83bbcdfaecadfc6574094272fd3edc429a23.tar.gz external_llvm-a84a83bbcdfaecadfc6574094272fd3edc429a23.tar.bz2 |
Extend RemapInstruction and friends to take an optional new parameter, a ValueMaterializer.
Extend LinkModules to pass a ValueMaterializer to RemapInstruction and friends to lazily create Functions for lazily linked globals. This is a big win when linking small modules with large (mostly unused) library modules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/Utils/ValueMapper.h')
-rw-r--r-- | include/llvm/Transforms/Utils/ValueMapper.h | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/include/llvm/Transforms/Utils/ValueMapper.h b/include/llvm/Transforms/Utils/ValueMapper.h index 5390c5e..d56ac07 100644 --- a/include/llvm/Transforms/Utils/ValueMapper.h +++ b/include/llvm/Transforms/Utils/ValueMapper.h @@ -33,6 +33,19 @@ namespace llvm { /// remap types while mapping values. virtual Type *remapType(Type *SrcTy) = 0; }; + + /// ValueMaterializer - This is a class that can be implemented by clients + /// to materialize Values on demand. + class ValueMaterializer { + virtual void anchor(); // Out of line method. + public: + virtual ~ValueMaterializer() {} + + /// materializeValueFor - The client should implement this method if they + /// want to generate a mapped Value on demand. For example, if linking + /// lazily. + virtual Value *materializeValueFor(Value *V) = 0; + }; /// RemapFlags - These are flags that the value mapping APIs allow. enum RemapFlags { @@ -55,23 +68,29 @@ namespace llvm { Value *MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags = RF_None, - ValueMapTypeRemapper *TypeMapper = 0); + ValueMapTypeRemapper *TypeMapper = 0, + ValueMaterializer *Materializer = 0); void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags = RF_None, - ValueMapTypeRemapper *TypeMapper = 0); + ValueMapTypeRemapper *TypeMapper = 0, + ValueMaterializer *Materializer = 0); /// MapValue - provide versions that preserve type safety for MDNode and /// Constants. inline MDNode *MapValue(const MDNode *V, ValueToValueMapTy &VM, RemapFlags Flags = RF_None, - ValueMapTypeRemapper *TypeMapper = 0) { - return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper)); + ValueMapTypeRemapper *TypeMapper = 0, + ValueMaterializer *Materializer = 0) { + return cast<MDNode>(MapValue((const Value*)V, VM, Flags, TypeMapper, + Materializer)); } inline Constant *MapValue(const Constant *V, ValueToValueMapTy &VM, RemapFlags Flags = RF_None, - ValueMapTypeRemapper *TypeMapper = 0) { - return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper)); + ValueMapTypeRemapper *TypeMapper = 0, + ValueMaterializer *Materializer = 0) { + return cast<Constant>(MapValue((const Value*)V, VM, Flags, TypeMapper, + Materializer)); } |