Modified cast so that it converts the int to a long before casting to
[oota-llvm.git] / lib / Target / MRegisterInfo.cpp
1 //===- MRegisterInfo.cpp - Target Register Information Implementation -----===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the MRegisterInfo interface.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/MRegisterInfo.h"
15
16 namespace llvm {
17
18 MRegisterInfo::MRegisterInfo(const MRegisterDesc *D, unsigned NR,
19                              regclass_iterator RCB, regclass_iterator RCE,
20                              int CFSO, int CFDO)
21   : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) {
22   assert(NumRegs < FirstVirtualRegister &&
23          "Target has too many physical registers!");
24
25   PhysRegClasses = new const TargetRegisterClass*[NumRegs];
26   for (unsigned i = 0; i != NumRegs; ++i)
27     PhysRegClasses[i] = 0;
28
29   // Fill in the PhysRegClasses map
30   for (MRegisterInfo::regclass_iterator I = regclass_begin(),
31          E = regclass_end(); I != E; ++I)
32     for (unsigned i = 0, e = (*I)->getNumRegs(); i != e; ++i) {
33       unsigned Reg = (*I)->getRegister(i);
34       assert(PhysRegClasses[Reg] == 0 && "Register in more than one class?");
35       PhysRegClasses[Reg] = *I;
36     }
37
38   CallFrameSetupOpcode   = CFSO;
39   CallFrameDestroyOpcode = CFDO;
40 }
41
42
43 MRegisterInfo::~MRegisterInfo() {
44   delete[] PhysRegClasses;
45 }
46
47 } // End llvm namespace