From 88ef728f2e36434618f1999e7999a5e751aca672 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 18 Jul 2014 23:30:30 +0000 Subject: [PATCH] [X86 inline-asm] Error out on inline-asm constraint "=f". llvm-svn: 213428 --- clang/lib/Basic/Targets.cpp | 8 +++++++- clang/test/Sema/asm.c | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 49e9444..fe72fe1 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -2927,6 +2927,13 @@ X86TargetInfo::validateAsmConstraint(const char *&Name, case 'm': // any MMX register, when inter-unit moves enabled. break; // falls through to setAllowsRegister. } + case 'f': // any x87 floating point stack register. + // Constraint 'f' cannot be used for output operands. + if (Info.ConstraintStr[0] == '=') + return false; + + Info.setAllowsRegister(); + return true; case 'a': // eax. case 'b': // ebx. case 'c': // ecx. @@ -2934,7 +2941,6 @@ X86TargetInfo::validateAsmConstraint(const char *&Name, case 'S': // esi. case 'D': // edi. case 'A': // edx:eax. - case 'f': // any x87 floating point stack register. case 't': // top of floating point stack. case 'u': // second from top of floating point stack. case 'q': // Any register accessible as [r]l: a, b, c, and d. diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c index 22b7497..89c8c57 100644 --- a/clang/test/Sema/asm.c +++ b/clang/test/Sema/asm.c @@ -157,3 +157,9 @@ struct foo { }; register struct foo bar asm("sp"); // expected-error {{bad type for named register variable}} register float baz asm("sp"); // expected-error {{bad type for named register variable}} + +double f_output_constraint(void) { + double result; + __asm("foo1": "=f" (result)); // expected-error {{invalid output constraint '=f' in asm}} + return result; +} -- 2.7.4