]> granicus.if.org Git - clang/commitdiff
[driver, ms-inline asm] MS-Style inline assembly is controlled by the
authorChad Rosier <mcrosier@apple.com>
Wed, 5 Dec 2012 21:08:21 +0000 (21:08 +0000)
committerChad Rosier <mcrosier@apple.com>
Wed, 5 Dec 2012 21:08:21 +0000 (21:08 +0000)
-fasm-blocks flag, not the -fms-extensions flag.
rdar://12808010

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169422 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/LangOptions.def
include/clang/Driver/Options.td
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Parse/ParseStmt.cpp
test/CodeGen/ms-inline-asm-64.c
test/CodeGen/ms-inline-asm.c
test/Driver/ms-inline-asm.c [new file with mode: 0644]
test/Parser/MicrosoftExtensions.c
test/Parser/ms-inline-asm.c
test/Sema/ms-inline-asm.c

index fc78e929a9455afd9f323e18aa092f2aedc0cd8d..f180e31fc8801f6a986e0edaff19540bf798e53e 100644 (file)
@@ -45,6 +45,7 @@ LANGOPT(C99               , 1, 0, "C99")
 LANGOPT(C11               , 1, 0, "C11")
 LANGOPT(MicrosoftExt      , 1, 0, "Microsoft extensions")
 LANGOPT(MicrosoftMode     , 1, 0, "Microsoft compatibility mode")
+LANGOPT(AsmBlocks         , 1, 0, "Microsoft inline asm blocks")
 LANGOPT(Borland           , 1, 0, "Borland extensions")
 LANGOPT(CPlusPlus         , 1, 0, "C++")
 LANGOPT(CPlusPlus0x       , 1, 0, "C++0x")
index 7cd550e42f509adfd707684dc409160c6b135dc1..432b754a4857c34da6303f3d83b20700faaba141 100644 (file)
@@ -300,7 +300,7 @@ def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>;
 def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">, Group<f_Group>;
 def fasm : Flag<["-"], "fasm">, Group<f_Group>;
 
-def fasm_blocks : Flag<["-"], "fasm-blocks">, Group<f_Group>;
+def fasm_blocks : Flag<["-"], "fasm-blocks">, Group<f_Group>, Flags<[CC1Option]>;
 def fno_asm_blocks : Flag<["-"], "fno-asm-blocks">, Group<f_Group>;
 
 def fassume_sane_operator_new : Flag<["-"], "fassume-sane-operator-new">, Group<f_Group>;
index 911a9dc51242ec909a24196e64f47ac1c1fccc95..7506c4ca8ee0cfbb1f6da60c8244b682b4d5f449 100644 (file)
@@ -2942,9 +2942,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("-fno-spell-checking");
 
 
-  // Silently ignore -fasm-blocks for now.
-  (void) Args.hasFlag(options::OPT_fasm_blocks, options::OPT_fno_asm_blocks,
-                      false);
+  // -fno-asm-blocks is default.
+  if (Args.hasFlag(options::OPT_fasm_blocks, options::OPT_fno_asm_blocks,
+                   false))
+    CmdArgs.push_back("-fasm-blocks");
 
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
     A->render(Args, CmdArgs);
index 0d886e23a37132b3cefe894ccd88ab690c2f9d72..9da28e5d026a7a38529960f630425ead04deb593 100644 (file)
@@ -1172,6 +1172,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.MicrosoftExt
     = Args.hasArg(OPT_fms_extensions) || Args.hasArg(OPT_fms_compatibility);
   Opts.MicrosoftMode = Args.hasArg(OPT_fms_compatibility);
+  Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks);
   Opts.MSCVersion = Args.getLastArgIntValue(OPT_fmsc_version, 0, Diags);
   Opts.Borland = Args.hasArg(OPT_fborland_extensions);
   Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings);
index d097d393e227ac1104569149a0aa3f790c284e6d..f6f5afe46714e064e614ded6756327a41ae685ff 100644 (file)
@@ -1820,7 +1820,7 @@ StmtResult Parser::ParseAsmStatement(bool &msAsm) {
   assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
   SourceLocation AsmLoc = ConsumeToken();
 
-  if (getLangOpts().MicrosoftExt && Tok.isNot(tok::l_paren) &&
+  if (getLangOpts().AsmBlocks && Tok.isNot(tok::l_paren) &&
       !isTypeQualifier()) {
     msAsm = true;
     return ParseMicrosoftAsmStatement(AsmLoc);
index a74ede09e001392b9149c2f8833b75fa9c0ddcc7..d5df6c3ff8e580e8c642d82d89fe9c8f9682865d 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: x86-64-registered-target
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fasm-blocks -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s
 
 void t1() {
   int var = 10;
index d0e9a7b1159cd181c1d3b31170bb570c82d94f21..f587afd106f87d70813196f0ce96b5a50240ebea 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: x86-64-registered-target
-// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -O0 -fms-extensions -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -O0 -fasm-blocks -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s
 
 void t1() {
 // CHECK: @t1
@@ -201,7 +201,6 @@ void t20() {
 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
 }
 
-
 void t21() {
   __asm {
     __asm push ebx
diff --git a/test/Driver/ms-inline-asm.c b/test/Driver/ms-inline-asm.c
new file mode 100644 (file)
index 0000000..0383564
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -### -fsyntax-only -fasm-blocks %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-BLOCKS < %t %s
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -### -fsyntax-only -fno-asm-blocks -fasm-blocks %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-BLOCKS < %t %s
+
+// CHECK-BLOCKS: "-fasm-blocks"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -### -fsyntax-only -fasm-blocks -fno-asm-blocks %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO-BLOCKS < %t %s
+
+// CHECK-NO-BLOCKS-NOT: "-fasm-blocks"
index 7703999d67ce6543398d8a7edb3f3fdb7f996377..a8e7b8950de1da70cbce05ada60856a198c1ca90 100644 (file)
@@ -18,15 +18,6 @@ void * __ptr32 PtrToPtr32(const void *p)
   return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p );
 }
 
-void __forceinline InterlockedBitTestAndSet (long *Base, long Bit)
-{
-  __asm { // expected-warning {{MS-style inline assembly is not supported}}
-    mov eax, Bit
-    mov ecx, Base
-    lock bts [ecx], eax
-    setc al
-  };
-}
 _inline int foo99() { return 99; }
 
 void test_ms_alignof_alias() {
index 0e8b317e56b055b4be69095326a17103758dd070..280881a1664686a0d2cf61a4c382912ee6b06fea 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fms-extensions
+// RUN: %clang_cc1 %s -verify -fasm-blocks
 
 #define M __asm int 0x2c
 #define M2 int
index f6a0fdcb42eb64a7b590519c0f8f48fe653a5907..8cdd54780d11ef3766ab73a1f866b8959f4e54cd 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: x86-64-registered-target
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fms-extensions -fenable-experimental-ms-inline-asm -Wno-microsoft -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fasm-blocks -fenable-experimental-ms-inline-asm -Wno-microsoft -verify -fsyntax-only
 
 void t1(void) { 
  __asm __asm // expected-error {{__asm used with no assembly instructions}}