summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-22 17:40:38 +0000
committerChris Lattner <sabre@nondot.org>2005-01-22 17:40:38 +0000
commit5765dba5ce9f493f063a7caf1106e7db9b6693b6 (patch)
tree09b96ea0fd3b1b64ef952f905cd7c99c31d12e94 /utils
parent741c11823091f88a3cd880aa5abbd9c3caa854e3 (diff)
downloadllvm-5765dba5ce9f493f063a7caf1106e7db9b6693b6.tar.gz
llvm-5765dba5ce9f493f063a7caf1106e7db9b6693b6.tar.bz2
llvm-5765dba5ce9f493f063a7caf1106e7db9b6693b6.tar.xz
Minor refactoring, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19753 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/AsmWriterEmitter.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp
index d44515fe2e..e9d33869c6 100644
--- a/utils/TableGen/AsmWriterEmitter.cpp
+++ b/utils/TableGen/AsmWriterEmitter.cpp
@@ -53,8 +53,9 @@ namespace {
struct AsmWriterInst {
std::vector<AsmWriterOperand> Operands;
+ const CodeGenInstruction *CGI;
- void ParseAsmString(const CodeGenInstruction &CGI, unsigned Variant);
+ AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant);
void EmitCode(std::ostream &OS) const {
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
Operands[i].EmitCode(OS);
@@ -84,8 +85,8 @@ void AsmWriterOperand::EmitCode(std::ostream &OS) const {
/// ParseAsmString - Parse the specified Instruction's AsmString into this
/// AsmWriterInst.
///
-void AsmWriterInst::ParseAsmString(const CodeGenInstruction &CGI,
- unsigned Variant) {
+AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
+ this->CGI = &CGI;
bool inVariant = false; // True if we are inside a {.|.|.} region.
const std::string &AsmString = CGI.AsmString;
@@ -152,10 +153,11 @@ void AsmWriterInst::ParseAsmString(const CodeGenInstruction &CGI,
throw "Stray '$' in '" + CGI.Name + "' asm string, maybe you want $$?";
unsigned OpNo = CGI.getOperandNamed(VarName);
+ CodeGenInstruction::OperandInfo OpInfo = CGI.OperandList[OpNo];
// If this is a two-address instruction and we are not accessing the
// 0th operand, remove an operand.
- unsigned MIOp = CGI.OperandList[OpNo].MIOperandNo;
+ unsigned MIOp = OpInfo.MIOperandNo;
if (CGI.isTwoAddress && MIOp != 0) {
if (MIOp == 1)
throw "Should refer to operand #0 instead of #1 for two-address"
@@ -163,8 +165,8 @@ void AsmWriterInst::ParseAsmString(const CodeGenInstruction &CGI,
--MIOp;
}
- Operands.push_back(AsmWriterOperand(CGI.OperandList[OpNo].PrinterMethodName,
- MIOp, CGI.OperandList[OpNo].Ty));
+ Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName,
+ MIOp, OpInfo.Ty));
LastEmitted = VarEnd;
}
}
@@ -193,17 +195,20 @@ void AsmWriterEmitter::run(std::ostream &O) {
std::string Namespace = Target.inst_begin()->second.Namespace;
+ std::vector<AsmWriterInst> Instructions;
+
for (CodeGenTarget::inst_iterator I = Target.inst_begin(),
E = Target.inst_end(); I != E; ++I)
- if (!I->second.AsmString.empty()) {
- O << " case " << Namespace << "::" << I->first << ": ";
-
- AsmWriterInst AWI;
- AWI.ParseAsmString(I->second, Variant);
- AWI.EmitCode(O);
- O << " break;\n";
- }
-
+ if (!I->second.AsmString.empty())
+ Instructions.push_back(AsmWriterInst(I->second, Variant));
+
+ for (unsigned i = 0, e = Instructions.size(); i != e; ++i) {
+ O << " case " << Namespace << "::"
+ << Instructions[i].CGI->Name << ": ";
+ Instructions[i].EmitCode(O);
+ O << " break;\n";
+ }
+
O << " }\n"
" return true;\n"
"}\n";