llvm.org GIT mirror llvm / 99dca4f
Remove the "WantsWholeFile" concept, as it's no longer needed. CBE and the others use the regular addPassesToEmitFile hook now, and llc no longer needs a bunch of redundant code to handle the whole-file case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103492 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
7 changed file(s) with 57 addition(s) and 112 deletion(s). Raw diff Collapse all Expand all
224224 bool = true) {
225225 return true;
226226 }
227
228 /// addPassesToEmitWholeFile - This method can be implemented by targets that
229 /// require having the entire module at once. This is not recommended, do not
230 /// use this.
231 virtual bool WantsWholeFile() const { return false; }
232 virtual bool addPassesToEmitWholeFile(PassManager &, formatted_raw_ostream &,
233 CodeGenFileType,
234 CodeGenOpt::Level,
235 bool = true) {
236 return true;
237 }
238227 };
239228
240229 /// LLVMTargetMachine - This class describes a target machine that is
35533553 // External Interface declaration
35543554 //===----------------------------------------------------------------------===//
35553555
3556 bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
3557 formatted_raw_ostream &o,
3558 CodeGenFileType FileType,
3559 CodeGenOpt::Level OptLevel,
3560 bool DisableVerify) {
3556 bool CTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
3557 formatted_raw_ostream &o,
3558 CodeGenFileType FileType,
3559 CodeGenOpt::Level OptLevel,
3560 bool DisableVerify) {
35613561 if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
35623562
35633563 PM.add(createGCLoweringPass());
2222 CTargetMachine(const Target &T, const std::string &TT, const std::string &FS)
2323 : TargetMachine(T) {}
2424
25 virtual bool WantsWholeFile() const { return true; }
26 virtual bool addPassesToEmitWholeFile(PassManager &PM,
27 formatted_raw_ostream &Out,
28 CodeGenFileType FileType,
29 CodeGenOpt::Level OptLevel,
30 bool DisableVerify);
25 virtual bool addPassesToEmitFile(PassManagerBase &PM,
26 formatted_raw_ostream &Out,
27 CodeGenFileType FileType,
28 CodeGenOpt::Level OptLevel,
29 bool DisableVerify);
3130
3231 virtual const TargetData *getTargetData() const { return 0; }
3332 };
20062006 // External Interface declaration
20072007 //===----------------------------------------------------------------------===//
20082008
2009 bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
2010 formatted_raw_ostream &o,
2011 CodeGenFileType FileType,
2012 CodeGenOpt::Level OptLevel,
2013 bool DisableVerify) {
2009 bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
2010 formatted_raw_ostream &o,
2011 CodeGenFileType FileType,
2012 CodeGenOpt::Level OptLevel,
2013 bool DisableVerify) {
20142014 if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
20152015 PM.add(new CppWriter(o));
20162016 return false;
2525 const std::string &FS)
2626 : TargetMachine(T) {}
2727
28 virtual bool WantsWholeFile() const { return true; }
29 virtual bool addPassesToEmitWholeFile(PassManager &PM,
30 formatted_raw_ostream &Out,
31 CodeGenFileType FileType,
32 CodeGenOpt::Level OptLevel,
33 bool DisableVerify);
28 virtual bool addPassesToEmitFile(PassManagerBase &PM,
29 formatted_raw_ostream &Out,
30 CodeGenFileType FileType,
31 CodeGenOpt::Level OptLevel,
32 bool DisableVerify);
3433
3534 virtual const TargetData *getTargetData() const { return 0; }
3635 };
3333 MSILTarget(const Target &T, const std::string &TT, const std::string &FS)
3434 : TargetMachine(T) {}
3535
36 virtual bool WantsWholeFile() const { return true; }
37 virtual bool addPassesToEmitWholeFile(PassManager &PM,
38 formatted_raw_ostream &Out,
39 CodeGenFileType FileType,
40 CodeGenOpt::Level OptLevel,
41 bool DisableVerify);
36 virtual bool addPassesToEmitFile(PassManagerBase &PM,
37 formatted_raw_ostream &Out,
38 CodeGenFileType FileType,
39 CodeGenOpt::Level OptLevel,
40 bool DisableVerify);
4241
4342 virtual const TargetData *getTargetData() const { return 0; }
4443 };
16851684 // External Interface declaration
16861685 //===----------------------------------------------------------------------===//
16871686
1688 bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM,
1689 formatted_raw_ostream &o,
1690 CodeGenFileType FileType,
1691 CodeGenOpt::Level OptLevel,
1692 bool DisableVerify)
1687 bool MSILTarget::addPassesToEmitFile(PassManagerBase &PM,
1688 formatted_raw_ostream &o,
1689 CodeGenFileType FileType,
1690 CodeGenOpt::Level OptLevel,
1691 bool DisableVerify)
16931692 {
16941693 if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
16951694 MSILWriter* Writer = new MSILWriter(o);
311311 bool DisableVerify = true;
312312 #endif
313313
314 // If this target requires addPassesToEmitWholeFile, do it now. This is
315 // used by strange things like the C backend.
316 if (Target.WantsWholeFile()) {
317 PassManager PM;
318
319 // Add the target data from the target machine, if it exists, or the module.
320 if (const TargetData *TD = Target.getTargetData())
321 PM.add(new TargetData(*TD));
322 else
323 PM.add(new TargetData(&mod));
324
325 if (!NoVerify)
326 PM.add(createVerifierPass());
327
328 // Ask the target to add backend passes as necessary.
329 if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl,
330 DisableVerify)) {
331 errs() << argv[0] << ": target does not support generation of this"
332 << " file type!\n";
333 if (Out != &fouts()) delete Out;
334 // And the Out file is empty and useless, so remove it now.
335 sys::Path(OutputFilename).eraseFromDisk();
336 return 1;
337 }
338 PM.run(mod);
339 } else {
340 // Build up all of the passes that we want to do to the module.
341 FunctionPassManager Passes(M.get());
342
343 // Add the target data from the target machine, if it exists, or the module.
344 if (const TargetData *TD = Target.getTargetData())
345 Passes.add(new TargetData(*TD));
346 else
347 Passes.add(new TargetData(&mod));
348
349 #ifndef NDEBUG
350 if (!NoVerify)
351 Passes.add(createVerifierPass());
352 #endif
353
354 // Override default to generate verbose assembly.
355 Target.setAsmVerbosityDefault(true);
356
357 if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl,
358 DisableVerify)) {
359 errs() << argv[0] << ": target does not support generation of this"
360 << " file type!\n";
361 if (Out != &fouts()) delete Out;
362 // And the Out file is empty and useless, so remove it now.
363 sys::Path(OutputFilename).eraseFromDisk();
364 return 1;
365 }
366
367 Passes.doInitialization();
368
369 // Run our queue of passes all at once now, efficiently.
370 // TODO: this could lazily stream functions out of the module.
371 for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I)
372 if (!I->isDeclaration()) {
373 if (DisableRedZone)
374 I->addFnAttr(Attribute::NoRedZone);
375 if (NoImplicitFloats)
376 I->addFnAttr(Attribute::NoImplicitFloat);
377 Passes.run(*I);
378 }
379
380 Passes.doFinalization();
381 }
314 // Build up all of the passes that we want to do to the module.
315 PassManager PM;
316
317 // Add the target data from the target machine, if it exists, or the module.
318 if (const TargetData *TD = Target.getTargetData())
319 PM.add(new TargetData(*TD));
320 else
321 PM.add(new TargetData(&mod));
322
323 if (!NoVerify)
324 PM.add(createVerifierPass());
325
326 // Override default to generate verbose assembly.
327 Target.setAsmVerbosityDefault(true);
328
329 // Ask the target to add backend passes as necessary.
330 if (Target.addPassesToEmitFile(PM, *Out, FileType, OLvl,
331 DisableVerify)) {
332 errs() << argv[0] << ": target does not support generation of this"
333 << " file type!\n";
334 if (Out != &fouts()) delete Out;
335 // And the Out file is empty and useless, so remove it now.
336 sys::Path(OutputFilename).eraseFromDisk();
337 return 1;
338 }
339
340 PM.run(mod);
382341
383342 // Delete the ostream if it's not a stdout stream
384343 if (Out != &fouts()) delete Out;