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_INCLUDE_CG_X64_X64_PROEPILOG_H 17 #define MAPLEBE_INCLUDE_CG_X64_X64_PROEPILOG_H 18 19 #include "proepilog.h" 20 #include "x64_cgfunc.h" 21 22 namespace maplebe { 23 using namespace maple; 24 25 class X64GenProEpilog : public GenProEpilog { 26 public: X64GenProEpilog(CGFunc & func)27 explicit X64GenProEpilog(CGFunc &func) : GenProEpilog(func) {} 28 ~X64GenProEpilog() override = default; 29 30 bool TailCallOpt() override; 31 bool NeedProEpilog() override; 32 void Run() override; 33 34 private: 35 void GenerateProlog(BB &bb); 36 void GenerateEpilog(BB &bb); 37 void GenerateCalleeSavedRegs(bool isPush); 38 void GeneratePushCalleeSavedRegs(RegOperand ®Opnd, MemOperand &memOpnd, uint32 regSize); 39 void GeneratePopCalleeSavedRegs(RegOperand ®Opnd, MemOperand &memOpnd, uint32 regSize); 40 void GeneratePushUnnamedVarargRegs(); 41 void GeneratePushRbpInsn(); 42 void GenerateMovRspToRbpInsn(); 43 void GenerateSubFrameSizeFromRspInsn(); 44 void GenerateAddFrameSizeToRspInsn(); 45 void GeneratePopInsn(); 46 void GenerateRetInsn(); 47 }; 48 } /* namespace maplebe */ 49 50 #endif /* MAPLEBE_INCLUDE_CG_X64_X64_PROEPILOG_H */ 51