Path: blob/master/runtime/compiler/aarch64/codegen/ARM64PrivateLinkage.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 ARM64_PRIVATELINKAGE_INCL23#define ARM64_PRIVATELINKAGE_INCL2425#include "codegen/Linkage.hpp"26#include "codegen/LinkageConventionsEnum.hpp"27#include "codegen/PrivateLinkage.hpp"2829#include "infra/Assert.hpp"3031class TR_ResolvedMethod;3233namespace TR { class CodeGenerator; }34namespace TR { class Instruction; }35namespace TR { class Register; }36namespace TR { class ResolvedMethodSymbol; }3738namespace J939{4041struct ARM64PICItem42{43TR_ALLOC(TR_Memory::Linkage);4445ARM64PICItem(TR_OpaqueClassBlock *clazz, TR_ResolvedMethod *method, float freq) :46_clazz(clazz), _method(method), _frequency(freq) {}4748TR_OpaqueClassBlock *_clazz;49TR_ResolvedMethod *_method;50float _frequency;51};5253namespace ARM6454{5556class PrivateLinkage : public J9::PrivateLinkage57{58protected:5960TR::ARM64LinkageProperties _properties;6162/**63* @brief Builds method arguments64* @param[in] node : caller node65* @param[in] dependencies : register dependency conditions66* @param[in] linkage : linkage type67*/68int32_t buildPrivateLinkageArgs(69TR::Node *callNode,70TR::RegisterDependencyConditions *dependencies,71TR_LinkageConventions linkage);7273/**74* @brief Store informaiton of outgoing memory argument75* @param[in] argReg : argument register76* @param[in] offset : offset from Java SP77* @param[in] opCode : opcode for storing argument78* @param[in] memArg : MemoryArgument79*/80void pushOutgoingMemArgument(81TR::Register *argReg,82int32_t offset,83TR::InstOpCode::Mnemonic opCode,84TR::ARM64MemoryArgument &memArg);8586public:8788/**89* @brief Constructor90* @param[in] cg : CodeGenerator91*/92PrivateLinkage(TR::CodeGenerator *cg);9394/**95* @brief Answers linkage properties96* @return linkage properties97*/98virtual TR::ARM64LinkageProperties& getProperties();99100/**101* @brief Gets the RightToLeft flag102* @return RightToLeft flag103*/104virtual uint32_t getRightToLeft();105106/**107* @brief Adjust stack index so that local references are aligned properly108* @param[in/out] stackIndex : index on stack109*/110virtual void alignLocalReferences(uint32_t &stackIndex);111/**112* @brief Maps symbols to locations on stack113* @param[in] method : method for which symbols are mapped on stack114*/115virtual void mapStack(TR::ResolvedMethodSymbol *method);116/**117* @brief Maps an automatic symbol to an index on stack118* @param[in] p : automatic symbol119* @param[in/out] stackIndex : index on stack120*/121virtual void mapSingleAutomatic(TR::AutomaticSymbol *p, uint32_t &stackIndex);122/**123* @brief Maps an automatic symbol to an index on stack124* @param[in] p : automatic symbol125* @param[in] size : size126* @param[in/out] stackIndex : index on stack127*/128virtual void mapSingleAutomatic(TR::AutomaticSymbol *p, uint32_t size, uint32_t &stackIndex);129130/**131* @brief Initializes ARM64 RealRegister linkage132*/133virtual void initARM64RealRegisterLinkage();134135/**136* @brief Calculates the amount of frame space required to save the137* preserved registers in this method.138*139* @param[out] registerSaveDescription : the bitmask of registers to preserve140* @param[out] numGPRsSaved : the number of GPRs saved141*142* @return : number of bytes required to reserve on the frame for143* preserved registers144*/145int32_t calculatePreservedRegisterSaveSize(146uint32_t ®isterSaveDescription,147uint32_t &numGPRsSaved);148149/**150* @brief Copy linkage register indices to parameter symbols151*152* @param[in] method : the resolved method symbol153*/154void setParameterLinkageRegisterIndex(TR::ResolvedMethodSymbol *method);155156/**157* @brief Creates method prologue158* @param[in] cursor : instruction cursor159*/160virtual void createPrologue(TR::Instruction *cursor);161/**162* @brief Creates method epilogue163* @param[in] cursor : instruction cursor164*/165virtual void createEpilogue(TR::Instruction *cursor);166167/**168* @brief Loads all parameters passed on the stack from the interpreter into169* the corresponding JITed method private linkage register.170*171* @param[in] cursor : the TR::Instruction to begin generating172* the load sequence at.173*174* @return : the instruction cursor after the load sequence175*/176virtual TR::Instruction *loadStackParametersToLinkageRegisters(TR::Instruction *cursor);177178/**179* @brief Stores parameters passed in linkage registers to the stack. This method is used only in FSD mode.180*181* @param[in] cursor : the instruction cursor to begin inserting copy instructions182*183* @return The instruction cursor after copies inserted.184*/185virtual TR::Instruction *saveParametersToStack(TR::Instruction *cursor);186187/**188* @brief Builds method arguments189* @param[in] node : caller node190* @param[in] dependencies : register dependency conditions191*/192virtual int32_t buildArgs(193TR::Node *callNode,194TR::RegisterDependencyConditions *dependencies);195196/**197* @brief Builds direct dispatch to method198* @param[in] node : caller node199*/200virtual TR::Register *buildDirectDispatch(TR::Node *callNode);201202/**203* @brief Builds direct call to method204* @param[in] node : caller node205* @param[in] callSymRef : target symbol reference206* @param[in] dependencies : register dependency conditions207* @param[in] pp : linkage properties208* @param[in] argSize : size of arguments209*/210void buildDirectCall(211TR::Node *callNode,212TR::SymbolReference *callSymRef,213TR::RegisterDependencyConditions *dependencies,214const TR::ARM64LinkageProperties &pp,215uint32_t argSize);216217/**218* @brief Builds indirect dispatch to method219* @param[in] node : caller node220*/221virtual TR::Register *buildIndirectDispatch(TR::Node *callNode);222223/**224* @brief Builds virtual dispatch to method225* @param[in] node : caller node226* @param[in] dependencies : register dependency conditions227* @param[in] argSize : size of arguments228*/229virtual void buildVirtualDispatch(230TR::Node *callNode,231TR::RegisterDependencyConditions *dependencies,232uint32_t argSize);233234/**235* @brief J9 private linkage override of OMR function236*/237virtual intptr_t entryPointFromCompiledMethod();238239/**240* @brief J9 private linkage override of OMR function241*/242virtual intptr_t entryPointFromInterpretedMethod();243244/**245* J9 private linkage override of OMR function246*/247virtual void performPostBinaryEncoding();248249/**250* @return Retrieve the interpretedMethodEntryPoint instruction251*/252TR::Instruction *getInterpretedMethodEntryPoint() { return _interpretedMethodEntryPoint; }253254/**255* @brief Sets the interpreted method entry point instruction256* @param[in] ins : interpreted method entry point instruction257*/258void setInterpretedMethodEntryPoint(TR::Instruction *ins) { _interpretedMethodEntryPoint = ins; }259260/**261* @return Retrieve the jittedMethodEntryPoint instruction262*/263TR::Instruction *getJittedMethodEntryPoint() { return _jittedMethodEntryPoint; }264265/**266* @brief Sets the jitted method entry point instruction267* @param[in] ins : jitted method entry point instruction268*/269void setJittedMethodEntryPoint(TR::Instruction *ins) { _jittedMethodEntryPoint = ins; }270271protected:272273/**274* The first TR::Instruction of the method when called from an interpreted method.275*/276TR::Instruction *_interpretedMethodEntryPoint;277278/**279* The first TR::Instruction of the method when called from a jitted method.280*/281TR::Instruction *_jittedMethodEntryPoint;282283private:284285// Tactical GRA286static uint32_t _globalRegisterNumberToRealRegisterMap[];287};288289290class HelperLinkage : public PrivateLinkage291{292public:293294/**295* @brief Constructor296* @param[in] cg : CodeGenerator297* @param[in] helperLinkage : linkage convention298*/299HelperLinkage(TR::CodeGenerator *cg, TR_LinkageConventions helperLinkage) : _helperLinkage(helperLinkage), PrivateLinkage(cg)300{301TR_ASSERT(helperLinkage == TR_Helper || helperLinkage == TR_CHelper, "Unexpected helper linkage convention");302}303304/**305* @brief Builds method arguments for helper call306* @param[in] node : caller node307* @param[in] dependencies : register dependency conditions308* @return total size that arguments occupy on Java stack309*/310virtual int32_t buildArgs(311TR::Node *callNode,312TR::RegisterDependencyConditions *dependencies);313protected:314315TR_LinkageConventions _helperLinkage;316317};318319}320321}322323#endif324325326