From: Chad Rosier Date: Wed, 5 Dec 2012 21:08:21 +0000 (+0000) Subject: [driver, ms-inline asm] MS-Style inline assembly is controlled by the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15490fd42d7d8dca2f9b5b3a9dc074892ca1acd7;p=clang [driver, ms-inline asm] MS-Style inline assembly is controlled by the -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 --- diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def index fc78e929a9..f180e31fc8 100644 --- a/include/clang/Basic/LangOptions.def +++ b/include/clang/Basic/LangOptions.def @@ -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") diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 7cd550e42f..432b754a48 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -300,7 +300,7 @@ def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group; def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">, Group; def fasm : Flag<["-"], "fasm">, Group; -def fasm_blocks : Flag<["-"], "fasm-blocks">, Group; +def fasm_blocks : Flag<["-"], "fasm-blocks">, Group, Flags<[CC1Option]>; def fno_asm_blocks : Flag<["-"], "fno-asm-blocks">, Group; def fassume_sane_operator_new : Flag<["-"], "fassume-sane-operator-new">, Group; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 911a9dc512..7506c4ca8e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 0d886e23a3..9da28e5d02 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -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); diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index d097d393e2..f6f5afe467 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -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); diff --git a/test/CodeGen/ms-inline-asm-64.c b/test/CodeGen/ms-inline-asm-64.c index a74ede09e0..d5df6c3ff8 100644 --- a/test/CodeGen/ms-inline-asm-64.c +++ b/test/CodeGen/ms-inline-asm-64.c @@ -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; diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c index d0e9a7b115..f587afd106 100644 --- a/test/CodeGen/ms-inline-asm.c +++ b/test/CodeGen/ms-inline-asm.c @@ -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 index 0000000000..03835647c3 --- /dev/null +++ b/test/Driver/ms-inline-asm.c @@ -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" diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index 7703999d67..a8e7b8950d 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -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() { diff --git a/test/Parser/ms-inline-asm.c b/test/Parser/ms-inline-asm.c index 0e8b317e56..280881a166 100644 --- a/test/Parser/ms-inline-asm.c +++ b/test/Parser/ms-inline-asm.c @@ -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 diff --git a/test/Sema/ms-inline-asm.c b/test/Sema/ms-inline-asm.c index f6a0fdcb42..8cdd54780d 100644 --- a/test/Sema/ms-inline-asm.c +++ b/test/Sema/ms-inline-asm.c @@ -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}}