~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Target/ARM/ARMConstantPoolValue.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
//===- ARMConstantPoolValue.cpp - ARM constantpool value --------*- C++ -*-===//
 
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 ARM specific constantpool value class.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#include "ARMConstantPoolValue.h"
 
15
#include "llvm/ADT/FoldingSet.h"
 
16
#include "llvm/Constant.h"
 
17
#include "llvm/Constants.h"
 
18
#include "llvm/GlobalValue.h"
 
19
#include "llvm/Type.h"
 
20
#include "llvm/Support/raw_ostream.h"
 
21
#include <cstdlib>
 
22
using namespace llvm;
 
23
 
 
24
ARMConstantPoolValue::ARMConstantPoolValue(Constant *cval, unsigned id,
 
25
                                           ARMCP::ARMCPKind K,
 
26
                                           unsigned char PCAdj,
 
27
                                           const char *Modif,
 
28
                                           bool AddCA)
 
29
  : MachineConstantPoolValue((const Type*)cval->getType()),
 
30
    CVal(cval), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj),
 
31
    Modifier(Modif), AddCurrentAddress(AddCA) {}
 
32
 
 
33
ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
 
34
                                           const char *s, unsigned id,
 
35
                                           unsigned char PCAdj,
 
36
                                           const char *Modif,
 
37
                                           bool AddCA)
 
38
  : MachineConstantPoolValue((const Type*)Type::getInt32Ty(C)),
 
39
    CVal(NULL), S(strdup(s)), LabelId(id), Kind(ARMCP::CPExtSymbol),
 
40
    PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {}
 
41
 
 
42
ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, const char *Modif)
 
43
  : MachineConstantPoolValue((const Type*)Type::getInt32Ty(gv->getContext())),
 
44
    CVal(gv), S(NULL), LabelId(0), Kind(ARMCP::CPValue), PCAdjust(0),
 
45
    Modifier(Modif) {}
 
46
 
 
47
GlobalValue *ARMConstantPoolValue::getGV() const {
 
48
  return dyn_cast_or_null<GlobalValue>(CVal);
 
49
}
 
50
 
 
51
BlockAddress *ARMConstantPoolValue::getBlockAddress() const {
 
52
  return dyn_cast_or_null<BlockAddress>(CVal);
 
53
}
 
54
 
 
55
int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
 
56
                                                    unsigned Alignment) {
 
57
  unsigned AlignMask = Alignment - 1;
 
58
  const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
 
59
  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
 
60
    if (Constants[i].isMachineConstantPoolEntry() &&
 
61
        (Constants[i].getAlignment() & AlignMask) == 0) {
 
62
      ARMConstantPoolValue *CPV =
 
63
        (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
 
64
      if (CPV->CVal == CVal &&
 
65
          CPV->LabelId == LabelId &&
 
66
          CPV->PCAdjust == PCAdjust &&
 
67
          (CPV->S == S || strcmp(CPV->S, S) == 0) &&
 
68
          (CPV->Modifier == Modifier || strcmp(CPV->Modifier, Modifier) == 0))
 
69
        return i;
 
70
    }
 
71
  }
 
72
 
 
73
  return -1;
 
74
}
 
75
 
 
76
ARMConstantPoolValue::~ARMConstantPoolValue() {
 
77
  free((void*)S);
 
78
}
 
79
 
 
80
void
 
81
ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) {
 
82
  ID.AddPointer(CVal);
 
83
  ID.AddPointer(S);
 
84
  ID.AddInteger(LabelId);
 
85
  ID.AddInteger(PCAdjust);
 
86
}
 
87
 
 
88
bool
 
89
ARMConstantPoolValue::hasSameValue(ARMConstantPoolValue *ACPV) {
 
90
  if (ACPV->Kind == Kind &&
 
91
      ACPV->CVal == CVal &&
 
92
      ACPV->PCAdjust == PCAdjust &&
 
93
      (ACPV->S == S || strcmp(ACPV->S, S) == 0) &&
 
94
      (ACPV->Modifier == Modifier || strcmp(ACPV->Modifier, Modifier) == 0)) {
 
95
    if (ACPV->LabelId == LabelId)
 
96
      return true;
 
97
    // Two PC relative constpool entries containing the same GV address or
 
98
    // external symbols. FIXME: What about blockaddress?
 
99
    if (Kind == ARMCP::CPValue || Kind == ARMCP::CPExtSymbol)
 
100
      return true;
 
101
  }
 
102
  return false;
 
103
}
 
104
 
 
105
void ARMConstantPoolValue::dump() const {
 
106
  errs() << "  " << *this;
 
107
}
 
108
 
 
109
 
 
110
void ARMConstantPoolValue::print(raw_ostream &O) const {
 
111
  if (CVal)
 
112
    O << CVal->getName();
 
113
  else
 
114
    O << S;
 
115
  if (Modifier) O << "(" << Modifier << ")";
 
116
  if (PCAdjust != 0) {
 
117
    O << "-(LPC" << LabelId << "+" << (unsigned)PCAdjust;
 
118
    if (AddCurrentAddress) O << "-.";
 
119
    O << ")";
 
120
  }
 
121
}