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/TargetMachine.h"
15 #include "llvm/Target/MRegisterInfo.h"
16 #include "llvm/Target/TargetFrameInfo.h"
17 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/CodeGen/MachineFrameInfo.h"
19 #include "llvm/CodeGen/MachineLocation.h"
20 #include "llvm/ADT/BitVector.h"
24 MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
25 regclass_iterator RCB, regclass_iterator RCE,
27 : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) {
28 assert(NumRegs < FirstVirtualRegister &&
29 "Target has too many physical registers!");
31 CallFrameSetupOpcode = CFSO;
32 CallFrameDestroyOpcode = CFDO;
35 MRegisterInfo::~MRegisterInfo() {}
37 BitVector MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
38 BitVector Allocatable(NumRegs);
39 for (MRegisterInfo::regclass_iterator I = regclass_begin(),
40 E = regclass_end(); I != E; ++I) {
41 const TargetRegisterClass *RC = *I;
42 for (TargetRegisterClass::iterator I = RC->allocation_order_begin(MF),
43 E = RC->allocation_order_end(MF); I != E; ++I)
49 /// getLocation - This method should return the actual location of a frame
50 /// variable given the frame index. The location is returned in ML.
51 /// Subclasses should override this method for special handling of frame
52 /// variables and then call MRegisterInfo::getLocation for the default action.
53 void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
54 MachineLocation &ML) const {
55 const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
56 MachineFrameInfo *MFI = MF.getFrameInfo();
57 ML.set(getFrameRegister(MF),
58 MFI->getObjectOffset(Index) +
60 TFI.getOffsetOfLocalArea() +
61 MFI->getOffsetAdjustment());
64 /// getInitialFrameState - Returns a list of machine moves that are assumed
65 /// on entry to a function.
67 MRegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const {
68 // Default is to do nothing.