Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / Target / Mips / MipsCallLowering.h
blobdc04d83733e7c400c7c24a6820de402c6705ed93
1 //===- MipsCallLowering.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// This file describes how to lower LLVM calls to machine code calls.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
15 #define LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
17 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
19 namespace llvm {
21 class MipsTargetLowering;
23 class MipsCallLowering : public CallLowering {
25 public:
26 class MipsHandler {
27 public:
28 MipsHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
29 : MIRBuilder(MIRBuilder), MRI(MRI) {}
31 virtual ~MipsHandler() = default;
33 bool handle(ArrayRef<CCValAssign> ArgLocs,
34 ArrayRef<CallLowering::ArgInfo> Args);
36 protected:
37 bool assignVRegs(ArrayRef<unsigned> VRegs, ArrayRef<CCValAssign> ArgLocs,
38 unsigned Index);
40 void setLeastSignificantFirst(SmallVectorImpl<unsigned> &VRegs);
42 MachineIRBuilder &MIRBuilder;
43 MachineRegisterInfo &MRI;
45 private:
46 bool assign(unsigned VReg, const CCValAssign &VA);
48 virtual unsigned getStackAddress(const CCValAssign &VA,
49 MachineMemOperand *&MMO) = 0;
51 virtual void assignValueToReg(unsigned ValVReg, const CCValAssign &VA) = 0;
53 virtual void assignValueToAddress(unsigned ValVReg,
54 const CCValAssign &VA) = 0;
56 virtual bool handleSplit(SmallVectorImpl<unsigned> &VRegs,
57 ArrayRef<CCValAssign> ArgLocs,
58 unsigned ArgLocsStartIndex, unsigned ArgsReg) = 0;
61 MipsCallLowering(const MipsTargetLowering &TLI);
63 bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
64 ArrayRef<unsigned> VRegs) const override;
66 bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
67 ArrayRef<unsigned> VRegs) const override;
69 bool lowerCall(MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv,
70 const MachineOperand &Callee, const ArgInfo &OrigRet,
71 ArrayRef<ArgInfo> OrigArgs) const override;
73 private:
74 /// Based on registers available on target machine split or extend
75 /// type if needed, also change pointer type to appropriate integer
76 /// type.
77 template <typename T>
78 void subTargetRegTypeForCallingConv(const Function &F, ArrayRef<ArgInfo> Args,
79 ArrayRef<unsigned> OrigArgIndices,
80 SmallVectorImpl<T> &ISDArgs) const;
82 /// Split structures and arrays, save original argument indices since
83 /// Mips calling convention needs info about original argument type.
84 void splitToValueTypes(const ArgInfo &OrigArg, unsigned OriginalIndex,
85 SmallVectorImpl<ArgInfo> &SplitArgs,
86 SmallVectorImpl<unsigned> &SplitArgsOrigIndices) const;
89 } // end namespace llvm
91 #endif // LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H