2006-11-17 06:43:37 +08:00
|
|
|
//===-- PPCMachineFunctionInfo.h - Private data used for PowerPC --*- 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
|
2006-11-17 06:43:37 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the PowerPC specific subclass of MachineFunctionInfo.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
|
2006-11-17 06:43:37 +08:00
|
|
|
|
2017-01-13 08:58:58 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2006-11-17 06:43:37 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetCallingConv.h"
|
2006-11-17 06:43:37 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
/// PPCFunctionInfo - This class is derived from MachineFunction private
|
|
|
|
/// PowerPC target-specific information for each MachineFunction.
|
|
|
|
class PPCFunctionInfo : public MachineFunctionInfo {
|
2011-12-20 10:50:00 +08:00
|
|
|
virtual void anchor();
|
|
|
|
|
2006-11-17 06:43:37 +08:00
|
|
|
/// FramePointerSaveIndex - Frame index of where the old frame pointer is
|
|
|
|
/// stored. Also used as an anchor for instructions that need to be altered
|
|
|
|
/// when using frame pointers (dyna_add, dyna_sub.)
|
2017-01-13 08:58:58 +08:00
|
|
|
int FramePointerSaveIndex = 0;
|
2018-07-31 03:41:25 +08:00
|
|
|
|
2007-12-08 14:59:59 +08:00
|
|
|
/// ReturnAddrSaveIndex - Frame index of where the return address is stored.
|
2007-02-27 19:55:45 +08:00
|
|
|
///
|
2017-01-13 08:58:58 +08:00
|
|
|
int ReturnAddrSaveIndex = 0;
|
2007-12-08 14:59:59 +08:00
|
|
|
|
2013-07-17 08:45:52 +08:00
|
|
|
/// Frame index where the old base pointer is stored.
|
2017-01-13 08:58:58 +08:00
|
|
|
int BasePointerSaveIndex = 0;
|
2013-07-17 08:45:52 +08:00
|
|
|
|
2015-01-10 09:57:21 +08:00
|
|
|
/// Frame index where the old PIC base pointer is stored.
|
2017-01-13 08:58:58 +08:00
|
|
|
int PICBasePointerSaveIndex = 0;
|
2015-01-10 09:57:21 +08:00
|
|
|
|
2008-10-25 05:24:23 +08:00
|
|
|
/// MustSaveLR - Indicates whether LR is defined (or clobbered) in the current
|
|
|
|
/// function. This is only valid after the initial scan of the function by
|
|
|
|
/// PEI.
|
|
|
|
bool MustSaveLR;
|
2006-11-17 06:43:37 +08:00
|
|
|
|
2019-07-06 02:38:09 +08:00
|
|
|
/// MustSaveTOC - Indicates that the TOC save needs to be performed in the
|
|
|
|
/// prologue of the function. This is typically the case when there are
|
|
|
|
/// indirect calls in the function and it is more profitable to save the
|
|
|
|
/// TOC pointer in the prologue than in the block(s) containing the call(s).
|
|
|
|
bool MustSaveTOC = false;
|
|
|
|
|
2018-02-24 07:08:34 +08:00
|
|
|
/// Do we have to disable shrink-wrapping? This has to be set if we emit any
|
|
|
|
/// instructions that clobber LR in the entry block because discovering this
|
|
|
|
/// in PEI is too late (happens after shrink-wrapping);
|
|
|
|
bool ShrinkWrapDisabled = false;
|
|
|
|
|
2013-03-15 13:06:04 +08:00
|
|
|
/// Does this function have any stack spills.
|
2017-01-13 08:58:58 +08:00
|
|
|
bool HasSpills = false;
|
2013-03-15 13:06:04 +08:00
|
|
|
|
2013-03-17 12:43:44 +08:00
|
|
|
/// Does this function spill using instructions with only r+r (not r+i)
|
|
|
|
/// forms.
|
2017-01-13 08:58:58 +08:00
|
|
|
bool HasNonRISpills = false;
|
2013-03-17 12:43:44 +08:00
|
|
|
|
2008-03-04 06:19:16 +08:00
|
|
|
/// SpillsCR - Indicates whether CR is spilled in the current function.
|
2017-01-13 08:58:58 +08:00
|
|
|
bool SpillsCR = false;
|
2008-03-04 06:19:16 +08:00
|
|
|
|
2013-03-24 06:06:03 +08:00
|
|
|
/// Indicates whether VRSAVE is spilled in the current function.
|
2017-01-13 08:58:58 +08:00
|
|
|
bool SpillsVRSAVE = false;
|
2013-03-24 06:06:03 +08:00
|
|
|
|
2007-12-08 14:59:59 +08:00
|
|
|
/// LRStoreRequired - The bool indicates whether there is some explicit use of
|
|
|
|
/// the LR/LR8 stack slot that is not obvious from scanning the code. This
|
|
|
|
/// requires that the code generator produce a store of LR to the stack on
|
|
|
|
/// entry, even though LR may otherwise apparently not be used.
|
2017-01-13 08:58:58 +08:00
|
|
|
bool LRStoreRequired = false;
|
2008-04-30 17:16:33 +08:00
|
|
|
|
[PowerPC] Make r2 allocatable on PPC64/ELF for some leaf functions
The TOC base pointer is passed in r2, and we normally reserve this register so
that we can depend on it being there. However, for leaf functions, and
specifically those leaf functions that don't do any TOC access of their own
(which is generally due to accessing the constant pool, using TLS, etc.),
we can treat r2 as an ordinary callee-saved register (it must be callee-saved
because, for local direct calls, the linker will not insert any save/restore
code).
The allocation order has been changed slightly for PPC64/ELF systems to put r2
at the end of the list (while leaving it near the beginning for Darwin systems
to prevent unnecessary output changes). While r2 is allocatable, using it still
requires spill/restore traffic, and thus comes at the end of the list.
llvm-svn: 227745
2015-02-01 23:03:28 +08:00
|
|
|
/// This function makes use of the PPC64 ELF TOC base pointer (register r2).
|
2017-01-13 08:58:58 +08:00
|
|
|
bool UsesTOCBasePtr = false;
|
[PowerPC] Make r2 allocatable on PPC64/ELF for some leaf functions
The TOC base pointer is passed in r2, and we normally reserve this register so
that we can depend on it being there. However, for leaf functions, and
specifically those leaf functions that don't do any TOC access of their own
(which is generally due to accessing the constant pool, using TLS, etc.),
we can treat r2 as an ordinary callee-saved register (it must be callee-saved
because, for local direct calls, the linker will not insert any save/restore
code).
The allocation order has been changed slightly for PPC64/ELF systems to put r2
at the end of the list (while leaving it near the beginning for Darwin systems
to prevent unnecessary output changes). While r2 is allocatable, using it still
requires spill/restore traffic, and thus comes at the end of the list.
llvm-svn: 227745
2015-02-01 23:03:28 +08:00
|
|
|
|
2008-04-30 17:16:33 +08:00
|
|
|
/// MinReservedArea - This is the frame size that is at least reserved in a
|
|
|
|
/// potential caller (parameter+linkage area).
|
2017-01-13 08:58:58 +08:00
|
|
|
unsigned MinReservedArea = 0;
|
2008-04-30 17:16:33 +08:00
|
|
|
|
|
|
|
/// TailCallSPDelta - Stack pointer delta used when tail calling. Maximum
|
|
|
|
/// amount the stack pointer is adjusted to make the frame bigger for tail
|
|
|
|
/// calls. Used for creating an area before the register spill area.
|
2017-01-13 08:58:58 +08:00
|
|
|
int TailCallSPDelta = 0;
|
2008-04-30 17:16:33 +08:00
|
|
|
|
|
|
|
/// HasFastCall - Does this function contain a fast call. Used to determine
|
|
|
|
/// how the caller's stack pointer should be calculated (epilog/dynamicalloc).
|
2017-01-13 08:58:58 +08:00
|
|
|
bool HasFastCall = false;
|
2008-04-30 17:16:33 +08:00
|
|
|
|
2010-04-17 22:41:14 +08:00
|
|
|
/// VarArgsFrameIndex - FrameIndex for start of varargs area.
|
2017-01-13 08:58:58 +08:00
|
|
|
int VarArgsFrameIndex = 0;
|
|
|
|
|
2010-04-17 22:41:14 +08:00
|
|
|
/// VarArgsStackOffset - StackOffset for start of stack
|
|
|
|
/// arguments.
|
2017-01-13 08:58:58 +08:00
|
|
|
|
|
|
|
int VarArgsStackOffset = 0;
|
|
|
|
|
2010-04-17 22:41:14 +08:00
|
|
|
/// VarArgsNumGPR - Index of the first unused integer
|
|
|
|
/// register for parameter passing.
|
2017-01-13 08:58:58 +08:00
|
|
|
unsigned VarArgsNumGPR = 0;
|
|
|
|
|
2010-04-17 22:41:14 +08:00
|
|
|
/// VarArgsNumFPR - Index of the first unused double
|
|
|
|
/// register for parameter passing.
|
2017-01-13 08:58:58 +08:00
|
|
|
unsigned VarArgsNumFPR = 0;
|
2010-04-17 22:41:14 +08:00
|
|
|
|
2013-02-25 01:34:50 +08:00
|
|
|
/// CRSpillFrameIndex - FrameIndex for CR spill slot for 32-bit SVR4.
|
2017-01-13 08:58:58 +08:00
|
|
|
int CRSpillFrameIndex = 0;
|
2013-02-25 01:34:50 +08:00
|
|
|
|
2013-04-15 10:07:05 +08:00
|
|
|
/// If any of CR[2-4] need to be saved in the prologue and restored in the
|
|
|
|
/// epilogue then they are added to this array. This is used for the
|
|
|
|
/// 64-bit SVR4 ABI.
|
|
|
|
SmallVector<unsigned, 3> MustSaveCRs;
|
|
|
|
|
2014-07-19 07:29:49 +08:00
|
|
|
/// Hold onto our MachineFunction context.
|
|
|
|
MachineFunction &MF;
|
|
|
|
|
|
|
|
/// Whether this uses the PIC Base register or not.
|
2017-01-13 08:58:58 +08:00
|
|
|
bool UsesPICBase = false;
|
2014-07-19 07:29:49 +08:00
|
|
|
|
2016-04-08 20:04:32 +08:00
|
|
|
/// True if this function has a subset of CSRs that is handled explicitly via
|
|
|
|
/// copies
|
2017-01-13 08:58:58 +08:00
|
|
|
bool IsSplitCSR = false;
|
2016-04-08 20:04:32 +08:00
|
|
|
|
2017-10-16 12:12:57 +08:00
|
|
|
/// We keep track attributes for each live-in virtual registers
|
|
|
|
/// to use SExt/ZExt flags in later optimization.
|
|
|
|
std::vector<std::pair<unsigned, ISD::ArgFlagsTy>> LiveInAttrs;
|
|
|
|
|
2006-11-17 06:43:37 +08:00
|
|
|
public:
|
2017-01-13 08:58:58 +08:00
|
|
|
explicit PPCFunctionInfo(MachineFunction &MF) : MF(MF) {}
|
2006-11-17 06:43:37 +08:00
|
|
|
|
|
|
|
int getFramePointerSaveIndex() const { return FramePointerSaveIndex; }
|
|
|
|
void setFramePointerSaveIndex(int Idx) { FramePointerSaveIndex = Idx; }
|
2018-07-31 03:41:25 +08:00
|
|
|
|
2007-12-08 14:59:59 +08:00
|
|
|
int getReturnAddrSaveIndex() const { return ReturnAddrSaveIndex; }
|
|
|
|
void setReturnAddrSaveIndex(int idx) { ReturnAddrSaveIndex = idx; }
|
2008-04-30 17:16:33 +08:00
|
|
|
|
2013-07-17 08:45:52 +08:00
|
|
|
int getBasePointerSaveIndex() const { return BasePointerSaveIndex; }
|
|
|
|
void setBasePointerSaveIndex(int Idx) { BasePointerSaveIndex = Idx; }
|
|
|
|
|
2015-01-10 09:57:21 +08:00
|
|
|
int getPICBasePointerSaveIndex() const { return PICBasePointerSaveIndex; }
|
|
|
|
void setPICBasePointerSaveIndex(int Idx) { PICBasePointerSaveIndex = Idx; }
|
|
|
|
|
2008-04-30 17:16:33 +08:00
|
|
|
unsigned getMinReservedArea() const { return MinReservedArea; }
|
|
|
|
void setMinReservedArea(unsigned size) { MinReservedArea = size; }
|
|
|
|
|
|
|
|
int getTailCallSPDelta() const { return TailCallSPDelta; }
|
|
|
|
void setTailCallSPDelta(int size) { TailCallSPDelta = size; }
|
|
|
|
|
2008-10-25 05:24:23 +08:00
|
|
|
/// MustSaveLR - This is set when the prolog/epilog inserter does its initial
|
|
|
|
/// scan of the function. It is true if the LR/LR8 register is ever explicitly
|
|
|
|
/// defined/clobbered in the machine function (e.g. by calls and movpctolr,
|
|
|
|
/// which is used in PIC generation), or if the LR stack slot is explicitly
|
|
|
|
/// referenced by builtin_return_address.
|
|
|
|
void setMustSaveLR(bool U) { MustSaveLR = U; }
|
|
|
|
bool mustSaveLR() const { return MustSaveLR; }
|
2006-11-17 06:43:37 +08:00
|
|
|
|
2019-07-06 02:38:09 +08:00
|
|
|
void setMustSaveTOC(bool U) { MustSaveTOC = U; }
|
|
|
|
bool mustSaveTOC() const { return MustSaveTOC; }
|
|
|
|
|
2018-02-24 07:08:34 +08:00
|
|
|
/// We certainly don't want to shrink wrap functions if we've emitted a
|
|
|
|
/// MovePCtoLR8 as that has to go into the entry, so the prologue definitely
|
|
|
|
/// has to go into the entry block.
|
|
|
|
void setShrinkWrapDisabled(bool U) { ShrinkWrapDisabled = U; }
|
|
|
|
bool shrinkWrapDisabled() const { return ShrinkWrapDisabled; }
|
|
|
|
|
2013-03-15 13:06:04 +08:00
|
|
|
void setHasSpills() { HasSpills = true; }
|
|
|
|
bool hasSpills() const { return HasSpills; }
|
2013-03-17 12:43:44 +08:00
|
|
|
|
|
|
|
void setHasNonRISpills() { HasNonRISpills = true; }
|
|
|
|
bool hasNonRISpills() const { return HasNonRISpills; }
|
2013-03-15 13:06:04 +08:00
|
|
|
|
2008-03-04 06:19:16 +08:00
|
|
|
void setSpillsCR() { SpillsCR = true; }
|
|
|
|
bool isCRSpilled() const { return SpillsCR; }
|
|
|
|
|
2013-03-24 06:06:03 +08:00
|
|
|
void setSpillsVRSAVE() { SpillsVRSAVE = true; }
|
|
|
|
bool isVRSAVESpilled() const { return SpillsVRSAVE; }
|
|
|
|
|
2007-12-08 14:59:59 +08:00
|
|
|
void setLRStoreRequired() { LRStoreRequired = true; }
|
|
|
|
bool isLRStoreRequired() const { return LRStoreRequired; }
|
2008-04-30 17:16:33 +08:00
|
|
|
|
[PowerPC] Make r2 allocatable on PPC64/ELF for some leaf functions
The TOC base pointer is passed in r2, and we normally reserve this register so
that we can depend on it being there. However, for leaf functions, and
specifically those leaf functions that don't do any TOC access of their own
(which is generally due to accessing the constant pool, using TLS, etc.),
we can treat r2 as an ordinary callee-saved register (it must be callee-saved
because, for local direct calls, the linker will not insert any save/restore
code).
The allocation order has been changed slightly for PPC64/ELF systems to put r2
at the end of the list (while leaving it near the beginning for Darwin systems
to prevent unnecessary output changes). While r2 is allocatable, using it still
requires spill/restore traffic, and thus comes at the end of the list.
llvm-svn: 227745
2015-02-01 23:03:28 +08:00
|
|
|
void setUsesTOCBasePtr() { UsesTOCBasePtr = true; }
|
|
|
|
bool usesTOCBasePtr() const { return UsesTOCBasePtr; }
|
|
|
|
|
2008-04-30 17:16:33 +08:00
|
|
|
void setHasFastCall() { HasFastCall = true; }
|
|
|
|
bool hasFastCall() const { return HasFastCall;}
|
2010-04-17 22:41:14 +08:00
|
|
|
|
|
|
|
int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
|
|
|
|
void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
|
|
|
|
|
|
|
|
int getVarArgsStackOffset() const { return VarArgsStackOffset; }
|
|
|
|
void setVarArgsStackOffset(int Offset) { VarArgsStackOffset = Offset; }
|
|
|
|
|
|
|
|
unsigned getVarArgsNumGPR() const { return VarArgsNumGPR; }
|
|
|
|
void setVarArgsNumGPR(unsigned Num) { VarArgsNumGPR = Num; }
|
|
|
|
|
|
|
|
unsigned getVarArgsNumFPR() const { return VarArgsNumFPR; }
|
|
|
|
void setVarArgsNumFPR(unsigned Num) { VarArgsNumFPR = Num; }
|
2013-02-25 01:34:50 +08:00
|
|
|
|
2017-10-16 12:12:57 +08:00
|
|
|
/// This function associates attributes for each live-in virtual register.
|
|
|
|
void addLiveInAttr(unsigned VReg, ISD::ArgFlagsTy Flags) {
|
|
|
|
LiveInAttrs.push_back(std::make_pair(VReg, Flags));
|
|
|
|
}
|
|
|
|
|
2018-06-13 16:54:13 +08:00
|
|
|
/// This function returns true if the specified vreg is
|
2017-10-16 12:12:57 +08:00
|
|
|
/// a live-in register and sign-extended.
|
|
|
|
bool isLiveInSExt(unsigned VReg) const;
|
|
|
|
|
2018-06-13 16:54:13 +08:00
|
|
|
/// This function returns true if the specified vreg is
|
2017-10-16 12:12:57 +08:00
|
|
|
/// a live-in register and zero-extended.
|
|
|
|
bool isLiveInZExt(unsigned VReg) const;
|
|
|
|
|
2013-02-25 01:34:50 +08:00
|
|
|
int getCRSpillFrameIndex() const { return CRSpillFrameIndex; }
|
|
|
|
void setCRSpillFrameIndex(int idx) { CRSpillFrameIndex = idx; }
|
2013-04-15 10:07:05 +08:00
|
|
|
|
2013-07-14 12:42:23 +08:00
|
|
|
const SmallVectorImpl<unsigned> &
|
2013-04-15 10:07:05 +08:00
|
|
|
getMustSaveCRs() const { return MustSaveCRs; }
|
|
|
|
void addMustSaveCR(unsigned Reg) { MustSaveCRs.push_back(Reg); }
|
2014-07-19 07:29:49 +08:00
|
|
|
|
|
|
|
void setUsesPICBase(bool uses) { UsesPICBase = uses; }
|
|
|
|
bool usesPICBase() const { return UsesPICBase; }
|
|
|
|
|
2016-04-08 20:04:32 +08:00
|
|
|
bool isSplitCSR() const { return IsSplitCSR; }
|
|
|
|
void setIsSplitCSR(bool s) { IsSplitCSR = s; }
|
|
|
|
|
2014-07-19 07:29:49 +08:00
|
|
|
MCSymbol *getPICOffsetSymbol() const;
|
2016-01-13 21:12:23 +08:00
|
|
|
|
|
|
|
MCSymbol *getGlobalEPSymbol() const;
|
|
|
|
MCSymbol *getLocalEPSymbol() const;
|
|
|
|
MCSymbol *getTOCOffsetSymbol() const;
|
2006-11-17 06:43:37 +08:00
|
|
|
};
|
|
|
|
|
2017-01-13 08:58:58 +08:00
|
|
|
} // end namespace llvm
|
2006-11-17 06:43:37 +08:00
|
|
|
|
2017-01-13 08:58:58 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_POWERPC_PPCMACHINEFUNCTIONINFO_H
|