Unify command line handling of MCTargetOptions and remove extra
authorEric Christopher <echristo@gmail.com>
Thu, 15 May 2014 01:10:50 +0000 (01:10 +0000)
committerEric Christopher <echristo@gmail.com>
Thu, 15 May 2014 01:10:50 +0000 (01:10 +0000)
options and code. No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208833 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/CommandFlags.h
include/llvm/MC/MCTargetOptionsCommandFlags.h
tools/llc/llc.cpp
tools/llvm-mc/llvm-mc.cpp

index 619826cf622e206da89d1c72bc36c8bf66def7ba..ac789e4af8a63f36ab256a760ab7fcda6da7b127 100644 (file)
@@ -70,11 +70,6 @@ CMModel("code-model",
                               "Large code model"),
                    clEnumValEnd));
 
-cl::opt<bool>
-RelaxAll("mc-relax-all",
-         cl::desc("When used with filetype=obj, "
-                  "relax all fixups in the emitted object file"));
-
 cl::opt<TargetMachine::CodeGenFileType>
 FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
   cl::desc("Choose a file type (not all types are supported by all targets):"),
@@ -87,9 +82,6 @@ FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
                         "Emit nothing, for performance testing"),
              clEnumValEnd));
 
-cl::opt<bool> EnableDwarfDirectory("enable-dwarf-directory", cl::Hidden,
-                  cl::desc("Use .file directives with an explicit directory."));
-
 cl::opt<bool>
 DisableRedZone("disable-red-zone",
                cl::desc("Do not emit code that uses the red zone."),
index b26fd944d82bca4cba9b784f98f60c0772a6e4df..0dddc2fdfb15cb5f7e31b4a875cd66f179fdaaa5 100644 (file)
 using namespace llvm;
 
 cl::opt<MCTargetOptions::AsmInstrumentation> AsmInstrumentation(
-    "asm-instrumentation",
-    cl::desc("Instrumentation of inline assembly and "
-             "assembly source files"),
+    "asm-instrumentation", cl::desc("Instrumentation of inline assembly and "
+                                    "assembly source files"),
     cl::init(MCTargetOptions::AsmInstrumentationNone),
-    cl::values(clEnumValN(MCTargetOptions::AsmInstrumentationNone,
-                          "none",
+    cl::values(clEnumValN(MCTargetOptions::AsmInstrumentationNone, "none",
                           "no instrumentation at all"),
-               clEnumValN(MCTargetOptions::AsmInstrumentationAddress,
-                          "address",
+               clEnumValN(MCTargetOptions::AsmInstrumentationAddress, "address",
                           "instrument instructions with memory arguments"),
                clEnumValEnd));
 
+cl::opt<bool> RelaxAll("mc-relax-all",
+                       cl::desc("When used with filetype=obj, "
+                                "relax all fixups in the emitted object file"));
+
+cl::opt<bool> EnableDwarfDirectory(
+    "enable-dwarf-directory", cl::Hidden,
+    cl::desc("Use .file directives with an explicit directory."));
+
+cl::opt<bool> NoExecStack("mc-no-exec-stack",
+                          cl::desc("File doesn't need an exec stack"));
+
+static cl::opt<bool>
+SaveTempLabels("L", cl::desc("Don't discard temporary labels"));
+
 static inline MCTargetOptions InitMCTargetOptionsFromFlags() {
   MCTargetOptions Options;
   Options.SanitizeAddress =
       (AsmInstrumentation == MCTargetOptions::AsmInstrumentationAddress);
+  Options.MCRelaxAll = RelaxAll;
+  Options.MCUseDwarfDirectory = EnableDwarfDirectory;
+  Options.MCNoExecStack = NoExecStack;
+  Options.MCSaveTempLabels = SaveTempLabels;
   return Options;
 }
 
index 712817d9347e8201f93c5ad92ee276e14a3399b7..269a5df9041411ace5f8b2bd6994836743de972b 100644 (file)
@@ -287,9 +287,6 @@ static int compileModule(char **argv, LLVMContext &Context) {
   assert(mod && "Should have exited if we didn't have a module!");
   TargetMachine &Target = *target.get();
 
-  if (EnableDwarfDirectory)
-    Target.setMCUseDwarfDirectory(true);
-
   if (GenerateSoftFloatCalls)
     FloatABIForCalls = FloatABI::Soft;
 
@@ -315,13 +312,10 @@ static int compileModule(char **argv, LLVMContext &Context) {
   // Override default to generate verbose assembly.
   Target.setAsmVerbosityDefault(true);
 
-  if (RelaxAll) {
-    if (FileType != TargetMachine::CGFT_ObjectFile)
-      errs() << argv[0]
+  if (RelaxAll.getNumOccurrences() > 0 &&
+      FileType != TargetMachine::CGFT_ObjectFile)
+    errs() << argv[0]
              << ": warning: ignoring -mc-relax-all because filetype != obj";
-    else
-      Target.setMCRelaxAll(true);
-  }
 
   {
     formatted_raw_ostream FOS(Out->os());
index 364ae73401e39cf6eb051b7edd1891e0b8f05f1f..e87f1eef2829429d6ea0b62472104734bf0fe62e 100644 (file)
@@ -65,12 +65,6 @@ static cl::opt<unsigned>
 OutputAsmVariant("output-asm-variant",
                  cl::desc("Syntax variant to use for output printing"));
 
-static cl::opt<bool>
-RelaxAll("mc-relax-all", cl::desc("Relax all fixups"));
-
-static cl::opt<bool>
-NoExecStack("mc-no-exec-stack", cl::desc("File doesn't need an exec stack"));
-
 enum OutputFileType {
   OFT_Null,
   OFT_AssemblyFile,
@@ -147,9 +141,6 @@ static cl::opt<bool>
 NoInitialTextSection("n", cl::desc("Don't assume assembly file starts "
                                    "in the text section"));
 
-static cl::opt<bool>
-SaveTempLabels("L", cl::desc("Don't discard temporary labels"));
-
 static cl::opt<bool>
 GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly "
                                   "source files"));