LCOV - code coverage report
Current view: top level - lib/MC - MCRegisterInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 45 47 95.7 %
Date: 2017-09-14 15:23:50 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- MC/MCRegisterInfo.cpp - Target Register Description ----------------===//
       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 implements MCRegisterInfo functions.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/MC/MCRegisterInfo.h"
      15             : #include "llvm/ADT/DenseMap.h"
      16             : #include "llvm/Support/ErrorHandling.h"
      17             : #include <algorithm>
      18             : #include <cassert>
      19             : #include <cstdint>
      20             : 
      21             : using namespace llvm;
      22             : 
      23       62712 : unsigned MCRegisterInfo::getMatchingSuperReg(unsigned Reg, unsigned SubIdx,
      24             :                                              const MCRegisterClass *RC) const {
      25      117539 :   for (MCSuperRegIterator Supers(Reg, this); Supers.isValid(); ++Supers)
      26      329917 :     if (RC->contains(*Supers) && Reg == getSubReg(*Supers, SubIdx))
      27       59367 :       return *Supers;
      28        3345 :   return 0;
      29             : }
      30             : 
      31      603404 : unsigned MCRegisterInfo::getSubReg(unsigned Reg, unsigned Idx) const {
      32             :   assert(Idx && Idx < getNumSubRegIndices() &&
      33             :          "This is not a subregister index");
      34             :   // Get a pointer to the corresponding SubRegIndices list. This list has the
      35             :   // name of each sub-register in the same order as MCSubRegIterator.
      36     1206808 :   const uint16_t *SRI = SubRegIndices + get(Reg).SubRegIndices;
      37     1644766 :   for (MCSubRegIterator Subs(Reg, this); Subs.isValid(); ++Subs, ++SRI)
      38      966406 :     if (*SRI == Idx)
      39      445725 :       return *Subs;
      40      157679 :   return 0;
      41             : }
      42             : 
      43       27036 : unsigned MCRegisterInfo::getSubRegIndex(unsigned Reg, unsigned SubReg) const {
      44             :   assert(SubReg && SubReg < getNumRegs() && "This is not a register");
      45             :   // Get a pointer to the corresponding SubRegIndices list. This list has the
      46             :   // name of each sub-register in the same order as MCSubRegIterator.
      47       54072 :   const uint16_t *SRI = SubRegIndices + get(Reg).SubRegIndices;
      48       62226 :   for (MCSubRegIterator Subs(Reg, this); Subs.isValid(); ++Subs, ++SRI)
      49       78542 :     if (*Subs == SubReg)
      50       21676 :       return *SRI;
      51        5360 :   return 0;
      52             : }
      53             : 
      54        1093 : unsigned MCRegisterInfo::getSubRegIdxSize(unsigned Idx) const {
      55             :   assert(Idx && Idx < getNumSubRegIndices() &&
      56             :          "This is not a subregister index");
      57        1093 :   return SubRegIdxRanges[Idx].Size;
      58             : }
      59             : 
      60         775 : unsigned MCRegisterInfo::getSubRegIdxOffset(unsigned Idx) const {
      61             :   assert(Idx && Idx < getNumSubRegIndices() &&
      62             :          "This is not a subregister index");
      63         775 :   return SubRegIdxRanges[Idx].Offset;
      64             : }
      65             : 
      66      114555 : int MCRegisterInfo::getDwarfRegNum(unsigned RegNum, bool isEH) const {
      67      114555 :   const DwarfLLVMRegPair *M = isEH ? EHL2DwarfRegs : L2DwarfRegs;
      68      114555 :   unsigned Size = isEH ? EHL2DwarfRegsSize : L2DwarfRegsSize;
      69             : 
      70      114555 :   if (!M)
      71             :     return -1;
      72      114555 :   DwarfLLVMRegPair Key = { RegNum, 0 };
      73      229110 :   const DwarfLLVMRegPair *I = std::lower_bound(M, M+Size, Key);
      74      114555 :   if (I == M+Size || I->FromReg != RegNum)
      75             :     return -1;
      76      113225 :   return I->ToReg;
      77             : }
      78             : 
      79       19643 : int MCRegisterInfo::getLLVMRegNum(unsigned RegNum, bool isEH) const {
      80       19643 :   const DwarfLLVMRegPair *M = isEH ? EHDwarf2LRegs : Dwarf2LRegs;
      81       19643 :   unsigned Size = isEH ? EHDwarf2LRegsSize : Dwarf2LRegsSize;
      82             : 
      83       19643 :   if (!M)
      84             :     return -1;
      85       19643 :   DwarfLLVMRegPair Key = { RegNum, 0 };
      86       39286 :   const DwarfLLVMRegPair *I = std::lower_bound(M, M+Size, Key);
      87             :   assert(I != M+Size && I->FromReg == RegNum && "Invalid RegNum");
      88       19643 :   return I->ToReg;
      89             : }
      90             : 
      91           7 : int MCRegisterInfo::getSEHRegNum(unsigned RegNum) const {
      92           7 :   const DenseMap<unsigned, int>::const_iterator I = L2SEHRegs.find(RegNum);
      93          14 :   if (I == L2SEHRegs.end()) return (int)RegNum;
      94           7 :   return I->second;
      95             : }
      96             : 
      97         155 : int MCRegisterInfo::getCodeViewRegNum(unsigned RegNum) const {
      98         310 :   if (L2CVRegs.empty())
      99           0 :     report_fatal_error("target does not implement codeview register mapping");
     100         155 :   const DenseMap<unsigned, int>::const_iterator I = L2CVRegs.find(RegNum);
     101         310 :   if (I == L2CVRegs.end())
     102           0 :     report_fatal_error("unknown codeview register");
     103         155 :   return I->second;
     104             : }

Generated by: LCOV version 1.13