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