From: Anders Carlsson Date: Wed, 6 Feb 2008 00:11:32 +0000 (+0000) Subject: Even more inline asm codegen fixes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea041758d49215167e473a515b8d46e77b170ccf;p=clang Even more inline asm codegen fixes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46784 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Basic/TargetInfo.cpp b/Basic/TargetInfo.cpp index fc6976af41..e0a464219b 100644 --- a/Basic/TargetInfo.cpp +++ b/Basic/TargetInfo.cpp @@ -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; diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp index 557588e9ac..5ef8b96cbf 100644 --- a/CodeGen/CGStmt.cpp +++ b/CodeGen/CGStmt.cpp @@ -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