[cfe-commits] r134283 - in /cfe/trunk/lib: Basic/Targets.cpp Frontend/InitHeaderSearch.cpp

Douglas Gregor dgregor at apple.com
Fri Jul 1 15:41:14 PDT 2011


Author: dgregor
Date: Fri Jul  1 17:41:14 2011
New Revision: 134283

URL: http://llvm.org/viewvc/llvm-project?rev=134283&view=rev
Log:
Add initial *-*-rtems* target, from Joel Sherrill

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=134283&r1=134282&r2=134283&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jul  1 17:41:14 2011
@@ -1665,6 +1665,65 @@
 };
 } // end anonymous namespace
 
+// RTEMS Target
+template<typename Target>
+class RTEMSTargetInfo : public OSTargetInfo<Target> {
+protected:
+  virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+                            MacroBuilder &Builder) const {
+    // RTEMS defines; list based off of gcc output
+
+    // FIXME: Move version number handling to llvm::Triple.
+    llvm::StringRef Release = Triple.getOSName().substr(strlen("rtems"), 1);
+
+    Builder.defineMacro("__rtems__");
+    Builder.defineMacro("__ELF__");
+  }
+public:
+  RTEMSTargetInfo(const std::string &triple)
+    : OSTargetInfo<Target>(triple) {
+      this->UserLabelPrefix = "";
+
+      llvm::Triple Triple(triple);
+      switch (Triple.getArch()) {
+        default:
+        case llvm::Triple::x86:
+          // this->MCountName = ".mcount";
+          break;
+        case llvm::Triple::mips:
+        case llvm::Triple::mipsel:
+        case llvm::Triple::ppc:
+        case llvm::Triple::ppc64:
+          // this->MCountName = "_mcount";
+          break;
+        case llvm::Triple::arm:
+          // this->MCountName = "__mcount";
+          break;
+      }
+
+    }
+};
+
+namespace {
+// x86-32 RTEMS target
+class RTEMSX86_32TargetInfo : public X86_32TargetInfo {
+public:
+  RTEMSX86_32TargetInfo(const std::string& triple)
+    : X86_32TargetInfo(triple) {
+    SizeType = UnsignedLong;
+    IntPtrType = SignedLong;
+    PtrDiffType = SignedLong;
+    this->UserLabelPrefix = "";
+  }
+  virtual void getTargetDefines(const LangOptions &Opts,
+                                MacroBuilder &Builder) const {
+    X86_32TargetInfo::getTargetDefines(Opts, Builder);
+    Builder.defineMacro("__INTEL__");
+    Builder.defineMacro("__rtems__");
+  }
+};
+} // end anonymous namespace
+
 namespace {
 // x86-64 generic target
 class X86_64TargetInfo : public X86TargetInfo {
@@ -2753,11 +2812,15 @@
       return new LinuxTargetInfo<ARMTargetInfo>(T);
     case llvm::Triple::FreeBSD:
       return new FreeBSDTargetInfo<ARMTargetInfo>(T);
+    case llvm::Triple::RTEMS:
+      return new RTEMSTargetInfo<ARMTargetInfo>(T);
     default:
       return new ARMTargetInfo(T);
     }
 
   case llvm::Triple::bfin:
+    if ( os == llvm::Triple::RTEMS )
+      return new RTEMSTargetInfo<BlackfinTargetInfo>(T);
     return new BlackfinTargetInfo(T);
 
   case llvm::Triple::msp430:
@@ -2768,6 +2831,8 @@
       return new PSPTargetInfo<MipsTargetInfo>(T);
     if (os == llvm::Triple::Linux)
       return new LinuxTargetInfo<MipsTargetInfo>(T);
+    if (os == llvm::Triple::RTEMS)
+      return new RTEMSTargetInfo<MipsTargetInfo>(T);
     return new MipsTargetInfo(T);
 
   case llvm::Triple::mipsel:
@@ -2775,6 +2840,8 @@
       return new PSPTargetInfo<MipselTargetInfo>(T);
     if (os == llvm::Triple::Linux)
       return new LinuxTargetInfo<MipselTargetInfo>(T);
+    if (os == llvm::Triple::RTEMS)
+      return new RTEMSTargetInfo<MipselTargetInfo>(T);
     return new MipselTargetInfo(T);
 
   case llvm::Triple::ppc:
@@ -2782,6 +2849,8 @@
       return new DarwinPPC32TargetInfo(T);
     else if (os == llvm::Triple::FreeBSD)
       return new FreeBSDTargetInfo<PPC32TargetInfo>(T);
+    if ( os == llvm::Triple::RTEMS )
+      return new RTEMSTargetInfo<PPC32TargetInfo>(T);
     return new PPC32TargetInfo(T);
 
   case llvm::Triple::ppc64:
@@ -2806,6 +2875,8 @@
       return new AuroraUXSparcV8TargetInfo(T);
     if (os == llvm::Triple::Solaris)
       return new SolarisSparcV8TargetInfo(T);
+    if ( os == llvm::Triple::RTEMS )
+      return new RTEMSTargetInfo<SparcV8TargetInfo>(T);
     return new SparcV8TargetInfo(T);
 
   // FIXME: Need a real SPU target.
@@ -2847,6 +2918,8 @@
       return new VisualStudioWindowsX86_32TargetInfo(T);
     case llvm::Triple::Haiku:
       return new HaikuX86_32TargetInfo(T);
+    case llvm::Triple::RTEMS:
+      return new RTEMSX86_32TargetInfo(T);
     default:
       return new X86_32TargetInfo(T);
     }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=134283&r1=134282&r2=134283&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Jul  1 17:41:14 2011
@@ -553,6 +553,8 @@
     AddPath("/boot/develop/headers/posix", System, true, false, false);
     AddPath("/boot/develop/headers",  System, true, false, false);
     break;
+  case llvm::Triple::RTEMS:
+    break;
   case llvm::Triple::Cygwin:
     AddPath("/usr/include/w32api", System, true, false, false);
     break;
@@ -590,7 +592,8 @@
     break;
   }
 
-  AddPath("/usr/include", System, false, false, false);
+  if ( os != llvm::Triple::RTEMS )
+    AddPath("/usr/include", System, false, false, false);
 }
 
 void InitHeaderSearch::





More information about the cfe-commits mailing list