[llvm] r209258 - Move the verbose asm option to be part of the options struct and

Eric Christopher echristo at gmail.com
Tue May 20 16:59:51 PDT 2014


Author: echristo
Date: Tue May 20 18:59:50 2014
New Revision: 209258

URL: http://llvm.org/viewvc/llvm-project?rev=209258&view=rev
Log:
Move the verbose asm option to be part of the options struct and
set appropriately.

Modified:
    llvm/trunk/include/llvm/MC/MCTargetOptions.h
    llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h
    llvm/trunk/include/llvm/Target/TargetMachine.h
    llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
    llvm/trunk/lib/MC/MCTargetOptions.cpp
    llvm/trunk/lib/Target/TargetMachine.cpp
    llvm/trunk/tools/llc/llc.cpp

Modified: llvm/trunk/include/llvm/MC/MCTargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetOptions.h?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCTargetOptions.h (original)
+++ llvm/trunk/include/llvm/MC/MCTargetOptions.h Tue May 20 18:59:50 2014
@@ -28,6 +28,7 @@ public:
   unsigned MCUseDwarfDirectory : 1;
   unsigned ShowMCEncoding : 1;
   unsigned ShowMCInst : 1;
+  unsigned AsmVerbose : 1;
   MCTargetOptions();
 };
 
@@ -39,7 +40,8 @@ inline bool operator==(const MCTargetOpt
           ARE_EQUAL(MCSaveTempLabels) &&
           ARE_EQUAL(MCUseDwarfDirectory) &&
           ARE_EQUAL(ShowMCEncoding) &&
-          ARE_EQUAL(ShowMCInst));
+          ARE_EQUAL(ShowMCInst) &&
+          ARE_EQUAL(AsmVerbose));
 #undef ARE_EQUAL
 }
 

Modified: llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h (original)
+++ llvm/trunk/include/llvm/MC/MCTargetOptionsCommandFlags.h Tue May 20 18:59:50 2014
@@ -47,6 +47,9 @@ cl::opt<bool> ShowMCEncoding("show-mc-en
 cl::opt<bool> ShowMCInst("show-mc-inst", cl::Hidden,
                          cl::desc("Show instruction structure in .s output"));
 
+cl::opt<bool> AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
+                         cl::init(false));
+
 static inline MCTargetOptions InitMCTargetOptionsFromFlags() {
   MCTargetOptions Options;
   Options.SanitizeAddress =
@@ -57,6 +60,7 @@ static inline MCTargetOptions InitMCTarg
   Options.MCSaveTempLabels = SaveTempLabels;
   Options.ShowMCEncoding = ShowMCEncoding;
   Options.ShowMCInst = ShowMCInst;
+  Options.AsmVerbose = AsmVerbose;
   return Options;
 }
 

Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Tue May 20 18:59:50 2014
@@ -187,11 +187,11 @@ public:
 
   /// getAsmVerbosityDefault - Returns the default value of asm verbosity.
   ///
-  static bool getAsmVerbosityDefault();
+  bool getAsmVerbosityDefault() const ;
 
   /// setAsmVerbosityDefault - Set the default value of asm verbosity. Default
   /// is false.
-  static void setAsmVerbosityDefault(bool);
+  void setAsmVerbosityDefault(bool);
 
   /// getDataSections - Return true if data objects should be emitted into their
   /// own section, corresponds to -fdata-sections.

Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Tue May 20 18:59:50 2014
@@ -43,19 +43,6 @@ static cl::opt<cl::boolOrDefault>
 EnableFastISelOption("fast-isel", cl::Hidden,
   cl::desc("Enable the \"fast\" instruction selector"));
 
-static cl::opt<cl::boolOrDefault>
-AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
-           cl::init(cl::BOU_UNSET));
-
-static bool getVerboseAsm() {
-  switch (AsmVerbose) {
-  case cl::BOU_UNSET: return TargetMachine::getAsmVerbosityDefault();
-  case cl::BOU_TRUE:  return true;
-  case cl::BOU_FALSE: return false;
-  }
-  llvm_unreachable("Invalid verbose asm state");
-}
-
 void LLVMTargetMachine::initAsmInfo() {
   MCAsmInfo *TmpAsmInfo = TheTarget.createMCAsmInfo(*getRegisterInfo(),
                                                     TargetTriple);
@@ -188,8 +175,9 @@ bool LLVMTargetMachine::addPassesToEmitF
     MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(),
                                                        TargetCPU);
     MCStreamer *S = getTarget().createAsmStreamer(
-        *Context, Out, getVerboseAsm(), Options.MCOptions.MCUseDwarfDirectory,
-        InstPrinter, MCE, MAB, Options.MCOptions.ShowMCInst);
+        *Context, Out, Options.MCOptions.AsmVerbose,
+        Options.MCOptions.MCUseDwarfDirectory, InstPrinter, MCE, MAB,
+        Options.MCOptions.ShowMCInst);
     AsmStreamer.reset(S);
     break;
   }

Modified: llvm/trunk/lib/MC/MCTargetOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCTargetOptions.cpp?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCTargetOptions.cpp (original)
+++ llvm/trunk/lib/MC/MCTargetOptions.cpp Tue May 20 18:59:50 2014
@@ -14,6 +14,6 @@ namespace llvm {
 MCTargetOptions::MCTargetOptions()
     : SanitizeAddress(false), MCRelaxAll(false), MCNoExecStack(false),
       MCSaveTempLabels(false), MCUseDwarfDirectory(false),
-      ShowMCEncoding(false), ShowMCInst(false) {}
+      ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false) {}
 
 } // end namespace llvm

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Tue May 20 18:59:50 2014
@@ -29,14 +29,6 @@
 using namespace llvm;
 
 //---------------------------------------------------------------------------
-// Command-line options that tend to be useful on more than one back-end.
-//
-
-namespace llvm {
-  bool AsmVerbosityDefault(false);
-}
-
-//---------------------------------------------------------------------------
 // TargetMachine Class
 //
 
@@ -162,12 +154,12 @@ void TargetMachine::setOptLevel(CodeGenO
     CodeGenInfo->setOptLevel(Level);
 }
 
-bool TargetMachine::getAsmVerbosityDefault() {
-  return AsmVerbosityDefault;
+bool TargetMachine::getAsmVerbosityDefault() const {
+  return Options.MCOptions.AsmVerbose;
 }
 
 void TargetMachine::setAsmVerbosityDefault(bool V) {
-  AsmVerbosityDefault = V;
+  Options.MCOptions.AsmVerbose = V;
 }
 
 bool TargetMachine::getFunctionSections() const {

Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=209258&r1=209257&r2=209258&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Tue May 20 18:59:50 2014
@@ -273,6 +273,10 @@ static int compileModule(char **argv, LL
   TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
   Options.DisableIntegratedAS = NoIntegratedAssembler;
 
+  // Override default to generate verbose assembly unless we've seen the flag.
+  if (AsmVerbose.getNumOccurrences() == 0)
+    Options.MCOptions.AsmVerbose = true;
+
   std::unique_ptr<TargetMachine> target(
       TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr,
                                      Options, RelocModel, CMModel, OLvl));
@@ -309,9 +313,6 @@ static int compileModule(char **argv, LL
     mod->setDataLayout(DL);
   PM.add(new DataLayoutPass(mod));
 
-  // Override default to generate verbose assembly.
-  Target.setAsmVerbosityDefault(true);
-
   if (RelaxAll.getNumOccurrences() > 0 &&
       FileType != TargetMachine::CGFT_ObjectFile)
     errs() << argv[0]





More information about the llvm-commits mailing list