summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-04-17 22:24:13 +0000
committerChris Lattner <sabre@nondot.org>2011-04-17 22:24:13 +0000
commita90dbc133f7bc7bf0e042fb03222bfdfafce3965 (patch)
tree3fa15c65f23e444bb7887d95fa1002a0855c2e12 /utils
parent4447d6506cdae78037226ef52c0824a42cf6baa6 (diff)
downloadllvm-a90dbc133f7bc7bf0e042fb03222bfdfafce3965.tar.gz
llvm-a90dbc133f7bc7bf0e042fb03222bfdfafce3965.tar.bz2
llvm-a90dbc133f7bc7bf0e042fb03222bfdfafce3965.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/CodeGenInstruction.h1
-rw-r--r--utils/TableGen/FastISelEmitter.cpp32
2 files changed, 17 insertions, 16 deletions
diff --git a/utils/TableGen/CodeGenInstruction.h b/utils/TableGen/CodeGenInstruction.h
index 6d2d8fba0c..5f1e0bea76 100644
--- a/utils/TableGen/CodeGenInstruction.h
+++ b/utils/TableGen/CodeGenInstruction.h
@@ -137,6 +137,7 @@ namespace llvm {
bool isVariadic;
// Provide transparent accessors to the operand list.
+ bool empty() const { return OperandList.empty(); }
unsigned size() const { return OperandList.size(); }
const OperandInfo &operator[](unsigned i) const { return OperandList[i]; }
OperandInfo &operator[](unsigned i) { return OperandList[i]; }
diff --git a/utils/TableGen/FastISelEmitter.cpp b/utils/TableGen/FastISelEmitter.cpp
index 8e04e40c0a..62ac64d8c1 100644
--- a/utils/TableGen/FastISelEmitter.cpp
+++ b/utils/TableGen/FastISelEmitter.cpp
@@ -40,7 +40,7 @@ struct InstructionMemo {
/// types. It has utility methods for emitting text based on the operands.
///
struct OperandsSignature {
- std::vector<std::string> Operands;
+ SmallVector<char, 3> Operands;
bool operator<(const OperandsSignature &O) const {
return Operands < O.Operands;
@@ -57,11 +57,11 @@ struct OperandsSignature {
if (!InstPatNode->isLeaf()) {
if (InstPatNode->getOperator()->getName() == "imm") {
- Operands.push_back("i");
+ Operands.push_back('i');
return true;
}
if (InstPatNode->getOperator()->getName() == "fpimm") {
- Operands.push_back("f");
+ Operands.push_back('f');
return true;
}
}
@@ -78,11 +78,11 @@ struct OperandsSignature {
if (!Op->isLeaf()) {
if (Op->getOperator()->getName() == "imm") {
- Operands.push_back("i");
+ Operands.push_back('i');
continue;
}
if (Op->getOperator()->getName() == "fpimm") {
- Operands.push_back("f");
+ Operands.push_back('f');
continue;
}
// For now, ignore other non-leaf nodes.
@@ -122,18 +122,18 @@ struct OperandsSignature {
return false;
} else
DstRC = RC;
- Operands.push_back("r");
+ Operands.push_back('r');
}
return true;
}
void PrintParameters(raw_ostream &OS) const {
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";
- } else if (Operands[i] == "i") {
+ } else if (Operands[i] == 'i') {
OS << "uint64_t imm" << i;
- } else if (Operands[i] == "f") {
+ } else if (Operands[i] == 'f') {
OS << "ConstantFP *f" << i;
} else {
assert("Unknown operand kind!");
@@ -155,13 +155,13 @@ struct OperandsSignature {
if (PrintedArg)
OS << ", ";
- if (Operands[i] == "r") {
+ if (Operands[i] == 'r') {
OS << "Op" << i << ", Op" << i << "IsKill";
PrintedArg = true;
- } else if (Operands[i] == "i") {
+ } else if (Operands[i] == 'i') {
OS << "imm" << i;
PrintedArg = true;
- } else if (Operands[i] == "f") {
+ } else if (Operands[i] == 'f') {
OS << "f" << i;
PrintedArg = true;
} else {
@@ -173,11 +173,11 @@ struct OperandsSignature {
void PrintArguments(raw_ostream &OS) const {
for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
- if (Operands[i] == "r") {
+ if (Operands[i] == 'r') {
OS << "Op" << i << ", Op" << i << "IsKill";
- } else if (Operands[i] == "i") {
+ } else if (Operands[i] == 'i') {
OS << "imm" << i;
- } else if (Operands[i] == "f") {
+ } else if (Operands[i] == 'f') {
OS << "f" << i;
} else {
assert("Unknown operand kind!");
@@ -266,7 +266,7 @@ void FastISelMap::CollectPatterns(CodeGenDAGPatterns &CGP) {
if (!Op->isSubClassOf("Instruction"))
continue;
CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);
- if (II.Operands.size() == 0)
+ if (II.Operands.empty())
continue;
// For now, ignore multi-instruction patterns.