diff options
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/Backend.cpp | 15 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/FrontendActions.cpp | 5 |
3 files changed, 15 insertions, 8 deletions
diff --git a/lib/Frontend/Backend.cpp b/lib/Frontend/Backend.cpp index aab0daefd7..d48e8ef5a8 100644 --- a/lib/Frontend/Backend.cpp +++ b/lib/Frontend/Backend.cpp @@ -303,16 +303,15 @@ bool BackendConsumer::AddEmitPasses() { case 3: OptLevel = CodeGenOpt::Aggressive; break; } - // Normal mode, emit a .s file by running the code generator. - // Note, this also adds codegenerator level optimization passes. - switch (TM->addPassesToEmitFile(*PM, FormattedOutStream, - TargetMachine::CGFT_AssemblyFile, - OptLevel)) { - default: + // Normal mode, emit a .s or .o file by running the code generator. Note, + // this also adds codegenerator level optimization passes. + TargetMachine::CodeGenFileType CGFT = TargetMachine::CGFT_AssemblyFile; + if (Action == Backend_EmitObj) + CGFT = TargetMachine::CGFT_ObjectFile; + if (TM->addPassesToEmitFile(*PM, FormattedOutStream, + CGFT, OptLevel) != CGFT) { Diags.Report(diag::err_fe_unable_to_interface_with_target); return false; - case TargetMachine::CGFT_AssemblyFile: - break; } } diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 6ece1f90a4..464c9938c8 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -280,6 +280,7 @@ static const char *getActionName(frontend::ActionKind Kind) { case frontend::EmitHTML: return "-emit-html"; case frontend::EmitLLVM: return "-emit-llvm"; case frontend::EmitLLVMOnly: return "-emit-llvm-only"; + case frontend::EmitObj: return "-emit-obj"; case frontend::FixIt: return "-fixit"; case frontend::GeneratePCH: return "-emit-pch"; case frontend::GeneratePTH: return "-emit-pth"; @@ -858,6 +859,8 @@ ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, Diagnostic &Diags) { Opts.ProgramAction = frontend::EmitLLVM; break; case OPT_emit_llvm_only: Opts.ProgramAction = frontend::EmitLLVMOnly; break; + case OPT_emit_obj: + Opts.ProgramAction = frontend::EmitObj; break; case OPT_fixit: Opts.ProgramAction = frontend::FixIt; break; case OPT_emit_pch: diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 0baba3f467..1c958a7087 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -177,6 +177,9 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, break; case Backend_EmitNothing: break; + case Backend_EmitObj: + OS.reset(CI.createDefaultOutputFile(true, InFile, "o")); + break; } if (BA != Backend_EmitNothing && !OS) return 0; @@ -196,6 +199,8 @@ EmitLLVMAction::EmitLLVMAction() : CodeGenAction(Backend_EmitLL) {} EmitLLVMOnlyAction::EmitLLVMOnlyAction() : CodeGenAction(Backend_EmitNothing) {} +EmitObjAction::EmitObjAction() : CodeGenAction(Backend_EmitObj) {} + //===----------------------------------------------------------------------===// // Preprocessor Actions //===----------------------------------------------------------------------===// |