aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/AsmPrinter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-26 23:59:50 +0000
committerChris Lattner <sabre@nondot.org>2006-09-26 23:59:50 +0000
commit3ce9b67e0c0f171c6d09c19407930ce6989f1b9d (patch)
tree4441d4ed2e9d4efbcd0b093e7c0e8aeb3472ea42 /lib/CodeGen/AsmPrinter.cpp
parent16f046a6cee08981084dc4339ceaf76b2e291b4c (diff)
Add support for ${:comment}, which expands to the current target's comment
character, and ${:uid} which expands to a unique ID for the MachineInstr. More can be added if/when they are needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30619 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter.cpp')
-rw-r--r--lib/CodeGen/AsmPrinter.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index bfc0519806..518aec3348 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -619,6 +619,30 @@ AsmPrinter::EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
abort();
}
+/// PrintSpecial - Print information related to the specified machine instr
+/// that is independent of the operand, and may be independent of the instr
+/// itself. This can be useful for portably encoding the comment character
+/// or other bits of target-specific knowledge into the asmstrings. The
+/// syntax used is ${:comment}. Targets can override this to add support
+/// for their own strange codes.
+void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
+ if (!strcmp(Code, "comment")) {
+ O << TAI->getCommentString();
+ } else if (!strcmp(Code, "uid")) {
+ // Assign a unique ID to this machine instruction.
+ static const MachineInstr *LastMI = 0;
+ static unsigned Counter = 0U-1;
+ // If this is a new machine instruction, bump the counter.
+ if (LastMI != MI) { ++Counter; LastMI = MI; }
+ O << Counter;
+ } else {
+ std::cerr << "Unknown special formatter '" << Code
+ << "' for machine instr: " << *MI;
+ exit(1);
+ }
+}
+
+
/// printInlineAsm - This method formats and prints the specified machine
/// instruction that is an inline asm.
void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {