llvm.org GIT mirror llvm / 4f6d26d
Move the verbose asm option to be part of the options struct and set appropriately. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209258 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 6 years ago
7 changed file(s) with 20 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
2727 unsigned MCUseDwarfDirectory : 1;
2828 unsigned ShowMCEncoding : 1;
2929 unsigned ShowMCInst : 1;
30 unsigned AsmVerbose : 1;
3031 MCTargetOptions();
3132 };
3233
3839 ARE_EQUAL(MCSaveTempLabels) &&
3940 ARE_EQUAL(MCUseDwarfDirectory) &&
4041 ARE_EQUAL(ShowMCEncoding) &&
41 ARE_EQUAL(ShowMCInst));
42 ARE_EQUAL(ShowMCInst) &&
43 ARE_EQUAL(AsmVerbose));
4244 #undef ARE_EQUAL
4345 }
4446
4646 cl::opt ShowMCInst("show-mc-inst", cl::Hidden,
4747 cl::desc("Show instruction structure in .s output"));
4848
49 cl::opt AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
50 cl::init(false));
51
4952 static inline MCTargetOptions InitMCTargetOptionsFromFlags() {
5053 MCTargetOptions Options;
5154 Options.SanitizeAddress =
5659 Options.MCSaveTempLabels = SaveTempLabels;
5760 Options.ShowMCEncoding = ShowMCEncoding;
5861 Options.ShowMCInst = ShowMCInst;
62 Options.AsmVerbose = AsmVerbose;
5963 return Options;
6064 }
6165
186186
187187 /// getAsmVerbosityDefault - Returns the default value of asm verbosity.
188188 ///
189 static bool getAsmVerbosityDefault();
189 bool getAsmVerbosityDefault() const ;
190190
191191 /// setAsmVerbosityDefault - Set the default value of asm verbosity. Default
192192 /// is false.
193 static void setAsmVerbosityDefault(bool);
193 void setAsmVerbosityDefault(bool);
194194
195195 /// getDataSections - Return true if data objects should be emitted into their
196196 /// own section, corresponds to -fdata-sections.
4242 EnableFastISelOption("fast-isel", cl::Hidden,
4343 cl::desc("Enable the \"fast\" instruction selector"));
4444
45 static cl::opt
46 AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
47 cl::init(cl::BOU_UNSET));
48
49 static bool getVerboseAsm() {
50 switch (AsmVerbose) {
51 case cl::BOU_UNSET: return TargetMachine::getAsmVerbosityDefault();
52 case cl::BOU_TRUE: return true;
53 case cl::BOU_FALSE: return false;
54 }
55 llvm_unreachable("Invalid verbose asm state");
56 }
57
5845 void LLVMTargetMachine::initAsmInfo() {
5946 MCAsmInfo *TmpAsmInfo = TheTarget.createMCAsmInfo(*getRegisterInfo(),
6047 TargetTriple);
187174 MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(),
188175 TargetCPU);
189176 MCStreamer *S = getTarget().createAsmStreamer(
190 *Context, Out, getVerboseAsm(), Options.MCOptions.MCUseDwarfDirectory,
191 InstPrinter, MCE, MAB, Options.MCOptions.ShowMCInst);
177 *Context, Out, Options.MCOptions.AsmVerbose,
178 Options.MCOptions.MCUseDwarfDirectory, InstPrinter, MCE, MAB,
179 Options.MCOptions.ShowMCInst);
192180 AsmStreamer.reset(S);
193181 break;
194182 }
1313 MCTargetOptions::MCTargetOptions()
1414 : SanitizeAddress(false), MCRelaxAll(false), MCNoExecStack(false),
1515 MCSaveTempLabels(false), MCUseDwarfDirectory(false),
16 ShowMCEncoding(false), ShowMCInst(false) {}
16 ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false) {}
1717
1818 } // end namespace llvm
2828 using namespace llvm;
2929
3030 //---------------------------------------------------------------------------
31 // Command-line options that tend to be useful on more than one back-end.
32 //
33
34 namespace llvm {
35 bool AsmVerbosityDefault(false);
36 }
37
38 //---------------------------------------------------------------------------
3931 // TargetMachine Class
4032 //
4133
161153 CodeGenInfo->setOptLevel(Level);
162154 }
163155
164 bool TargetMachine::getAsmVerbosityDefault() {
165 return AsmVerbosityDefault;
156 bool TargetMachine::getAsmVerbosityDefault() const {
157 return Options.MCOptions.AsmVerbose;
166158 }
167159
168160 void TargetMachine::setAsmVerbosityDefault(bool V) {
169 AsmVerbosityDefault = V;
161 Options.MCOptions.AsmVerbose = V;
170162 }
171163
172164 bool TargetMachine::getFunctionSections() const {
272272 TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
273273 Options.DisableIntegratedAS = NoIntegratedAssembler;
274274
275 // Override default to generate verbose assembly unless we've seen the flag.
276 if (AsmVerbose.getNumOccurrences() == 0)
277 Options.MCOptions.AsmVerbose = true;
278
275279 std::unique_ptr target(
276280 TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr,
277281 Options, RelocModel, CMModel, OLvl));
307311 if (const DataLayout *DL = Target.getDataLayout())
308312 mod->setDataLayout(DL);
309313 PM.add(new DataLayoutPass(mod));
310
311 // Override default to generate verbose assembly.
312 Target.setAsmVerbosityDefault(true);
313314
314315 if (RelaxAll.getNumOccurrences() > 0 &&
315316 FileType != TargetMachine::CGFT_ObjectFile)