~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Target/TargetRegisterInfo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- TargetRegisterInfo.cpp - Target Register Information Implementation ===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file implements the TargetRegisterInfo interface.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#include "llvm/Target/TargetMachine.h"
 
15
#include "llvm/Target/TargetRegisterInfo.h"
 
16
#include "llvm/Target/TargetFrameInfo.h"
 
17
#include "llvm/CodeGen/MachineFunction.h"
 
18
#include "llvm/CodeGen/MachineFrameInfo.h"
 
19
#include "llvm/ADT/BitVector.h"
 
20
 
 
21
using namespace llvm;
 
22
 
 
23
TargetRegisterInfo::TargetRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
 
24
                             regclass_iterator RCB, regclass_iterator RCE,
 
25
                             int CFSO, int CFDO,
 
26
                             const unsigned* subregs, const unsigned subregsize,
 
27
                         const unsigned* superregs, const unsigned superregsize,
 
28
                         const unsigned* aliases, const unsigned aliasessize)
 
29
  : SubregHash(subregs), SubregHashSize(subregsize),
 
30
    SuperregHash(superregs), SuperregHashSize(superregsize),
 
31
    AliasesHash(aliases), AliasesHashSize(aliasessize),
 
32
    Desc(D), NumRegs(NR), RegClassBegin(RCB), RegClassEnd(RCE) {
 
33
  assert(NumRegs < FirstVirtualRegister &&
 
34
         "Target has too many physical registers!");
 
35
 
 
36
  CallFrameSetupOpcode   = CFSO;
 
37
  CallFrameDestroyOpcode = CFDO;
 
38
}
 
39
 
 
40
TargetRegisterInfo::~TargetRegisterInfo() {}
 
41
 
 
42
/// getPhysicalRegisterRegClass - Returns the Register Class of a physical
 
43
/// register of the given type. If type is EVT::Other, then just return any
 
44
/// register class the register belongs to.
 
45
const TargetRegisterClass *
 
46
TargetRegisterInfo::getPhysicalRegisterRegClass(unsigned reg, EVT VT) const {
 
47
  assert(isPhysicalRegister(reg) && "reg must be a physical register");
 
48
 
 
49
  // Pick the most super register class of the right type that contains
 
50
  // this physreg.
 
51
  const TargetRegisterClass* BestRC = 0;
 
52
  for (regclass_iterator I = regclass_begin(), E = regclass_end(); I != E; ++I){
 
53
    const TargetRegisterClass* RC = *I;
 
54
    if ((VT == MVT::Other || RC->hasType(VT)) && RC->contains(reg) &&
 
55
        (!BestRC || BestRC->hasSuperClass(RC)))
 
56
      BestRC = RC;
 
57
  }
 
58
 
 
59
  assert(BestRC && "Couldn't find the register class");
 
60
  return BestRC;
 
61
}
 
62
 
 
63
/// getAllocatableSetForRC - Toggle the bits that represent allocatable
 
64
/// registers for the specific register class.
 
65
static void getAllocatableSetForRC(const MachineFunction &MF,
 
66
                                   const TargetRegisterClass *RC, BitVector &R){  
 
67
  for (TargetRegisterClass::iterator I = RC->allocation_order_begin(MF),
 
68
         E = RC->allocation_order_end(MF); I != E; ++I)
 
69
    R.set(*I);
 
70
}
 
71
 
 
72
BitVector TargetRegisterInfo::getAllocatableSet(const MachineFunction &MF,
 
73
                                          const TargetRegisterClass *RC) const {
 
74
  BitVector Allocatable(NumRegs);
 
75
  if (RC) {
 
76
    getAllocatableSetForRC(MF, RC, Allocatable);
 
77
    return Allocatable;
 
78
  }
 
79
 
 
80
  for (TargetRegisterInfo::regclass_iterator I = regclass_begin(),
 
81
         E = regclass_end(); I != E; ++I)
 
82
    getAllocatableSetForRC(MF, *I, Allocatable);
 
83
  return Allocatable;
 
84
}
 
85
 
 
86
/// getFrameIndexOffset - Returns the displacement from the frame register to
 
87
/// the stack frame of the specified index. This is the default implementation
 
88
/// which is overridden for some targets.
 
89
int TargetRegisterInfo::getFrameIndexOffset(const MachineFunction &MF,
 
90
                                            int FI) const {
 
91
  const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo();
 
92
  const MachineFrameInfo *MFI = MF.getFrameInfo();
 
93
  return MFI->getObjectOffset(FI) + MFI->getStackSize() -
 
94
    TFI.getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
 
95
}
 
96
 
 
97
/// getInitialFrameState - Returns a list of machine moves that are assumed
 
98
/// on entry to a function.
 
99
void
 
100
TargetRegisterInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const{
 
101
  // Default is to do nothing.
 
102
}
 
103
 
 
104
const TargetRegisterClass *
 
105
llvm::getCommonSubClass(const TargetRegisterClass *A,
 
106
                        const TargetRegisterClass *B) {
 
107
  // First take care of the trivial cases
 
108
  if (A == B)
 
109
    return A;
 
110
  if (!A || !B)
 
111
    return 0;
 
112
 
 
113
  // If B is a subclass of A, it will be handled in the loop below
 
114
  if (B->hasSubClass(A))
 
115
    return A;
 
116
 
 
117
  const TargetRegisterClass *Best = 0;
 
118
  for (TargetRegisterClass::sc_iterator I = A->subclasses_begin();
 
119
       const TargetRegisterClass *X = *I; ++I) {
 
120
    if (X == B)
 
121
      return B;                 // B is a subclass of A
 
122
 
 
123
    // X must be a common subclass of A and B
 
124
    if (!B->hasSubClass(X))
 
125
      continue;
 
126
 
 
127
    // A superclass is definitely better.
 
128
    if (!Best || Best->hasSuperClass(X)) {
 
129
      Best = X;
 
130
      continue;
 
131
    }
 
132
 
 
133
    // A subclass is definitely worse
 
134
    if (Best->hasSubClass(X))
 
135
      continue;
 
136
 
 
137
    // Best and *I have no super/sub class relation - pick the larger class, or
 
138
    // the smaller spill size.
 
139
    int nb = std::distance(Best->begin(), Best->end());
 
140
    int ni = std::distance(X->begin(), X->end());
 
141
    if (ni>nb || (ni==nb && X->getSize() < Best->getSize()))
 
142
      Best = X;
 
143
  }
 
144
  return Best;
 
145
}