diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-15 06:48:46 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-15 06:48:46 +0000 |
commit | d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0 (patch) | |
tree | e082f87bb3c2c8ba64c0e6e0b77f6e39bcc885e1 /lib/Frontend | |
parent | 7745cab137b9d91205f13a7adaebe6ed801595f7 (diff) |
Add TargetOptions and use it when constructing targets.
- This ended up being hard to factor, sorry for the large diff.
- Some post-commit cleanup to come.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 10 | ||||
-rw-r--r-- | lib/Frontend/Backend.cpp | 24 | ||||
-rw-r--r-- | lib/Frontend/FrontendActions.cpp | 4 |
3 files changed, 25 insertions, 13 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 82786aaa7f..e3cd6ddd08 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -18,6 +18,7 @@ #include "clang/AST/StmtVisitor.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Basic/TargetOptions.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Diagnostic.h" #include "llvm/Support/Compiler.h" @@ -132,7 +133,14 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename, // PCH loaded successfully. Now create the preprocessor. // Get information about the target being compiled for. - AST->Target.reset(TargetInfo::CreateTargetInfo(TargetTriple)); + // + // FIXME: This is broken, we should store the TargetOptions in the PCH. + TargetOptions TargetOpts; + TargetOpts.ABI = ""; + TargetOpts.CPU = ""; + TargetOpts.Features.clear(); + TargetOpts.Triple = TargetTriple; + AST->Target.reset(TargetInfo::CreateTargetInfo(AST->Diags, TargetOpts)); AST->PP.reset(new Preprocessor(AST->Diags, LangInfo, *AST->Target.get(), AST->getSourceManager(), HeaderInfo)); Preprocessor &PP = *AST->PP.get(); diff --git a/lib/Frontend/Backend.cpp b/lib/Frontend/Backend.cpp index 23d59cf919..bc56029e73 100644 --- a/lib/Frontend/Backend.cpp +++ b/lib/Frontend/Backend.cpp @@ -8,12 +8,13 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/ASTConsumers.h" -#include "clang/CodeGen/ModuleBuilder.h" -#include "clang/CodeGen/CodeGenOptions.h" -#include "clang/AST/ASTContext.h" #include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/DeclGroup.h" #include "clang/Basic/TargetInfo.h" +#include "clang/Basic/TargetOptions.h" +#include "clang/CodeGen/CodeGenOptions.h" +#include "clang/CodeGen/ModuleBuilder.h" #include "llvm/Module.h" #include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" @@ -41,6 +42,7 @@ namespace { class VISIBILITY_HIDDEN BackendConsumer : public ASTConsumer { BackendAction Action; CodeGenOptions CodeGenOpts; + TargetOptions TargetOpts; llvm::raw_ostream *AsmOutStream; llvm::formatted_raw_ostream FormattedOutStream; ASTContext *Context; @@ -76,10 +78,11 @@ namespace { public: BackendConsumer(BackendAction action, Diagnostic &Diags, const LangOptions &langopts, const CodeGenOptions &compopts, - const std::string &infile, llvm::raw_ostream* OS, - LLVMContext& C) : + const TargetOptions &targetopts, const std::string &infile, + llvm::raw_ostream* OS, LLVMContext& C) : Action(action), CodeGenOpts(compopts), + TargetOpts(targetopts), AsmOutStream(OS), LLVMIRGeneration("LLVM IR Generation Time"), CodeGenerationTime("Code Generation Time"), @@ -213,12 +216,12 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) { } std::string FeaturesStr; - if (CodeGenOpts.CPU.size() || CodeGenOpts.Features.size()) { + if (TargetOpts.CPU.size() || TargetOpts.Features.size()) { SubtargetFeatures Features; - Features.setCPU(CodeGenOpts.CPU); + Features.setCPU(TargetOpts.CPU); for (std::vector<std::string>::iterator - it = CodeGenOpts.Features.begin(), - ie = CodeGenOpts.Features.end(); it != ie; ++it) + it = TargetOpts.Features.begin(), + ie = TargetOpts.Features.end(); it != ie; ++it) Features.AddFeature(*it); FeaturesStr = Features.getString(); } @@ -371,9 +374,10 @@ ASTConsumer *clang::CreateBackendConsumer(BackendAction Action, Diagnostic &Diags, const LangOptions &LangOpts, const CodeGenOptions &CodeGenOpts, + const TargetOptions &TargetOpts, const std::string& InFile, llvm::raw_ostream* OS, LLVMContext& C) { return new BackendConsumer(Action, Diags, LangOpts, CodeGenOpts, - InFile, OS, C); + TargetOpts, InFile, OS, C); } diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 3222471efc..7a7537bce4 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -170,8 +170,8 @@ ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI, OS.reset(CI.createDefaultOutputFile(true, InFile, "bc")); return CreateBackendConsumer(BA, CI.getDiagnostics(), CI.getLangOpts(), - CI.getCodeGenOpts(), InFile, OS.take(), - CI.getLLVMContext()); + CI.getCodeGenOpts(), CI.getTargetOpts(), InFile, + OS.take(), CI.getLLVMContext()); } EmitAssemblyAction::EmitAssemblyAction() |