clang -cc1: Wire up -emit-obj, for emitting object files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95182 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-02-03 01:18:43 +00:00
Родитель 09cc141c89
Коммит da1573f959
8 изменённых файлов: 28 добавлений и 11 удалений

Просмотреть файл

@ -281,6 +281,8 @@ def emit_llvm_bc : Flag<"-emit-llvm-bc">,
HelpText<"Build ASTs then convert to LLVM, emit .bc file">;
def emit_llvm_only : Flag<"-emit-llvm-only">,
HelpText<"Build ASTs and convert to LLVM, discarding output">;
def emit_obj : Flag<"-emit-obj">,
HelpText<"Emit native object files">;
def rewrite_test : Flag<"-rewrite-test">,
HelpText<"Rewriter playground">;
def rewrite_objc : Flag<"-rewrite-objc">,

Просмотреть файл

@ -73,10 +73,11 @@ ASTConsumer *CreateObjCRewriter(const std::string &InFile,
// assembly. This runs optimizations depending on the CodeGenOptions
// parameter. The output depends on the Action parameter.
enum BackendAction {
Backend_EmitAssembly, // Emit native assembly
Backend_EmitBC, // Emit LLVM bitcode file
Backend_EmitAssembly, // Emit native assembly files
Backend_EmitBC, // Emit LLVM bitcode files
Backend_EmitLL, // Emit human-readable LLVM assembly
Backend_EmitNothing // Don't emit anything (benchmarking mode)
Backend_EmitNothing, // Don't emit anything (benchmarking mode)
Backend_EmitObj // Emit native object files
};
ASTConsumer *CreateBackendConsumer(BackendAction Action,
Diagnostic &Diags,

Просмотреть файл

@ -154,6 +154,11 @@ public:
EmitLLVMOnlyAction();
};
class EmitObjAction : public CodeGenAction {
public:
EmitObjAction();
};
//===----------------------------------------------------------------------===//
// Preprocessor Actions
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -31,6 +31,7 @@ namespace frontend {
EmitHTML, ///< Translate input source into HTML.
EmitLLVM, ///< Emit a .ll file.
EmitLLVMOnly, ///< Generate LLVM IR, but do not
EmitObj, ///< Emit a .o file.
FixIt, ///< Parse and apply any fixits to the source.
GeneratePCH, ///< Generate pre-compiled header.
GeneratePTH, ///< Generate pre-tokenized header.

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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:

Просмотреть файл

@ -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
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -70,6 +70,7 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {
case EmitHTML: return new HTMLPrintAction();
case EmitLLVM: return new EmitLLVMAction();
case EmitLLVMOnly: return new EmitLLVMOnlyAction();
case EmitObj: return new EmitObjAction();
case FixIt: return new FixItAction();
case GeneratePCH: return new GeneratePCHAction();
case GeneratePTH: return new GeneratePTHAction();