1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MAPLEBE_CG_INCLUDE_CG_STACKMAP_COMPUTATION_H 17 #define MAPLEBE_CG_INCLUDE_CG_STACKMAP_COMPUTATION_H 18 19 #include "cgfunc.h" 20 #include "cg_phase.h" 21 #include "stackmap.h" 22 23 namespace maplebe { 24 class StackmapComputation { 25 public: StackmapComputation(CGFunc & func,MemPool & memPool)26 explicit StackmapComputation(CGFunc &func, MemPool &memPool) 27 : cgFunc(func), 28 alloc(&memPool), 29 derivedRef2Base(alloc.Adapter()), 30 regInfo(func.GetTargetRegInfo()) 31 { 32 regInfo->Init(); 33 } 34 ~StackmapComputation()35 ~StackmapComputation() {}; 36 void run(); 37 void SpillOperand(Insn &insn, regno_t regNO); 38 void SetStackmapDerivedInfo(); 39 void RelocateStackmapInfo(); 40 void CollectReferenceMap(); 41 void CollectDeoptInfo(); 42 void SolveMemOpndDeoptInfo(const MemOperand &memOpnd, DeoptInfo &deoptInfo, int32 deoptVregNO) const; 43 void SolveRegOpndDeoptInfo(const RegOperand ®Opnd, DeoptInfo &deoptInfo, int32 deoptVregNO) const; 44 void LoadOperand(Insn &insn, regno_t); 45 MemOperand *GetSpillMem(uint32 vRegNO, bool isDest, Insn &insn, regno_t regNO, bool &isOutOfRange, uint32 bitSize); 46 PhaseName()47 std::string PhaseName() const 48 { 49 return "stackmapcomputation"; 50 } 51 SetNeedDump(bool dump)52 void SetNeedDump(bool dump) 53 { 54 needDump = dump; 55 } 56 57 protected: 58 CGFunc &cgFunc; 59 MapleAllocator alloc; 60 MapleUnorderedMap<regno_t, RegOperand*> derivedRef2Base; 61 bool needDump = false; 62 RegisterInfo *regInfo = nullptr; 63 }; 64 65 MAPLE_FUNC_PHASE_DECLARE(CgStackmapComputation, maplebe::CGFunc) 66 } // namespace maplebe 67 68 #endif // MAPLEBE_CG_INCLUDE_CG_STACKMAP_COMPUTATION_H 69