Index: tools/driver/cc1as_main.cpp =================================================================== --- tools/driver/cc1as_main.cpp +++ tools/driver/cc1as_main.cpp @@ -33,7 +33,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCTargetAsmParser.h" -#include "llvm/MC/MCTargetOptions.h" +#include "llvm/MC/MCTargetOptionsCommandFlags.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/OptTable.h" @@ -74,6 +74,9 @@ /// are legal. std::string CPU; + /// If given, the name of the target ABI. + std::string ABI; + /// The list of target specific features to enable or disable -- this should /// be a list of strings starting with '+' or '-'. std::vector Features; @@ -184,6 +187,7 @@ // Target Options Opts.Triple = llvm::Triple::normalize(Args->getLastArgValue(OPT_triple)); Opts.CPU = Args->getLastArgValue(OPT_target_cpu); + Opts.ABI = Args->getLastArgValue(OPT_target_abi); Opts.Features = Args->getAllArgValues(OPT_target_feature); // Use the default target triple if unspecified. @@ -278,6 +282,16 @@ return new formatted_raw_ostream(*Out, formatted_raw_ostream::DELETE_STREAM); } +static inline MCTargetOptions InitFromAssemblerInvocation( + AssemblerInvocation &Opt) { + MCTargetOptions Options; + + Options.MCRelaxAll = Opt.RelaxAll; + Options.DwarfVersion = Opt.DwarfVersion; + Options.ShowMCInst = Opt.ShowInst; + Options.ABIName = Opt.ABI; + return Options; +} static bool ExecuteAssembler(AssemblerInvocation &Opts, DiagnosticsEngine &Diags) { // Get the target specific parser. @@ -355,6 +369,7 @@ std::unique_ptr MCII(TheTarget->createMCInstrInfo()); std::unique_ptr STI( TheTarget->createMCSubtargetInfo(Opts.Triple, Opts.CPU, FS)); + MCTargetOptions Options = InitFromAssemblerInvocation(Opts); // FIXME: There is a bit of code duplication with addPassesToEmitFile. if (Opts.OutputType == AssemblerInvocation::FT_Asm) { @@ -365,7 +380,7 @@ MCAsmBackend *MAB = nullptr; if (Opts.ShowEncoding) { CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); - MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU); + MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU, Options); } Str.reset(TheTarget->createAsmStreamer(Ctx, *Out, /*asmverbose*/true, /*useDwarfDirectory*/ true, @@ -378,7 +393,7 @@ "Invalid file type!"); MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, - Opts.CPU); + Opts.CPU, Options); Str.reset(TheTarget->createMCObjectStreamer(Opts.Triple, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll)); Str.get()->InitSections(Opts.NoExecStack); @@ -389,8 +404,6 @@ std::unique_ptr Parser( createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI)); - // FIXME: init MCTargetOptions from sanitizer flags here. - MCTargetOptions Options; std::unique_ptr TAP( TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options)); if (!TAP)