diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-10 05:37:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-10 05:37:13 +0000 |
commit | 1522e2498fc88671170726d5a9a27448c856548f (patch) | |
tree | 86581201c91a322b682399b82180dba1f589a759 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | |
parent | b4947e4378fee65ba0d7410da03ab9f185e56074 (diff) | |
download | bcm5719-llvm-1522e2498fc88671170726d5a9a27448c856548f.tar.gz bcm5719-llvm-1522e2498fc88671170726d5a9a27448c856548f.zip |
wire up support for emitting "special" values from inline asm
format strings with the standard ${:foo} syntax.
llvm-svn: 66527
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 0e04a16c86a..2a3a8bb32d2 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1185,7 +1185,7 @@ void AsmPrinter::EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) { /// 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) { +void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) const { if (!strcmp(Code, "private")) { O << TAI->getPrivateGlobalPrefix(); } else if (!strcmp(Code, "comment")) { @@ -1307,6 +1307,25 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { HasCurlyBraces = true; } + // If we have ${:foo}, then this is not a real operand reference, it is a + // "magic" string reference, just like in .td files. Arrange to call + // PrintSpecial. + if (HasCurlyBraces && *LastEmitted == ':') { + ++LastEmitted; + const char *StrStart = LastEmitted; + const char *StrEnd = strchr(StrStart, '}'); + if (StrEnd == 0) { + cerr << "Unterminated ${:foo} operand in inline asm string: '" + << AsmStr << "'\n"; + exit(1); + } + + std::string Val(StrStart, StrEnd); + PrintSpecial(MI, Val.c_str()); + LastEmitted = StrEnd+1; + break; + } + const char *IDStart = LastEmitted; char *IDEnd; errno = 0; |