llvm.org GIT mirror llvm / 3e0cc26
wire up support for emitting "special" values from inline asm format strings with the standard ${:foo} syntax. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66527 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
3 changed file(s) with 27 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
175175 /// or other bits of target-specific knowledge into the asmstrings. The
176176 /// syntax used is ${:comment}. Targets can override this to add support
177177 /// for their own strange codes.
178 virtual void PrintSpecial(const MachineInstr *MI, const char *Code);
178 virtual void PrintSpecial(const MachineInstr *MI, const char *Code) const;
179179
180180 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
181181 /// instruction, using the specified assembler variant. Targets should
11841184 /// or other bits of target-specific knowledge into the asmstrings. The
11851185 /// syntax used is ${:comment}. Targets can override this to add support
11861186 /// for their own strange codes.
1187 void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
1187 void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) const {
11881188 if (!strcmp(Code, "private")) {
11891189 O << TAI->getPrivateGlobalPrefix();
11901190 } else if (!strcmp(Code, "comment")) {
13061306 HasCurlyBraces = true;
13071307 }
13081308
1309 // If we have ${:foo}, then this is not a real operand reference, it is a
1310 // "magic" string reference, just like in .td files. Arrange to call
1311 // PrintSpecial.
1312 if (HasCurlyBraces && *LastEmitted == ':') {
1313 ++LastEmitted;
1314 const char *StrStart = LastEmitted;
1315 const char *StrEnd = strchr(StrStart, '}');
1316 if (StrEnd == 0) {
1317 cerr << "Unterminated ${:foo} operand in inline asm string: '"
1318 << AsmStr << "'\n";
1319 exit(1);
1320 }
1321
1322 std::string Val(StrStart, StrEnd);
1323 PrintSpecial(MI, Val.c_str());
1324 LastEmitted = StrEnd+1;
1325 break;
1326 }
1327
13091328 const char *IDStart = LastEmitted;
13101329 char *IDEnd;
13111330 errno = 0;
0 ; RUN: llvm-as < %s | llc | grep "foo 0 0"
1
2 define void @bar() nounwind {
3 tail call void asm sideeffect "foo ${:uid} ${:uid}", ""() nounwind
4 ret void
5 }