r208683 - Support -masm= flag for x86 targets.

Hal Finkel hfinkel at anl.gov
Tue May 13 15:11:30 PDT 2014


----- Original Message -----
> From: "Eric Christopher" <echristo at gmail.com>
> To: "Nico Weber" <nicolasweber at gmx.de>
> Cc: cfe-commits at cs.uiuc.edu
> Sent: Tuesday, May 13, 2014 1:29:14 PM
> Subject: Re: r208683 - Support -masm= flag for x86 targets.
> 
> Not that this is at all clear, but I think you want -backend-option
> here.

But then I think that Chandler might frown -- as I recall a lot of work was done to remove all uses of -backend-option because it does not play well with the tooling interface.

 -Hal

> 
> Should probably change the hexagon and mips bits to do that as well.
> 
> -eric
> 
> On Tue, May 13, 2014 at 4:11 AM, Nico Weber <nicolasweber at gmx.de>
> wrote:
> > Author: nico
> > Date: Tue May 13 06:11:24 2014
> > New Revision: 208683
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=208683&view=rev
> > Log:
> > 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.
> >
> > Added:
> >     cfe/trunk/test/Driver/masm.c
> > Modified:
> >     cfe/trunk/include/clang/Driver/Options.td
> >     cfe/trunk/lib/Driver/Tools.cpp
> >
> > Modified: cfe/trunk/include/clang/Driver/Options.td
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=208683&r1=208682&r2=208683&view=diff
> > ==============================================================================
> > --- cfe/trunk/include/clang/Driver/Options.td (original)
> > +++ cfe/trunk/include/clang/Driver/Options.td Tue May 13 06:11:24
> > 2014
> > @@ -1005,6 +1005,7 @@ def m3dnow : Flag<["-"], "m3dnow">, Grou
> >  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>;
> >
> > Modified: cfe/trunk/lib/Driver/Tools.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=208683&r1=208682&r2=208683&view=diff
> > ==============================================================================
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)
> > +++ cfe/trunk/lib/Driver/Tools.cpp Tue May 13 06:11:24 2014
> > @@ -1486,6 +1486,17 @@ void Clang::AddX86TargetArgs(const ArgLi
> >    }
> >    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) {
> >
> > Added: cfe/trunk/test/Driver/masm.c
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/masm.c?rev=208683&view=auto
> > ==============================================================================
> > --- cfe/trunk/test/Driver/masm.c (added)
> > +++ cfe/trunk/test/Driver/masm.c Tue May 13 06:11:24 2014
> > @@ -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;
> > +}
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-commits mailing list