mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Use the cast machinery to remove dummy uses of formatted_raw_ostream.
If we know we are producing an object, we don't need to wrap the stream in a formatted_raw_ostream anymore. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
271631a0af
commit
23295f613b
@ -207,8 +207,9 @@ public:
|
|||||||
/// emitted. Typically this will involve several steps of code generation.
|
/// emitted. Typically this will involve several steps of code generation.
|
||||||
/// This method should return true if emission of this file type is not
|
/// This method should return true if emission of this file type is not
|
||||||
/// supported, or false on success.
|
/// supported, or false on success.
|
||||||
virtual bool addPassesToEmitFile(PassManagerBase &,
|
/// If producing assembly, the stream must be a formatted_raw_ostream.
|
||||||
formatted_raw_ostream &,
|
/// For other formats any raw_ostream will do.
|
||||||
|
virtual bool addPassesToEmitFile(PassManagerBase &, raw_ostream &,
|
||||||
CodeGenFileType,
|
CodeGenFileType,
|
||||||
bool /*DisableVerify*/ = true,
|
bool /*DisableVerify*/ = true,
|
||||||
AnalysisID /*StartAfter*/ = nullptr,
|
AnalysisID /*StartAfter*/ = nullptr,
|
||||||
@ -255,9 +256,7 @@ public:
|
|||||||
/// for generating a pipeline of CodeGen passes.
|
/// for generating a pipeline of CodeGen passes.
|
||||||
virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
|
virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
|
||||||
|
|
||||||
/// Add passes to the specified pass manager to get the specified file
|
bool addPassesToEmitFile(PassManagerBase &PM, raw_ostream &Out,
|
||||||
/// emitted. Typically this will involve several steps of code generation.
|
|
||||||
bool addPassesToEmitFile(PassManagerBase &PM, formatted_raw_ostream &Out,
|
|
||||||
CodeGenFileType FileType, bool DisableVerify = true,
|
CodeGenFileType FileType, bool DisableVerify = true,
|
||||||
AnalysisID StartAfter = nullptr,
|
AnalysisID StartAfter = nullptr,
|
||||||
AnalysisID StopAfter = nullptr) override;
|
AnalysisID StopAfter = nullptr) override;
|
||||||
|
@ -140,12 +140,9 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM,
|
|||||||
return &MMI->getContext();
|
return &MMI->getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
bool LLVMTargetMachine::addPassesToEmitFile(
|
||||||
formatted_raw_ostream &Out,
|
PassManagerBase &PM, raw_ostream &Out, CodeGenFileType FileType,
|
||||||
CodeGenFileType FileType,
|
bool DisableVerify, AnalysisID StartAfter, AnalysisID StopAfter) {
|
||||||
bool DisableVerify,
|
|
||||||
AnalysisID StartAfter,
|
|
||||||
AnalysisID StopAfter) {
|
|
||||||
// Add common CodeGen passes.
|
// Add common CodeGen passes.
|
||||||
MCContext *Context = addPassesToGenerateCode(this, PM, DisableVerify,
|
MCContext *Context = addPassesToGenerateCode(this, PM, DisableVerify,
|
||||||
StartAfter, StopAfter);
|
StartAfter, StopAfter);
|
||||||
@ -185,9 +182,9 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(),
|
MCAsmBackend *MAB = getTarget().createMCAsmBackend(MRI, getTargetTriple(),
|
||||||
TargetCPU);
|
TargetCPU);
|
||||||
MCStreamer *S = getTarget().createAsmStreamer(
|
MCStreamer *S = getTarget().createAsmStreamer(
|
||||||
*Context, Out, Options.MCOptions.AsmVerbose,
|
*Context, cast<formatted_raw_ostream>(Out),
|
||||||
Options.MCOptions.MCUseDwarfDirectory, InstPrinter, MCE, MAB,
|
Options.MCOptions.AsmVerbose, Options.MCOptions.MCUseDwarfDirectory,
|
||||||
Options.MCOptions.ShowMCInst);
|
InstPrinter, MCE, MAB, Options.MCOptions.ShowMCInst);
|
||||||
AsmStreamer.reset(S);
|
AsmStreamer.reset(S);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "llvm/MC/SubtargetFeature.h"
|
#include "llvm/MC/SubtargetFeature.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/Signals.h"
|
#include "llvm/Support/Signals.h"
|
||||||
@ -574,13 +573,11 @@ bool LTOCodeGenerator::compileOptimized(raw_ostream &out, std::string &errMsg) {
|
|||||||
|
|
||||||
legacy::PassManager codeGenPasses;
|
legacy::PassManager codeGenPasses;
|
||||||
|
|
||||||
formatted_raw_ostream Out(out);
|
|
||||||
|
|
||||||
// If the bitcode files contain ARC code and were compiled with optimization,
|
// If the bitcode files contain ARC code and were compiled with optimization,
|
||||||
// the ObjCARCContractPass must be run, so do it unconditionally here.
|
// the ObjCARCContractPass must be run, so do it unconditionally here.
|
||||||
codeGenPasses.add(createObjCARCContractPass());
|
codeGenPasses.add(createObjCARCContractPass());
|
||||||
|
|
||||||
if (TargetMach->addPassesToEmitFile(codeGenPasses, Out,
|
if (TargetMach->addPassesToEmitFile(codeGenPasses, out,
|
||||||
TargetMachine::CGFT_ObjectFile)) {
|
TargetMachine::CGFT_ObjectFile)) {
|
||||||
errMsg = "target file type not supported";
|
errMsg = "target file type not supported";
|
||||||
return false;
|
return false;
|
||||||
|
@ -2146,13 +2146,13 @@ char CppWriter::ID = 0;
|
|||||||
// External Interface declaration
|
// External Interface declaration
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM, raw_ostream &o,
|
||||||
formatted_raw_ostream &o,
|
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
bool DisableVerify,
|
bool DisableVerify,
|
||||||
AnalysisID StartAfter,
|
AnalysisID StartAfter,
|
||||||
AnalysisID StopAfter) {
|
AnalysisID StopAfter) {
|
||||||
if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
|
if (FileType != TargetMachine::CGFT_AssemblyFile)
|
||||||
PM.add(new CppWriter(o));
|
return true;
|
||||||
|
PM.add(new CppWriter(cast<formatted_raw_ostream>(o)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ struct CPPTargetMachine : public TargetMachine {
|
|||||||
: TargetMachine(T, "", TT, CPU, FS, Options) {}
|
: TargetMachine(T, "", TT, CPU, FS, Options) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool addPassesToEmitFile(PassManagerBase &PM, formatted_raw_ostream &Out,
|
bool addPassesToEmitFile(PassManagerBase &PM, raw_ostream &Out,
|
||||||
CodeGenFileType FileType, bool DisableVerify,
|
CodeGenFileType FileType, bool DisableVerify,
|
||||||
AnalysisID StartAfter,
|
AnalysisID StartAfter,
|
||||||
AnalysisID StopAfter) override;
|
AnalysisID StopAfter) override;
|
||||||
|
@ -183,7 +183,9 @@ void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
|
static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
|
||||||
formatted_raw_ostream &OS, LLVMCodeGenFileType codegen, char **ErrorMessage) {
|
raw_ostream &OS,
|
||||||
|
LLVMCodeGenFileType codegen,
|
||||||
|
char **ErrorMessage) {
|
||||||
TargetMachine* TM = unwrap(T);
|
TargetMachine* TM = unwrap(T);
|
||||||
Module* Mod = unwrap(M);
|
Module* Mod = unwrap(M);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "llvm/Linker/Linker.h"
|
#include "llvm/Linker/Linker.h"
|
||||||
#include "llvm/MC/SubtargetFeature.h"
|
#include "llvm/MC/SubtargetFeature.h"
|
||||||
#include "llvm/Object/IRObjectFile.h"
|
#include "llvm/Object/IRObjectFile.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
@ -804,9 +804,8 @@ static void codegen(Module &M) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
raw_fd_ostream OS(FD, true);
|
raw_fd_ostream OS(FD, true);
|
||||||
formatted_raw_ostream FOS(OS);
|
|
||||||
|
|
||||||
if (TM->addPassesToEmitFile(CodeGenPasses, FOS,
|
if (TM->addPassesToEmitFile(CodeGenPasses, OS,
|
||||||
TargetMachine::CGFT_ObjectFile))
|
TargetMachine::CGFT_ObjectFile))
|
||||||
message(LDPL_FATAL, "Failed to setup codegen");
|
message(LDPL_FATAL, "Failed to setup codegen");
|
||||||
CodeGenPasses.run(M);
|
CodeGenPasses.run(M);
|
||||||
|
Loading…
Reference in New Issue
Block a user