blob: a6b50e591277bd511da5d680810bdd8f649920fd [file] [log] [blame]
Sean Callanan5cf4a1c2010-07-03 01:35:46 +00001//===-- IRForTarget.cpp -------------------------------------------*- 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#include "lldb/Expression/IRForTarget.h"
11
12#include "llvm/Support/raw_ostream.h"
13#include "llvm/InstrTypes.h"
14#include "llvm/Module.h"
15
16#include "lldb/Core/dwarf.h"
17#include "lldb/Core/Log.h"
18#include "lldb/Core/Scalar.h"
19#include "lldb/Core/StreamString.h"
20#include "lldb/Expression/ClangExpressionDeclMap.h"
21
22#include <map>
23
24using namespace llvm;
25
26IRForTarget::IRForTarget(const void *pid,
27 lldb_private::ClangExpressionDeclMap *decl_map) :
28 ModulePass(pid),
29 m_decl_map(decl_map)
30{
31}
32
33IRForTarget::~IRForTarget()
34{
35}
36
37bool
38IRForTarget::runOnBasicBlock(BasicBlock &BB)
39{
40 lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
41
42 /////////////////////////////////////////////////////////////////////////
43 // Prepare the current basic block for execution in the remote process
44 //
45
46 if (log)
47 {
48 log->Printf("Preparing basic block %s:",
49 BB.hasName() ? BB.getNameStr().c_str() : "[anonymous]");
50
51 llvm::BasicBlock::iterator ii;
52
53 for (ii = BB.begin();
54 ii != BB.end();
55 ++ii)
56 {
57 llvm::Instruction &inst = *ii;
58
59 std::string s;
60 raw_string_ostream os(s);
61
62 inst.print(os);
63
64 if (log)
65 log->Printf(" %s", s.c_str());
66 }
67 }
68
69 return true;
70}
71
72bool
73IRForTarget::runOnModule(Module &M)
74{
75 lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
76
77 llvm::Function* function = M.getFunction(StringRef("___clang_expr"));
78
79 if (!function)
80 {
81 if (log)
82 log->Printf("Couldn't find ___clang_expr() in the module");
83
84 return false;
85 }
86
87 llvm::Function::iterator bbi;
88
89 for (bbi = function->begin();
90 bbi != function->end();
91 ++bbi)
92 {
93 runOnBasicBlock(*bbi);
94 }
95
96 return true;
97}
98
99void
100IRForTarget::assignPassManager(PMStack &PMS,
101 PassManagerType T)
102{
103}
104
105PassManagerType
106IRForTarget::getPotentialPassManagerType() const
107{
108 return PMT_ModulePassManager;
109}