IRInterpreter.h revision 44199f15f5b69bee8b64aa28e5e2b6d87d0fc932
1//===-- IRInterpreter.h -----------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef liblldb_IRInterpreter_h_ 11#define liblldb_IRInterpreter_h_ 12 13#include "lldb/lldb-public.h" 14#include "lldb/Core/ConstString.h" 15#include "lldb/Core/Stream.h" 16#include "lldb/Symbol/TaggedASTType.h" 17#include "llvm/Pass.h" 18 19namespace llvm { 20 class Function; 21 class Module; 22} 23 24namespace lldb_private { 25 26class ClangExpressionDeclMap; 27class IRMemoryMap; 28 29} 30 31//---------------------------------------------------------------------- 32/// @class IRInterpreter IRInterpreter.h "lldb/Expression/IRInterpreter.h" 33/// @brief Attempt to interpret the function's code if it does not require 34/// running the target. 35/// 36/// In some cases, the IR for an expression can be evaluated entirely 37/// in the debugger, manipulating variables but not executing any code 38/// in the target. The IRInterpreter attempts to do this. 39//---------------------------------------------------------------------- 40class IRInterpreter 41{ 42public: 43 //------------------------------------------------------------------ 44 /// Run the IR interpreter on a single function 45 /// 46 /// @param[in] result 47 /// This variable is populated with the return value of the 48 /// function, if it could be interpreted completely. 49 /// 50 /// @param[in] result_name 51 /// The name of the result in the IR. If this name got a 52 /// value written to it as part of execution, then that value 53 /// will be used to create the result variable. 54 /// 55 /// @param[in] result_type 56 /// The type of the result. 57 /// 58 /// @param[in] llvm_function 59 /// The function to interpret. 60 /// 61 /// @param[in] llvm_module 62 /// The module containing the function. 63 /// 64 /// @param[in] error 65 /// If the expression fails to interpret, a reason why. 66 /// 67 /// @return 68 /// True on success; false otherwise 69 //------------------------------------------------------------------ 70 static bool 71 maybeRunOnFunction (lldb_private::ClangExpressionDeclMap *decl_map, 72 lldb_private::IRMemoryMap &memory_map, 73 lldb_private::Stream *error_stream, 74 lldb::ClangExpressionVariableSP &result, 75 const lldb_private::ConstString &result_name, 76 lldb_private::TypeFromParser result_type, 77 llvm::Function &llvm_function, 78 llvm::Module &llvm_module, 79 lldb_private::Error &err); 80private: 81 static bool 82 supportsFunction (llvm::Function &llvm_function, 83 lldb_private::Error &err); 84 85 static bool 86 runOnFunction (lldb_private::ClangExpressionDeclMap *decl_map, 87 lldb_private::IRMemoryMap &memory_map, 88 lldb_private::Stream *error_stream, 89 lldb::ClangExpressionVariableSP &result, 90 const lldb_private::ConstString &result_name, 91 lldb_private::TypeFromParser result_type, 92 llvm::Function &llvm_function, 93 llvm::Module &llvm_module, 94 lldb_private::Error &err); 95}; 96 97#endif 98