mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
Add support for escaping {} in asm strings, based on patch from Nick Burns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48450 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
315123fb6a
commit
817affccd5
@ -122,7 +122,7 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
||||
std::string::size_type LastEmitted = 0;
|
||||
while (LastEmitted != AsmString.size()) {
|
||||
std::string::size_type DollarPos =
|
||||
AsmString.find_first_of("${|}", LastEmitted);
|
||||
AsmString.find_first_of("${|}\\", LastEmitted);
|
||||
if (DollarPos == std::string::npos) DollarPos = AsmString.size();
|
||||
|
||||
// Emit a constant string fragment.
|
||||
@ -132,6 +132,23 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
||||
AddLiteralString(std::string(AsmString.begin()+LastEmitted,
|
||||
AsmString.begin()+DollarPos));
|
||||
LastEmitted = DollarPos;
|
||||
} else if (AsmString[DollarPos] == '\\') {
|
||||
if (DollarPos+1 != AsmString.size() &&
|
||||
(CurVariant == Variant || CurVariant == ~0U)) {
|
||||
if (AsmString[DollarPos+1] == 'n') {
|
||||
AddLiteralString("\\n");
|
||||
} else if (AsmString[DollarPos+1] == 't') {
|
||||
AddLiteralString("\\t");
|
||||
} else if (std::string("${|}\\").find(AsmString[DollarPos+1])
|
||||
!= std::string::npos) {
|
||||
AddLiteralString(std::string(1, AsmString[DollarPos+1]));
|
||||
} else {
|
||||
throw "Non-supported escaped character found in instruction '" +
|
||||
CGI.TheDef->getName() + "'!";
|
||||
}
|
||||
LastEmitted = DollarPos+2;
|
||||
continue;
|
||||
}
|
||||
} else if (AsmString[DollarPos] == '{') {
|
||||
if (CurVariant != ~0U)
|
||||
throw "Nested variants found for instruction '" +
|
||||
|
Loading…
x
Reference in New Issue
Block a user