LCOV - code coverage report
Current view: top level - lib/CodeGen - AllocationOrder.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 9 100.0 %
Date: 2018-10-20 13:21:21 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- llvm/CodeGen/AllocationOrder.cpp - Allocation Order ---------------===//
       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 an allocation order for virtual registers.
      11             : //
      12             : // The preferred allocation order for a virtual register depends on allocation
      13             : // hints and target hooks. The AllocationOrder class encapsulates all of that.
      14             : //
      15             : //===----------------------------------------------------------------------===//
      16             : 
      17             : #include "AllocationOrder.h"
      18             : #include "llvm/CodeGen/MachineFunction.h"
      19             : #include "llvm/CodeGen/MachineRegisterInfo.h"
      20             : #include "llvm/CodeGen/RegisterClassInfo.h"
      21             : #include "llvm/CodeGen/VirtRegMap.h"
      22             : #include "llvm/Support/Debug.h"
      23             : #include "llvm/Support/raw_ostream.h"
      24             : 
      25             : using namespace llvm;
      26             : 
      27             : #define DEBUG_TYPE "regalloc"
      28             : 
      29             : // Compare VirtRegMap::getRegAllocPref().
      30     1698369 : AllocationOrder::AllocationOrder(unsigned VirtReg,
      31             :                                  const VirtRegMap &VRM,
      32             :                                  const RegisterClassInfo &RegClassInfo,
      33     1698369 :                                  const LiveRegMatrix *Matrix)
      34     1698369 :   : Pos(0), HardHints(false) {
      35     1698369 :   const MachineFunction &MF = VRM.getMachineFunction();
      36     1698369 :   const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo();
      37     3396738 :   Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg));
      38     1698369 :   if (TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM, Matrix))
      39           5 :     HardHints = true;
      40             :   rewind();
      41             : 
      42             :   LLVM_DEBUG({
      43             :     if (!Hints.empty()) {
      44             :       dbgs() << "hints:";
      45             :       for (unsigned I = 0, E = Hints.size(); I != E; ++I)
      46             :         dbgs() << ' ' << printReg(Hints[I], TRI);
      47             :       dbgs() << '\n';
      48             :     }
      49             :   });
      50             : #ifndef NDEBUG
      51             :   for (unsigned I = 0, E = Hints.size(); I != E; ++I)
      52             :     assert(is_contained(Order, Hints[I]) &&
      53             :            "Target hint is outside allocation order.");
      54             : #endif
      55     1698369 : }

Generated by: LCOV version 1.13