CACAO
SSAConstructionPass.hpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/SSAConstructionPass.hpp - SSAConstructionPass
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_SSACONSTRUCTIONPASS
26 #define _JIT_COMPILER2_SSACONSTRUCTIONPASS
27 
30 #include "vm/jit/jit.hpp"
32 
34 
35 MM_MAKE_NAME(SSAConstructionPass)
36 
37 namespace cacao {
38 namespace jit {
39 namespace compiler2 {
40 
41 class InVarPhis;
42 
43 /**
44  * SSAConstructionPass
45  *
46  * This Pass constructs the compiler2 specific SSA based IR from
47  * the ICMD_* style IR used in the baseline compiler.
48  *
49  * The approach is based on "Simple and Efficient Construction of
50  * Static Singe Assignment Form" by Braun et al. 2013 @cite SSAsimple2013.
51  */
52 class SSAConstructionPass : public Pass, public memory::ManagerMixin<SSAConstructionPass> {
53 private:
59  // TODO may be changed to std::vector<unordered_map<int,PHIInst*> > incomplete_phi;
61  // TODO this should be merged with incomplete_phi
63 
65  //
68  void write_variable(size_t varindex, size_t bb, Value *V);
69  Value* read_variable_recursive(size_t varindex, size_t bb);
70  Value* add_phi_operands(size_t varindex, PHIInst *phi);
71  Value* try_remove_trivial_phi(PHIInst *phi);
72  void seal_block(size_t bb);
73  bool try_seal_block(basicblock *bb);
74  void print_current_def() const;
75 public:
76  Value* read_variable(size_t varindex, size_t bb);
77  static char ID;
79  virtual bool run(JITData &JD);
80  virtual bool verify() const;
81  virtual PassUsage& get_PassUsage(PassUsage &PU) const;
82 };
83 
84 } // end namespace cacao
85 } // end namespace jit
86 } // end namespace compiler2
87 
88 #endif /* _JIT_COMPILER2_SSACONSTRUCTIONPASS */
89 
90 
91 /*
92  * These are local overrides for various environment variables in Emacs.
93  * Please do not remove this and leave it at the end of the file, where
94  * Emacs will automagically detect them.
95  * ---------------------------------------------------------------------
96  * Local variables:
97  * mode: c++
98  * indent-tabs-mode: t
99  * c-basic-offset: 4
100  * tab-width: 4
101  * End:
102  * vim:noexpandtab:sw=4:ts=4:
103  */
Pass superclass All compiler passes should inheritate this class.
Definition: Pass.hpp:48
alloc::vector< alloc::vector< Value * >::type >::type current_def
alloc::vector< BeginInst * >::type BB
Definition: jit.hpp:126
Custom new/delete handler mixin.
Definition: Manager.hpp:43
#define MM_MAKE_NAME(x)
Definition: memstats.hpp:127
alloc::vector< alloc::vector< PHIInst * >::type >::type incomplete_phi
alloc::vector< Type::TypeID >::type var_type_tbl
std::vector< T, Allocator< T > > type
Definition: vector.hpp:38
Stores the interdependencies of a pass.
Definition: PassUsage.hpp:55
alloc::unordered_map< BeginInst *, size_t >::type beginToIndex
alloc::vector< alloc::list< InVarPhis * >::type >::type incomplete_in_phi