2018-02-23 19:06:40 +08:00
|
|
|
//===- MipsCallLowering.h ---------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-02-23 19:06:40 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// This file describes how to lower LLVM calls to machine code calls.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MipsTargetLowering;
|
|
|
|
|
|
|
|
class MipsCallLowering : public CallLowering {
|
|
|
|
|
|
|
|
public:
|
2018-04-11 23:12:32 +08:00
|
|
|
class MipsHandler {
|
|
|
|
public:
|
|
|
|
MipsHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
|
|
|
|
: MIRBuilder(MIRBuilder), MRI(MRI) {}
|
|
|
|
|
|
|
|
virtual ~MipsHandler() = default;
|
|
|
|
|
2018-09-28 21:28:47 +08:00
|
|
|
bool handle(ArrayRef<CCValAssign> ArgLocs,
|
|
|
|
ArrayRef<CallLowering::ArgInfo> Args);
|
|
|
|
|
2018-04-11 23:12:32 +08:00
|
|
|
protected:
|
2019-06-24 23:50:29 +08:00
|
|
|
bool assignVRegs(ArrayRef<Register> VRegs, ArrayRef<CCValAssign> ArgLocs,
|
2019-03-25 19:23:41 +08:00
|
|
|
unsigned ArgLocsStartIndex, const EVT &VT);
|
2018-09-28 21:28:47 +08:00
|
|
|
|
2019-06-24 23:50:29 +08:00
|
|
|
void setLeastSignificantFirst(SmallVectorImpl<Register> &VRegs);
|
2018-04-11 23:12:32 +08:00
|
|
|
|
|
|
|
MachineIRBuilder &MIRBuilder;
|
|
|
|
MachineRegisterInfo &MRI;
|
2018-07-03 17:31:48 +08:00
|
|
|
|
|
|
|
private:
|
2019-06-24 23:50:29 +08:00
|
|
|
bool assign(Register VReg, const CCValAssign &VA, const EVT &VT);
|
2018-09-28 21:28:47 +08:00
|
|
|
|
2019-06-25 00:16:12 +08:00
|
|
|
virtual Register getStackAddress(const CCValAssign &VA,
|
2018-08-24 04:41:09 +08:00
|
|
|
MachineMemOperand *&MMO) = 0;
|
2018-07-03 17:31:48 +08:00
|
|
|
|
2019-06-24 23:50:29 +08:00
|
|
|
virtual void assignValueToReg(Register ValVReg, const CCValAssign &VA,
|
2019-03-25 19:23:41 +08:00
|
|
|
const EVT &VT) = 0;
|
2018-07-03 17:31:48 +08:00
|
|
|
|
2019-06-24 23:50:29 +08:00
|
|
|
virtual void assignValueToAddress(Register ValVReg,
|
2018-08-24 04:41:09 +08:00
|
|
|
const CCValAssign &VA) = 0;
|
2018-09-28 21:28:47 +08:00
|
|
|
|
2019-06-24 23:50:29 +08:00
|
|
|
virtual bool handleSplit(SmallVectorImpl<Register> &VRegs,
|
2018-09-28 21:28:47 +08:00
|
|
|
ArrayRef<CCValAssign> ArgLocs,
|
2019-06-24 23:50:29 +08:00
|
|
|
unsigned ArgLocsStartIndex, Register ArgsReg,
|
2019-03-25 19:23:41 +08:00
|
|
|
const EVT &VT) = 0;
|
2018-04-11 23:12:32 +08:00
|
|
|
};
|
|
|
|
|
2018-02-23 19:06:40 +08:00
|
|
|
MipsCallLowering(const MipsTargetLowering &TLI);
|
|
|
|
|
2018-08-02 16:33:31 +08:00
|
|
|
bool lowerReturn(MachineIRBuilder &MIRBuilder, const Value *Val,
|
2019-06-24 23:50:29 +08:00
|
|
|
ArrayRef<Register> VRegs) const override;
|
2018-02-23 19:06:40 +08:00
|
|
|
|
|
|
|
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
|
2019-06-27 16:54:17 +08:00
|
|
|
ArrayRef<ArrayRef<Register>> VRegs) const override;
|
2018-04-11 23:12:32 +08:00
|
|
|
|
2018-06-06 15:24:52 +08:00
|
|
|
bool lowerCall(MachineIRBuilder &MIRBuilder, CallingConv::ID CallConv,
|
|
|
|
const MachineOperand &Callee, const ArgInfo &OrigRet,
|
[GISel] Pass MD_callees metadata down in call lowering.
Summary:
This will make it possible to improve IPRA by taking into account
register usage in indirect calls.
NFC yet; this is just laying the groundwork to start building
up patches to take advantage of the information for improved register
allocation.
Reviewers: aditya_nandakumar, volkan, qcolombet, arsenm, rovka, aemerson, paquette
Subscribers: sdardis, wdng, javed.absar, hiraditya, jrtc27, atanasyan, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65488
llvm-svn: 367476
2019-08-01 04:34:02 +08:00
|
|
|
ArrayRef<ArgInfo> OrigArgs,
|
2019-08-01 04:34:05 +08:00
|
|
|
const MDNode *KnownCallees = nullptr) const override;
|
2018-06-06 15:24:52 +08:00
|
|
|
|
2018-04-11 23:12:32 +08:00
|
|
|
private:
|
|
|
|
/// Based on registers available on target machine split or extend
|
|
|
|
/// type if needed, also change pointer type to appropriate integer
|
2018-09-28 21:28:47 +08:00
|
|
|
/// type.
|
|
|
|
template <typename T>
|
|
|
|
void subTargetRegTypeForCallingConv(const Function &F, ArrayRef<ArgInfo> Args,
|
2018-04-11 23:12:32 +08:00
|
|
|
ArrayRef<unsigned> OrigArgIndices,
|
2018-09-28 21:28:47 +08:00
|
|
|
SmallVectorImpl<T> &ISDArgs) const;
|
2018-04-11 23:12:32 +08:00
|
|
|
|
|
|
|
/// Split structures and arrays, save original argument indices since
|
2018-10-22 21:27:50 +08:00
|
|
|
/// Mips calling convention needs info about original argument type.
|
2018-04-11 23:12:32 +08:00
|
|
|
void splitToValueTypes(const ArgInfo &OrigArg, unsigned OriginalIndex,
|
|
|
|
SmallVectorImpl<ArgInfo> &SplitArgs,
|
|
|
|
SmallVectorImpl<unsigned> &SplitArgsOrigIndices) const;
|
2018-02-23 19:06:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_MIPS_MIPSCALLLOWERING_H
|