CACAO
MachineInstruction.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/MachineInstruction.cpp - MachineInstruction
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 
28 
29 #include "toolbox/OStream.hpp"
30 
31 #define DEBUG_NAME "compiler2/MachineInstruction"
32 
33 namespace cacao {
34 namespace jit {
35 namespace compiler2 {
36 
37 std::size_t MachineInstruction::id_counter = 0;
38 
40  // print id
41  OS << "[" << setw(4) << fillzero << get_id() << "] ";
42  // print name
43  OS << get_name();
44  // print operands
45  OS << " ";
46  OS = print_operands(OS);
47  // print result
49  if (!result->to_VoidOperand()) {
50  OS << " -> ";
51  OS = print_result(OS);
52  }
53  // print successors
54  if (!successor_empty()) {
55  OS << " [";
56  std::size_t index = 0;
58  i != e; ++i) {
59  print_successor_label(OS,index) << "=" << **i << " ";
60  ++index;
61  }
62  OS << "]";
63  }
64  if (comment) {
65  OS << " # " << comment;
66  }
67  return OS;
68 }
69 
71  return OS << get_result().op;
72 }
73 
76  e = end(); i != e ; ++i) {
77  OS << (*i) << " ";
78  }
79  return OS;
80 }
81 
83  return OS << index;
84 }
85 
87  ABORT_MSG("emit not yet implemented", "emit for " << this << " is not yet implemented");
88 }
89 
91  ABORT_MSG("link not implemented", "link for "
92  << this << " is not implemented");
93 }
94 
96  if (!MI) {
97  return OS << "(MachineInstruction) NULL";
98  }
99  return OS << *MI;
100 }
102  return MI.print(OS);
103 }
104 
106  if (!MOD) {
107  return OS << "(MachineOperandDesc) NULL";
108  }
109  return OS << *MOD;
110 }
112  return OS << MOD.op;
113 }
114 
115 } // end namespace compiler2
116 } // end namespace jit
117 } // end namespace cacao
118 
119 
120 /*
121  * These are local overrides for various environment variables in Emacs.
122  * Please do not remove this and leave it at the end of the file, where
123  * Emacs will automagically detect them.
124  * ---------------------------------------------------------------------
125  * Local variables:
126  * mode: c++
127  * indent-tabs-mode: t
128  * c-basic-offset: 4
129  * tab-width: 4
130  * End:
131  * vim:noexpandtab:sw=4:ts=4:
132  */
std::size_t index
static SetWidth setw(size_t w)
Definition: OStream.hpp:395
virtual void emit(CodeMemory *CM) const
emit machine code
operand_list::const_iterator const_operand_iterator
Descriptor of a MachineOperand.
virtual VoidOperand * to_VoidOperand()
FillZero fillzero
Definition: OStream.cpp:45
OStream & print(OStream &OS) const
print instruction
successor_list::const_iterator const_successor_iterator
Simple stream class for formatted output.
Definition: OStream.hpp:141
OStream & operator<<(OStream &OS, const Conditional::CondID &cond)
Definition: Conditional.cpp:34
MIIterator i
virtual OStream & print_operands(OStream &OS) const
print operands
OStream & OS
virtual void link(CodeFragment &CF) const
link machine code
MIIterator e
Proxy to encode explicit and implicit successors.
Operands that can be directly used by the machine (register, memory, stackslot)
const MachineOperandDesc & get_result() const
Segment reference.
Definition: Segment.hpp:44
virtual OStream & print_successor_label(OStream &OS, std::size_t index) const
print successor label
#define ABORT_MSG(EXPR_SHORT, EXPR_LONG)
Definition: logging.hpp:133
virtual OStream & print_result(OStream &OS) const
print result