~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Bitcode/Writer/ValueEnumerator.h

  • 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
//===-- Bitcode/Writer/ValueEnumerator.h - Number values --------*- 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 class gives values and types Unique ID's.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef VALUE_ENUMERATOR_H
 
15
#define VALUE_ENUMERATOR_H
 
16
 
 
17
#include "llvm/ADT/DenseMap.h"
 
18
#include "llvm/Attributes.h"
 
19
#include <vector>
 
20
 
 
21
namespace llvm {
 
22
 
 
23
class Type;
 
24
class Value;
 
25
class Instruction;
 
26
class BasicBlock;
 
27
class Function;
 
28
class Module;
 
29
class MetadataBase;
 
30
class NamedMDNode;
 
31
class AttrListPtr;
 
32
class TypeSymbolTable;
 
33
class ValueSymbolTable;
 
34
class MDSymbolTable;
 
35
 
 
36
class ValueEnumerator {
 
37
public:
 
38
  // For each type, we remember its Type* and occurrence frequency.
 
39
  typedef std::vector<std::pair<const Type*, unsigned> > TypeList;
 
40
 
 
41
  // For each value, we remember its Value* and occurrence frequency.
 
42
  typedef std::vector<std::pair<const Value*, unsigned> > ValueList;
 
43
private:
 
44
  typedef DenseMap<const Type*, unsigned> TypeMapType;
 
45
  TypeMapType TypeMap;
 
46
  TypeList Types;
 
47
 
 
48
  typedef DenseMap<const Value*, unsigned> ValueMapType;
 
49
  ValueMapType ValueMap;
 
50
  ValueList Values;
 
51
  ValueList MDValues;
 
52
  ValueMapType MDValueMap;
 
53
  
 
54
  typedef DenseMap<void*, unsigned> AttributeMapType;
 
55
  AttributeMapType AttributeMap;
 
56
  std::vector<AttrListPtr> Attributes;
 
57
  
 
58
  /// GlobalBasicBlockIDs - This map memoizes the basic block ID's referenced by
 
59
  /// the "getGlobalBasicBlockID" method.
 
60
  mutable DenseMap<const BasicBlock*, unsigned> GlobalBasicBlockIDs;
 
61
  
 
62
  typedef DenseMap<const Instruction*, unsigned> InstructionMapType;
 
63
  InstructionMapType InstructionMap;
 
64
  unsigned InstructionCount;
 
65
 
 
66
  /// BasicBlocks - This contains all the basic blocks for the currently
 
67
  /// incorporated function.  Their reverse mapping is stored in ValueMap.
 
68
  std::vector<const BasicBlock*> BasicBlocks;
 
69
  
 
70
  /// When a function is incorporated, this is the size of the Values list
 
71
  /// before incorporation.
 
72
  unsigned NumModuleValues;
 
73
  unsigned FirstFuncConstantID;
 
74
  unsigned FirstInstID;
 
75
  
 
76
  ValueEnumerator(const ValueEnumerator &);  // DO NOT IMPLEMENT
 
77
  void operator=(const ValueEnumerator &);   // DO NOT IMPLEMENT
 
78
public:
 
79
  ValueEnumerator(const Module *M);
 
80
 
 
81
  unsigned getValueID(const Value *V) const;
 
82
 
 
83
  unsigned getTypeID(const Type *T) const {
 
84
    TypeMapType::const_iterator I = TypeMap.find(T);
 
85
    assert(I != TypeMap.end() && "Type not in ValueEnumerator!");
 
86
    return I->second-1;
 
87
  }
 
88
 
 
89
  unsigned getInstructionID(const Instruction *I) const;
 
90
  void setInstructionID(const Instruction *I);
 
91
 
 
92
  unsigned getAttributeID(const AttrListPtr &PAL) const {
 
93
    if (PAL.isEmpty()) return 0;  // Null maps to zero.
 
94
    AttributeMapType::const_iterator I = AttributeMap.find(PAL.getRawPointer());
 
95
    assert(I != AttributeMap.end() && "Attribute not in ValueEnumerator!");
 
96
    return I->second;
 
97
  }
 
98
 
 
99
  /// getFunctionConstantRange - Return the range of values that corresponds to
 
100
  /// function-local constants.
 
101
  void getFunctionConstantRange(unsigned &Start, unsigned &End) const {
 
102
    Start = FirstFuncConstantID;
 
103
    End = FirstInstID;
 
104
  }
 
105
  
 
106
  const ValueList &getValues() const { return Values; }
 
107
  const ValueList &getMDValues() const { return MDValues; }
 
108
  const TypeList &getTypes() const { return Types; }
 
109
  const std::vector<const BasicBlock*> &getBasicBlocks() const {
 
110
    return BasicBlocks; 
 
111
  }
 
112
  const std::vector<AttrListPtr> &getAttributes() const {
 
113
    return Attributes;
 
114
  }
 
115
  
 
116
  /// getGlobalBasicBlockID - This returns the function-specific ID for the
 
117
  /// specified basic block.  This is relatively expensive information, so it
 
118
  /// should only be used by rare constructs such as address-of-label.
 
119
  unsigned getGlobalBasicBlockID(const BasicBlock *BB) const;
 
120
 
 
121
  /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
 
122
  /// use these two methods to get its data into the ValueEnumerator!
 
123
  ///
 
124
  void incorporateFunction(const Function &F);
 
125
  void purgeFunction();
 
126
 
 
127
private:
 
128
  void OptimizeConstants(unsigned CstStart, unsigned CstEnd);
 
129
    
 
130
  void EnumerateMetadata(const Value *MD);
 
131
  void EnumerateNamedMDNode(const NamedMDNode *NMD);
 
132
  void EnumerateValue(const Value *V);
 
133
  void EnumerateType(const Type *T);
 
134
  void EnumerateOperandType(const Value *V);
 
135
  void EnumerateAttributes(const AttrListPtr &PAL);
 
136
  
 
137
  void EnumerateTypeSymbolTable(const TypeSymbolTable &ST);
 
138
  void EnumerateValueSymbolTable(const ValueSymbolTable &ST);
 
139
  void EnumerateMDSymbolTable(const MDSymbolTable &ST);
 
140
};
 
141
 
 
142
} // End llvm namespace
 
143
 
 
144
#endif