2015-07-30 06:32:47 +08:00
|
|
|
//=- AArch64MachineFunctionInfo.h - AArch64 machine function info -*- C++ -*-=//
|
2014-03-29 18:18:08 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2014-05-24 20:50:23 +08:00
|
|
|
// This file declares AArch64-specific per-machine-function information.
|
2014-03-29 18:18:08 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
|
2014-03-29 18:18:08 +08:00
|
|
|
|
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/MC/MCLinkerOptimizationHint.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
/// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
|
|
|
|
/// contains private AArch64-specific information for each MachineFunction.
|
|
|
|
class AArch64FunctionInfo : public MachineFunctionInfo {
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2014-05-15 09:33:17 +08:00
|
|
|
/// Number of bytes of arguments this function has on the stack. If the callee
|
|
|
|
/// is expected to restore the argument stack this should be a multiple of 16,
|
|
|
|
/// all usable during a tail call.
|
|
|
|
///
|
|
|
|
/// The alternative would forbid tail call optimisation in some cases: if we
|
|
|
|
/// want to transfer control from a function with 8-bytes of stack-argument
|
|
|
|
/// space to a function with 16-bytes then misalignment of this value would
|
|
|
|
/// make a stack adjustment necessary, which could not be undone by the
|
|
|
|
/// callee.
|
|
|
|
unsigned BytesInStackArgArea;
|
|
|
|
|
|
|
|
/// The number of bytes to restore to deallocate space for incoming
|
|
|
|
/// arguments. Canonically 0 in the C calling convention, but non-zero when
|
|
|
|
/// callee is expected to pop the args.
|
|
|
|
unsigned ArgumentStackToRestore;
|
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
/// HasStackFrame - True if this function has a stack frame. Set by
|
2015-07-15 07:06:07 +08:00
|
|
|
/// determineCalleeSaves().
|
2014-03-29 18:18:08 +08:00
|
|
|
bool HasStackFrame;
|
|
|
|
|
|
|
|
/// \brief Amount of stack frame size, not including callee-saved registers.
|
|
|
|
unsigned LocalStackSize;
|
|
|
|
|
2016-02-02 00:29:19 +08:00
|
|
|
/// \brief Amount of stack frame size used for saving callee-saved registers.
|
|
|
|
unsigned CalleeSavedStackSize;
|
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
/// \brief Number of TLS accesses using the special (combinable)
|
|
|
|
/// _TLS_MODULE_BASE_ symbol.
|
|
|
|
unsigned NumLocalDynamicTLSAccesses;
|
|
|
|
|
|
|
|
/// \brief FrameIndex for start of varargs area for arguments passed on the
|
|
|
|
/// stack.
|
|
|
|
int VarArgsStackIndex;
|
|
|
|
|
|
|
|
/// \brief FrameIndex for start of varargs area for arguments passed in
|
|
|
|
/// general purpose registers.
|
|
|
|
int VarArgsGPRIndex;
|
|
|
|
|
|
|
|
/// \brief Size of the varargs area for arguments passed in general purpose
|
|
|
|
/// registers.
|
|
|
|
unsigned VarArgsGPRSize;
|
|
|
|
|
|
|
|
/// \brief FrameIndex for start of varargs area for arguments passed in
|
|
|
|
/// floating-point registers.
|
|
|
|
int VarArgsFPRIndex;
|
|
|
|
|
|
|
|
/// \brief Size of the varargs area for arguments passed in floating-point
|
|
|
|
/// registers.
|
|
|
|
unsigned VarArgsFPRSize;
|
|
|
|
|
2015-12-17 05:04:19 +08:00
|
|
|
/// True if this function has a subset of CSRs that is handled explicitly via
|
|
|
|
/// copies.
|
|
|
|
bool IsSplitCSR;
|
|
|
|
|
2016-03-15 02:17:41 +08:00
|
|
|
/// True when the stack gets realigned dynamically because the size of stack
|
|
|
|
/// frame is unknown at compile time. e.g., in case of VLAs.
|
|
|
|
bool StackRealigned;
|
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
public:
|
2014-05-24 20:50:23 +08:00
|
|
|
AArch64FunctionInfo()
|
2014-05-15 09:33:17 +08:00
|
|
|
: BytesInStackArgArea(0), ArgumentStackToRestore(0), HasStackFrame(false),
|
|
|
|
NumLocalDynamicTLSAccesses(0), VarArgsStackIndex(0), VarArgsGPRIndex(0),
|
2015-12-17 05:04:19 +08:00
|
|
|
VarArgsGPRSize(0), VarArgsFPRIndex(0), VarArgsFPRSize(0),
|
2016-03-15 02:17:41 +08:00
|
|
|
IsSplitCSR(false), StackRealigned(false) {}
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
explicit AArch64FunctionInfo(MachineFunction &MF)
|
2014-05-15 09:33:17 +08:00
|
|
|
: BytesInStackArgArea(0), ArgumentStackToRestore(0), HasStackFrame(false),
|
|
|
|
NumLocalDynamicTLSAccesses(0), VarArgsStackIndex(0), VarArgsGPRIndex(0),
|
2015-12-17 05:04:19 +08:00
|
|
|
VarArgsGPRSize(0), VarArgsFPRIndex(0), VarArgsFPRSize(0),
|
2016-03-15 02:17:41 +08:00
|
|
|
IsSplitCSR(false), StackRealigned(false) {
|
2014-03-29 18:18:08 +08:00
|
|
|
(void)MF;
|
|
|
|
}
|
|
|
|
|
2014-05-15 09:33:17 +08:00
|
|
|
unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
|
|
|
|
void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
|
|
|
|
|
|
|
|
unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
|
|
|
|
void setArgumentStackToRestore(unsigned bytes) {
|
|
|
|
ArgumentStackToRestore = bytes;
|
|
|
|
}
|
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
bool hasStackFrame() const { return HasStackFrame; }
|
|
|
|
void setHasStackFrame(bool s) { HasStackFrame = s; }
|
|
|
|
|
2016-03-15 02:17:41 +08:00
|
|
|
bool isStackRealigned() const { return StackRealigned; }
|
|
|
|
void setStackRealigned(bool s) { StackRealigned = s; }
|
|
|
|
|
2015-12-17 05:04:19 +08:00
|
|
|
bool isSplitCSR() const { return IsSplitCSR; }
|
|
|
|
void setIsSplitCSR(bool s) { IsSplitCSR = s; }
|
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
|
|
|
|
unsigned getLocalStackSize() const { return LocalStackSize; }
|
|
|
|
|
2016-02-02 00:29:19 +08:00
|
|
|
void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
|
|
|
|
unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
|
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
|
|
|
|
unsigned getNumLocalDynamicTLSAccesses() const {
|
|
|
|
return NumLocalDynamicTLSAccesses;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getVarArgsStackIndex() const { return VarArgsStackIndex; }
|
|
|
|
void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
|
|
|
|
|
|
|
|
int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
|
|
|
|
void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
|
|
|
|
|
|
|
|
unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
|
|
|
|
void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
|
|
|
|
|
|
|
|
int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
|
|
|
|
void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
|
|
|
|
|
|
|
|
unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
|
|
|
|
void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
|
|
|
|
|
|
|
|
typedef SmallPtrSet<const MachineInstr *, 16> SetOfInstructions;
|
|
|
|
|
|
|
|
const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
|
|
|
|
|
|
|
|
// Shortcuts for LOH related types.
|
2014-03-30 03:21:20 +08:00
|
|
|
class MILOHDirective {
|
|
|
|
MCLOHType Kind;
|
|
|
|
|
|
|
|
/// Arguments of this directive. Order matters.
|
|
|
|
SmallVector<const MachineInstr *, 3> Args;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef SmallVectorImpl<const MachineInstr *> LOHArgs;
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2014-03-30 03:21:20 +08:00
|
|
|
MILOHDirective(MCLOHType Kind, const LOHArgs &Args)
|
|
|
|
: Kind(Kind), Args(Args.begin(), Args.end()) {
|
|
|
|
assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
|
|
|
|
}
|
|
|
|
|
|
|
|
MCLOHType getKind() const { return Kind; }
|
|
|
|
const LOHArgs &getArgs() const { return Args; }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef MILOHDirective::LOHArgs MILOHArgs;
|
|
|
|
typedef SmallVector<MILOHDirective, 32> MILOHContainer;
|
2014-03-29 18:18:08 +08:00
|
|
|
|
|
|
|
const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
|
|
|
|
|
|
|
|
/// Add a LOH directive of this @p Kind and this @p Args.
|
|
|
|
void addLOHDirective(MCLOHType Kind, const MILOHArgs &Args) {
|
2014-03-30 03:21:20 +08:00
|
|
|
LOHContainerSet.push_back(MILOHDirective(Kind, Args));
|
|
|
|
LOHRelated.insert(Args.begin(), Args.end());
|
2014-03-29 18:18:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Hold the lists of LOHs.
|
|
|
|
MILOHContainer LOHContainerSet;
|
|
|
|
SetOfInstructions LOHRelated;
|
|
|
|
};
|
2015-06-23 17:49:53 +08:00
|
|
|
} // End llvm namespace
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|