diff options
author | David Greene <greened@obbligato.org> | 2009-07-13 20:25:48 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2009-07-13 20:25:48 +0000 |
commit | 014700c1a8cba203fd21ff129426ba8a426ab244 (patch) | |
tree | 0459af1b54ae0b03b14896eb77b53801d40d4997 /utils/TableGen | |
parent | b8ac841c9a275cc8d4e1a92dd06cc99323e35fa2 (diff) | |
download | external_llvm-014700c1a8cba203fd21ff129426ba8a426ab244.zip external_llvm-014700c1a8cba203fd21ff129426ba8a426ab244.tar.gz external_llvm-014700c1a8cba203fd21ff129426ba8a426ab244.tar.bz2 |
Add infrastructure to allow post instruction printing action triggers.
We'll eventually use this to print comments in asm files and do other
fun things.
This adds interfaces to the AsmPrinter and changes TableGen to invoke
the postInstructionAction when appropriate. It also add parameters to
TargetAsmInfo to control comment layout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r-- | utils/TableGen/AsmWriterEmitter.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp index f34feef..92ad96e 100644 --- a/utils/TableGen/AsmWriterEmitter.cpp +++ b/utils/TableGen/AsmWriterEmitter.cpp @@ -259,8 +259,6 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) { LastEmitted = VarEnd; } } - - AddLiteralString("\\n"); } /// MatchesAllButOneOp - If this instruction is exactly identical to the @@ -357,7 +355,6 @@ static void EmitInstructions(std::vector<AsmWriterInst> &Insts, } O << "\n"; } - O << " break;\n"; } @@ -385,8 +382,12 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands, Command = " " + Inst->Operands[0].getCode() + "\n"; // If this is the last operand, emit a return. - if (Inst->Operands.size() == 1) + if (Inst->Operands.size() == 1) { + Command += " postInstructionAction(*MI);\n"; + // Print the final newline + Command += " O << \"\\n\";\n"; Command += " return true;\n"; + } // Check to see if we already have 'Command' in UniqueOperandCommands. // If not, add it. @@ -452,8 +453,12 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands, std::string Command = " " + FirstInst->Operands[Op].getCode() + "\n"; // If this is the last operand, emit a return after the code. - if (FirstInst->Operands.size() == Op+1) + if (FirstInst->Operands.size() == Op+1) { + Command += " postInstructionAction(*MI);\n"; + // Print the final newline + Command += " O << \"\\n\";\n"; Command += " return true;\n"; + } UniqueOperandCommands[CommandIdx] += Command; InstOpsUsed[CommandIdx]++; @@ -564,10 +569,11 @@ void AsmWriterEmitter::run(raw_ostream &O) { // For the first operand check, add a default value for instructions with // just opcode strings to use. if (isFirst) { - UniqueOperandCommands.push_back(" return true;\n"); + // Do the post instruction processing and print the final newline + UniqueOperandCommands.push_back(" postInstructionAction(*MI);\n O << \"\\n\";\n return true;\n"); isFirst = false; } - + std::vector<unsigned> InstIdxs; std::vector<unsigned> NumInstOpsHandled; FindUniqueOperandCommands(UniqueOperandCommands, InstIdxs, @@ -739,6 +745,9 @@ void AsmWriterEmitter::run(raw_ostream &O) { EmitInstructions(Instructions, O); O << " }\n"; + O << " postInstructionAction(*MI);\n"; + // Print the final newline + O << " O << \"\\n\";\n"; O << " return true;\n"; } |