[PATCH] [clang][Driver][MCTargetOptions]Change clang driver to adopt new definition of createAsmBackend

Vladimir Medic Vladimir.Medic at imgtec.com
Tue Feb 24 01:47:24 PST 2015


MCTargetOptions instance is not initiated anymore using InitMCTargetOptionsFromFlags but newly defined method which uses AssemblerInvocation structure to populate fields from clang driver options.


http://reviews.llvm.org/D7747

Files:
  tools/driver/cc1as_main.cpp

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<std::string> 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<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
   std::unique_ptr<MCSubtargetInfo> 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<MCAsmParser> Parser(
       createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
 
-  // FIXME: init MCTargetOptions from sanitizer flags here.
-  MCTargetOptions Options;
   std::unique_ptr<MCTargetAsmParser> TAP(
       TheTarget->createMCAsmParser(*STI, *Parser, *MCII, Options));
   if (!TAP)

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7747.20576.patch
Type: text/x-patch
Size: 3451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150224/67b13bb9/attachment.bin>


More information about the llvm-commits mailing list