-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathBytecodeBuilder.hpp
executable file
·117 lines (93 loc) · 4.51 KB
/
BytecodeBuilder.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*******************************************************************************
*
* (c) Copyright IBM Corp. 2000, 2016
*
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0 and
* Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* Contributors:
* Multiple authors (IBM Corp.) - initial implementation and documentation
******************************************************************************/
#ifndef BYTECODE_BUILDER_INCL
#define BYTECODE_BUILDER_INCL
#ifndef TR_BYTECODEBUILDER_DEFINED
#define TR_BYTECODEBUILDER_DEFINED
#define PUT_OMR_BYTECODEBUILDER_INTO_TR
#endif // !defined(TR_BYTECODEBUILDER_DEFINED)
#include "ilgen/IlBuilder.hpp"
namespace TR { class BytecodeBuilder; }
namespace TR { class MethodBuilder; }
namespace OMR { class VirtualMachineState; }
namespace OMR
{
class BytecodeBuilder : public TR::IlBuilder
{
public:
TR_ALLOC(TR_Memory::IlGenerator)
BytecodeBuilder(TR::MethodBuilder *methodBuilder, int32_t bcIndex, char *name=NULL);
virtual bool isBytecodeBuilder() { return true; }
virtual uint32_t countBlocks();
void AddFallThroughBuilder(TR::BytecodeBuilder *ftb);
void AddSuccessorBuilders(uint32_t numBuilders, ...);
void AddSuccessorBuilder(TR::BytecodeBuilder **b) { AddSuccessorBuilders(1, b); }
OMR::VirtualMachineState *initialVMState() { return _initialVMState; }
OMR::VirtualMachineState *vmState() { return _vmState; }
void setVMState(OMR::VirtualMachineState *vmState) { _vmState = vmState; }
void propagateVMState(OMR::VirtualMachineState *fromVMState);
// The following control flow services are meant to hide the similarly named services
// provided by the IlBuilder class. The reason these implementations exist is to
// automatically manage the propagation of virtual machine states between bytecode
// builders. By using these services, and AddFallthroughBuilder(), users do not have
// to do anything to propagate VM states; it's all just taken care of under the covers.
void Goto(TR::BytecodeBuilder **dest);
void Goto(TR::BytecodeBuilder *dest);
void IfCmpEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpEqualZero(TR::BytecodeBuilder **dest, TR::IlValue *c);
void IfCmpEqualZero(TR::BytecodeBuilder *dest, TR::IlValue *c);
void IfCmpNotEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpNotEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpNotEqualZero(TR::BytecodeBuilder **dest, TR::IlValue *c);
void IfCmpNotEqualZero(TR::BytecodeBuilder *dest, TR::IlValue *c);
void IfCmpLessThan(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpLessThan(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpGreaterThan(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpGreaterThan(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
protected:
TR::BytecodeBuilder * _fallThroughBuilder;
List<TR::BytecodeBuilder> * _successorBuilders;
int32_t _bcIndex;
char * _name;
OMR::VirtualMachineState * _initialVMState;
OMR::VirtualMachineState * _vmState;
virtual void appendBlock(TR::Block *block = 0, bool addEdge=true);
void addAllSuccessorBuildersToWorklist();
bool connectTrees();
virtual void setHandlerInfo(uint32_t catchType);
void transferVMState(TR::BytecodeBuilder **b);
};
} // namespace OMR
#if defined(PUT_OMR_BYTECODEBUILDER_INTO_TR)
namespace TR
{
class BytecodeBuilder : public OMR::BytecodeBuilder
{
public:
BytecodeBuilder(TR::MethodBuilder *methodBuilder, int32_t bcIndex, char *name=NULL)
: OMR::BytecodeBuilder(methodBuilder, bcIndex, name)
{ }
void initialize(TR::IlGeneratorMethodDetails * details,
TR::ResolvedMethodSymbol * methodSymbol,
TR::FrontEnd * fe,
TR::SymbolReferenceTable * symRefTab);
};
} // namespace TR
#endif // defined(PUT_OMR_BYTECODEBUILDER_INTO_TR)
#endif // !defined(OMR_ILBUILDER_INCL)