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_ARGS_H 17 #define MAPLEBE_INCLUDE_CG_X64_X64_ARGS_H 18 19 #include "args.h" 20 #include "x64_isa.h" 21 #include "x64_cgfunc.h" 22 #include "x64_call_conv.h" 23 24 namespace maplebe { 25 using namespace maple; 26 using namespace x64; 27 struct X64ArgInfo { 28 X64reg reg; 29 MIRType *mirTy; 30 uint32 symSize; 31 uint32 stkSize; 32 RegType regType; 33 MIRSymbol *sym; 34 const X64SymbolAlloc *symLoc; 35 uint8 memPairSecondRegSize; /* struct arg requiring two regs, size of 2nd reg */ 36 bool doMemPairOpt; 37 bool createTwoStores; 38 bool isTwoRegParm; 39 }; 40 41 class X64MoveRegArgs : public MoveRegArgs { 42 public: X64MoveRegArgs(CGFunc & func)43 explicit X64MoveRegArgs(CGFunc &func) : MoveRegArgs(func) {} 44 ~X64MoveRegArgs() override = default; 45 void Run() override; 46 47 private: 48 void CollectRegisterArgs(std::map<uint32, X64reg> &argsList, std::vector<uint32> &indexList, 49 std::map<uint32, X64reg> &pairReg, std::vector<uint32> &numFpRegs, 50 std::vector<uint32> &fpSize) const; 51 X64ArgInfo GetArgInfo(std::map<uint32, X64reg> &argsList, uint32 argIndex, std::vector<uint32> &numFpRegs, 52 std::vector<uint32> &fpSize) const; 53 void GenerateMovInsn(X64ArgInfo &argInfo, X64reg reg2); 54 void MoveRegisterArgs(); 55 void MoveVRegisterArgs(); 56 void LoadStackArgsToVReg(MIRSymbol &mirSym); 57 void MoveArgsToVReg(const CCLocInfo &ploc, MIRSymbol &mirSym); 58 }; 59 } /* namespace maplebe */ 60 61 #endif /* MAPLEBE_INCLUDE_CG_X64_X64_ARGS_H */ 62