1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
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
|