]> granicus.if.org Git - clang/commitdiff
Move setting of LangOpts based on target flags out of CompilerInstance
authorEric Christopher <echristo@gmail.com>
Wed, 22 Mar 2017 06:36:09 +0000 (06:36 +0000)
committerEric Christopher <echristo@gmail.com>
Wed, 22 Mar 2017 06:36:09 +0000 (06:36 +0000)
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
lib/Basic/TargetInfo.cpp
lib/Basic/Targets.cpp
lib/Frontend/CompilerInstance.cpp

index 46db89548913f2008ad272a117a96cc77a2fe5fa..39c5e2ec40629efb4fced6f362470162c0d48661 100644 (file)
@@ -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,
index b1b01e5f584fbdb1ffacb2fe335137de86a8106b..e19404dc54cba5113946bb870178bdc342d1fa20 100644 (file)
@@ -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)
index 472a57b197e70682c0687e1ba9f3018af0eb4d17..22105184586c307958423ec7b8b28cddea5609cb 100644 (file)
@@ -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,
index e4a1be61fc920957d77acc05cbec60b714d95385..f660429e49d688c18891fe2c78cd89a1473e898d 100644 (file)
@@ -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<TargetOptions>();