CACAO
Backend.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/Backend.cpp - Backend
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 "Target.hpp"
30 
31 namespace cacao {
32 namespace jit {
33 namespace compiler2 {
34 
36  return new BackendBase<Target>(JD);
37 }
38 
39 void LoweringVisitorBase::visit(BeginInst* I, bool copyOperands) {
40  assert(I);
41  MachineInstruction *label = new MachineLabelInst();
42  get_current()->push_back(label);
43  //set_op(I,label->get_result().op);
44 }
45 
46 void LoweringVisitorBase::visit(GOTOInst* I, bool copyOperands) {
47  assert(I);
48  MachineInstruction *jump = backend->create_Jump(get(I->get_target().get()));
49  get_current()->push_back(jump);
50  set_op(I,jump->get_result().op);
51 }
52 
53 void LoweringVisitorBase::visit(PHIInst* I, bool copyOperands) {
54  assert(I);
55  MachinePhiInst *phi = new MachinePhiInst(I->op_size(),I->get_type(),I);
56  //get_current()->push_back(phi);
57  get_current()->insert_phi(phi);
58  set_op(I,phi->get_result().op);
59 }
60 
61 void LoweringVisitorBase::visit(CONSTInst* I, bool copyOperands) {
62  assert(I);
63  VirtualRegister *reg = new VirtualRegister(I->get_type());
64  Immediate *imm = new Immediate(I);
65  MachineInstruction *move = backend->create_Move(imm,reg);
66  get_current()->push_back(move);
67  set_op(I,move->get_result().op);
68 }
69 
71  return *schedule->insert_after(get_current()->self_iterator(),MBBBuilder());
72 }
73 
74 
75 } // end namespace compiler2
76 } // end namespace jit
77 } // end namespace cacao
78 
79 
80 /*
81  * These are local overrides for various environment variables in Emacs.
82  * Please do not remove this and leave it at the end of the file, where
83  * Emacs will automagically detect them.
84  * ---------------------------------------------------------------------
85  * Local variables:
86  * mode: c++
87  * indent-tabs-mode: t
88  * c-basic-offset: 4
89  * tab-width: 4
90  * End:
91  * vim:noexpandtab:sw=4:ts=4:
92  */
void set_op(Instruction *I, MachineOperand *op) const
Definition: Backend.hpp:106
virtual MachineInstruction * create_Move(MachineOperand *src, MachineOperand *dst) const =0
Type::TypeID get_type() const
get the value type of the instruction
Definition: Value.hpp:68
This Instruction mark the start of a basic block.
A basic block of (scheduled) machine instructions.
virtual void visit(BeginInst *I, bool copyOperands)
Definition: Backend.cpp:39
virtual MachineInstruction * create_Jump(MachineBasicBlock *target) const =0
static Backend * factory(JITData *JD)
Definition: Backend.cpp:35
void push_back(MachineInstruction *value)
Appends the given element value to the end of the container.
void insert_phi(MachinePhiInst *value)
Appends the given element value to the list of phis.
MachineInstructionSchedule::iterator insert_after(iterator pos, const MBBBuilder &value)
inserts value after the element pointed to by pos
Proxy to encode explicit and implicit successors.
MachineBasicBlock * get_current() const
Definition: Backend.hpp:121
#define I(value)
Definition: codegen.c:279
const MachineOperandDesc & get_result() const
MachineBasicBlock * new_block() const
Definition: Backend.cpp:70
MachineInstructionSchedule * schedule
Definition: Backend.hpp:89