[cfe-commits] Patch: Add R600 TargetInfo
Tom Stellard
thomas.stellard at amd.com
Thu Mar 8 10:19:31 PST 2012
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
-------------- next part --------------
diff --git lib/Basic/Targets.cpp lib/Basic/Targets.cpp
index 19fa423..46b3da6 100644
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1062,6 +1062,73 @@ namespace {
}
namespace {
+
+class AMDGPUTargetInfo : public TargetInfo {
+public:
+
+ AMDGPUTargetInfo(const std::string& triple) : TargetInfo(triple) { }
+
+ virtual const char * getClobbers() const {
+ return "";
+ }
+
+ virtual void getGCCRegNames(const char * const *&Names,
+ unsigned &numNames) const {
+ Names = NULL;
+ numNames = 0;
+ }
+
+ virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
+ unsigned &NumAliases) const {
+ Aliases = NULL;
+ NumAliases = 0;
+ }
+
+ virtual bool validateAsmConstraint(const char *&Name,
+ TargetInfo::ConstraintInfo &info) const {
+ return true;
+ }
+
+ virtual void getTargetBuiltins(const Builtin::Info *&Records,
+ unsigned &NumRecords) const {
+ Records = NULL;
+ NumRecords = 0;
+ }
+};
+
+
+static const unsigned R600AddrSpaceMap[] = {
+ 1, // opencl_global
+ 3, // opencl_local
+ 2 // opencl_constant
+};
+
+class R600TargetInfo : public AMDGPUTargetInfo {
+public:
+ R600TargetInfo(const std::string& triple) : AMDGPUTargetInfo(triple) {
+ DescriptionString =
+ "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16"
+ "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32"
+ "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64"
+ "-v96:128:128-v128:128:128-v192:256:256-v256:256:256"
+ "-v512:512:512-v1024:1024:1024-v2048:2048:2048"
+ "-n8:16:32:64";
+ AddrSpaceMap = &R600AddrSpaceMap;
+ }
+
+ virtual void getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+ Builder.defineMacro("__R600__");
+ }
+
+ virtual const char * getVAListDeclaration() const {
+ return "";
+ }
+};
+
+} // end anonymous namespace
+
+namespace {
// MBlaze abstract base class
class MBlazeTargetInfo : public TargetInfo {
static const char * const GCCRegNames[];
@@ -3957,6 +4024,9 @@ static TargetInfo *AllocateTarget(const std::string &T) {
case llvm::Triple::mblaze:
return new MBlazeTargetInfo(T);
+ case llvm::Triple::r600:
+ return new R600TargetInfo(T);
+
case llvm::Triple::sparc:
switch (os) {
case llvm::Triple::Linux:
More information about the cfe-commits
mailing list