Misc. SSE2 intrinsics: clflush, lfench, mfence
[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 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/CodeGen/MachineFrameInfo.h"
18 #include "llvm/CodeGen/MachineLocation.h"
19
20 using namespace llvm;
21
22 MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
23                              regclass_iterator RCB, regclass_iterator RCE,
24                              int CFSO, int CFDO)
25   : Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) {
26   assert(NumRegs < FirstVirtualRegister &&
27          "Target has too many physical registers!");
28
29   CallFrameSetupOpcode   = CFSO;
30   CallFrameDestroyOpcode = CFDO;
31 }
32
33 MRegisterInfo::~MRegisterInfo() {}
34
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;
43   }
44   return Allocatable;
45 }
46
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());
56 }
57
58 /// getInitialFrameState - Returns a list of machine moves that are assumed
59 /// on entry to a function.
60 void
61 MRegisterInfo::getInitialFrameState(std::vector<MachineMove *> &Moves) const {
62   // Default is to do nothing.
63 }
64