diff options
author | John Leidel <john.leidel@ttu.edu> | 2015-05-08 20:45:35 -0500 |
---|---|---|
committer | Craig Griffiths <craig.griffiths@codethink.co.uk> | 2015-08-14 10:21:49 +0100 |
commit | a24fc66f762ac96da219aa47c8959d0cef7d01dd (patch) | |
tree | d3bd6c0b7d4dfd48b71c5c798aec96e9d6b85c58 | |
parent | 8cfe7f554d5c8f1639e3dc337aafb8956c7a8b7f (diff) | |
download | flang-a24fc66f762ac96da219aa47c8959d0cef7d01dd.tar.gz |
fix for Issue #3, fixing output ostream such that we successfully generate object files
-rw-r--r-- | tools/driver/Main.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/driver/Main.cpp b/tools/driver/Main.cpp index 1d6e861431..e83befc658 100644 --- a/tools/driver/Main.cpp +++ b/tools/driver/Main.cpp @@ -256,7 +256,8 @@ std::string GetOutputName(StringRef Filename, return std::string(Path.begin(), Path.size()); } -static bool EmitFile(llvm::raw_ostream &Out, +//static bool EmitFile(llvm::raw_ostream &Out, +static bool EmitFile(llvm::raw_pwrite_stream &Out, llvm::Module *Module, llvm::TargetMachine* TM, BackendAction Action) { @@ -264,9 +265,19 @@ static bool EmitFile(llvm::raw_ostream &Out, if(Action == Backend_EmitObj || Action == Backend_EmitAssembly){ llvm::Module &Mod = *Module; llvm::TargetMachine &Target = *TM; +#if 0 llvm::TargetMachine::CodeGenFileType FileType = Action == Backend_EmitObj ? llvm::TargetMachine::CGFT_ObjectFile : llvm::TargetMachine::CGFT_AssemblyFile; +#endif + llvm::TargetMachine::CodeGenFileType CGFT = llvm::TargetMachine::CGFT_AssemblyFile; + + if (Action == Backend_EmitObj) + CGFT = llvm::TargetMachine::CGFT_ObjectFile; + else if (Action == Backend_EmitMCNull) + CGFT = llvm::TargetMachine::CGFT_Null; + else + assert(Action == Backend_EmitAssembly && "Invalid action!"); llvm::legacy::PassManager PM; @@ -279,15 +290,16 @@ static bool EmitFile(llvm::raw_ostream &Out, //if (Target.addPassesToEmitFile(PM, FOS, FileType, true)) { // return true; //} + if( TM->addPassesToEmitFile(PM, Out, CGFT, true, nullptr, nullptr)){ + return false; + } PM.run(Mod); - } - else if(Action == Backend_EmitBC ){ + } else if(Action == Backend_EmitBC ){ llvm::WriteBitcodeToFile(Module, Out); } else if(Action == Backend_EmitLL ) { Module->print(Out, nullptr); } - return false; } static bool EmitOutputFile(const std::string &Input, |