forked from OSchip/llvm-project
change OperandsSignature to use SmallVector<char> instead of std::vector<string>
since the strings are always exactly one character, and there are usually only 2-3 operands. llvm-svn: 129678
This commit is contained in:
parent
0d7a5a7daa
commit
9080391b55
|
@ -137,6 +137,7 @@ namespace llvm {
|
||||||
bool isVariadic;
|
bool isVariadic;
|
||||||
|
|
||||||
// Provide transparent accessors to the operand list.
|
// Provide transparent accessors to the operand list.
|
||||||
|
bool empty() const { return OperandList.empty(); }
|
||||||
unsigned size() const { return OperandList.size(); }
|
unsigned size() const { return OperandList.size(); }
|
||||||
const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
|
const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
|
||||||
OperandInfo &operator[](unsigned i) { return OperandList[i]; }
|
OperandInfo &operator[](unsigned i) { return OperandList[i]; }
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct InstructionMemo {
|
||||||
/// types. It has utility methods for emitting text based on the operands.
|
/// types. It has utility methods for emitting text based on the operands.
|
||||||
///
|
///
|
||||||
struct OperandsSignature {
|
struct OperandsSignature {
|
||||||
std::vector<std::string> Operands;
|
SmallVector<char, 3> Operands;
|
||||||
|
|
||||||
bool operator<(const OperandsSignature &O) const {
|
bool operator<(const OperandsSignature &O) const {
|
||||||
return Operands < O.Operands;
|
return Operands < O.Operands;
|
||||||
|
@ -57,11 +57,11 @@ struct OperandsSignature {
|
||||||
|
|
||||||
if (!InstPatNode->isLeaf()) {
|
if (!InstPatNode->isLeaf()) {
|
||||||
if (InstPatNode->getOperator()->getName() == "imm") {
|
if (InstPatNode->getOperator()->getName() == "imm") {
|
||||||
Operands.push_back("i");
|
Operands.push_back('i');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (InstPatNode->getOperator()->getName() == "fpimm") {
|
if (InstPatNode->getOperator()->getName() == "fpimm") {
|
||||||
Operands.push_back("f");
|
Operands.push_back('f');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,11 @@ struct OperandsSignature {
|
||||||
|
|
||||||
if (!Op->isLeaf()) {
|
if (!Op->isLeaf()) {
|
||||||
if (Op->getOperator()->getName() == "imm") {
|
if (Op->getOperator()->getName() == "imm") {
|
||||||
Operands.push_back("i");
|
Operands.push_back('i');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Op->getOperator()->getName() == "fpimm") {
|
if (Op->getOperator()->getName() == "fpimm") {
|
||||||
Operands.push_back("f");
|
Operands.push_back('f');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// For now, ignore other non-leaf nodes.
|
// For now, ignore other non-leaf nodes.
|
||||||
|
@ -122,18 +122,18 @@ struct OperandsSignature {
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
DstRC = RC;
|
DstRC = RC;
|
||||||
Operands.push_back("r");
|
Operands.push_back('r');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintParameters(raw_ostream &OS) const {
|
void PrintParameters(raw_ostream &OS) const {
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
|
||||||
if (Operands[i] == "r") {
|
if (Operands[i] == 'r') {
|
||||||
OS << "unsigned Op" << i << ", bool Op" << i << "IsKill";
|
OS << "unsigned Op" << i << ", bool Op" << i << "IsKill";
|
||||||
} else if (Operands[i] == "i") {
|
} else if (Operands[i] == 'i') {
|
||||||
OS << "uint64_t imm" << i;
|
OS << "uint64_t imm" << i;
|
||||||
} else if (Operands[i] == "f") {
|
} else if (Operands[i] == 'f') {
|
||||||
OS << "ConstantFP *f" << i;
|
OS << "ConstantFP *f" << i;
|
||||||
} else {
|
} else {
|
||||||
assert("Unknown operand kind!");
|
assert("Unknown operand kind!");
|
||||||
|
@ -155,13 +155,13 @@ struct OperandsSignature {
|
||||||
|
|
||||||
if (PrintedArg)
|
if (PrintedArg)
|
||||||
OS << ", ";
|
OS << ", ";
|
||||||
if (Operands[i] == "r") {
|
if (Operands[i] == 'r') {
|
||||||
OS << "Op" << i << ", Op" << i << "IsKill";
|
OS << "Op" << i << ", Op" << i << "IsKill";
|
||||||
PrintedArg = true;
|
PrintedArg = true;
|
||||||
} else if (Operands[i] == "i") {
|
} else if (Operands[i] == 'i') {
|
||||||
OS << "imm" << i;
|
OS << "imm" << i;
|
||||||
PrintedArg = true;
|
PrintedArg = true;
|
||||||
} else if (Operands[i] == "f") {
|
} else if (Operands[i] == 'f') {
|
||||||
OS << "f" << i;
|
OS << "f" << i;
|
||||||
PrintedArg = true;
|
PrintedArg = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -173,11 +173,11 @@ struct OperandsSignature {
|
||||||
|
|
||||||
void PrintArguments(raw_ostream &OS) const {
|
void PrintArguments(raw_ostream &OS) const {
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
|
||||||
if (Operands[i] == "r") {
|
if (Operands[i] == 'r') {
|
||||||
OS << "Op" << i << ", Op" << i << "IsKill";
|
OS << "Op" << i << ", Op" << i << "IsKill";
|
||||||
} else if (Operands[i] == "i") {
|
} else if (Operands[i] == 'i') {
|
||||||
OS << "imm" << i;
|
OS << "imm" << i;
|
||||||
} else if (Operands[i] == "f") {
|
} else if (Operands[i] == 'f') {
|
||||||
OS << "f" << i;
|
OS << "f" << i;
|
||||||
} else {
|
} else {
|
||||||
assert("Unknown operand kind!");
|
assert("Unknown operand kind!");
|
||||||
|
@ -266,7 +266,7 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
|
||||||
if (!Op->isSubClassOf("Instruction"))
|
if (!Op->isSubClassOf("Instruction"))
|
||||||
continue;
|
continue;
|
||||||
CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);
|
CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);
|
||||||
if (II.Operands.size() == 0)
|
if (II.Operands.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// For now, ignore multi-instruction patterns.
|
// For now, ignore multi-instruction patterns.
|
||||||
|
|
Loading…
Reference in New Issue