]> granicus.if.org Git - clang/commitdiff
Added preliminary support step for PS3
authorJohn Thompson <John.Thompson.JTSoftware@gmail.com>
Thu, 19 Nov 2009 17:18:50 +0000 (17:18 +0000)
committerJohn Thompson <John.Thompson.JTSoftware@gmail.com>
Thu, 19 Nov 2009 17:18:50 +0000 (17:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89362 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp

index 07c2bb960bcf01362a779897fd361144b9f2566d..8a4614acc7495c9b43779842a6d7cd3f242dc30b 100644 (file)
@@ -313,6 +313,42 @@ public:
   }
 };
 
+// PS3 PPU Target
+template<typename Target>
+class PS3PPUTargetInfo : public OSTargetInfo<Target> {
+protected:
+  virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+                           std::vector<char> &Defs) const {
+    // PS3 PPU defines.
+    Define(Defs, "__PPU__", "1");
+    Define(Defs, "__CELLOS_LV2__", "1");
+    Define(Defs, "__ELF__", "1");
+  }
+public:
+  PS3PPUTargetInfo(const std::string& triple)
+    : OSTargetInfo<Target>(triple) {
+    this->UserLabelPrefix = "";
+  }
+};
+
+// FIXME: Need a real SPU target.
+// PS3 SPU Target
+template<typename Target>
+class PS3SPUTargetInfo : public OSTargetInfo<Target> {
+protected:
+  virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+                           std::vector<char> &Defs) const {
+    // PS3 PPU defines.
+    Define(Defs, "__SPU__", "1");
+    Define(Defs, "__ELF__", "1");
+  }
+public:
+  PS3SPUTargetInfo(const std::string& triple)
+    : OSTargetInfo<Target>(triple) {
+    this->UserLabelPrefix = "";
+  }
+};
+
 // AuroraUX target
 template<typename Target>
 class AuroraUXTargetInfo : public OSTargetInfo<Target> {
@@ -445,6 +481,11 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
 
   // FIXME: Should be controlled by command line option.
   Define(Defs, "__LONG_DOUBLE_128__");
+  
+  if (Opts.AltiVec) {
+    Define(Defs, "__VEC__", "10206");
+    Define(Defs, "__ALTIVEC__", "1");
+  }
 }
 
 
@@ -1990,6 +2031,8 @@ static TargetInfo *AllocateTarget(const std::string &T) {
   case llvm::Triple::ppc64:
     if (os == llvm::Triple::Darwin)
       return new DarwinTargetInfo<PPC64TargetInfo>(T);
+    else if (os == llvm::Triple::Lv2)
+      return new PS3PPUTargetInfo<PPC64TargetInfo>(T);
     return new PPC64TargetInfo(T);
 
   case llvm::Triple::sparc:
@@ -1999,6 +2042,10 @@ static TargetInfo *AllocateTarget(const std::string &T) {
       return new SolarisSparcV8TargetInfo(T);
     return new SparcV8TargetInfo(T);
 
+  // FIXME: Need a real SPU target.
+  case llvm::Triple::cellspu:
+    return new PS3SPUTargetInfo<PPC64TargetInfo>(T);
+
   case llvm::Triple::systemz:
     return new SystemZTargetInfo(T);