1 //===- MipsCallLowering.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file describes how to lower LLVM calls to machine code calls.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
16 #define LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
18 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
22 class MipsTargetLowering;
24 class MipsCallLowering : public CallLowering {
29 MipsHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
30 : MIRBuilder(MIRBuilder), MRI(MRI) {}
32 virtual ~MipsHandler() = default;
34 bool handle(ArrayRef<CCValAssign> ArgLocs,
35 ArrayRef<CallLowering::ArgInfo> Args);
38 bool assignVRegs(ArrayRef<unsigned> VRegs, ArrayRef<CCValAssign> ArgLocs,
41 void setLeastSignificantFirst(SmallVectorImpl<unsigned> &VRegs);
43 MachineIRBuilder &MIRBuilder;
44 MachineRegisterInfo &MRI;
47 bool assign(unsigned VReg, const CCValAssign &VA);
49 virtual unsigned getStackAddress(const CCValAssign &VA,
50 MachineMemOperand *&MMO) = 0;
52 virtual void assignValueToReg(unsigned ValVReg, const CCValAssign &VA) = 0;
54 virtual void assignValueToAddress(unsigned ValVReg,
55 const CCValAssign &VA) = 0;
57 virtual bool handleSplit(SmallVectorImpl<unsigned> &VRegs,
58 ArrayRef<CCValAssign> ArgLocs,
59 unsigned ArgLocsStartIndex, unsigned ArgsReg) = 0;
62 MipsCallLowering(const MipsTargetLowering &TLI);
64 bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
65 ArrayRef<unsigned> VRegs) const override;
67 bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
68 ArrayRef<unsigned> VRegs) const override;
70 bool lowerCall(MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv,
71 const MachineOperand &Callee, const ArgInfo &OrigRet,
72 ArrayRef<ArgInfo> OrigArgs) const override;
75 /// Based on registers available on target machine split or extend
76 /// type if needed, also change pointer type to appropriate integer
79 void subTargetRegTypeForCallingConv(const Function &F, ArrayRef<ArgInfo> Args,
80 ArrayRef<unsigned> OrigArgIndices,
81 SmallVectorImpl<T> &ISDArgs) const;
83 /// Split structures and arrays, save original argument indices since
84 /// Mips calling convention needs info about original argument type.
85 void splitToValueTypes(const ArgInfo &OrigArg, unsigned OriginalIndex,
86 SmallVectorImpl<ArgInfo> &SplitArgs,
87 SmallVectorImpl<unsigned> &SplitArgsOrigIndices) const;
90 } // end namespace llvm
92 #endif // LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H