LCOV - code coverage report
Current view: top level - lib/Target/ARM - ARMBaseRegisterInfo.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 17 17 100.0 %
Date: 2017-09-14 15:23:50 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- ARMBaseRegisterInfo.h - ARM Register Information Impl ---*- 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 contains the base ARM implementation of TargetRegisterInfo class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_LIB_TARGET_ARM_ARMBASEREGISTERINFO_H
      15             : #define LLVM_LIB_TARGET_ARM_ARMBASEREGISTERINFO_H
      16             : 
      17             : #include "MCTargetDesc/ARMBaseInfo.h"
      18             : #include "llvm/CodeGen/MachineBasicBlock.h"
      19             : #include "llvm/CodeGen/MachineInstr.h"
      20             : #include "llvm/IR/CallingConv.h"
      21             : #include "llvm/MC/MCRegisterInfo.h"
      22             : #include "llvm/Target/TargetRegisterInfo.h"
      23             : #include <cstdint>
      24             : 
      25             : #define GET_REGINFO_HEADER
      26             : #include "ARMGenRegisterInfo.inc"
      27             : 
      28             : namespace llvm {
      29             : 
      30             : /// Register allocation hints.
      31             : namespace ARMRI {
      32             : 
      33             :   enum {
      34             :     RegPairOdd  = 1,
      35             :     RegPairEven = 2
      36             :   };
      37             : 
      38             : } // end namespace ARMRI
      39             : 
      40             : /// isARMArea1Register - Returns true if the register is a low register (r0-r7)
      41             : /// or a stack/pc register that we should push/pop.
      42       20860 : static inline bool isARMArea1Register(unsigned Reg, bool isIOS) {
      43             :   using namespace ARM;
      44             : 
      45       20860 :   switch (Reg) {
      46             :     case R0:  case R1:  case R2:  case R3:
      47             :     case R4:  case R5:  case R6:  case R7:
      48             :     case LR:  case SP:  case PC:
      49             :       return true;
      50        3879 :     case R8:  case R9:  case R10: case R11: case R12:
      51             :       // For iOS we want r7 and lr to be next to each other.
      52        3879 :       return !isIOS;
      53        2327 :     default:
      54        2327 :       return false;
      55             :   }
      56             : }
      57             : 
      58       20860 : static inline bool isARMArea2Register(unsigned Reg, bool isIOS) {
      59             :   using namespace ARM;
      60             : 
      61       20860 :   switch (Reg) {
      62             :     case R8: case R9: case R10: case R11: case R12:
      63             :       // iOS has this second area.
      64             :       return isIOS;
      65       16981 :     default:
      66       16981 :       return false;
      67             :   }
      68             : }
      69             : 
      70       20908 : static inline bool isARMArea3Register(unsigned Reg, bool isIOS) {
      71             :   using namespace ARM;
      72             : 
      73       20908 :   switch (Reg) {
      74             :     case D15: case D14: case D13: case D12:
      75             :     case D11: case D10: case D9:  case D8:
      76             :     case D7:  case D6:  case D5:  case D4:
      77             :     case D3:  case D2:  case D1:  case D0:
      78             :     case D31: case D30: case D29: case D28:
      79             :     case D27: case D26: case D25: case D24:
      80             :     case D23: case D22: case D21: case D20:
      81             :     case D19: case D18: case D17: case D16:
      82             :       return true;
      83       18533 :     default:
      84       18533 :       return false;
      85             :   }
      86             : }
      87             : 
      88             : static inline bool isCalleeSavedRegister(unsigned Reg,
      89             :                                          const MCPhysReg *CSRegs) {
      90       47363 :   for (unsigned i = 0; CSRegs[i]; ++i)
      91       24919 :     if (Reg == CSRegs[i])
      92             :       return true;
      93             :   return false;
      94             : }
      95             : 
      96        8890 : class ARMBaseRegisterInfo : public ARMGenRegisterInfo {
      97             : protected:
      98             :   /// BasePtr - ARM physical register used as a base ptr in complex stack
      99             :   /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
     100             :   /// variable size stack objects.
     101             :   unsigned BasePtr = ARM::R6;
     102             : 
     103             :   // Can be only subclassed.
     104             :   explicit ARMBaseRegisterInfo();
     105             : 
     106             :   // Return the opcode that implements 'Op', or 0 if no opcode
     107             :   unsigned getOpcode(int Op) const;
     108             : 
     109             : public:
     110             :   /// Code Generation virtual methods...
     111             :   const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
     112             :   const MCPhysReg *
     113             :   getCalleeSavedRegsViaCopy(const MachineFunction *MF) const;
     114             :   const uint32_t *getCallPreservedMask(const MachineFunction &MF,
     115             :                                        CallingConv::ID) const override;
     116             :   const uint32_t *getNoPreservedMask() const override;
     117             :   const uint32_t *getTLSCallPreservedMask(const MachineFunction &MF) const;
     118             :   const uint32_t *getSjLjDispatchPreservedMask(const MachineFunction &MF) const;
     119             : 
     120             :   /// getThisReturnPreservedMask - Returns a call preserved mask specific to the
     121             :   /// case that 'returned' is on an i32 first argument if the calling convention
     122             :   /// is one that can (partially) model this attribute with a preserved mask
     123             :   /// (i.e. it is a calling convention that uses the same register for the first
     124             :   /// i32 argument and an i32 return value)
     125             :   ///
     126             :   /// Should return NULL in the case that the calling convention does not have
     127             :   /// this property
     128             :   const uint32_t *getThisReturnPreservedMask(const MachineFunction &MF,
     129             :                                              CallingConv::ID) const;
     130             : 
     131             :   BitVector getReservedRegs(const MachineFunction &MF) const override;
     132             : 
     133             :   const TargetRegisterClass *
     134             :   getPointerRegClass(const MachineFunction &MF,
     135             :                      unsigned Kind = 0) const override;
     136             :   const TargetRegisterClass *
     137             :   getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
     138             : 
     139             :   const TargetRegisterClass *
     140             :   getLargestLegalSuperClass(const TargetRegisterClass *RC,
     141             :                             const MachineFunction &MF) const override;
     142             : 
     143             :   unsigned getRegPressureLimit(const TargetRegisterClass *RC,
     144             :                                MachineFunction &MF) const override;
     145             : 
     146             :   void getRegAllocationHints(unsigned VirtReg,
     147             :                              ArrayRef<MCPhysReg> Order,
     148             :                              SmallVectorImpl<MCPhysReg> &Hints,
     149             :                              const MachineFunction &MF,
     150             :                              const VirtRegMap *VRM,
     151             :                              const LiveRegMatrix *Matrix) const override;
     152             : 
     153             :   void updateRegAllocHint(unsigned Reg, unsigned NewReg,
     154             :                           MachineFunction &MF) const override;
     155             : 
     156             :   bool hasBasePointer(const MachineFunction &MF) const;
     157             : 
     158             :   bool canRealignStack(const MachineFunction &MF) const override;
     159             :   int64_t getFrameIndexInstrOffset(const MachineInstr *MI,
     160             :                                    int Idx) const override;
     161             :   bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override;
     162             :   void materializeFrameBaseRegister(MachineBasicBlock *MBB,
     163             :                                     unsigned BaseReg, int FrameIdx,
     164             :                                     int64_t Offset) const override;
     165             :   void resolveFrameIndex(MachineInstr &MI, unsigned BaseReg,
     166             :                          int64_t Offset) const override;
     167             :   bool isFrameOffsetLegal(const MachineInstr *MI, unsigned BaseReg,
     168             :                           int64_t Offset) const override;
     169             : 
     170             :   bool cannotEliminateFrame(const MachineFunction &MF) const;
     171             : 
     172             :   // Debug information queries.
     173             :   unsigned getFrameRegister(const MachineFunction &MF) const override;
     174             :   unsigned getBaseRegister() const { return BasePtr; }
     175             : 
     176             :   bool isLowRegister(unsigned Reg) const;
     177             : 
     178             : 
     179             :   /// emitLoadConstPool - Emits a load from constpool to materialize the
     180             :   /// specified immediate.
     181             :   virtual void
     182             :   emitLoadConstPool(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI,
     183             :                     const DebugLoc &dl, unsigned DestReg, unsigned SubIdx,
     184             :                     int Val, ARMCC::CondCodes Pred = ARMCC::AL,
     185             :                     unsigned PredReg = 0,
     186             :                     unsigned MIFlags = MachineInstr::NoFlags) const;
     187             : 
     188             :   /// Code Generation virtual methods...
     189             :   bool requiresRegisterScavenging(const MachineFunction &MF) const override;
     190             : 
     191             :   bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override;
     192             : 
     193             :   bool requiresFrameIndexScavenging(const MachineFunction &MF) const override;
     194             : 
     195             :   bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override;
     196             : 
     197             :   void eliminateFrameIndex(MachineBasicBlock::iterator II,
     198             :                            int SPAdj, unsigned FIOperandNum,
     199             :                            RegScavenger *RS = nullptr) const override;
     200             : 
     201             :   /// \brief SrcRC and DstRC will be morphed into NewRC if this returns true
     202             :   bool shouldCoalesce(MachineInstr *MI,
     203             :                       const TargetRegisterClass *SrcRC,
     204             :                       unsigned SubReg,
     205             :                       const TargetRegisterClass *DstRC,
     206             :                       unsigned DstSubReg,
     207             :                       const TargetRegisterClass *NewRC) const override;
     208             : };
     209             : 
     210             : } // end namespace llvm
     211             : 
     212             : #endif // LLVM_LIB_TARGET_ARM_ARMBASEREGISTERINFO_H

Generated by: LCOV version 1.13