From 9a1877f04c1a225ff4acae5524d18be91f7fba3f Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 22 Mar 2017 06:36:09 +0000 Subject: [PATCH] Move setting of LangOpts based on target flags out of CompilerInstance and into TargetInfo::adjust so that it gets called in more places throughout the compiler (AST serialization in particular). Should fix PPC modules after removing of faltivec. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298487 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/TargetInfo.h | 5 +++-- lib/Basic/TargetInfo.cpp | 5 +++-- lib/Basic/Targets.cpp | 7 +++++++ lib/Frontend/CompilerInstance.cpp | 6 ------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index 46db895489..39c5e2ec40 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -823,8 +823,9 @@ public: /// \brief Set forced language options. /// /// Apply changes to the target information with respect to certain - /// language options which change the target configuration. - virtual void adjust(const LangOptions &Opts); + /// language options which change the target configuration and adjust + /// the language based on the target options where applicable. + virtual void adjust(LangOptions &Opts); /// \brief Adjust target options based on codegen options. virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index b1b01e5f58..e19404dc54 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -282,8 +282,9 @@ bool TargetInfo::isTypeSigned(IntType T) { /// adjust - Set forced language options. /// Apply changes to the target information with respect to certain -/// language options which change the target configuration. -void TargetInfo::adjust(const LangOptions &Opts) { +/// language options which change the target configuration and adjust +/// the language based on the target options where applicable. +void TargetInfo::adjust(LangOptions &Opts) { if (Opts.NoBitFieldTypeAlign) UseBitFieldTypeAlignment = false; if (Opts.ShortWChar) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 472a57b197..2210518458 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -933,6 +933,13 @@ public: ArchDefineA2q = 1 << 15 } ArchDefineTypes; + // Set the language option for altivec based on our value. + void adjust(LangOptions &Opts) override { + if (HasAltivec) + Opts.AltiVec = 1; + TargetInfo::adjust(Opts); + } + // Note: GCC recognizes the following additional cpus: // 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801, // 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell, diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index e4a1be61fc..f660429e49 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -916,12 +916,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { if (!hasTarget()) return false; - // FIXME: Setting this here is less than ideal, but it is set based on a - // target option for compatibility and this is immediately after we construct - // a target. - if (getTarget().hasFeature("altivec")) - getLangOpts().AltiVec = 1; - // Create TargetInfo for the other side of CUDA compilation. if (getLangOpts().CUDA && !getFrontendOpts().AuxTriple.empty()) { auto TO = std::make_shared(); -- 2.40.0