On Thu, Mar 08, 2012 at 01:19:31PM -0500, Tom Stellard wrote: > Hi, > > This patch adds a TargetInfo definition for the R600 target, > which represents AMD GPUs (HD2XXX-HD6XXX). This patch depends > on the r600 target triple patch, which was sent to llvm-commits: > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120305/138626.html > > This is the bare minimum needed to successfully compile OpenCL kernels > for the r600 target, and in the future we would like to add some target > specific builtins for handling OpenCL C functions. > > Please Review. > > Thanks, > Tom Stellard
Has anyone had a chance to look at this patch yet? I have attached a second patch to this email that I would like to get committed along with the first one. The second patch adds some builtin definitions for r600. -Tom
diff --git include/clang/Basic/BuiltinsR600.def include/clang/Basic/BuiltinsR600.def new file mode 100644 index 0000000..ce1f30e --- /dev/null +++ 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 <[email protected]> +// + +// 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 include/clang/Basic/TargetBuiltins.h include/clang/Basic/TargetBuiltins.h index 7c04bf7..3460cd5 100644 --- include/clang/Basic/TargetBuiltins.h +++ 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 lib/Basic/Targets.cpp lib/Basic/Targets.cpp index 64dc01c..03f1a18 100644 --- lib/Basic/Targets.cpp +++ 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 {
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
