CACAO
MachineInstructions.hpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/MachineInstructions.hpp - Machine Instruction Types
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 
25 #ifndef _JIT_COMPILER2_MACHINEINSTRUCTIONS
26 #define _JIT_COMPILER2_MACHINEINSTRUCTIONS
27 
29 
30 namespace cacao {
31 namespace jit {
32 namespace compiler2 {
33 
35 public:
37  virtual void emit(CodeMemory* CM) const;
38  virtual bool is_label() const {
39  return true;
40  }
41 };
42 
44 private:
46 public:
47  MachinePhiInst(unsigned num_operands, Type::TypeID type, PHIInst* phi)
48  : MachineInstruction("MPhi", new VirtualRegister(type),
49  num_operands), phi(phi) {
50  for(unsigned i = 0; i < num_operands; ++i) {
51  operands[i].op = new UnassignedReg(type);
52  }
53  }
54 
55  virtual bool is_phi() const {
56  return true;
57  }
59  return this;
60  }
61  // phis are never emitted
62  virtual void emit(CodeMemory* CM) const {};
63 
64  PHIInst* get_PHIInst() const {
65  return phi;
66  }
67 };
68 #if 0
69 class MachineConstInst : public MachineInstruction {
70 public:
71  /**
72  * TODO: get const parameter
73  */
74  MachineConstInst(s8 value) : MachineInstruction("MConst",
75  new Immediate(value), 0) {}
76  // mconsts are never emitted
77  virtual void emit(CodeMemory* CM) const {};
78 };
79 
80 /**
81  * Load from memory to register
82  */
83 class MachineLoadInst : public MachineInstruction {
84 public:
85  MachineLoadInst(
86  MachineOperand *dst,
87  MachineOperand *src)
88  : MachineInstruction("MLoad", dst, 1) {
89  operands[0].op = src;
90  }
91 
92 };
93 
94 /**
95  * Store register to memory
96  */
97 class MachineStoreInst : public MachineInstruction {
98 public:
99  MachineStoreInst(
100  MachineOperand *dst,
101  MachineOperand *src)
102  : MachineInstruction("MStore", dst, 1) {
103  operands[0].op = src;
104  }
105 
106 };
107 
108 class MachineOperandInst : public MachineInstruction {
109 private:
110  MachineOperand *MO;
111 public:
112  MachineOperandInst(MachineOperand *MO)
113  : MachineInstruction("MachineOperandInst", MO, 0), MO(MO) {
114  }
115 
116 };
117 #endif
119 public:
120  MachineJumpInst(const char *name)
121  : MachineInstruction(name, &NoOperand, 0) {}
122  virtual void emit(CodeMemory* CM) const = 0;
123  virtual void link(CodeFragment &CF) const = 0;
124 };
125 #if 0
126 /**
127  * Move operand to operand
128  */
129 class MachineMoveInst : public MachineInstruction {
130 public:
131  MachineMoveInst( const char* name,
132  MachineOperand *src,
133  MachineOperand *dst)
134  : MachineInstruction(name, dst, 1) {
135  operands[0].op = src;
136  }
137  virtual bool accepts_immediate(unsigned i, Immediate *imm) const {
138  return true;
139  }
140  virtual MachineMoveInst* to_MachineMoveInst() {
141  return this;
142  }
143  virtual void emit(CodeMemory* CM) const = 0;
144 
145 };
146 #endif
147 
148 } // end namespace compiler2
149 } // end namespace jit
150 } // end namespace cacao
151 
152 #endif /* _JIT_COMPILER2_MACHINEINSTRUCTIONS */
153 
154 
155 /*
156  * These are local overrides for various environment variables in Emacs.
157  * Please do not remove this and leave it at the end of the file, where
158  * Emacs will automagically detect them.
159  * ---------------------------------------------------------------------
160  * Local variables:
161  * mode: c++
162  * indent-tabs-mode: t
163  * c-basic-offset: 4
164  * tab-width: 4
165  * End:
166  * vim:noexpandtab:sw=4:ts=4:
167  */
virtual void emit(CodeMemory *CM) const
emit machine code
MachinePhiInst(unsigned num_operands, Type::TypeID type, PHIInst *phi)
JNIEnv jclass jobject const char * name
Definition: jvmti.h:312
int64_t s8
Definition: types.hpp:48
virtual void emit(CodeMemory *CM) const =0
emit machine code
MIIterator i
Proxy to encode explicit and implicit successors.
virtual MachinePhiInst * to_MachinePhiInst()
Segment reference.
Definition: Segment.hpp:44
virtual void link(CodeFragment &CF) const =0
link machine code
virtual void emit(CodeMemory *CM) const
emit machine code