Even more inline asm codegen fixes.

llvm-svn: 46784
This commit is contained in:
Anders Carlsson 2008-02-06 00:11:32 +00:00
parent 3399bb424c
commit 3ed4aea198
2 changed files with 13 additions and 5 deletions

View 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;

View 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