r217694 - Add support for le64.

JF Bastien jfb at google.com
Fri Sep 12 10:52:48 PDT 2014


Author: jfb
Date: Fri Sep 12 12:52:47 2014
New Revision: 217694

URL: http://llvm.org/viewvc/llvm-project?rev=217694&view=rev
Log:
Add support for le64.

Summary:
le64 is a generic little-endian 64-bit processor, mimicking le32.

Also see the associated LLVM change.

Test Plan: make check-all

Reviewers: dschuff

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5318

Added:
    cfe/trunk/include/clang/Basic/BuiltinsLe64.def   (with props)
    cfe/trunk/test/Driver/le64-unknown-unknown.cpp   (with props)
Modified:
    cfe/trunk/include/clang/Basic/TargetBuiltins.h
    cfe/trunk/include/clang/module.modulemap
    cfe/trunk/lib/Basic/Targets.cpp

Added: cfe/trunk/include/clang/Basic/BuiltinsLe64.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsLe64.def?rev=217694&view=auto
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsLe64.def (added)
+++ cfe/trunk/include/clang/Basic/BuiltinsLe64.def Fri Sep 12 12:52:47 2014
@@ -0,0 +1,19 @@
+//==- BuiltinsLe64.def - Le64 Builtin function database ----------*- C++ -*-==//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the Le64-specific builtin function database.  Users of this
+// file must define the BUILTIN macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+// The format of this database matches clang/Basic/Builtins.def.
+
+BUILTIN(__clear_cache, "vv*v*", "i")
+
+#undef BUILTIN

Propchange: cfe/trunk/include/clang/Basic/BuiltinsLe64.def
------------------------------------------------------------------------------
    svn:eol-style = LF

Modified: cfe/trunk/include/clang/Basic/TargetBuiltins.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetBuiltins.h?rev=217694&r1=217693&r2=217694&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetBuiltins.h (original)
+++ cfe/trunk/include/clang/Basic/TargetBuiltins.h Fri Sep 12 12:52:47 2014
@@ -164,6 +164,17 @@ namespace clang {
         LastTSBuiltin
     };
   }
+
+  /// \brief Le64 builtins
+  namespace Le64 {
+  enum {
+    LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
+  #define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+  #include "clang/Basic/BuiltinsLe64.def"
+    LastTSBuiltin
+  };
+  }
+
 } // end namespace clang.
 
 #endif

Modified: cfe/trunk/include/clang/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=217694&r1=217693&r2=217694&view=diff
==============================================================================
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Fri Sep 12 12:52:47 2014
@@ -39,6 +39,7 @@ module Clang_Basic {
   exclude header "Basic/BuiltinsR600.def"
   exclude header "Basic/BuiltinsX86.def"
   exclude header "Basic/BuiltinsXCore.def"
+  exclude header "Basic/BuiltinsLe64.def"
   exclude header "Basic/DiagnosticOptions.def"
   exclude header "Basic/LangOptions.def"
   exclude header "Basic/OpenCLExtensions.def"

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=217694&r1=217693&r2=217694&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Sep 12 12:52:47 2014
@@ -5962,6 +5962,63 @@ void PNaClTargetInfo::getGCCRegAliases(c
 } // end anonymous namespace.
 
 namespace {
+class Le64TargetInfo : public TargetInfo {
+  static const Builtin::Info BuiltinInfo[];
+
+public:
+  Le64TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
+    BigEndian = false;
+    NoAsmVariants = true;
+    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
+    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+    DescriptionString =
+        "e-S128-p:64:64-v16:16-v32:32-v64:64-v96:32-v128:32-m:e-n8:16:32:64";
+  }
+
+  void getTargetDefines(const LangOptions &Opts,
+                        MacroBuilder &Builder) const override {
+    DefineStd(Builder, "unix", Opts);
+    defineCPUMacros(Builder, "le64", /*Tuning=*/false);
+    Builder.defineMacro("__ELF__");
+  }
+  void getTargetBuiltins(const Builtin::Info *&Records,
+                         unsigned &NumRecords) const override {
+    Records = BuiltinInfo;
+    NumRecords = clang::Le64::LastTSBuiltin - Builtin::FirstTSBuiltin;
+  }
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+    return TargetInfo::PNaClABIBuiltinVaList;
+  }
+  const char *getClobbers() const override { return ""; }
+  void getGCCRegNames(const char *const *&Names,
+                      unsigned &NumNames) const override {
+    Names = nullptr;
+    NumNames = 0;
+  }
+  void getGCCRegAliases(const GCCRegAlias *&Aliases,
+                        unsigned &NumAliases) const override {
+    Aliases = nullptr;
+    NumAliases = 0;
+  }
+  bool validateAsmConstraint(const char *&Name,
+                             TargetInfo::ConstraintInfo &Info) const override {
+    return false;
+  }
+
+  bool hasProtectedVisibility() const override { return false; }
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+    return CC == CC_PnaclCall ? CCCR_OK : CCCR_Warning;
+  }
+};
+} // end anonymous namespace.
+
+const Builtin::Info Le64TargetInfo::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)                                               \
+  { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES },
+#include "clang/Basic/BuiltinsLe64.def"
+};
+
+namespace {
   static const unsigned SPIRAddrSpaceMap[] = {
     1,    // opencl_global
     3,    // opencl_local
@@ -6282,6 +6339,9 @@ static TargetInfo *AllocateTarget(const
         return nullptr;
     }
 
+  case llvm::Triple::le64:
+    return new Le64TargetInfo(Triple);
+
   case llvm::Triple::ppc:
     if (Triple.isOSDarwin())
       return new DarwinPPC32TargetInfo(Triple);

Added: cfe/trunk/test/Driver/le64-unknown-unknown.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/le64-unknown-unknown.cpp?rev=217694&view=auto
==============================================================================
--- cfe/trunk/test/Driver/le64-unknown-unknown.cpp (added)
+++ cfe/trunk/test/Driver/le64-unknown-unknown.cpp Fri Sep 12 12:52:47 2014
@@ -0,0 +1,137 @@
+// RUN: %clang -target le64-unknown-nacl -### %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
+// RUN: %clang -target le64-unknown-nacl %s -emit-llvm -S -c -o - | FileCheck %s
+
+// ECHO: {{.*}} "-cc1" {{.*}}le64-unknown-unknown.c
+
+// Check platform defines
+#include <stdarg.h>
+#include <stddef.h>
+
+extern "C" {
+
+// CHECK: @align_c = global i32 1
+int align_c = __alignof(char);
+
+// CHECK: @align_s = global i32 2
+int align_s = __alignof(short);
+
+// CHECK: @align_i = global i32 4
+int align_i = __alignof(int);
+
+// CHECK: @align_l = global i32 8
+int align_l = __alignof(long);
+
+// CHECK: @align_ll = global i32 8
+int align_ll = __alignof(long long);
+
+// CHECK: @align_p = global i32 8
+int align_p = __alignof(void*);
+
+// CHECK: @align_f = global i32 4
+int align_f = __alignof(float);
+
+// CHECK: @align_d = global i32 8
+int align_d = __alignof(double);
+
+// CHECK: @align_ld = global i32 8
+int align_ld = __alignof(long double);
+
+// CHECK: @align_vl = global i32 4
+int align_vl = __alignof(va_list);
+
+// CHECK: __LITTLE_ENDIAN__defined
+#ifdef __LITTLE_ENDIAN__
+void __LITTLE_ENDIAN__defined() {}
+#endif
+
+// CHECK: __le64defined
+#ifdef __le64
+void __le64defined() {}
+#endif
+
+// CHECK: __le64__defined
+#ifdef __le64__
+void __le64__defined() {}
+#endif
+
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
+#endif
+
+// CHECK: __unixdefined
+#ifdef __unix
+void __unixdefined() {}
+#endif
+
+// CHECK: __unix__defined
+#ifdef __unix__
+void __unix__defined() {}
+#endif
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// Check types
+
+// CHECK: signext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: i64 @check_long()
+long check_long() { return 0; }
+
+// CHECK: i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: i64 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: i64 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: i64 @check_ptrdiff_t()
+ptrdiff_t check_ptrdiff_t() { return 0; }
+
+// CHECK: float @check_float()
+float check_float() { return 0; }
+
+// CHECK: double @check_double()
+double check_double() { return 0; }
+
+// CHECK: double @check_longdouble()
+long double check_longdouble() { return 0; }
+
+}
+
+template<int> void Switch();
+template<> void Switch<4>();
+template<> void Switch<8>();
+template<> void Switch<16>();
+
+void check_pointer_size() {
+  // CHECK: SwitchILi8
+  Switch<sizeof(void*)>();
+
+  // CHECK: SwitchILi16
+  Switch<sizeof(va_list)>();
+}

Propchange: cfe/trunk/test/Driver/le64-unknown-unknown.cpp
------------------------------------------------------------------------------
    svn:eol-style = LF





More information about the cfe-commits mailing list