[PATCH] D136089: [clang] Add MorphOS Target

Jonathan Schleifer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 17 08:56:17 PDT 2022


js updated this revision to Diff 468226.
js added a reviewer: chandlerc.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136089/new/

https://reviews.llvm.org/D136089

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Sema/tls.c


Index: clang/test/Sema/tls.c
===================================================================
--- clang/test/Sema/tls.c
+++ clang/test/Sema/tls.c
@@ -19,4 +19,7 @@
 // Haiku does not support TLS.
 // RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
 
+// MorphOS does not support TLS.
+// RUN: not %clang_cc1 -triple ppc-morphos -fsyntax-only %s
+
 __thread int x;
Index: clang/lib/Basic/Targets/PPC.h
===================================================================
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -522,6 +522,12 @@
   using AIXTargetInfo::AIXTargetInfo;
 };
 
+class LLVM_LIBRARY_VISIBILITY MorphOSPPC32TargetInfo :
+  public MorphOSTargetInfo<PPC32TargetInfo> {
+public:
+  using MorphOSTargetInfo::MorphOSTargetInfo;
+};
+
 } // namespace targets
 } // namespace clang
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_PPC_H
Index: clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -991,6 +991,35 @@
   }
 };
 
+// MorphOS target
+template <typename Target>
+class LLVM_LIBRARY_VISIBILITY MorphOSTargetInfo : public OSTargetInfo<Target> {
+protected:
+  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+                    MacroBuilder &Builder) const override {
+    Builder.defineMacro("__MORPHOS__");
+    Builder.defineMacro("__morphos__");
+    Builder.defineMacro("__amigaos");
+    Builder.defineMacro("__amigaos__");
+    Builder.defineMacro("amigaos");
+    Builder.defineMacro("AMIGA");
+    Builder.defineMacro("_AMIGA");
+    Builder.defineMacro("__AMIGA");
+    Builder.defineMacro("__ELF__");
+    Builder.defineMacro("_CALL_SYSV");
+    Builder.defineMacro("__saveds", "__attribute__((__saveds__))");
+  }
+
+public:
+  MorphOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+      : OSTargetInfo<Target>(Triple, Opts) {
+    this->SizeType = TargetInfo::UnsignedInt;
+    this->IntPtrType = TargetInfo::SignedLong;
+    this->PtrDiffType = TargetInfo::SignedLong;
+    this->TLSSupported = false;
+  }
+};
+
 } // namespace targets
 } // namespace clang
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_OSTARGETS_H
Index: clang/lib/Basic/Targets.cpp
===================================================================
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -345,6 +345,8 @@
       return new RTEMSTargetInfo<PPC32TargetInfo>(Triple, Opts);
     case llvm::Triple::AIX:
       return new AIXPPC32TargetInfo(Triple, Opts);
+    case llvm::Triple::MorphOS:
+      return new MorphOSTargetInfo<PPC32TargetInfo>(Triple, Opts);
     default:
       return new PPC32TargetInfo(Triple, Opts);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136089.468226.patch
Type: text/x-patch
Size: 2754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221017/d698224b/attachment-0001.bin>


More information about the cfe-commits mailing list