1 //===-- llvm/CodeGen/AllocationOrder.h - Allocation Order -*- C++ -*-------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements an allocation order for virtual registers.
12 // The preferred allocation order for a virtual register depends on allocation
13 // hints and target hooks. The AllocationOrder class encapsulates all of that.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_CODEGEN_ALLOCATIONORDER_H
18 #define LLVM_CODEGEN_ALLOCATIONORDER_H
20 #include "llvm/MC/MCRegisterInfo.h"
24 class RegisterClassInfo;
27 class AllocationOrder {
28 const MCPhysReg *Begin;
31 const RegisterClassInfo &RCI;
36 /// AllocationOrder - Create a new AllocationOrder for VirtReg.
37 /// @param VirtReg Virtual register to allocate for.
38 /// @param VRM Virtual register map for function.
39 /// @param RegClassInfo Information about reserved and allocatable registers.
40 AllocationOrder(unsigned VirtReg,
41 const VirtRegMap &VRM,
42 const RegisterClassInfo &RegClassInfo);
46 /// next - Return the next physical register in the allocation order, or 0.
47 /// It is safe to call next again after it returned 0.
48 /// It will keep returning 0 until rewind() is called.
50 // First take the hint.
56 // Then look at the order from TRI.
58 unsigned Reg = *Pos++;
65 /// rewind - Start over from the beginning.
66 void rewind() { Pos = 0; }
68 /// isHint - Return true if PhysReg is a preferred register.
69 bool isHint(unsigned PhysReg) const { return PhysReg == Hint; }
72 } // end namespace llvm