diff options
author | Anders Carlsson <andersca@mac.com> | 2008-02-06 00:11:32 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-02-06 00:11:32 +0000 |
commit | ea041758d49215167e473a515b8d46e77b170ccf (patch) | |
tree | d50e162be9abe125970be117e34308e9b733de47 | |
parent | 4efe45919836728a2a38a50b8d79cd36432e1708 (diff) |
Even more inline asm codegen fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46784 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Basic/TargetInfo.cpp | 13 | ||||
-rw-r--r-- | CodeGen/CGStmt.cpp | 5 |
2 files changed, 13 insertions, 5 deletions
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 |