[clang] [Clang][Xtensa] Add Xtensa target. (PR #118008)

Alexey Gerenkov via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 11 06:26:17 PST 2024


================
@@ -0,0 +1,62 @@
+//===--- Xtensa.cpp - Implement Xtensa target feature support -------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements Xtensa TargetInfo objects.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Xtensa.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetBuiltins.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+void XtensaTargetInfo::getTargetDefines(const LangOptions &Opts,
+                                        MacroBuilder &Builder) const {
+  Builder.defineMacro("__xtensa__");
+  Builder.defineMacro("__XTENSA__");
+  if (BigEndian)
----------------
gerekon wrote:

I can do like it is done in ARM: `xtensa` - little-endian and `xtensaeb` - big-endian. But for big endian support I will have to update LLVM Triple code also. If that will be acceptable to be a part of this Clang related patch I will do it.

Another option is to support `xtensa` only and hard-code `BigEndian = false` until the patch with big endianess support if any.

https://github.com/llvm/llvm-project/pull/118008


More information about the cfe-commits mailing list