]> granicus.if.org Git - clang/commitdiff
Even more inline asm codegen fixes.
authorAnders Carlsson <andersca@mac.com>
Wed, 6 Feb 2008 00:11:32 +0000 (00:11 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 6 Feb 2008 00:11:32 +0000 (00:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46784 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/TargetInfo.cpp
CodeGen/CGStmt.cpp

index fc6976af41fd5c3bd7cd0e39f9457a73d262e0a2..e0a464219b44f3474144fa6a1aff3e67f1308d5c 100644 (file)
@@ -276,6 +276,12 @@ const char *TargetInfo::getVAListDeclaration() const {
   return PrimaryTarget->getVAListDeclaration();
 }
 
+static void removeGCCRegisterPrefix(const char *&Name)
+{
+  if (Name[0] == '%' || Name[0] == '#')
+    Name++;
+}
+
 /// isValidGCCRegisterName - Returns whether the passed in string
 /// is a valid register name according to GCC. This is used by Sema for
 /// inline asm statements.
@@ -284,8 +290,8 @@ bool TargetInfo::isValidGCCRegisterName(const char *Name) const {
   unsigned NumNames;
   
   // Get rid of any register prefix.
-  if (Name[0] == '%' || Name[0] == '#')
-    Name++;
+  removeGCCRegisterPrefix(Name);
+
   
   if (strcmp(Name, "memory") == 0 ||
       strcmp(Name, "cc") == 0)
@@ -328,8 +334,7 @@ const char *TargetInfo::getNormalizedGCCRegisterName(const char *Name) const
 {
   assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
   
-  if (strcmp(Name, "memory") == 0)
-    return "~{memory}";
+  removeGCCRegisterPrefix(Name);
     
   const char * const *Names;
   unsigned NumNames;
index 557588e9ac457cc29ae653b62e71a4ec5c91f099..5ef8b96cbf477ec301e574116b206293f2f61117 100644 (file)
@@ -749,9 +749,12 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
 
     Clobber = Target.getNormalizedGCCRegisterName(Clobber.c_str());
     
-    if (i != 0)
+    if (i != 0 || NumConstraints != 0)
       Constraints += ',';
+    
+    Constraints += "~{";
     Constraints += Clobber;
+    Constraints += '}';
   }
   
   // Add machine specific clobbers