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 // the address of this variable is used to identify the pass
59 
60 Option<bool> MachineInstructionPrinterPass::enabled("MachineInstructionPrinterPass","compiler2: enable MachineInstructionPrinterPass",false,::cacao::option::xx_root());
61 
62 // register pass
63 static PassRegistry<MachineInstructionPrinterPass> X("MachineInstructionPrinterPass");
64 
65 // run pass
67  #if defined(ENABLE_LOGGING)
68  if (enabled) {
69  MachineInstructionSchedule *MIS = get_Pass<MachineInstructionSchedulingPass>();
70  assert(MIS);
71  for (MachineInstructionSchedule::iterator i = MIS->begin(), e = MIS->end();
72  i != e; ++i) {
73  MachineBasicBlock *MBB = *i;
74  dbg() << *MBB << " ";
75  print_ptr_container(dbg(),MBB->pred_begin(),MBB->pred_end()) << nl;
76  // print label
77  dbg() << *MBB->front() << nl;
78  // print phi
80  e = MBB->phi_end(); i != e; ++i) {
81  MachinePhiInst *phi = *i;
82  dbg() << *phi << nl;
83  }
84  // print remaining instructions
85  for (MachineBasicBlock::iterator i = ++MBB->begin(), e = MBB->end();
86  i != e ; ++i) {
87  MachineInstruction *MI = *i;
88  dbg() << *MI << nl;
89  }
90  }
91  }
92  #endif
93  return true;
94 }
95 
96 } // end namespace cacao
97 } // end namespace jit
98 } // end namespace compiler2
99 
100 
101 /*
102  * These are local overrides for various environment variables in Emacs.
103  * Please do not remove this and leave it at the end of the file, where
104  * Emacs will automagically detect them.
105  * ---------------------------------------------------------------------
106  * Local variables:
107  * mode: c++
108  * indent-tabs-mode: t
109  * c-basic-offset: 4
110  * tab-width: 4
111  * End:
112  * vim:noexpandtab:sw=4:ts=4:
113  */
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