LLVM API Documentation

GVMaterializer.h
Go to the documentation of this file.
00001 //===- GVMaterializer.h - Interface for GV materializers --------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file provides an abstract interface for loading a module from some
00011 // place.  This interface allows incremental or random access loading of
00012 // functions from the file.  This is useful for applications like JIT compilers
00013 // or interprocedural optimizers that do not need the entire program in memory
00014 // at the same time.
00015 //
00016 //===----------------------------------------------------------------------===//
00017 
00018 #ifndef LLVM_IR_GVMATERIALIZER_H
00019 #define LLVM_IR_GVMATERIALIZER_H
00020 
00021 #include <system_error>
00022 
00023 namespace llvm {
00024 class Function;
00025 class GlobalValue;
00026 class Module;
00027 
00028 class GVMaterializer {
00029 protected:
00030   GVMaterializer() {}
00031 
00032 public:
00033   virtual ~GVMaterializer();
00034 
00035   /// True if GV can be materialized from whatever backing store this
00036   /// GVMaterializer uses and has not been materialized yet.
00037   virtual bool isMaterializable(const GlobalValue *GV) const = 0;
00038 
00039   /// True if GV has been materialized and can be dematerialized back to
00040   /// whatever backing store this GVMaterializer uses.
00041   virtual bool isDematerializable(const GlobalValue *GV) const = 0;
00042 
00043   /// Make sure the given GlobalValue is fully read.
00044   ///
00045   virtual std::error_code Materialize(GlobalValue *GV) = 0;
00046 
00047   /// If the given GlobalValue is read in, and if the GVMaterializer supports
00048   /// it, release the memory for the GV, and set it up to be materialized
00049   /// lazily. If the Materializer doesn't support this capability, this method
00050   /// is a noop.
00051   ///
00052   virtual void Dematerialize(GlobalValue *) {}
00053 
00054   /// Make sure the entire Module has been completely read.
00055   ///
00056   virtual std::error_code MaterializeModule(Module *M) = 0;
00057 };
00058 
00059 } // End llvm namespace
00060 
00061 #endif