1 //===- MRegisterInfo.cpp - Target Register Information Implementation -----===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the MRegisterInfo interface.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/MRegisterInfo.h"
16 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/CodeGen/MachineFrameInfo.h"
18 #include "llvm/CodeGen/MachineLocation.h"
22 MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
23 regclass_iterator RCB, regclass_iterator RCE,
25 : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) {
26 assert(NumRegs < FirstVirtualRegister &&
27 "Target has too many physical registers!");
29 CallFrameSetupOpcode = CFSO;
30 CallFrameDestroyOpcode = CFDO;
33 MRegisterInfo::~MRegisterInfo() {}
35 std::vector<bool> MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
36 std::vector<bool> Allocatable(NumRegs);
37 for (MRegisterInfo::regclass_iterator I = regclass_begin(),
38 E = regclass_end(); I != E; ++I) {
39 const TargetRegisterClass *RC = *I;
40 for (TargetRegisterClass::iterator I = RC->allocation_order_begin(MF),
41 E = RC->allocation_order_end(MF); I != E; ++I)
42 Allocatable[*I] = true;
47 /// getLocation - This method should return the actual location of a frame
48 /// variable given the frame index. The location is returned in ML.
49 /// Subclasses should override this method for special handling of frame
50 /// variables and then call MRegisterInfo::getLocation for the default action.
51 void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
52 MachineLocation &ML) const {
53 MachineFrameInfo *MFI = MF.getFrameInfo();
54 ML.set(getFrameRegister(MF),
55 MFI->getObjectOffset(Index) + MFI->getStackSize());
58 /// getInitialFrameState - Returns a list of machine moves that are assumed
59 /// on entry to a function.
61 MRegisterInfo::getInitialFrameState(std::vector<MachineMove *> &Moves) const {
62 // Default is to do nothing.