CACAO
Matcher.hpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/Matcher.hpp - Matcher class
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 #ifndef _JIT_COMPILER2_MATCHER
25 #define _JIT_COMPILER2_MATCHER
26 
27 #include <stdio.h>
28 #include <assert.h>
29 #include <stdlib.h>
30 
31 #include "Instruction.hpp"
37 #include "Target.hpp"
38 
39 #include "future/memory.hpp"
40 
41 // #include "vm/jit/compiler2/MatcherDefs.hpp"
42 
43 namespace cacao {
44 namespace jit {
45 namespace compiler2{
46 
47 // typedefs and macros needed by generated matcher
49 typedef struct burm_state STATE_TYPE;
50 
51 // INCLUDE GENERATED DEFINES
52 #define GENDEFS
53 #include "Grammar.inc"
54 
55 class Matcher {
56 
57 public:
58 
59  // typedefs to avoid naming dependency to generated matcher
67 
69  sched(sched), basicBlock(BI), LV(LV) { }
70 
71  void run();
72 
73 private:
79 
84 
86 
87 // INCLUDE GENERATED MATCHER ALGORITHM
88 #define GENMETHODDEFS
89 #include "Grammar.inc"
90 
91  // matching
92  void findRoots();
93  bool checkIsNodeExcluded(Instruction* inst);
94  Instruction* getOperand(Instruction* op, unsigned pos);
95  Instruction* createProxy(Instruction* op, unsigned pos, Instruction* operand, bool dependency);
96 
97  // debug output
98  void dumpCover(Instruction* p, int goalnt, int indent);
99  void printDependencies(Instruction* inst);
100 
101  // scheduling and lowering
102  void scheduleTrees();
103  void lowerTree(Instruction* p, int goalnt);
104  void lowerRule(Instruction* inst, RuleId id);
105 
106 };
107 
108 }
109 }
110 }
111 
112 #endif
113 
114 /*
115  * These are local overrides for various environment variables in Emacs.
116  * Please do not remove this and leave it at the end of the file, where
117  * Emacs will automagically detect them.
118  * ---------------------------------------------------------------------
119  * Local variables:
120  * mode: c++
121  * indent-tabs-mode: t
122  * c-basic-offset: 4
123  * tab-width: 4
124  * End:
125  * vim:noexpandtab:sw=4:ts=4:
126  */
std::set< Key, Compare, Allocator< Key > > type
Definition: set.hpp:38
GlobalSchedule TODO: more info.
LoweringVisitor * LV
Definition: Matcher.hpp:76
static const ExcludeSetTy excluded_nodes
Definition: Matcher.hpp:85
This Instruction mark the start of a basic block.
u2 op
Definition: disass.cpp:129
Instruction * NODEPTR_TYPE
Definition: Matcher.hpp:48
alloc::set< Instruction * >::type InstSetTy
Definition: Matcher.hpp:62
alloc::unordered_map< Instruction *, shared_ptr< STATE_TYPE > >::type InstToStateLabelTy
Definition: Matcher.hpp:60
InstToStateLabelTy state_labels
Definition: Matcher.hpp:80
alloc::unordered_map< int, shared_ptr< Instruction > >::type ProxyMapByInstTy
Definition: Matcher.hpp:63
std::list< T, Allocator< T > > type
Definition: list.hpp:38
void printDependencies(Instruction *inst)
Definition: Matcher.cpp:234
Indent indent
Definition: OStream.cpp:54
void dumpCover(Instruction *p, int goalnt, int indent)
Definition: Matcher.cpp:219
Instruction * getOperand(Instruction *op, unsigned pos)
Definition: Matcher.cpp:161
bool checkIsNodeExcluded(Instruction *inst)
Definition: Matcher.cpp:157
Instruction * createProxy(Instruction *op, unsigned pos, Instruction *operand, bool dependency)
Definition: Matcher.cpp:195
alloc::unordered_map< Instruction *, shared_ptr< InstSetTy > >::type DependencyMapTy
Definition: Matcher.hpp:65
Instruction super class.
Definition: Instruction.hpp:73
Matcher(GlobalSchedule *sched, BeginInst *BI, LoweringVisitor *LV)
Definition: Matcher.hpp:68
MIIterator pos
alloc::list< Instruction * >::type InstListTy
Definition: Matcher.hpp:61
GlobalSchedule * sched
Definition: Matcher.hpp:74
alloc::set< Instruction::InstID >::type ExcludeSetTy
Definition: Matcher.hpp:64
struct burm_state STATE_TYPE
Definition: Matcher.hpp:49
void lowerRule(Instruction *inst, RuleId id)
Definition: Matcher.cpp:311
void lowerTree(Instruction *p, int goalnt)
Definition: Matcher.cpp:296
alloc::unordered_map< Instruction *, shared_ptr< ProxyMapByInstTy > >::type ProxyMapTy
Definition: Matcher.hpp:66