tstellar / rpms / llvm

Forked from rpms/llvm 2 years ago
Clone
dcd073
From a014573ad193775b2301e39275a1ca0ac3bb5847 Mon Sep 17 00:00:00 2001
dcd073
From: Tom Stellard <thomas.stellard@amd.com>
dcd073
Date: Tue, 13 Mar 2012 13:54:51 -0400
dcd073
Subject: [PATCH 2/3] r600: Add some target builtins
dcd073
dcd073
---
dcd073
 include/clang/Basic/BuiltinsR600.def |   32 ++++++++++++++++++++++++++++++++
dcd073
 include/clang/Basic/TargetBuiltins.h |   10 ++++++++++
dcd073
 lib/Basic/Targets.cpp                |   12 ++++++++++--
dcd073
 3 files changed, 52 insertions(+), 2 deletions(-)
dcd073
 create mode 100644 include/clang/Basic/BuiltinsR600.def
dcd073
dcd073
diff --git a/include/clang/Basic/BuiltinsR600.def b/include/clang/Basic/BuiltinsR600.def
dcd073
new file mode 100644
dcd073
index 0000000..ce1f30e
dcd073
--- /dev/null
dcd073
+++ b/include/clang/Basic/BuiltinsR600.def
dcd073
@@ -0,0 +1,32 @@
dcd073
+//===--- BuiltinsR600.def - R600 Builtin function database --  --*- C++ -*-===//
dcd073
+//
dcd073
+//                     The LLVM Compiler Infrastructure
dcd073
+//
dcd073
+// This file is distributed under the University of Illinois Open Source
dcd073
+// License. See LICENSE.TXT for details.
dcd073
+//
dcd073
+//===----------------------------------------------------------------------===//
dcd073
+//
dcd073
+// This file defines the R600-specific builtin function database.  Users of
dcd073
+// this file must define the BUILTIN macro to make use of this information.
dcd073
+//
dcd073
+//===----------------------------------------------------------------------===//
dcd073
+//
dcd073
+// Authors: Tom Stellard <thomas.stellard@amd.com>
dcd073
+//
dcd073
+
dcd073
+// The format of this database matches clang/Basic/Builtins.def.
dcd073
+
dcd073
+BUILTIN(__builtin_r600_read_ngroups_x, "z", "nc")
dcd073
+BUILTIN(__builtin_r600_read_ngroups_y, "z", "nc")
dcd073
+BUILTIN(__builtin_r600_read_ngroups_z, "z", "nc")
dcd073
+
dcd073
+BUILTIN(__builtin_r600_read_tidig_x, "z", "nc")
dcd073
+BUILTIN(__builtin_r600_read_tidig_y, "z", "nc")
dcd073
+BUILTIN(__builtin_r600_read_tidig_z, "z", "nc")
dcd073
+
dcd073
+BUILTIN(__builtin_r600_read_tgid_x, "z", "nc")
dcd073
+BUILTIN(__builtin_r600_read_tgid_y, "z", "nc")
dcd073
+BUILTIN(__builtin_r600_read_tgid_z, "z", "nc")
dcd073
+
dcd073
+#undef BUILTIN
dcd073
diff --git a/include/clang/Basic/TargetBuiltins.h b/include/clang/Basic/TargetBuiltins.h
dcd073
index 7c04bf7..3460cd5 100644
dcd073
--- a/include/clang/Basic/TargetBuiltins.h
dcd073
+++ b/include/clang/Basic/TargetBuiltins.h
dcd073
@@ -45,6 +45,16 @@ namespace clang {
dcd073
     };
dcd073
   }
dcd073
 
dcd073
+  /// R600 builtins
dcd073
+  namespace R600 {
dcd073
+    enum {
dcd073
+        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
dcd073
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
dcd073
+#include "clang/Basic/BuiltinsR600.def"
dcd073
+        LastTSBuiltin
dcd073
+    };
dcd073
+  }
dcd073
+
dcd073
 
dcd073
   /// X86 builtins
dcd073
   namespace X86 {
dcd073
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
dcd073
index 64dc01c..03f1a18 100644
dcd073
--- a/lib/Basic/Targets.cpp
dcd073
+++ b/lib/Basic/Targets.cpp
dcd073
@@ -1070,6 +1070,7 @@ namespace {
dcd073
 namespace {
dcd073
 
dcd073
 class AMDGPUTargetInfo : public TargetInfo {
dcd073
+  static const Builtin::Info BuiltinInfo[];
dcd073
 public:
dcd073
 
dcd073
   AMDGPUTargetInfo(const std::string& triple) : TargetInfo(triple) { }
dcd073
@@ -1097,8 +1098,8 @@ public:
dcd073
 
dcd073
   virtual void getTargetBuiltins(const Builtin::Info *&Records,
dcd073
                                  unsigned &NumRecords) const {
dcd073
-    Records = NULL;
dcd073
-    NumRecords = 0;
dcd073
+    Records = BuiltinInfo;
dcd073
+    NumRecords = clang::R600::LastTSBuiltin-Builtin::FirstTSBuiltin;
dcd073
   }
dcd073
 };
dcd073
 
dcd073
@@ -1132,6 +1133,13 @@ public:
dcd073
   }
dcd073
 };
dcd073
 
dcd073
+const Builtin::Info AMDGPUTargetInfo::BuiltinInfo[] = {
dcd073
+#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES },
dcd073
+#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\
dcd073
+                                              ALL_LANGUAGES },
dcd073
+#include "clang/Basic/BuiltinsR600.def"
dcd073
+};
dcd073
+
dcd073
 } // end anonymous namespace
dcd073
 
dcd073
 namespace {
dcd073
-- 
dcd073
1.7.7.6
dcd073