62
61
class CodeGenTarget {
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;
75
mutable std::vector<const CodeGenInstruction*> InstrsByEnum;
103
const std::vector<Record*> &getSubRegIndices() const {
104
if (SubRegIndices.empty()) ReadSubRegIndices();
105
return SubRegIndices;
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;
100
117
const std::vector<CodeGenRegisterClass> &getRegisterClasses() const {
101
118
if (RegisterClasses.empty()) ReadRegisterClasses();
102
119
return RegisterClasses;
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)
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;
172
189
const std::vector<MVT::SimpleValueType> &getLegalValueTypes() const {
173
190
if (LegalValueTypes.empty()) ReadLegalValueTypes();
186
/// getInstructions - Return all of the instructions defined for this target.
188
const std::map<std::string, CodeGenInstruction> &getInstructions() const {
189
if (Instructions.empty()) ReadInstructions();
192
std::map<std::string, CodeGenInstruction> &getInstructions() {
193
if (Instructions.empty()) ReadInstructions();
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);
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(); }
204
DenseMap<const Record*, CodeGenInstruction*> &getInstructions() const {
205
if (Instructions.empty()) ReadInstructions();
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");
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);
220
const std::vector<const CodeGenInstruction*> &
221
getInstructionsByEnumValue() const {
222
if (InstrsByEnum.empty()) ComputeInstrsByEnum();
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(); }
214
231
/// isLittleEndianEncoding - are instruction bit patterns defined as [0..n]?
216
233
bool isLittleEndianEncoding() const;
236
void ComputeInstrsByEnum() const;
219
239
/// ComplexPattern - ComplexPattern info, corresponding to the ComplexPattern