Path: blob/master/runtime/compiler/aarch64/codegen/J9MemoryReference.hpp
6004 views
/*******************************************************************************1* Copyright (c) 2019, 2022 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#ifndef J9_ARM64_MEMORY_REFERENCE_INCL23#define J9_ARM64_MEMORY_REFERENCE_INCL2425/*26* The following #define and typedef must appear before any #includes in this file27*/28#ifndef J9_MEMORY_REFERENCE_CONNECTOR29#define J9_MEMORY_REFERENCE_CONNECTOR3031namespace J9 { namespace ARM64 { class MemoryReference; } }32namespace J9 { typedef J9::ARM64::MemoryReference MemoryReferenceConnector; }33#else34#error J9::ARM64::MemoryReference expected to be a primary connector, but a J9 connector is already defined35#endif3637#include "codegen/OMRMemoryReference.hpp"38#include "infra/Flags.hpp"3940namespace J941{4243namespace ARM6444{4546class OMR_EXTENSIBLE MemoryReference : public OMR::MemoryReferenceConnector47{48flags8_t _j9Flags;4950protected:5152/**53* @brief Constructor54* @param[in] cg : CodeGenerator object55*/56MemoryReference(TR::CodeGenerator *cg)57: OMR::MemoryReferenceConnector(cg), _j9Flags(0)58{59setupCausesImplicitNullPointerException(cg);60}6162/**63* @brief Constructor64* @param[in] br : base register65* @param[in] ir : index register66* @param[in] cg : CodeGenerator object67*/68MemoryReference(69TR::Register *br,70TR::Register *ir,71TR::CodeGenerator *cg)72: OMR::MemoryReferenceConnector(br, ir, cg), _j9Flags(0)73{74setupCausesImplicitNullPointerException(cg);75}7677/**78* @brief Constructor79* @param[in] br : base register80* @param[in] ir : index register81* @param[in] scale : scale of index82* @param[in] cg : CodeGenerator object83*/84MemoryReference(85TR::Register *br,86TR::Register *ir,87uint8_t scale,88TR::CodeGenerator *cg)89: OMR::MemoryReferenceConnector(br, ir, scale, cg), _j9Flags(0)90{91setupCausesImplicitNullPointerException(cg);92}9394/**95* @brief Constructor96* @param[in] br : base register97* @param[in] disp : displacement98* @param[in] cg : CodeGenerator object99*/100MemoryReference(101TR::Register *br,102int32_t disp,103TR::CodeGenerator *cg)104: OMR::MemoryReferenceConnector(br, disp, cg), _j9Flags(0)105{106setupCausesImplicitNullPointerException(cg);107}108109/**110* @brief Constructor111* @param[in] node : load or store node112* @param[in] cg : CodeGenerator object113*/114MemoryReference(TR::Node *node, TR::CodeGenerator *cg);115116/**117* @brief Constructor118* @param[in] node : node119* @param[in] symRef : symbol reference120* @param[in] cg : CodeGenerator object121*/122MemoryReference(TR::Node *node, TR::SymbolReference *symRef, TR::CodeGenerator *cg);123124public:125TR_ALLOC(TR_Memory::MemoryReference)126127typedef enum128{129TR_ARM64MemoryReferenceControl_ThrowsImplicitNullPointerException = 0x01,130/* To be added more if necessary */131} TR_ARM64MemoryReferenceExtraControl;132133134/**135* @brief Implicit NullPointerException can be thrown or not136* @return true if implicit NullPointerException can be thrown137*/138bool getCausesImplicitNullPointerException()139{140return _j9Flags.testAll(TR_ARM64MemoryReferenceControl_ThrowsImplicitNullPointerException);141}142143/**144* @brief Sets Implicit NullPointerException flag145*/146void setCausesImplicitNullPointerException()147{148_j9Flags.set(TR_ARM64MemoryReferenceControl_ThrowsImplicitNullPointerException);149}150151/**152* @brief Analyzes current node and sets Implicit NullPointerException flag if necessary153* @param[in] cg : CodeGenerator154*/155void setupCausesImplicitNullPointerException(TR::CodeGenerator *cg);156157/**158* @brief Adjustment for resolution159* @param[in] cg : CodeGenerator160*/161void adjustForResolution(TR::CodeGenerator *cg);162163/**164* @brief Assigns registers165* @param[in] currentInstruction : current instruction166* @param[in] cg : CodeGenerator167*/168void assignRegisters(TR::Instruction *currentInstruction, TR::CodeGenerator *cg);169170/**171* @brief Estimates the length of generated binary172* @param[in] op : opcode of the instruction to attach this memory reference to173* @return estimated binary length174*/175uint32_t estimateBinaryLength(TR::InstOpCode op);176177/**178* @brief Generates binary encoding179* @param[in] ci : current instruction180* @param[in] cursor : instruction cursor181* @param[in] cg : CodeGenerator182* @return instruction cursor after encoding183*/184uint8_t *generateBinaryEncoding(TR::Instruction *ci, uint8_t *cursor, TR::CodeGenerator *cg);185};186187} // ARM64188189} // J9190191#endif192193194