LLVM API Documentation

MRegisterInfo.cpp

Go to the documentation of this file.
00001 //===- MRegisterInfo.cpp - Target Register Information Implementation -----===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the MRegisterInfo interface.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "llvm/Target/MRegisterInfo.h"
00015 
00016 #include "llvm/CodeGen/MachineFunction.h"
00017 #include "llvm/CodeGen/MachineFrameInfo.h"
00018 #include "llvm/CodeGen/MachineLocation.h"
00019 
00020 using namespace llvm;
00021 
00022 MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
00023                              regclass_iterator RCB, regclass_iterator RCE,
00024                              int CFSO, int CFDO)
00025   : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) {
00026   assert(NumRegs < FirstVirtualRegister &&
00027          "Target has too many physical registers!");
00028 
00029   CallFrameSetupOpcode   = CFSO;
00030   CallFrameDestroyOpcode = CFDO;
00031 }
00032 
00033 MRegisterInfo::~MRegisterInfo() {}
00034 
00035 std::vector<bool> MRegisterInfo::getAllocatableSet(MachineFunction &MF) const {
00036   std::vector<bool> Allocatable(NumRegs);
00037   for (MRegisterInfo::regclass_iterator I = regclass_begin(),
00038          E = regclass_end(); I != E; ++I) {
00039     const TargetRegisterClass *RC = *I;
00040     for (TargetRegisterClass::iterator I = RC->allocation_order_begin(MF),
00041            E = RC->allocation_order_end(MF); I != E; ++I)
00042       Allocatable[*I] = true;
00043   }
00044   return Allocatable;
00045 }
00046 
00047 /// getLocation - This method should return the actual location of a frame
00048 /// variable given the frame index.  The location is returned in ML.
00049 /// Subclasses should override this method for special handling of frame
00050 /// variables and then call MRegisterInfo::getLocation for the default action.
00051 void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
00052                         MachineLocation &ML) const {
00053   MachineFrameInfo *MFI = MF.getFrameInfo();
00054   ML.set(getFrameRegister(MF),
00055          MFI->getObjectOffset(Index) + MFI->getStackSize());
00056 }
00057 
00058 /// getInitialFrameState - Returns a list of machine moves that are assumed
00059 /// on entry to a function.
00060 void
00061 MRegisterInfo::getInitialFrameState(std::vector<MachineMove *> &Moves) const {
00062   // Default is to do nothing.
00063 }
00064