diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2014-05-13 11:11:24 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2014-05-13 11:11:24 +0000 |
| commit | ad8e36c41aa15f525ec50bffcf755428e45d8f14 (patch) | |
| tree | 3bd50c91bf2cf7b6375143aecbe3bc261e1a8638 | |
| parent | 7d07fe20a03aa19579e5c52e380dfd91b855e651 (diff) | |
| download | bcm5719-llvm-ad8e36c41aa15f525ec50bffcf755428e45d8f14.tar.gz bcm5719-llvm-ad8e36c41aa15f525ec50bffcf755428e45d8f14.zip | |
Support -masm= flag for x86 targets.
`clang -S -o - file.c -masm=att` will write assembly to stdout in at&t syntax
(the default), `-masm=intel` will instead output intel style asm.
llvm-svn: 208683
| -rw-r--r-- | clang/include/clang/Driver/Options.td | 1 | ||||
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 11 | ||||
| -rw-r--r-- | clang/test/Driver/masm.c | 12 |
3 files changed, 24 insertions, 0 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 2cd7a216d0a..0e251aa6b14 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1005,6 +1005,7 @@ def m3dnow : Flag<["-"], "m3dnow">, Group<m_x86_Features_Group>; def m64 : Flag<["-"], "m64">, Group<m_Group>, Flags<[DriverOption, CoreOption]>; def mabi_EQ : Joined<["-"], "mabi=">, Group<m_Group>; def march_EQ : Joined<["-"], "march=">, Group<m_Group>; +def masm_EQ : Joined<["-"], "masm=">, Group<m_Group>, Flags<[DriverOption]>; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>; def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group<clang_ignored_m_Group>; def mcpu_EQ : Joined<["-"], "mcpu=">, Group<m_Group>; diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index fcd1275d6ba..1f9e12bb538 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1486,6 +1486,17 @@ void Clang::AddX86TargetArgs(const ArgList &Args, } if (NoImplicitFloat) CmdArgs.push_back("-no-implicit-float"); + + if (Arg *A = Args.getLastArg(options::OPT_masm_EQ)) { + StringRef Value = A->getValue(); + if (Value == "intel" || Value == "att") { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back(Args.MakeArgString("-x86-asm-syntax=" + Value)); + } else { + getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << Value; + } + } } static inline bool HasPICArg(const ArgList &Args) { diff --git a/clang/test/Driver/masm.c b/clang/test/Driver/masm.c new file mode 100644 index 00000000000..e9e4422aedf --- /dev/null +++ b/clang/test/Driver/masm.c @@ -0,0 +1,12 @@ +// RUN: %clang -target i386-unknown-linux -masm=intel %s -S -o - | FileCheck --check-prefix=CHECK-INTEL %s +// RUN: %clang -target i386-unknown-linux -masm=att %s -S -o - | FileCheck --check-prefix=CHECK-ATT %s +// RUN: not %clang -target i386-unknown-linux -masm=somerequired %s -S -o - 2>&1 | FileCheck --check-prefix=CHECK-SOMEREQUIRED %s +// RUN: %clang -target arm-unknown-eabi -masm=intel %s -S -o - 2>&1 | FileCheck --check-prefix=CHECK-ARM %s + +int f() { +// CHECK-ATT: movl $0, %eax +// CHECK-INTEL: mov eax, 0 +// CHECK-SOMEREQUIRED: error: unsupported argument 'somerequired' to option 'masm=' +// CHECK-ARM: warning: argument unused during compilation: '-masm=intel' + return 0; +} |

