Skip to content

Commit 9a1877f

Browse files
committed
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
1 parent bdf93f3 commit 9a1877f

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

include/clang/Basic/TargetInfo.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,9 @@ class TargetInfo : public RefCountedBase<TargetInfo> {
823823
/// \brief Set forced language options.
824824
///
825825
/// Apply changes to the target information with respect to certain
826-
/// language options which change the target configuration.
827-
virtual void adjust(const LangOptions &Opts);
826+
/// language options which change the target configuration and adjust
827+
/// the language based on the target options where applicable.
828+
virtual void adjust(LangOptions &Opts);
828829

829830
/// \brief Adjust target options based on codegen options.
830831
virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,

lib/Basic/TargetInfo.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@ bool TargetInfo::isTypeSigned(IntType T) {
282282

283283
/// adjust - Set forced language options.
284284
/// Apply changes to the target information with respect to certain
285-
/// language options which change the target configuration.
286-
void TargetInfo::adjust(const LangOptions &Opts) {
285+
/// language options which change the target configuration and adjust
286+
/// the language based on the target options where applicable.
287+
void TargetInfo::adjust(LangOptions &Opts) {
287288
if (Opts.NoBitFieldTypeAlign)
288289
UseBitFieldTypeAlignment = false;
289290
if (Opts.ShortWChar)

lib/Basic/Targets.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,13 @@ class PPCTargetInfo : public TargetInfo {
933933
ArchDefineA2q = 1 << 15
934934
} ArchDefineTypes;
935935

936+
// Set the language option for altivec based on our value.
937+
void adjust(LangOptions &Opts) override {
938+
if (HasAltivec)
939+
Opts.AltiVec = 1;
940+
TargetInfo::adjust(Opts);
941+
}
942+
936943
// Note: GCC recognizes the following additional cpus:
937944
// 401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
938945
// 821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,

lib/Frontend/CompilerInstance.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -916,12 +916,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
916916
if (!hasTarget())
917917
return false;
918918

919-
// FIXME: Setting this here is less than ideal, but it is set based on a
920-
// target option for compatibility and this is immediately after we construct
921-
// a target.
922-
if (getTarget().hasFeature("altivec"))
923-
getLangOpts().AltiVec = 1;
924-
925919
// Create TargetInfo for the other side of CUDA compilation.
926920
if (getLangOpts().CUDA && !getFrontendOpts().AuxTriple.empty()) {
927921
auto TO = std::make_shared<TargetOptions>();

0 commit comments

Comments
 (0)