CACAO
MachineInstructionPrinterPass.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/MachineInstructionPrinterPass.cpp - MachineInstructionPrinterPass
2 
3  Copyright (C) 2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
36 
37 #include "toolbox/GraphPrinter.hpp"
38 
39 #include "vm/utf8.hpp"
40 #include "vm/jit/jit.hpp"
41 #include "vm/class.hpp"
42 
43 #include <sstream>
44 
45 #define DEBUG_NAME "compiler2/MachineInstructionPrinterPass"
46 
47 namespace cacao {
48 namespace jit {
49 namespace compiler2 {
50 
55  return PU;
56 }
57 
58 Option<bool> MachineInstructionPrinterPass::enabled("MachineInstructionPrinterPass","compiler2: enable MachineInstructionPrinterPass",false,::cacao::option::xx_root());
59 
60 // register pass
61 static PassRegistry<MachineInstructionPrinterPass> X("MachineInstructionPrinterPass");
62 
63 // run pass
65  #if defined(ENABLE_LOGGING)
66  if (enabled) {
67  MachineInstructionSchedule *MIS = get_Pass<MachineInstructionSchedulingPass>();
68  assert(MIS);
69  for (MachineInstructionSchedule::iterator i = MIS->begin(), e = MIS->end();
70  i != e; ++i) {
71  MachineBasicBlock *MBB = *i;
72  dbg() << *MBB << " ";
73  print_ptr_container(dbg(),MBB->pred_begin(),MBB->pred_end()) << nl;
74  // print label
75  dbg() << *MBB->front() << nl;
76  // print phi
78  e = MBB->phi_end(); i != e; ++i) {
79  MachinePhiInst *phi = *i;
80  dbg() << *phi << nl;
81  }
82  // print remaining instructions
83  for (MachineBasicBlock::iterator i = ++MBB->begin(), e = MBB->end();
84  i != e ; ++i) {
85  MachineInstruction *MI = *i;
86  dbg() << *MI << nl;
87  }
88  }
89  }
90  #endif
91  return true;
92 }
93 
94 } // end namespace cacao
95 } // end namespace jit
96 } // end namespace compiler2
97 
98 
99 /*
100  * These are local overrides for various environment variables in Emacs.
101  * Please do not remove this and leave it at the end of the file, where
102  * Emacs will automagically detect them.
103  * ---------------------------------------------------------------------
104  * Local variables:
105  * mode: c++
106  * indent-tabs-mode: t
107  * c-basic-offset: 4
108  * tab-width: 4
109  * End:
110  * vim:noexpandtab:sw=4:ts=4:
111  */
virtual PassUsage & get_PassUsage(PassUsage &PU) const
Set the requirements for the pass.
const_pred_iterator pred_end() const
returns an const iterator to the predecessors
const_phi_iterator phi_end() const
returns an const iterator to the phi instructions
A basic block of (scheduled) machine instructions.
void add_run_before()
Run before PassName.
Definition: PassUsage.hpp:113
iterator end()
returns an iterator to the end
CodeGenPass TODO: more info.
Definition: CodeGenPass.hpp:49
ordered iterator
iterator begin()
returns an iterator to the beginning
const_phi_iterator phi_begin() const
returns an const iterator to the phi instructions
const_reference front() const
access the first element
iterator begin()
returns an iterator to the beginning
Stores the interdependencies of a pass.
Definition: PassUsage.hpp:55
const_pred_iterator pred_begin() const
returns an const iterator to the predecessors
MIIterator i
MIIterator e
Proxy to encode explicit and implicit successors.
OptionPrefix & xx_root()
Definition: Option.cpp:39
OStream & print_ptr_container(OStream &OS, _ForwardIterator i, const _ForwardIterator &e)
Definition: OStream.hpp:448
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
Nl nl
Definition: OStream.cpp:56
OStream & dbg()
The default destination for logging messages.
void add_requires()
PassName is required.
Definition: PassUsage.hpp:78