[MIPS GlobalISel] Set operand order for G_MERGE and G_UNMERGE
[llvm-complete.git] / lib / Target / Mips / MipsCallLowering.h
blob9916b04ef50ca25d3ed66b1d2d2f11e6e9621e62
1 //===- MipsCallLowering.h ---------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
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"
20 namespace llvm {
22 class MipsTargetLowering;
24 class MipsCallLowering : public CallLowering {
26 public:
27 class MipsHandler {
28 public:
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);
37 protected:
38 bool assignVRegs(ArrayRef<unsigned> VRegs, ArrayRef<CCValAssign> ArgLocs,
39 unsigned Index);
41 void setLeastSignificantFirst(SmallVectorImpl<unsigned> &VRegs);
43 MachineIRBuilder &MIRBuilder;
44 MachineRegisterInfo &MRI;
46 private:
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;
74 private:
75 /// Based on registers available on target machine split or extend
76 /// type if needed, also change pointer type to appropriate integer
77 /// type.
78 template <typename T>
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