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_AARCH64_AARCH64_ARGS_H 17 #define MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_ARGS_H 18 19 #include "args.h" 20 #include "aarch64_cgfunc.h" 21 22 namespace maplebe { 23 using namespace maple; 24 25 struct ArgInfo { 26 AArch64reg reg; 27 MIRType *mirTy; 28 uint32 symSize; 29 uint32 stkSize; 30 RegType regType; 31 MIRSymbol *sym; 32 const AArch64SymbolAlloc *symLoc; 33 uint8 memPairSecondRegSize; /* struct arg requiring two regs, size of 2nd reg */ 34 bool doMemPairOpt; 35 bool createTwoStores; 36 bool isTwoRegParm; 37 }; 38 39 class AArch64MoveRegArgs : public MoveRegArgs { 40 public: AArch64MoveRegArgs(CGFunc & func)41 explicit AArch64MoveRegArgs(CGFunc &func) : MoveRegArgs(func) {} 42 ~AArch64MoveRegArgs() override = default; 43 void Run() override; 44 45 private: 46 RegOperand *baseReg = nullptr; 47 const MemSegment *lastSegment = nullptr; 48 void CollectRegisterArgs(std::map<uint32, AArch64reg> &argsList, std::vector<uint32> &indexList, 49 std::map<uint32, AArch64reg> &pairReg, std::vector<uint32> &numFpRegs, 50 std::vector<uint32> &fpSize) const; 51 ArgInfo GetArgInfo(std::map<uint32, AArch64reg> &argsList, std::vector<uint32> &numFpRegs, 52 std::vector<uint32> &fpSize, uint32 argIndex) const; 53 bool IsInSameSegment(const ArgInfo &firstArgInfo, const ArgInfo &secondArgInfo) const; 54 void GenOneInsn(const ArgInfo &argInfo, RegOperand &baseOpnd, uint32 stBitSize, AArch64reg dest, 55 int32 offset) const; 56 void GenerateStpInsn(const ArgInfo &firstArgInfo, const ArgInfo &secondArgInfo); 57 void GenerateStrInsn(const ArgInfo &argInfo, AArch64reg reg2, uint32 numFpRegs, uint32 fpSize); 58 void MoveRegisterArgs(); 59 void MoveVRegisterArgs(); 60 void MoveLocalRefVarToRefLocals(MIRSymbol &mirSym) const; 61 void LoadStackArgsToVReg(MIRSymbol &mirSym) const; 62 void MoveArgsToVReg(const CCLocInfo &ploc, MIRSymbol &mirSym) const; 63 }; 64 } /* namespace maplebe */ 65 66 #endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_ARGS_H */ 67