aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-10 06:38:02 +0000
committerChris Lattner <sabre@nondot.org>2009-03-10 06:38:02 +0000
commit02af974dca0f855dc36d8a8c26bb87f373310815 (patch)
tree229215599fa18bea3e47b812c680cc953ec2f861 /lib/CodeGen
parent10ca96ae9aed6906c3302403ef1a146a8d4c6b74 (diff)
reduce duplication of parsing code between %0 and %x0 and
add support for modifiers on named references, like %c[foo]. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66532 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGStmt.cpp37
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 93c4f5b07d..1aa62e7e03 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -739,31 +739,27 @@ static std::string ConvertAsmString(const AsmStmt& S, bool &Failed) {
continue;
}
+ // Handle %x4 and %x[foo] by capturing x as the modifier character.
+ char Modifier = '\0';
+ if (isalpha(EscapedChar)) {
+ Modifier = EscapedChar;
+ EscapedChar = *StrStart++;
+ }
+
if (isdigit(EscapedChar)) {
// %n - Assembler operand n
char *End;
unsigned long N = strtoul(StrStart-1, &End, 10);
assert(End != StrStart-1 && "We know that EscapedChar is a digit!");
-
- // FIXME: This should be caught during Sema.
- assert(N < NumOperands && "Operand number out of range!");
-
- Result += '$' + llvm::utostr(N);
StrStart = End;
- continue;
- }
-
- if (isalpha(EscapedChar)) {
- char *End;
- // Skip the single letter escape and read the number, e.g. "%x4".
- unsigned long N = strtoul(StrStart, &End, 10);
- // FIXME: This should be caught during Sema.
- assert(End != StrStart && "Missing operand!");
+
// FIXME: This should be caught during Sema.
assert(N < NumOperands && "Operand number out of range!");
- Result += "${" + llvm::utostr(N) + ':' + EscapedChar + '}';
- StrStart = End;
+ if (Modifier == '\0')
+ Result += '$' + llvm::utostr(N);
+ else
+ Result += "${" + llvm::utostr(N) + ':' + Modifier + '}';
continue;
}
@@ -776,10 +772,13 @@ static std::string ConvertAsmString(const AsmStmt& S, bool &Failed) {
std::string SymbolicName(StrStart, NameEnd);
StrStart = NameEnd+1;
- int OperandIndex = S.getNamedOperand(SymbolicName);
- assert(OperandIndex != -1 && "FIXME: Catch in Sema.");
+ int N = S.getNamedOperand(SymbolicName);
+ assert(N != -1 && "FIXME: Catch in Sema.");
- Result += '$' + llvm::utostr(unsigned(OperandIndex));
+ if (Modifier == '\0')
+ Result += '$' + llvm::utostr(N);
+ else
+ Result += "${" + llvm::utostr(N) + ':' + Modifier + '}';
continue;
}