Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/aarch64/codegen/J9MemoryReference.hpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2019, 2022 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#ifndef J9_ARM64_MEMORY_REFERENCE_INCL
24
#define J9_ARM64_MEMORY_REFERENCE_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_MEMORY_REFERENCE_CONNECTOR
30
#define J9_MEMORY_REFERENCE_CONNECTOR
31
32
namespace J9 { namespace ARM64 { class MemoryReference; } }
33
namespace J9 { typedef J9::ARM64::MemoryReference MemoryReferenceConnector; }
34
#else
35
#error J9::ARM64::MemoryReference expected to be a primary connector, but a J9 connector is already defined
36
#endif
37
38
#include "codegen/OMRMemoryReference.hpp"
39
#include "infra/Flags.hpp"
40
41
namespace J9
42
{
43
44
namespace ARM64
45
{
46
47
class OMR_EXTENSIBLE MemoryReference : public OMR::MemoryReferenceConnector
48
{
49
flags8_t _j9Flags;
50
51
protected:
52
53
/**
54
* @brief Constructor
55
* @param[in] cg : CodeGenerator object
56
*/
57
MemoryReference(TR::CodeGenerator *cg)
58
: OMR::MemoryReferenceConnector(cg), _j9Flags(0)
59
{
60
setupCausesImplicitNullPointerException(cg);
61
}
62
63
/**
64
* @brief Constructor
65
* @param[in] br : base register
66
* @param[in] ir : index register
67
* @param[in] cg : CodeGenerator object
68
*/
69
MemoryReference(
70
TR::Register *br,
71
TR::Register *ir,
72
TR::CodeGenerator *cg)
73
: OMR::MemoryReferenceConnector(br, ir, cg), _j9Flags(0)
74
{
75
setupCausesImplicitNullPointerException(cg);
76
}
77
78
/**
79
* @brief Constructor
80
* @param[in] br : base register
81
* @param[in] ir : index register
82
* @param[in] scale : scale of index
83
* @param[in] cg : CodeGenerator object
84
*/
85
MemoryReference(
86
TR::Register *br,
87
TR::Register *ir,
88
uint8_t scale,
89
TR::CodeGenerator *cg)
90
: OMR::MemoryReferenceConnector(br, ir, scale, cg), _j9Flags(0)
91
{
92
setupCausesImplicitNullPointerException(cg);
93
}
94
95
/**
96
* @brief Constructor
97
* @param[in] br : base register
98
* @param[in] disp : displacement
99
* @param[in] cg : CodeGenerator object
100
*/
101
MemoryReference(
102
TR::Register *br,
103
int32_t disp,
104
TR::CodeGenerator *cg)
105
: OMR::MemoryReferenceConnector(br, disp, cg), _j9Flags(0)
106
{
107
setupCausesImplicitNullPointerException(cg);
108
}
109
110
/**
111
* @brief Constructor
112
* @param[in] node : load or store node
113
* @param[in] cg : CodeGenerator object
114
*/
115
MemoryReference(TR::Node *node, TR::CodeGenerator *cg);
116
117
/**
118
* @brief Constructor
119
* @param[in] node : node
120
* @param[in] symRef : symbol reference
121
* @param[in] cg : CodeGenerator object
122
*/
123
MemoryReference(TR::Node *node, TR::SymbolReference *symRef, TR::CodeGenerator *cg);
124
125
public:
126
TR_ALLOC(TR_Memory::MemoryReference)
127
128
typedef enum
129
{
130
TR_ARM64MemoryReferenceControl_ThrowsImplicitNullPointerException = 0x01,
131
/* To be added more if necessary */
132
} TR_ARM64MemoryReferenceExtraControl;
133
134
135
/**
136
* @brief Implicit NullPointerException can be thrown or not
137
* @return true if implicit NullPointerException can be thrown
138
*/
139
bool getCausesImplicitNullPointerException()
140
{
141
return _j9Flags.testAll(TR_ARM64MemoryReferenceControl_ThrowsImplicitNullPointerException);
142
}
143
144
/**
145
* @brief Sets Implicit NullPointerException flag
146
*/
147
void setCausesImplicitNullPointerException()
148
{
149
_j9Flags.set(TR_ARM64MemoryReferenceControl_ThrowsImplicitNullPointerException);
150
}
151
152
/**
153
* @brief Analyzes current node and sets Implicit NullPointerException flag if necessary
154
* @param[in] cg : CodeGenerator
155
*/
156
void setupCausesImplicitNullPointerException(TR::CodeGenerator *cg);
157
158
/**
159
* @brief Adjustment for resolution
160
* @param[in] cg : CodeGenerator
161
*/
162
void adjustForResolution(TR::CodeGenerator *cg);
163
164
/**
165
* @brief Assigns registers
166
* @param[in] currentInstruction : current instruction
167
* @param[in] cg : CodeGenerator
168
*/
169
void assignRegisters(TR::Instruction *currentInstruction, TR::CodeGenerator *cg);
170
171
/**
172
* @brief Estimates the length of generated binary
173
* @param[in] op : opcode of the instruction to attach this memory reference to
174
* @return estimated binary length
175
*/
176
uint32_t estimateBinaryLength(TR::InstOpCode op);
177
178
/**
179
* @brief Generates binary encoding
180
* @param[in] ci : current instruction
181
* @param[in] cursor : instruction cursor
182
* @param[in] cg : CodeGenerator
183
* @return instruction cursor after encoding
184
*/
185
uint8_t *generateBinaryEncoding(TR::Instruction *ci, uint8_t *cursor, TR::CodeGenerator *cg);
186
};
187
188
} // ARM64
189
190
} // J9
191
192
#endif
193
194