[cfe-commits] r46779 - /cfe/trunk/CodeGen/CGStmt.cpp
Anders Carlsson
andersca at mac.com
Tue Feb 5 15:18:59 PST 2008
Author: andersca
Date: Tue Feb 5 17:18:57 2008
New Revision: 46779
URL: http://llvm.org/viewvc/llvm-project?rev=46779&view=rev
Log:
Improvements to inline asm code generation.
Modified:
cfe/trunk/CodeGen/CGStmt.cpp
Modified: cfe/trunk/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGStmt.cpp?rev=46779&r1=46778&r2=46779&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/CodeGen/CGStmt.cpp Tue Feb 5 17:18:57 2008
@@ -506,13 +506,30 @@
}
static inline std::string ConvertAsmString(const char *Start,
- unsigned NumOperands)
+ unsigned NumOperands,
+ bool IsSimple)
{
static unsigned AsmCounter = 0;
AsmCounter++;
std::string Result;
+ if (IsSimple) {
+ while (*Start) {
+ switch (*Start) {
+ default:
+ Result += *Start;
+ break;
+ case '$':
+ Result += "$$";
+ break;
+ }
+
+ Start++;
+ }
+
+ return Result;
+ }
while (*Start) {
switch (*Start) {
@@ -552,6 +569,21 @@
}
Result += '$' + llvm::utostr(n);
+ Start = End;
+ } else if (isalpha(EscapedChar)) {
+ char *End;
+
+ unsigned long n = strtoul(Start + 1, &End, 10);
+ if (Start == End) {
+ // FIXME: This should be caught during Sema.
+ assert(0 && "Missing operand!");
+ } else if (n >= NumOperands) {
+ // FIXME: This should be caught during Sema.
+ assert(0 && "Operand number out of range!");
+ }
+
+ Result += "${" + llvm::utostr(n) + ':' + EscapedChar + '}';
+ Start = End;
} else {
assert(0 && "Unhandled asm escaped character!");
}
@@ -591,7 +623,7 @@
std::string AsmString =
ConvertAsmString(std::string(S.getAsmString()->getStrData(),
S.getAsmString()->getByteLength()).c_str(),
- S.getNumOutputs() + S.getNumInputs());
+ S.getNumOutputs() + S.getNumInputs(), S.isSimple());
std::string Constraints;
More information about the cfe-commits
mailing list