KModule.h

Go to the documentation of this file.
00001 //===-- KModule.h -----------------------------------------------*- C++ -*-===//
00002 //
00003 //                     The KLEE Symbolic Virtual Machine
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef KLEE_KMODULE_H
00011 #define KLEE_KMODULE_H
00012 
00013 #include "klee/Interpreter.h"
00014 
00015 #include <map>
00016 #include <set>
00017 #include <vector>
00018 
00019 namespace llvm {
00020   class BasicBlock;
00021   class Constant;
00022   class Function;
00023   class Instruction;
00024   class Module;
00025   class TargetData;
00026 }
00027 
00028 namespace klee {
00029   class Cell;
00030   class Executor;
00031   class Expr;
00032   class InterpreterHandler;
00033   class InstructionInfoTable;
00034   class KInstruction;
00035   class KModule;
00036   template<class T> class ref;
00037 
00038   struct KFunction {
00039     llvm::Function *function;
00040 
00041     unsigned numArgs, numRegisters;
00042 
00043     unsigned numInstructions;
00044     KInstruction **instructions;
00045 
00046     std::map<llvm::BasicBlock*, unsigned> basicBlockEntry;
00047 
00050     bool trackCoverage;
00051 
00052   private:
00053     KFunction(const KFunction&);
00054     KFunction &operator=(const KFunction&);
00055 
00056   public:
00057     explicit KFunction(llvm::Function*, KModule *);
00058     ~KFunction();
00059 
00060     unsigned getArgRegister(unsigned index) { return index; }
00061   };
00062 
00063 
00064   class KConstant {
00065   public:
00067     llvm::Constant* ct;
00068 
00070     unsigned id;
00071 
00074     KInstruction *ki;
00075 
00076     KConstant(llvm::Constant*, unsigned, KInstruction*);
00077   };
00078 
00079 
00080   class KModule {
00081   public:
00082     llvm::Module *module;
00083     llvm::TargetData *targetData;
00084     
00085     // Some useful functions to know the address of
00086     llvm::Function *dbgStopPointFn, *kleeMergeFn;
00087 
00088     // Our shadow versions of LLVM structures.
00089     std::vector<KFunction*> functions;
00090     std::map<llvm::Function*, KFunction*> functionMap;
00091 
00092     // Functions which escape (may be called indirectly)
00093     // XXX change to KFunction
00094     std::set<llvm::Function*> escapingFunctions;
00095 
00096     InstructionInfoTable *infos;
00097 
00098     std::vector<llvm::Constant*> constants;
00099     std::map<llvm::Constant*, KConstant*> constantMap;
00100     KConstant* getKConstant(llvm::Constant *c);
00101 
00102     Cell *constantTable;
00103 
00104   public:
00105     KModule(llvm::Module *_module);
00106     ~KModule();
00107 
00109     //
00110     // FIXME: ihandler should not be here
00111     void prepare(const Interpreter::ModuleOptions &opts, 
00112                  InterpreterHandler *ihandler);
00113 
00115     unsigned getConstantID(llvm::Constant *c, KInstruction* ki);
00116   };
00117 } // End klee namespace
00118 
00119 #endif

Generated on Fri Jun 5 03:31:31 2009 for klee by  doxygen 1.5.8