~ubuntu-branches/ubuntu/maverick/clamav/maverick-proposed

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/TableGen/CodeGenTarget.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-17 12:30:20 UTC
  • mfrom: (0.35.17 sid)
  • Revision ID: james.westby@ubuntu.com-20101217123020-dbtsp3upnaxsgg89
Tags: 0.96.5+dfsg-1ubuntu1.10.10.1
* Microversion update for Maverick (LP: #691414)
  - Improved database login times
  - Expanded use of new bytecode signatures
  - Other bugfixes/improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#ifndef CODEGEN_TARGET_H
18
18
#define CODEGEN_TARGET_H
19
19
 
20
 
#include "llvm/Support/raw_ostream.h"
21
20
#include "CodeGenRegisters.h"
22
21
#include "CodeGenInstruction.h"
 
22
#include "Record.h"
 
23
#include "llvm/Support/raw_ostream.h"
23
24
#include <algorithm>
24
 
#include <map>
25
25
 
26
26
namespace llvm {
27
27
 
28
 
class Record;
29
 
class RecordKeeper;
30
28
struct CodeGenRegister;
31
29
class CodeGenTarget;
32
30
 
43
41
  SDNPMayLoad,
44
42
  SDNPMayStore,
45
43
  SDNPSideEffect,
46
 
  SDNPMemOperand
 
44
  SDNPMemOperand,
 
45
  SDNPVariadic
47
46
};
48
47
 
49
48
/// getValueType - Return the MVT::SimpleValueType that the specified TableGen
62
61
class CodeGenTarget {
63
62
  Record *TargetRec;
64
63
 
65
 
  mutable std::map<std::string, CodeGenInstruction> Instructions;
 
64
  mutable DenseMap<const Record*, CodeGenInstruction*> Instructions;
66
65
  mutable std::vector<CodeGenRegister> Registers;
 
66
  mutable std::vector<Record*> SubRegIndices;
67
67
  mutable std::vector<CodeGenRegisterClass> RegisterClasses;
68
68
  mutable std::vector<MVT::SimpleValueType> LegalValueTypes;
69
69
  void ReadRegisters() const;
 
70
  void ReadSubRegIndices() const;
70
71
  void ReadRegisterClasses() const;
71
72
  void ReadInstructions() const;
72
73
  void ReadLegalValueTypes() const;
 
74
  
 
75
  mutable std::vector<const CodeGenInstruction*> InstrsByEnum;
73
76
public:
74
77
  CodeGenTarget();
75
78
 
97
100
    return Registers;
98
101
  }
99
102
 
 
103
  const std::vector<Record*> &getSubRegIndices() const {
 
104
    if (SubRegIndices.empty()) ReadSubRegIndices();
 
105
    return SubRegIndices;
 
106
  }
 
107
 
 
108
  // Map a SubRegIndex Record to its number.
 
109
  unsigned getSubRegIndexNo(Record *idx) const {
 
110
    if (SubRegIndices.empty()) ReadSubRegIndices();
 
111
    std::vector<Record*>::const_iterator i =
 
112
      std::find(SubRegIndices.begin(), SubRegIndices.end(), idx);
 
113
    assert(i != SubRegIndices.end() && "Not a SubRegIndex");
 
114
    return (i - SubRegIndices.begin()) + 1;
 
115
  }
 
116
 
100
117
  const std::vector<CodeGenRegisterClass> &getRegisterClasses() const {
101
118
    if (RegisterClasses.empty()) ReadRegisterClasses();
102
119
    return RegisterClasses;
103
120
  }
104
 
  
 
121
 
105
122
  const CodeGenRegisterClass &getRegisterClass(Record *R) const {
106
123
    const std::vector<CodeGenRegisterClass> &RC = getRegisterClasses();
107
124
    for (unsigned i = 0, e = RC.size(); i != e; ++i)
167
184
 
168
185
  /// getRegisterVTs - Find the union of all possible SimpleValueTypes for the
169
186
  /// specified physical register.
170
 
  std::vector<unsigned char> getRegisterVTs(Record *R) const;
 
187
  std::vector<MVT::SimpleValueType> getRegisterVTs(Record *R) const;
171
188
  
172
189
  const std::vector<MVT::SimpleValueType> &getLegalValueTypes() const {
173
190
    if (LegalValueTypes.empty()) ReadLegalValueTypes();
183
200
    return false;    
184
201
  }
185
202
 
186
 
  /// getInstructions - Return all of the instructions defined for this target.
187
 
  ///
188
 
  const std::map<std::string, CodeGenInstruction> &getInstructions() const {
189
 
    if (Instructions.empty()) ReadInstructions();
190
 
    return Instructions;
191
 
  }
192
 
  std::map<std::string, CodeGenInstruction> &getInstructions() {
193
 
    if (Instructions.empty()) ReadInstructions();
194
 
    return Instructions;
195
 
  }
196
 
 
197
 
  CodeGenInstruction &getInstruction(const std::string &Name) const {
198
 
    const std::map<std::string, CodeGenInstruction> &Insts = getInstructions();
199
 
    assert(Insts.count(Name) && "Not an instruction!");
200
 
    return const_cast<CodeGenInstruction&>(Insts.find(Name)->second);
201
 
  }
202
 
 
203
 
  typedef std::map<std::string,
204
 
                   CodeGenInstruction>::const_iterator inst_iterator;
205
 
  inst_iterator inst_begin() const { return getInstructions().begin(); }
206
 
  inst_iterator inst_end() const { return Instructions.end(); }
 
203
private:
 
204
  DenseMap<const Record*, CodeGenInstruction*> &getInstructions() const {
 
205
    if (Instructions.empty()) ReadInstructions();
 
206
    return Instructions;
 
207
  }
 
208
public:
 
209
  
 
210
  CodeGenInstruction &getInstruction(const Record *InstRec) const {
 
211
    if (Instructions.empty()) ReadInstructions();
 
212
    DenseMap<const Record*, CodeGenInstruction*>::iterator I =
 
213
      Instructions.find(InstRec);
 
214
    assert(I != Instructions.end() && "Not an instruction");
 
215
    return *I->second;
 
216
  }
207
217
 
208
218
  /// getInstructionsByEnumValue - Return all of the instructions defined by the
209
219
  /// target, ordered by their enum value.
210
 
  void getInstructionsByEnumValue(std::vector<const CodeGenInstruction*>
211
 
                                                &NumberedInstructions);
212
 
 
213
 
 
 
220
  const std::vector<const CodeGenInstruction*> &
 
221
  getInstructionsByEnumValue() const {
 
222
    if (InstrsByEnum.empty()) ComputeInstrsByEnum();
 
223
    return InstrsByEnum;
 
224
  }
 
225
 
 
226
  typedef std::vector<const CodeGenInstruction*>::const_iterator inst_iterator;
 
227
  inst_iterator inst_begin() const{return getInstructionsByEnumValue().begin();}
 
228
  inst_iterator inst_end() const { return getInstructionsByEnumValue().end(); }
 
229
  
 
230
  
214
231
  /// isLittleEndianEncoding - are instruction bit patterns defined as  [0..n]?
215
232
  ///
216
233
  bool isLittleEndianEncoding() const;
 
234
  
 
235
private:
 
236
  void ComputeInstrsByEnum() const;
217
237
};
218
238
 
219
239
/// ComplexPattern - ComplexPattern info, corresponding to the ComplexPattern