summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2012-06-11 22:35:19 +0000
committerHal Finkel <hfinkel@anl.gov>2012-06-11 22:35:19 +0000
commit8eb592851461ff710241ec5e5209751cafb5385c (patch)
tree26a09f50377e3d62d6c13de8e42d1ea071d737ba /clang/lib/Basic
parent8a87c12355856dd9034c5a017f5b5dd4794f91e8 (diff)
downloadbcm5719-llvm-8eb592851461ff710241ec5e5209751cafb5385c.tar.gz
bcm5719-llvm-8eb592851461ff710241ec5e5209751cafb5385c.zip
Add PPC support for translating gcc-style -mcpu options into LLVM -target-cpu options.
This functionality is based on what is done on ARM, and enables selecting PPC CPUs in a way compatible with gcc's driver. Also, mirroring gcc (and what is done on x86), -mcpu=native support was added. This uses the host cpu detection from LLVM (which will also soon be updated by refactoring code currently in backend). In order for this to work, the target needs a list of valid CPUs -- we now accept all CPUs accepted by LLVM. A few preprocessor defines for common CPU types have been added. llvm-svn: 158334
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r--clang/lib/Basic/Targets.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 2f75743e217..989d1754abf 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -575,12 +575,47 @@ class PPCTargetInfo : public TargetInfo {
static const Builtin::Info BuiltinInfo[];
static const char * const GCCRegNames[];
static const TargetInfo::GCCRegAlias GCCRegAliases[];
+ std::string CPU;
public:
PPCTargetInfo(const std::string& triple) : TargetInfo(triple) {
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
}
+ virtual bool setCPU(const std::string &Name) {
+ bool CPUKnown = llvm::StringSwitch<bool>(Name)
+ .Case("generic", true)
+ .Case("440", true)
+ .Case("450", true)
+ .Case("601", true)
+ .Case("602", true)
+ .Case("603", true)
+ .Case("603e", true)
+ .Case("603ev", true)
+ .Case("604", true)
+ .Case("604e", true)
+ .Case("620", true)
+ .Case("g3", true)
+ .Case("7400", true)
+ .Case("g4", true)
+ .Case("7450", true)
+ .Case("g4+", true)
+ .Case("750", true)
+ .Case("970", true)
+ .Case("g5", true)
+ .Case("a2", true)
+ .Case("pwr6", true)
+ .Case("pwr7", true)
+ .Case("ppc", true)
+ .Case("ppc64", true)
+ .Default(false);
+
+ if (CPUKnown)
+ CPU = Name;
+
+ return CPUKnown;
+ }
+
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {
Records = BuiltinInfo;
@@ -744,6 +779,20 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__VEC__", "10206");
Builder.defineMacro("__ALTIVEC__");
}
+
+ // CPU identification.
+ if (CPU == "440") {
+ Builder.defineMacro("_ARCH_440");
+ } else if (CPU == "450") {
+ Builder.defineMacro("_ARCH_440");
+ Builder.defineMacro("_ARCH_450");
+ } else if (CPU == "970") {
+ Builder.defineMacro("_ARCH_970");
+ } else if (CPU == "pwr6") {
+ Builder.defineMacro("_ARCH_PWR6");
+ } else if (CPU == "pwr7") {
+ Builder.defineMacro("_ARCH_PWR7");
+ }
}
bool PPCTargetInfo::hasFeature(StringRef Feature) const {
OpenPOWER on IntegriCloud