diff options
| author | Eric Christopher <echristo@gmail.com> | 2013-10-16 21:19:26 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2013-10-16 21:19:26 +0000 |
| commit | 2fe3b4a49096a7171adc24a72e5f42cd2c7c147d (patch) | |
| tree | 34a314aadbb6a21dbb98f15eb54a6677c34dd696 /clang/lib/Basic/Targets.cpp | |
| parent | c26a5b4f9d16eae6309a627b46166eb9a705f93a (diff) | |
| download | bcm5719-llvm-2fe3b4a49096a7171adc24a72e5f42cd2c7c147d.tar.gz bcm5719-llvm-2fe3b4a49096a7171adc24a72e5f42cd2c7c147d.zip | |
Add preprocessor support for powerpc vsx.
The test should be expanded upon for more powerpc checking.
llvm-svn: 192849
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index d1b459701b3..8037ebad863 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -658,8 +658,13 @@ class PPCTargetInfo : public TargetInfo { static const char * const GCCRegNames[]; static const TargetInfo::GCCRegAlias GCCRegAliases[]; std::string CPU; + + // Target cpu features. + bool HasVSX; + public: - PPCTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { + PPCTargetInfo(const llvm::Triple &Triple) + : TargetInfo(Triple), HasVSX(false) { BigEndian = (Triple.getArch() != llvm::Triple::ppc64le); LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble; @@ -755,6 +760,8 @@ public: virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const; + virtual bool HandleTargetFeatures(std::vector<std::string> &Features, + DiagnosticsEngine &Diags); virtual bool hasFeature(StringRef Feature) const; virtual void getGCCRegNames(const char * const *&Names, @@ -876,6 +883,29 @@ const Builtin::Info PPCTargetInfo::BuiltinInfo[] = { #include "clang/Basic/BuiltinsPPC.def" }; + /// HandleTargetFeatures - Perform initialization based on the user +/// configured set of features. +bool PPCTargetInfo::HandleTargetFeatures(std::vector<std::string> &Features, + DiagnosticsEngine &Diags) { + // Remember the maximum enabled sselevel. + for (unsigned i = 0, e = Features.size(); i !=e; ++i) { + // Ignore disabled features. + if (Features[i][0] == '-') + continue; + + StringRef Feature = StringRef(Features[i]).substr(1); + + if (Feature == "vsx") { + HasVSX = true; + continue; + } + + // TODO: Finish this list and add an assert that we've handled them + // all. + } + + return true; +} /// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific /// #defines that are not tied to a specific subtarget. @@ -1006,13 +1036,15 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__TOS_BGQ__"); } + if (HasVSX) + Builder.defineMacro("__VSX__"); + // FIXME: The following are not yet generated here by Clang, but are // generated by GCC: // // _SOFT_FLOAT_ // __RECIP_PRECISION__ // __APPLE_ALTIVEC__ - // __VSX__ // __RECIP__ // __RECIPF__ // __RSQRTE__ |

