2016-02-17 03:26:02 +08:00
|
|
|
//===-- llvm/lib/Target/AArch64/AArch64CallLowering.h - Call lowering -----===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// This file describes how to lower LLVM calls to machine code calls.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING
|
|
|
|
#define LLVM_LIB_TARGET_AARCH64_AARCH64CALLLOWERING
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
|
2016-08-11 05:44:01 +08:00
|
|
|
#include "llvm/CodeGen/CallingConvLower.h"
|
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
2016-02-17 03:26:02 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class AArch64TargetLowering;
|
2016-04-15 01:23:33 +08:00
|
|
|
|
2016-02-17 03:26:02 +08:00
|
|
|
class AArch64CallLowering: public CallLowering {
|
|
|
|
public:
|
2016-09-22 21:49:25 +08:00
|
|
|
|
|
|
|
/// Argument handling is mostly uniform between the four places that
|
|
|
|
/// make these decisions: function formal arguments, call
|
|
|
|
/// instruction args, call instruction returns and function
|
|
|
|
/// returns. However, once a decision has been made on where an
|
|
|
|
/// arugment should go, exactly what happens can vary slightly. This
|
|
|
|
/// class abstracts the differences.
|
|
|
|
struct ValueHandler {
|
|
|
|
/// Materialize a VReg containing the address of the specified
|
|
|
|
/// stack-based object. This is either based on a FrameIndex or
|
|
|
|
/// direct SP manipulation, depending on the context. \p MPO
|
|
|
|
/// should be initialized to an appropriate description of the
|
|
|
|
/// address created.
|
|
|
|
virtual unsigned getStackAddress(uint64_t Size, int64_t Offset,
|
|
|
|
MachinePointerInfo &MPO) = 0;
|
|
|
|
|
|
|
|
/// The specified value has been assigned to a physical register,
|
|
|
|
/// handle the appropriate COPY (either to or from) and mark any
|
|
|
|
/// relevant uses/defines as needed.
|
|
|
|
virtual void assignValueToReg(unsigned ValVReg, unsigned PhysReg,
|
|
|
|
CCValAssign &VA) = 0;
|
|
|
|
|
|
|
|
/// The specified value has been assigned to a stack
|
|
|
|
/// location. Load or store it there, with appropriate extension
|
|
|
|
/// if necessary.
|
|
|
|
virtual void assignValueToAddress(unsigned ValVReg, unsigned Addr,
|
|
|
|
uint64_t Size, MachinePointerInfo &MPO,
|
|
|
|
CCValAssign &VA) = 0;
|
|
|
|
|
|
|
|
unsigned extendRegister(unsigned ValReg, CCValAssign &VA);
|
|
|
|
|
|
|
|
ValueHandler(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI)
|
|
|
|
: MIRBuilder(MIRBuilder), MRI(MRI) {}
|
|
|
|
|
|
|
|
virtual ~ValueHandler() {}
|
|
|
|
|
|
|
|
MachineIRBuilder &MIRBuilder;
|
|
|
|
MachineRegisterInfo &MRI;
|
|
|
|
};
|
|
|
|
|
2016-02-17 03:26:02 +08:00
|
|
|
AArch64CallLowering(const AArch64TargetLowering &TLI);
|
2016-04-15 01:23:33 +08:00
|
|
|
|
|
|
|
bool lowerReturn(MachineIRBuilder &MIRBuiler, const Value *Val,
|
2016-02-17 03:26:02 +08:00
|
|
|
unsigned VReg) const override;
|
2016-08-11 05:44:01 +08:00
|
|
|
|
2016-09-21 20:57:35 +08:00
|
|
|
bool lowerFormalArguments(MachineIRBuilder &MIRBuilder, const Function &F,
|
2016-08-11 05:44:01 +08:00
|
|
|
ArrayRef<unsigned> VRegs) const override;
|
|
|
|
|
2016-08-30 03:07:16 +08:00
|
|
|
bool lowerCall(MachineIRBuilder &MIRBuilder, const MachineOperand &Callee,
|
2016-09-21 20:57:45 +08:00
|
|
|
const ArgInfo &OrigRet,
|
|
|
|
ArrayRef<ArgInfo> OrigArgs) const override;
|
2016-08-11 05:44:01 +08:00
|
|
|
|
|
|
|
private:
|
2016-09-21 20:57:45 +08:00
|
|
|
typedef std::function<void(MachineIRBuilder &, Type *, unsigned,
|
|
|
|
CCValAssign &)>
|
2016-09-22 21:49:25 +08:00
|
|
|
RegHandler;
|
|
|
|
|
|
|
|
typedef std::function<void(MachineIRBuilder &, int, CCValAssign &)>
|
|
|
|
MemHandler;
|
2016-08-11 05:44:01 +08:00
|
|
|
|
2016-09-20 23:20:36 +08:00
|
|
|
typedef std::function<void(ArrayRef<unsigned>, ArrayRef<uint64_t>)>
|
|
|
|
SplitArgTy;
|
|
|
|
|
2016-09-21 20:57:45 +08:00
|
|
|
void splitToValueTypes(const ArgInfo &OrigArgInfo,
|
|
|
|
SmallVectorImpl<ArgInfo> &SplitArgs,
|
2016-09-20 23:20:36 +08:00
|
|
|
const DataLayout &DL, MachineRegisterInfo &MRI,
|
|
|
|
SplitArgTy SplitArg) const;
|
|
|
|
|
2016-08-11 05:44:01 +08:00
|
|
|
bool handleAssignments(MachineIRBuilder &MIRBuilder, CCAssignFn *AssignFn,
|
2016-09-21 20:57:45 +08:00
|
|
|
ArrayRef<ArgInfo> Args,
|
2016-09-22 21:49:25 +08:00
|
|
|
ValueHandler &Callback) const;
|
2016-02-17 03:26:02 +08:00
|
|
|
};
|
|
|
|
} // End of namespace llvm;
|
|
|
|
#endif
|