LCOV - code coverage report
Current view: top level - lib/Target/AArch64 - AArch64MachineFunctionInfo.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 23 42 54.8 %
Date: 2018-10-20 13:21:21 Functions: 2 27 7.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //=- AArch64MachineFunctionInfo.h - AArch64 machine function info -*- C++ -*-=//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file declares AArch64-specific per-machine-function information.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
      15             : #define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
      16             : 
      17             : #include "llvm/ADT/ArrayRef.h"
      18             : #include "llvm/ADT/Optional.h"
      19             : #include "llvm/ADT/SmallPtrSet.h"
      20             : #include "llvm/ADT/SmallVector.h"
      21             : #include "llvm/CodeGen/MachineFunction.h"
      22             : #include "llvm/MC/MCLinkerOptimizationHint.h"
      23             : #include <cassert>
      24             : 
      25             : namespace llvm {
      26             : 
      27             : class MachineInstr;
      28             : 
      29             : /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
      30             : /// contains private AArch64-specific information for each MachineFunction.
      31             : class AArch64FunctionInfo final : public MachineFunctionInfo {
      32             :   /// Number of bytes of arguments this function has on the stack. If the callee
      33             :   /// is expected to restore the argument stack this should be a multiple of 16,
      34             :   /// all usable during a tail call.
      35             :   ///
      36             :   /// The alternative would forbid tail call optimisation in some cases: if we
      37             :   /// want to transfer control from a function with 8-bytes of stack-argument
      38             :   /// space to a function with 16-bytes then misalignment of this value would
      39             :   /// make a stack adjustment necessary, which could not be undone by the
      40             :   /// callee.
      41             :   unsigned BytesInStackArgArea = 0;
      42             : 
      43             :   /// The number of bytes to restore to deallocate space for incoming
      44             :   /// arguments. Canonically 0 in the C calling convention, but non-zero when
      45             :   /// callee is expected to pop the args.
      46             :   unsigned ArgumentStackToRestore = 0;
      47             : 
      48             :   /// HasStackFrame - True if this function has a stack frame. Set by
      49             :   /// determineCalleeSaves().
      50             :   bool HasStackFrame = false;
      51             : 
      52             :   /// Amount of stack frame size, not including callee-saved registers.
      53             :   unsigned LocalStackSize;
      54             : 
      55             :   /// Amount of stack frame size used for saving callee-saved registers.
      56             :   unsigned CalleeSavedStackSize;
      57             : 
      58             :   /// Number of TLS accesses using the special (combinable)
      59             :   /// _TLS_MODULE_BASE_ symbol.
      60             :   unsigned NumLocalDynamicTLSAccesses = 0;
      61             : 
      62             :   /// FrameIndex for start of varargs area for arguments passed on the
      63             :   /// stack.
      64             :   int VarArgsStackIndex = 0;
      65             : 
      66             :   /// FrameIndex for start of varargs area for arguments passed in
      67             :   /// general purpose registers.
      68             :   int VarArgsGPRIndex = 0;
      69             : 
      70             :   /// Size of the varargs area for arguments passed in general purpose
      71             :   /// registers.
      72             :   unsigned VarArgsGPRSize = 0;
      73             : 
      74             :   /// FrameIndex for start of varargs area for arguments passed in
      75             :   /// floating-point registers.
      76             :   int VarArgsFPRIndex = 0;
      77             : 
      78             :   /// Size of the varargs area for arguments passed in floating-point
      79             :   /// registers.
      80             :   unsigned VarArgsFPRSize = 0;
      81             : 
      82             :   /// True if this function has a subset of CSRs that is handled explicitly via
      83             :   /// copies.
      84             :   bool IsSplitCSR = false;
      85             : 
      86             :   /// True when the stack gets realigned dynamically because the size of stack
      87             :   /// frame is unknown at compile time. e.g., in case of VLAs.
      88             :   bool StackRealigned = false;
      89             : 
      90             :   /// True when the callee-save stack area has unused gaps that may be used for
      91             :   /// other stack allocations.
      92             :   bool CalleeSaveStackHasFreeSpace = false;
      93             : 
      94             :   /// Has a value when it is known whether or not the function uses a
      95             :   /// redzone, and no value otherwise.
      96             :   /// Initialized during frame lowering, unless the function has the noredzone
      97             :   /// attribute, in which case it is set to false at construction.
      98             :   Optional<bool> HasRedZone;
      99             : 
     100             : public:
     101             :   AArch64FunctionInfo() = default;
     102             : 
     103       14840 :   explicit AArch64FunctionInfo(MachineFunction &MF) {
     104             :     (void)MF;
     105             : 
     106             :     // If we already know that the function doesn't have a redzone, set
     107             :     // HasRedZone here.
     108       14840 :     if (MF.getFunction().hasFnAttribute(Attribute::NoRedZone))
     109             :       HasRedZone = false;
     110       14840 :   }
     111             : 
     112           0 :   unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
     113       13604 :   void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
     114             : 
     115           0 :   unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
     116           0 :   void setArgumentStackToRestore(unsigned bytes) {
     117          21 :     ArgumentStackToRestore = bytes;
     118           0 :   }
     119             : 
     120           0 :   bool hasStackFrame() const { return HasStackFrame; }
     121        1401 :   void setHasStackFrame(bool s) { HasStackFrame = s; }
     122             : 
     123           0 :   bool isStackRealigned() const { return StackRealigned; }
     124          20 :   void setStackRealigned(bool s) { StackRealigned = s; }
     125             : 
     126           0 :   bool hasCalleeSaveStackFreeSpace() const {
     127           0 :     return CalleeSaveStackHasFreeSpace;
     128             :   }
     129             :   void setCalleeSaveStackHasFreeSpace(bool s) {
     130       15047 :     CalleeSaveStackHasFreeSpace = s;
     131             :   }
     132             : 
     133           0 :   bool isSplitCSR() const { return IsSplitCSR; }
     134           6 :   void setIsSplitCSR(bool s) { IsSplitCSR = s; }
     135             : 
     136       14788 :   void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
     137           0 :   unsigned getLocalStackSize() const { return LocalStackSize; }
     138             : 
     139       15047 :   void setCalleeSavedStackSize(unsigned Size) { CalleeSavedStackSize = Size; }
     140           0 :   unsigned getCalleeSavedStackSize() const { return CalleeSavedStackSize; }
     141             : 
     142          12 :   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
     143           0 :   unsigned getNumLocalDynamicTLSAccesses() const {
     144           0 :     return NumLocalDynamicTLSAccesses;
     145             :   }
     146             : 
     147             :   Optional<bool> hasRedZone() const { return HasRedZone; }
     148             :   void setHasRedZone(bool s) { HasRedZone = s; }
     149             : 
     150           0 :   int getVarArgsStackIndex() const { return VarArgsStackIndex; }
     151          29 :   void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
     152             : 
     153           0 :   int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
     154          19 :   void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
     155             : 
     156           0 :   unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
     157          19 :   void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
     158             : 
     159           0 :   int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
     160           6 :   void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
     161             : 
     162           0 :   unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
     163           6 :   void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
     164             : 
     165             :   using SetOfInstructions = SmallPtrSet<const MachineInstr *, 16>;
     166             : 
     167             :   const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
     168             : 
     169             :   // Shortcuts for LOH related types.
     170         442 :   class MILOHDirective {
     171             :     MCLOHType Kind;
     172             : 
     173             :     /// Arguments of this directive. Order matters.
     174             :     SmallVector<const MachineInstr *, 3> Args;
     175             : 
     176             :   public:
     177             :     using LOHArgs = ArrayRef<const MachineInstr *>;
     178             : 
     179             :     MILOHDirective(MCLOHType Kind, LOHArgs Args)
     180         221 :         : Kind(Kind), Args(Args.begin(), Args.end()) {
     181             :       assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
     182             :     }
     183             : 
     184           0 :     MCLOHType getKind() const { return Kind; }
     185             :     LOHArgs getArgs() const { return Args; }
     186             :   };
     187             : 
     188             :   using MILOHArgs = MILOHDirective::LOHArgs;
     189             :   using MILOHContainer = SmallVector<MILOHDirective, 32>;
     190             : 
     191             :   const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
     192             : 
     193             :   /// Add a LOH directive of this @p Kind and this @p Args.
     194         221 :   void addLOHDirective(MCLOHType Kind, MILOHArgs Args) {
     195         221 :     LOHContainerSet.push_back(MILOHDirective(Kind, Args));
     196         221 :     LOHRelated.insert(Args.begin(), Args.end());
     197         221 :   }
     198             : 
     199             : private:
     200             :   // Hold the lists of LOHs.
     201             :   MILOHContainer LOHContainerSet;
     202             :   SetOfInstructions LOHRelated;
     203             : };
     204             : 
     205             : } // end namespace llvm
     206             : 
     207             : #endif // LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H

Generated by: LCOV version 1.13