Move the verbose asm option to be part of the options struct and
authorEric Christopher <echristo@gmail.com>
Tue, 20 May 2014 23:59:50 +0000 (23:59 +0000)
committerEric Christopher <echristo@gmail.com>
Tue, 20 May 2014 23:59:50 +0000 (23:59 +0000)
set appropriately.

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

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

index ad34958ae3802a8c27bdac23d9c4d0aa5a9e59fc..b4f5a979720d04f805965f1bf30bbda43ad5069a 100644 (file)
@@ -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 MCTargetOptions &LHS, const MCTargetOptions &RHS) {
           ARE_EQUAL(MCSaveTempLabels) &&
           ARE_EQUAL(MCUseDwarfDirectory) &&
           ARE_EQUAL(ShowMCEncoding) &&
-          ARE_EQUAL(ShowMCInst));
+          ARE_EQUAL(ShowMCInst) &&
+          ARE_EQUAL(AsmVerbose));
 #undef ARE_EQUAL
 }
 
index 1edf8f75b1398318e61fd86717f32baa89c85724..55ac14215724efaa099f15eddd238000751cd210 100644 (file)
@@ -47,6 +47,9 @@ cl::opt<bool> ShowMCEncoding("show-mc-encoding", cl::Hidden,
 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 InitMCTargetOptionsFromFlags() {
   Options.MCSaveTempLabels = SaveTempLabels;
   Options.ShowMCEncoding = ShowMCEncoding;
   Options.ShowMCInst = ShowMCInst;
+  Options.AsmVerbose = AsmVerbose;
   return Options;
 }
 
index 17ebd07e5d7862bdf8fa0f710400a3c67a26d11b..b263c571d9e66a850741839263eba77a98adbd49 100644 (file)
@@ -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.
index c8211b76be4e8b022dd6a1ba752d109c6d0d02c2..a5ac0578ab88b500a9f56664a53d8129f87b4328 100644 (file)
@@ -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::addPassesToEmitFile(PassManagerBase &PM,
     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;
   }
index e1b6a5889d89b90db64239421b9c3fd07fa061dd..8e946d57f7fb1d54b693e90ebed77dd4357da4c7 100644 (file)
@@ -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
index 4ccf5194947b543ca45e218212dbae7b6370897e..dbd433d5240c0afe4de031a24b250e39dc64449f 100644 (file)
 #include "llvm/Target/TargetLoweringObjectFile.h"
 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(CodeGenOpt::Level Level) const {
     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 {
index 269a5df9041411ace5f8b2bd6994836743de972b..abdc1ab634cf76bfe4023438a3374fbb9a1898dc 100644 (file)
@@ -273,6 +273,10 @@ static int compileModule(char **argv, LLVMContext &Context) {
   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, LLVMContext &Context) {
     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]